Chapter 16 - Network Layer Protocols
Chapter 16 - Network Layer Protocols
Chapter 16 - Network Layer Protocols
[Network Layer]
➢ IP (Internet Protocol):
▪ The main protocol of network layer that performs source-to-
destination delivery (one source to one destination delivery - unicasting).
▪ Provides the following services (through which source-to-destination
delivery is achieved):
– Logical addressing
– Packetizing
– Fragmentation & reassembly
▪ Versions: Currently we are using IPv4, and slowly we are
migrating to IPv6.
The routing protocols are discussed in the next chapter. We shall not discuss IGMP, RARP,
and BOOTP.
[Fig. 16.1:
IPv4
Datagram
Format]
Max. data length = max. IP packet length which is 65535 bytes - min. header
length which is 20 bytes = 655515 bytes
➢ Version (VER) (4 bits): It defines the version of the IPv4 protocol. For
IPv4, its value is 4.
➢ Identification (16 bits), Flags (3 bits), and Fragmentation offset (13 bits):
▪ All these fields are used in fragmentation (discussed in the next
section).
➢ Header checksum (16 bits): This field contains the checksum (for the
header part only) which is used to detect the presence of any error in
the header part.
[NOTE]: The checksum is calculated by dividing the header part into 16-bit sections,
adding them together, and then complementing the result (sum).
◼ Example 1: An IPv4 packet has arrived with the first 8 bits: 01000010. The
receiver discards the packet. Why?
◼ Example 2: In an IPv4 packet, the value of HLEN is 1000 in binary. How many
bytes of options are being carried by this packet?
Solution: The HLEN value is 8 (1000), which means the total number of bytes in
the header is 8 × 4, or 32 bytes. The first 20 bytes are the base header, the next
12 bytes are the options.
Solution: The HLEN value is 5, which means the total number of bytes in the
header is 5 × 4, or 20 bytes (no options). The total length is 40 bytes, which
means the packet is carrying 20 bytes of data (40 − 20).
◼ Example 4: An IPv4 packet has arrived with the first few hexadecimal digits as:
0x45000028000100000102 . . . How many hops can this packet travel before
being dropped? The data belong to what upper-layer protocol?
Solution: .
➢ To find the number of hops this packet can travel before being dropped,
we have to find the value of the TTL field. To find this, we skip 8 bytes (16
hex digits). The TTL field is the 9th byte, which is 01. This means that the
packet can travel only one hop before being dropped.
➢ The protocol field is the 10th byte which is 02. This means that the upper-
layer protocol is IGMP.
➢ Since the length of the IPv4 datagram can be up to 65535 bytes, it must
be divided (fragmented) when it needs to be encapsulated into a frame
whose MTU is less than 65535.
➢ If a datagram is fragmented, it must be reassembled.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 16.18
◼ Fragmentation & Reassembly - By Whom and How Many Times?
➢ In IPv4, a datagram can be fragmented by the source host or any router
in the path.
➢ A datagram can be fragmented any number of times if required.
However, the source host can disallow fragmentation (by setting the “do
not fragment” bit in the “Flag” field of the header - discussed next).
➢ The reassembling of the datagram is done just once only by the
destination host.
The following set of actions are taken by the source or a router when a
datagram needs to be fragmented:
1. The size of the fragments (to be created) are determined depending upon
the MTU. Accordingly, the size of the data part in the fragments are
determined (data size = fragment size - header size).
2. The data from the original datagram is decapsulated, chopped (as per the
determined data size), and re-encapsulated into individual fragments.
3. The headers of these new fragments are formulated by copying all the
fields except the following from the original datagram header
▪ Total length
▪ Flags
▪ Fragmentation offset
▪ Header checksum
▪ Options & padding
The destination host uses the following strategy to reassemble the original
datagram from the fragments received (if none of them is lost):
◼ Example 1: A packet has arrived with an M bit value of 0. Is this the first
fragment, the last fragment, or a middle fragment? Do we know if the packet
was fragmented?
Solution: If the M bit is 0, it means that there are no more fragments; the
fragment is the last one. However, we cannot say if the original packet was
fragmented or not. A non-fragmented packet is considered the last fragment.
◼ Example 2: A packet has arrived with an M bit value of 1. Is this the first
fragment, the last fragment, or a middle fragment? Do we know if the packet
was fragmented?
Solution: If the M bit is 1, it means that there is at least one more fragment. This
fragment can be the first one or a middle one, but not the last one. We don’t
know if it is the first one or a middle one; we need more information (the value
of the fragmentation offset).
Solution: Because the M bit is 1, it is either the first fragment or a middle one.
Because the offset value is 0, it is the first fragment.
◼ Example 4: A packet has arrived in which the offset value is 100. What is the
number of the first byte? Do we know the number of the last byte?
Solution: To find the number of the first byte, we multiply the offset value by 8.
This means that the first byte number is 800. We cannot determine the number
of the last byte unless we know the length.
Solution: The first byte number is 100 × 8 = 800. The total length is 100 bytes,
and the header length is 20 bytes (5 × 4), which means that there are 80 bytes in
this datagram. If the first byte number is 800, the last byte number must be 879.
◼ IPv6 is slowly replacing IPv4 and becoming the standard for internetworking.
◼ Why IPv6?: As already discussed in the last chapter, IPv6 was proposed mainly
to overcome the following deficiencies in IPv4:
➢ Address depletion.
➢ Lack of accommodation for real-time audio / video transmission.
➢ Lack of encryption and authentication mechanisms.
◼ Services: IPv6 provides all the functionality and services that IPv4 provides.
Moreover, IPv6 provides some additional features like good QoS, security etc.
2. Better header format: IPv6 uses a new header format in which options are
separated from the base header and inserted, when needed, between the base
header and the upper-layer data. This simplifies and speeds up the routing
process because most of the options do not need to be checked by routers.
3. New options: IPv6 has new options to allow for additional functionalities.
4. Allowance for extension: IPv6 is designed to allow the extension of the protocol
if required by new technologies or applications.
6. Support for more security: The encryption and authentication options in IPv6
provide confidentiality and integrity of the packet.
➢ Priority (PRI) (4 bits): It defines the priority of the packet with respect to
other packets from the same source in case of traffic congestion. For
example, if one of two consecutive datagrams must be discarded due to
congestion, the datagram with the lower packet priority is discarded.
➢ Source address (16 bytes / 128 bits): It is the IPv6 address of the source.
➢ Destination address (16 bytes / 128 bits): It is the IPv6 address of the
destination.
In order to give greater functionality to the IPv6 datagram, the base header can
be followed by up to six extension headers. Many of these headers are
"options" in IPv4. The six types of base headers are shown in Fig. 16.8.
➢ Fragmentation:
▪ This extension header contains fragmentation related
information when an IPV6 datagram is fragmented.
◼ Three strategies have been devised by the IETF for the transition::
1. Dual stack
2. Tunneling
3. Header Translation
◼ The IP address of the destination is obtained (by the source) from the DNS. But
how does each hop on the path to the destination find the physical address of
its next hop? For this, the ARP is used.
◼ The ARP is a network layer protocol that finds (discovers) the physical address
of a node from its IP address dynamically (i.e., as and when required). This process
is called address resolution.
[NOTE 1]: The reverse process, i.e., obtaining logical address from physical address is called
“reverse address resolution”. For this, the protocols RARP and BOOTP are used.
[NOTE 2]: ARP, RARP and BOOTP are used only with IPv4. In IPv6, the functionality of
ARP is integrated with ICMPv6 and the protocols RARP and BOOTP are dropped because
reverse address resolution is rarely required.
◼ There can be four cases (shown in Fig. 16.12) where ARP is used (i.e., address
resolution is required).
1. The sender (the source or a router on the path to destination) prepares an “ARP
request” packet. The packet (the packet format is discussed next) includes (among
other information) the physical address of the sender, the IP addresses of the
sender, and the IP address of the target (the next hop) (the sender finds the IP
address of its next hop from its routing table).
2. This packet is broadcasted over the network (to which the sender belongs).
3. Every host or router in the network receives the ARP request packet. However,
all machines except the target, drop the packet. The target machine
recognizes its IP address.
4. The target replies with an “ARP reply” packet. It includes (among other
information) the physical address of the target, the IP addresses of the target,
the physical address of the sender, and the IP address of the sender.
5. The packet is unicasted directly to the source.
➢ Protocol type (16 bits): It defines the network layer protocol for which
the ARP request is intended. For IPv4 protocol, this field has the value
Ox0800.
➢ Operation (16 bits): It defines the type of ARP packet. For ARP request
packet the value of this field is 1 and for ARP reply packet it is 2.
➢ Sender protocol address (32 bits): It defines the IP address of the node
sending the ARP request / reply packet.
➢ Target hardware address (32 bits): It defines the physical address of the
node for which the ARP request / reply packet is intended. In an ARP
request packet, this field is not filled.
➢ Target protocol address (32 bits): It defines the IP address of the node
for which the ARP request / reply packet is intended.
◼ Unlike some other network layer protocol (such as ICMP, IGMP, OSPF etc.)
whose packets are encapsulated in an IP packet and the IP packet is
encapsulated in a data link layer frame, an ARP packet is encapsulated directly
into a data link frame.
◼ Whenever a router running a proxy ARP receives an ARP request looking for
the IP address of one of these hosts, the router sends an ARP reply announcing
its own hardware (physical) address. After the router receives the actual IP
packet, it sends the packet to the appropriate host or router.
[Fig. 16.16:
Proxy ARP]
◼ The ICMP has been designed to compensate for the above two deficiencies.
◼ The ICMP is a companion to the IPv4 protocol that provides error reporting (not
error correcting) and query services in the network layer.
◼ ICMP provides its services (error reporting & query) through different messages.
◼ In accordance with the services, the ICMP messages are divided into two
broad categories: (I) Error-reporting messages (II) Query messages. The detail
classification is shown below.
◼ Each category has its own message types and packet formats.
ICMP Messages
◼ Use: These messages are used to report different errors to the source host that
a router or the destination host may encounter when it processes an IP packet.
2. Source quench (Type: 4): This message is sent to the source when a
router or a host discards the datagram due to congestion (the input queue
/ buffer of the router or host is already filled). This message informs the source
two things:
a) The datagram is discarded.
b) There is a congestion somewhere in the path and the source
should slow down (quench) the sending process.
4. Time exceeded (Type: 11): This message is sent to the source in two
cases:
a) When a router discards a datagram because its TTL field has
reach the value 0.
b) When the destination host discards all fragments of a datagram
because it has not received all fragments within a predetermined
time limit.
5. Parameter problem (Type: 12): This message is sent to the source when
a router or the destination discards a datagram because of some
ambiguity or missing values in the header part.
Dr. N. K. Pani, Dept. of CSEA, IGIT Sarang | 16.61
◼ Some Important Points about ICMP Error-Reporting Messages.
[Fig. 16.17:
ICMP Error-reporting
Message Format]
[Fig. 16.18:
Encapsulation of ICMP
Error-reporting
Messages]
◼ Use: These messages are used by a host or a network manager to get specific
information about a router or another host. For example: the ping command.
◼ Types: There are 4 types of query messages (4 types of queries can be made).
Each type is identified by an integer.
[Fig. 16.19:
ICMP Query Message
Format]
Like the error-reporting messages this packet has also two parts:
➢ Header (64 bits): It consists of four fields
▪ Type (8 bits), Code (8 bits), and Checksum (8 bits): Have the same
functionality as that of the error-reporting messages.
▪ Identifier (16 bits) and Sequence number (16 bits): Carries
different information for different query messages.
➢ Data section (variable size): In query messages, this section carries extra
information based on the type of query.
[Fig. 16.20:
Encapsulation of ICMP
Query Messages]
The query message is encapsulated in a IPv4 packet and sent to the target.
◼ ICMPv4 was not suitable for IPv6. Therefore, some of its features were
modified, and it is called ICMPv6. Fig. 16.21 compares the network layers of
version 4 and version 6.
[Fig. 16.21:
Comparison
of Network
Layer in v4
and v6]
◼ The ICMPv6 is designed to provide the services of ICMPv4, ARP, and IGMP
combined.
◼ The protocols RARP and BOOTP were dropped from the suite because they
were rarely used.
◼ The working principle of ICMPv6 is exactly same as ICMPv4; the services (of
ICMPv4, ARP, and IGMP) are provided through the error-reporting and query
messages. However, in order to address the new services, some new message
types are added, and some existing message types are eliminated in each
category in comparison to the ICMPv4.
◼ Error-Reporting Messages:
In ICMPv6, 5 types of errors are reported (to the source). The table below
compares the error-reporting messages of ICMPv4 and ICMPv6.
➢ The messages types “echo request & reply” and “router solicitation &
advertisement ” are identical to the ones in ICMPv4.