Unit 2 Part 1
Unit 2 Part 1
Unit 2 Part 1
NETWORK LAYER
SYLLABUS
• Network Layer – IPv4 Addressing – Network Layer
Protocols (IP,ICMP and Mobile IP) Unicast and
Multicast Routing – Intradomain and Interdomain
Routing Protocols – IPv6 Addresses – IPv6 – Datagram
Format - Transition from IPv4 to IPv6.
INTRODUCTION
• The network layer in the TCP/IP protocol suite is responsible for the
host-to-host delivery of datagrams.
• It provides services to the transport layer and receives services from
the data-link layer
NETWORK-LAYER SERVICES
1) Packetizing
• The first duty of the network layer is definitely packetizing:
encapsulating the payload (data received from upper layer) in a
network-layer packet at the source and decapsulating the payload
from the network-layer packet at the destination.
• The network layer is doing the service of a carrier such as the postal
office, which is responsible for delivery of packages from a sender to a
receiver without changing or using the contents
• The source is not allowed to change the content of the payload unless
it is too large for delivery and needs to be fragmented.
2) Routing and Forwarding
• Routing
o The network layer is responsible for routing the packet from its source to the
destination.
o A physical network is a combination of networks (LANs and WANs) and routers
that connect them.
o This means that there is more than one route from the source to the destination.
o The network layer is responsible for finding the best one among these possible
routes.
o The network layer needs to have some specific strategies for defining the best
route.
o In the Internet today, this is done by running some routing protocols to help the
routers coordinate their knowledge about the neighborhood and to come up with
consistent tables to be used when a packet arrives.
• Forwarding
o If routing is applying strategies and running some routing protocols to
create the decision-making tables for each router, forwarding can be
defined as the action applied by each router when a packet arrives at one
of its interfaces.
o The decision-making table a router normally uses for applying this action
is sometimes called the forwarding table and sometimes the routing table.
o When a router receives a packet from one of its attached networks, it
needs to forward the packet to another attached network (in unicast
routing) or to some attached networks (in multicast routing).
o To make this decision, the router uses a piece of information in the packet
header, which can be the destination address or a label, to find the
corresponding output interface number in the forwarding table.
• Figure shows the idea of the forwarding process in a router.
3) Other Services
• Error Control
• Flow Control
• Congestion Control
• Quality of Service
• Security
IPV4 ADDRESSES
• The identifier used in the IP layer of the TCP/IP protocol suite to identify the
connection of each device to the Internet is called the Internet address or IP
address.
• An IPv4 address is a 32-bit address that uniquely and universally defines the
connection of a host or a router to the Internet.
• The IP address is the address of the connection, not the host or the router,
because if the device is moved to another network, the IP address may be
changed.
• IPv4 addresses are unique in the sense that each address defines one, and only
one, connection to the Internet.
• If a device has two connections to the Internet, via two networks, it has two IPv4
addresses.
• IPv4 addresses are universal in the sense that the addressing system must be
accepted by any host that wants to be connected to the Internet.
1) Address Space
• A protocol like IPv4 that defines addresses has an address space.
• An address space is the total number of addresses used by the
protocol.
• If a protocol uses b bits to define an address, the address space is 2b
because each bit can have two different values (0 or 1).
• IPv4 uses 32-bit addresses, which means that the address space is 232
or 4,294,967,296 (more than four billion).
• If there were no restrictions, more than 4 billion devices could be
connected to the Internet.
• Notation
o There are three common notations to show an IPv4 address: binary
notation (base 2), dotted-decimal notation (base 256), and
hexadecimal notation (base 16).
• Binary notation,
o An IPv4 address is displayed as 32 bits.
o To make the address more readable, one or more spaces are usually inserted between
each octet (8 bits).
o Each octet is often referred to as a byte.
• Dotted-decimal notation
o To make the IPv4 address more compact and easier to read, it is usually written in
decimal form with a decimal point (dot) separating the bytes.
o Note that because each byte (octet) is only 8 bits, each number in the dotted-decimal
notation is between 0 and 255.
• Hexadecimal notation
o Each hexadecimal digit is equivalent to four bits.
o This means that a 32-bit address has 8 hexadecimal digits.
o This notation is often used in network programming.
• Hierarchy in Addressing
o In any communication network that involves delivery, such as a
telephone network or a postal network, the addressing system is
hierarchical.
o In a postal network, the postal address (mailing address) includes the
country, state, city, street, house number, and the name of the mail
recipient.
o Similarly, a telephone number is divided into the country code, area
code, local exchange, and the connection.
o A 32-bit IPv4 address is also hierarchical, but divided only into two parts.
o The first part of the address, called the prefix, defines the network; the
second part of the address, called the suffix, defines the node
(connection of a device to the Internet).
• A prefix can be fixed length or variable length.
• The network identifier in the IPv4 was first designed as a fixed-length
prefix and is referred to as classful addressing.
• The new scheme, which is referred to as classless addressing, uses a
variable-length network prefix.
2) Classful Addressing
• An IPv4 address was designed with a fixed-length prefix, but to
accommodate both small and large networks, three fixed-length
prefixes were designed instead of one (n = 8, n = 16, and n = 24).
• The whole address space was divided into five classes (class A, B, C, D,
and E).
• In class A, the network length is 8 bits, but since the first bit, which is 0,
defines the class, we can have only seven bits as the network identifier. This
means there are only 27 = 128 networks in the world that can have a class A
address.
• In class B, the network length is 16 bits, but since the first two bits, which are
(10)2, define the class, we can have only 14 bits as the network identifier.
This means there are only 214 = 16,384 networks in the world that can have
a class B address. All addresses that start with (110)2 belong to class C.
• In class C, the network length is 24 bits, but since three bits define the class,
we can have only 21 bits as the network identifier. This means there are 221
= 2,097,152 networks in the world that can have a class C address.
• Class D is not divided into prefix and suffix. It is used for multicast addresses.
All addresses that start with 1111 in binary belong to class E. As in Class D,
Class E is not divided into prefix and suffix and is used as reserve
• Address Depletion
o The reason that classful addressing has become obsolete is address depletion.
o Since the addresses were not distributed properly, the Internet was faced with
the problem of the addresses being rapidly used up, resulting in no more
addresses available for organizations and individuals that needed to be
connected to the Internet
• Subnetting and Supernetting
o To alleviate address depletion, two strategies were proposed.
o In subnetting, a class A or class B block is divided into several subnets. Each
subnet has a larger prefix length than the original network.
o While subnetting was devised to divide a large block into smaller ones,
supernetting was devised to combine several class C blocks into a larger block
to be attractive toorganizations that need more than the 256 addresses
available in a class C block
• Advantage of Classful Addressing
o Given an address, we can easily find the class of the address and,
since the prefix length for each class is fixed, we can find the prefix
length immediately.
o In other words, the prefix length in classful addressing is inherent in
the address; no extra information is needed to extract the prefix and
the suffix
3) Classless Addressing
• Subnetting and supernetting in classful addressing did not really solve the address
depletion problem.
• With the growth of the Internet, it was clear that a larger address space was
needed as a long-term solution.
• The larger address space, however, requires that the length of IP addresses also
be increased, which means the format of the IP packets needs to be changed.
• Although the long-range solution has already been devised and is called IPv6 ,a
short-term solution was also devised to use the same address space but to
change the distribution of addresses to provide a fair share to each organization.
• The short-term solution still uses IPv4 addresses, but it is called classless
addressing.
• In classless addressing, variable-length blocks are used that belong to
no classes. We can have a block of 1 address, 2 addresses, 4
addresses, 128 addresses, and so on.
• In classless addressing, the whole address space is divided into
variable length blocks.
• The prefix in an address defines the block (network); the suffix defines
the node (device).
• Theoretically, we can have a block of 20, 21, 22, ...,232 addresses. One
of the restrictions is that the number of addresses in a block needs to
be a power of 2.
• An organization can be granted one block of addresses.
• Unlike classful addressing, the prefix length in classless addressing is
variable and a prefix length that ranges from 0 to 32.
• The size of the network is inversely proportional to the length of the
prefix.
• A small prefix means a larger network; a large prefix means a smaller
network.
• An address in class A can be thought of as a classless address in which
the prefix length is 8.
• An address in class B can be thought of as a classless address in which
the prefix is 16, and so on.
• In other words, classful addressing is a special case of classless
addressing.
• Prefix Length: Slash Notation
• The prefix length, n, is added to the address, separated by a slash.
• The notation is informally referred to as slash notation and formally as
classless interdomain routing or CIDR (pronounced cider) strategy.
• An address in classless addressing can then be represented as shown
in Figure
• Extracting Information from an Address
• Given any address in the block, we normally like to know three pieces
of information about the block to which the address belongs: the
number of addresses, the first address in the block, and the last
address.
• Since the value of prefix length, n, is given, we can easily find these
three pieces of information, as shown in Figure.
1. The number of addresses in the block is found as N = 232−n.
2. To find the first address, we keep the n leftmost bits and set the (32
− n) rightmost bits all to 0s.
3. To find the last address, we keep the n leftmost bits and set the (32
− n) rightmost bits all to 1s.
Example
• A classless address is given as 167.199.170.82/27. We can find the
above three pieces of information as follows.
Solution:
• The number of addresses in the network is 2^(32 − n) = 2^5 = 32
addresses.
• The first address can be found by keeping the first 27 bits and
changing the rest of the bits to 0s.
Address:
167.199.170.82/27 10100111 11000111 10101010 01010010
First address:
167.199.170.64/27 10100111 11000111 10101010 01000000
• The last address can be found by keeping the first 27 bits and
changing the rest of the bits to 1s.
• Address:
167.199.170.82/27 10100111 11000111 10101010 01010010
• Last address:
167.199.170.95/27 10100111 11000111 10101010 01011111
• Address Mask
• Another way to find the first and last addresses in the block is to use the
address mask.
• The address mask is a 32-bit number in which the n leftmost bits are set to 1s
and the rest of the bits (32 − n) are set to 0s.
• A computer can easily find the address mask because it is the complement of
(2^(32 − n) − 1).
• The reason for defining a mask in this way is that it can be used by a computer
program to extract the information in a block, using the three bit-wise
operations NOT, AND, and OR.
1. The number of addresses in the block N = NOT (mask) + 1.
2. The first address in the block = (Any address in the block) AND (mask).
3. The last address in the block = (Any address in the block) OR [(NOT (mask)].
• Network Address
• The first address, the network address, is particularly important
because it is used in routing a packet to its destination network.
• For the moment, let us assume that an internet is made of m
networks and a router with m interfaces.
• When a packet arrives at the router from any source host, the router
needs to know to which network the packet should be sent: from
which interface the packet should be sent out.
• Block Allocation
• The next issue in classless addressing is block allocation.
• The ultimate responsibility of block allocation is given to a global
authority called the Internet Corporation for Assigned Names and
Numbers (ICANN).
• ICANN does not normally allocate addresses to individual Internet
users and it assigns a large block of addresses to an ISP (or a larger
organization that is considered an ISP in this case).
• For the proper operation of the CIDR, two restrictions need to be
applied to the allocated block.
1. The number of requested addresses, N, needs to be a power of 2.
The reason is that N = or n = 32 − log2N. If N is not a power of
2.we cannot have an integer value for n.
2. The requested block needs to be allocated where there is an
adequate number of contiguous addresses available in the address
space. However, there is a restriction on choosing the first address
in the block. The first address needs to be divisible by the number
of addresses in the block. The reason is that the first address needs
to be the prefix followed by (32 − n) number of 0s. The decimal
value of the first address is then
• Subnetting
• More levels of hierarchy can be created using subnetting.
• An organization (or an ISP) that is granted a range of addresses may divide the
range into several subranges and assign each subrange to a subnetwork (or
subnet).
• A sub-subnetwork can be divided into several sub-sub-subnetworks, and so on.
(i) Designing Subnets
• The subnetworks in a network should be carefully designed to enable the
routing of packets.
• We assume the total number of addresses granted to the organization is N, the
prefix length is n, the assigned number of addresses to each subnetwork is
Nsub, and the prefix length for each subnetwork is nsub.
• Then the following steps need to be carefully followed to guarantee the proper
operation of the subnetworks.
o The number of addresses in each subnetwork should be a power of 2.
o The prefix length for each subnetwork should be found using the
following formula:
nsub = 32 − log2Nsub
o The starting address in each subnetwork should be divisible by the
number of addresses in that subnetwork. This can be achieved if we
first assign addresses to larger subnetworks.
(ii)Finding Information about Each Subnetwork
o After designing the subnetworks, the information about each
subnetwork, such as first and last address, can be found using the
process we described to find the information about each network in
the Internet.
Example
• An organization is granted a block of addresses with the beginning address
14.24.74.0/24. The organization needs to have 3 subblocks of addresses to use in
its three subnets: one subblock of 10 addresses, one subblock of 60 addresses,
and one subblock of 120 addresses. Design the subblocks.
Solution
There are 2^32 – 24 = 256 addresses in this block. The first address is
14.24.74.0/24; the last address is 14.24.74.255/24. To satisfy the third requirement,
we assign addresses to subblocks, starting with the largest and ending with the
smallest one.
a. The number of addresses in the largest subblock, which requires 120 addresses,
is not a power of 2. We allocate 128 addresses. The subnet mask for this subnet
can be found as n1 =32−log2128=25. The first address in this block is
14.24.74.0/25; the last address is 14.24.74.127/25.
b. The number of addresses in the second largest subblock, which requires 60
addresses, is not a power of 2 either. We allocate 64 addresses. The subnet mask
for this subnet can be found as n2 = 32 − log264 = 26. The first address in this
block is 14.24.74.128/26; the last address is 14.24.74.191/26.
c. The number of addresses in the smallest subblock, which requires 10
addresses, is not a power of 2 either. We allocate 16 addresses. The subnet
mask for this subnet can be found as n3 = 32 − log216 = 28. The first address in
this block is 14.24.74.192/28; the last address is 14.24.74.207/28.
• If we add all addresses in the previous subblocks, the result is 208 addresses,
which means 48 addresses are left in reserve. The first address in this range is
14.24.74.208. The last address is 14.24.74.255. We don’t know about the
prefix length yet. Figure shows the configuration of blocks. We have shown the
first address in each block.
• Address Aggregation
• One of the advantages of the CIDR strategy is address aggregation
(sometimes called address summarization or route summarization).
• When blocks of addresses are combined to create a larger block,
routing can be done based on the prefix of the larger block.
• ICANN assigns a large block of addresses to an ISP.
• Each ISP in turn divides its assigned block into smaller subblocks and
grants the subblocks to its customers.
• Special Addresses
• There are five special addresses that are used for special purposes.
1) This-host Address
- 0.0.0.0/32 and it is used whenever a host needs to send an IP datagram
but it does not know its own address to use as the source address.
2) Limited-broadcast Address
-255.255.255.255/32 and It is used whenever a router or a host needs to
send a datagram to all devices in a network.
3) Loopback Address
-127.0.0.0/8 and A packet with one of the addresses in this block as the
destination address never leaves the host; it will remain in the host
4) Private Addresses
-Four blocks are assigned as private addresses: 10.0.0.0/8,
172.16.0.0/12, 192.168.0.0/16, and 169.254.0.0/16.
5) Multicast Addresses
-The block 224.0.0.0/4 is reserved for multicast addresses.
4) Dynamic Host Configuration Protocol (DHCP)
• After a block of addresses are assigned to an organization, the network administration can
manually assign addresses to the individual hosts or routers.
• However, address assignment in an organization can be done automatically using the Dynamic
Host Configuration Protocol (DHCP).
• DHCP is an application-layer program, using the client-server paradigm, that actually helps TCP/IP
at the network layer.
• DHCP has found such widespread use in the Internet that it is often called a plug-and-play
protocol and it can be used in many situations.
• A network manager can configure DHCP to assign permanent IP addresses to the host and
routers.
• DHCP can also be configured to provide temporary, on demand, IP addresses to hosts.
• The second capability can provide a temporary IP address to a traveler to connect her laptop to
the Internet while she is staying in the hotel.
• It also allows an ISP with 1000 granted addresses to provide services to 4000 households,
assuming not more than one-forth of customers use the Internet at the same time.
• DHCP can be used to provide these pieces of information to the host.
• DHCP Message Format
• The 64-byte option field has a dual purpose.
• It can carry either additional information or some specific vendor
information.
• The server uses a number, called a magic cookie, in the format of an
IP address with the value of 99.130.83.99.
• When the client finishes reading the message, it looks for this magic
cookie.
• If present, the next 60 bytes are options.
• An option is composed of three fields: a 1-byte tag field, a 1-byte
length field, and a variable-length value field.
• There are several tag fields that are mostly used by vendors.
• If the tag field is 53, the value field defines one of the 8 message
types shown in Figure
DHCP Operation
• Two Well-Known Ports
• DHCP uses two well-known ports (68 and 67) instead of one well-known
and one ephemeral.
• Using FTP
• The client can then use a file transfer protocol to obtain the rest of the
needed information.
• Error Control
• DHCP uses the service of UDP, which is not reliable.
• To provide error control, DHCP uses two strategies.
1. First, DHCP requires that UDP use the checksum.
2. Second, the DHCP client uses timers and a retransmission policy if it does
not receive the DHCP reply to a request.
• Transition States
Network-Layer Protocols
•.
• Agent Solicitation: Mobile IP does not use a new packet type for agent
solicitation; it uses the router solicitation packet of ICMP
2)Registration:To register with the foreign agent and the home agent,
the mobile host uses a registration request and a registration reply
• Registration Request
• A registration request is sent from the mobile host to the foreign
agent to register its care-of address and also to announce its home
address and home agent address.
• Registration Reply
• A registration reply is sent from the home agent to the foreign agent
and then relayed to the mobile host. The reply confirms or denies the
registration request
• Data Transfer
• After agent discovery and registration, a mobile host can
communicate with a remote host.
• From Remote Host to Home Agent
• From Home Agent to Foreign Agent
• From Foreign Agent to Mobile Host
• From Mobile Host to Remote Host
• Transparency
4) Inefficiency in Mobile IP
• Communication involving mobile IP can be inefficient.
• The inefficiency can be severe or moderate.
• The severe case is called double crossing or 2X.
• The moderate case is called triangle routing or dog-leg routing.
Double Crossing
• Double crossing occurs when a remote host communicates with a
mobile host that has moved to the same network (or site) as the
remote host.
• When the mobile host sends a packet to the remote host, there is no
inefficiency; the communication is local.
• However, when the remote host sends a packet to the mobile host,
the packet crosses the Internet twice.
• Since a computer usually communicates with other local computers
(principle of locality), the inefficiency from double crossing is
significant.
• Double Crossing
• Triangle Routing
Triangle Routing
• Triangle routing, the less severe case, occurs when the remote host
communicates with a mobile host that is not attached to the same
network (or site) as the mobile host.
• When the mobile host sends a packet to the remote host, there is no
inefficiency.
• However, when the remote host sends a packet to the mobile host,
the packet goes from the remote host to the home agent and then to
the mobile host.
• The packet travels the two sides of a triangle, instead of just one side
Solution
• One solution to inefficiency is for the remote host to bind the care-of
address to the home address of a mobile host.
• For example, when a home agent receives the first packet for a
mobile host, it forwards the packet to the foreign agent; it could also
send an update binding packet to the remote host so that future
packets to this host could be sent to the care-of address.
• The remote host can keep this information in a cache.
• The problem with this strategy is that the cache entry becomes
outdated once the mobile host moves.
• In this case the home agent needs to send a warning packet to the
remote host to inform it of the change.