Yarmouk University – Faculty of Information 
Technology and CS Computer Science 
Department 
Network Layer Protocols
Internet Protocol (IPv4) 
• It is a layer 3 protocol 
– Host-to-host network layer 
delivery protocol for the 
internet. 
– It is unreliable and 
connectionless protocol. 
• No error control. 
• No flow control. 
• It has error detection (discard) 
– If reliability is of concern, 
the IP has to be tied to a 
connection-oriented 
protocol (i.e. TCP) 
- In reality, each packet (datagram) is 
handled independently: 
- Each packet can follow different 
rout to destination. 
-Thus, Packets may arrive out 
of order, dropped and/or lost. 
 IP relies on above layers to take care 
of the above issue.
Internet Protocol (IPv4): Header Format 
Layer 3 PDU
Internet Protocol (IPv4): Header Format 
Field Length Description 
Version 4 bit Identifies the version of IP used to generate the datagram 
HLEN 4 bit Specifies the length of the IP header, including the length of any 
options and padding. The normal value of this field when no options 
are used is (20 bytes) value must be multiplied by 4 to give the length in bytes 
Service 
(TOS) 
8 bit Type of Service (TOS): A field designed to carry information to 
provide quality of service features, such as prioritized delivery, for IP 
datagram. 
Total Length (TL) 16 bit Specifies the total length of the IP datagram, in bytes. Since this field 
is 16 bits, the maximum length of an IP datagram is 65,535 bytes 
(2^16 – 1) of which 20-60 byte is the header. 
Identification 16 bit This field is used by the receiver to reassemble messages without 
mixing fragments from different messages. 
Flags 3 bit Control flags to manage fragmentation 
Fragmentation 
offset 
13 bit This field specifies the offset, or position, in the overall message 
where the data in this fragment goes. 
Time to live (TTL) 8 bits Specifies how long the datagram is allowed to “live” on the network, 
in terms of router hops. Each router decrements the value of the TTL 
by one prior to transmitting it. If the TTL =0, the datagram is 
discarded.
Internet Protocol (IPv4): Header Format 
Field Length Description 
Protocol 8 bit Identifies the higher layers protocols (transport or encapsulated 
network layer protocols) carried in the datagram 
Header checksum 16 A checksum computed over the header to provide basic protection 
against corruption in transmission 
Source address 32 bit The 32-bit IP address of the originator of the datagram 
(intermediate device will not change it) 
Destination address 32 bit The 32-bit IP address of the intended recipient of the datagram. 
(intermediate device will not change it) 
options var One or more of several types of options may be included after the 
standard headers in certain IP datagram 
• The header length (HLEN) value must be multiplied by 4 to give the length in bytes 
• Total Length (TL) defines the total datagram length including the data part in bytes. 
• to find the length of the data coming from the upper layer (upper layer PDU) 
Length of data = total length (Tl) – [header length (HLEN)*4]
Internet Protocol (IPv4): Header Format 
8 bit 8 bit 
Transport 
layer 
protocols
Internet Protocol (IPv4): Header Format 
• The datagram has to be less then the defined MTU (L2). Otherwise a fragmentation is a must 
• To make the IP independent of the physical network, the maximum length of the IP 
datagram has to be equal to the MTU (65,535 bytes). Otherwise a fragmentation has to occur 
• at the host if the IP datagram > the host MTU. 
• at the router if the IP datagram > the router MTU. 
•Can we guarantee that the fragmented datagram travel using the same route? 
•NO
Internet Protocol (IPv4): Header Format 
Data has to be always equal to MTU, if less then the MTU, then packet is padded 
with 0’s until it is equal to the MTU.
Network Protocol: ICMP 
• The IP protocol has no error-reporting or error-correcting 
mechanism (unreliable and connectionless 
delivery). 
• The IP protocol also lacks a mechanism for host 
and management queries ( a host need to know if a 
router or another host is alive). 
• The Internet Control Message Protocol (ICMP) 
has been designed to compensate for the above 
two deficiencies. 
– It is a companion to the IP protocol.
Network Protocol: ICMP: Encapsulation 
• ICMP is Layer 3 protocol. 
– It is crafted in the network layer itself. 
• ICMP Packets are encapsulated within the IP 
datagram. 
• The IP datagram is passed directly to Layer 2.
Network Protocol: ICMP: Message Format 
• The Protocol field within the IP header is 1 to indicate it is an ICMP Message. 
• ICMP always reports error messages to the original source.
Network Protocol: ICMP: Error Reporting 
• Error Messages are always sent back to the source, WHY? 
– The only information available in the datagram about the route is the 
source and destination IP. 
Important points about ICMP error messages: 
❏ No ICMP error message will be generated in response to a datagram 
carrying an ICMP error message. 
❏ No ICMP error message will be generated for a fragmented 
datagram that is not the first fragment. 
❏ No ICMP error message will be generated for a datagram having a 
multicast address. 
❏ No ICMP error message will be generated for a datagram having a 
special address such as 127.0.0.0 or 0.0.0.0.
Network Protocol: ICMP: Error Reporting 
• Type 3: when a router cannot route a datagram, or a host cannot deliver a datagram, the 
datagram is discarded and the sender is notified through ICMP message type 3. 
•Type 4: when a router or a host discard a datagram due to congestion in the path from 
source to destination. Thus the sender is notified on the error and quenched to slow down 
the transmission. 
• Type 11: to notify the sender when a router discard a datagram with TTL =0 and/or 
when all fragments did not reach the destination within a certain time window. 
• Type 12: to notify the sender when a router or any host discarded a datagram because 
there is an error/ missing info from any field of the datagram. 
• Type 5: to notify the sender when he sends a datagram to the wrong router. The 
receiving router will forward the datagram to the correct router and notify the host to 
update his routing table.
14 
Network Protocol: ICMP: Types 
Type Code Meaning 
0 0 echo reply 
3 0 network unreachable 
3 1 host is unreachable 
3 3 port is unreachable 
4 0 source quench 
5 0 redirect 
8 0 echo request 
9/10 0 router discovery/advertisement 
11 0 time exceed 
12 0 parameter problem 
13/14 0 time stamp request 
17/18 0 network request/reply
Network Protocol: ICMP: Echo Request/Reply 
• PING sends icmp type 8 echo request to a 
node and expects an icmp type 0 echo reply 
Send 
Reply 
8 
0 
0 
0
Network Protocol: ICMP: Destination unreachable 
• Router is unable to deliver datagram, it can 
return the ICMP type 3 with failure code 
Destination unreachable Reply 
3 
0/1/3 
Sent
Network Protocol: ICMP: Source Quench 
• Router detected hosts were overloaded would send 
this message to hosts to reduce the rate at which 
subsequence message are sent 
Source quench 
4 0 
Sent

Ip and icmp

  • 1.
    Yarmouk University –Faculty of Information Technology and CS Computer Science Department Network Layer Protocols
  • 2.
    Internet Protocol (IPv4) • It is a layer 3 protocol – Host-to-host network layer delivery protocol for the internet. – It is unreliable and connectionless protocol. • No error control. • No flow control. • It has error detection (discard) – If reliability is of concern, the IP has to be tied to a connection-oriented protocol (i.e. TCP) - In reality, each packet (datagram) is handled independently: - Each packet can follow different rout to destination. -Thus, Packets may arrive out of order, dropped and/or lost.  IP relies on above layers to take care of the above issue.
  • 3.
    Internet Protocol (IPv4):Header Format Layer 3 PDU
  • 4.
    Internet Protocol (IPv4):Header Format Field Length Description Version 4 bit Identifies the version of IP used to generate the datagram HLEN 4 bit Specifies the length of the IP header, including the length of any options and padding. The normal value of this field when no options are used is (20 bytes) value must be multiplied by 4 to give the length in bytes Service (TOS) 8 bit Type of Service (TOS): A field designed to carry information to provide quality of service features, such as prioritized delivery, for IP datagram. Total Length (TL) 16 bit Specifies the total length of the IP datagram, in bytes. Since this field is 16 bits, the maximum length of an IP datagram is 65,535 bytes (2^16 – 1) of which 20-60 byte is the header. Identification 16 bit This field is used by the receiver to reassemble messages without mixing fragments from different messages. Flags 3 bit Control flags to manage fragmentation Fragmentation offset 13 bit This field specifies the offset, or position, in the overall message where the data in this fragment goes. Time to live (TTL) 8 bits Specifies how long the datagram is allowed to “live” on the network, in terms of router hops. Each router decrements the value of the TTL by one prior to transmitting it. If the TTL =0, the datagram is discarded.
  • 5.
    Internet Protocol (IPv4):Header Format Field Length Description Protocol 8 bit Identifies the higher layers protocols (transport or encapsulated network layer protocols) carried in the datagram Header checksum 16 A checksum computed over the header to provide basic protection against corruption in transmission Source address 32 bit The 32-bit IP address of the originator of the datagram (intermediate device will not change it) Destination address 32 bit The 32-bit IP address of the intended recipient of the datagram. (intermediate device will not change it) options var One or more of several types of options may be included after the standard headers in certain IP datagram • The header length (HLEN) value must be multiplied by 4 to give the length in bytes • Total Length (TL) defines the total datagram length including the data part in bytes. • to find the length of the data coming from the upper layer (upper layer PDU) Length of data = total length (Tl) – [header length (HLEN)*4]
  • 6.
    Internet Protocol (IPv4):Header Format 8 bit 8 bit Transport layer protocols
  • 7.
    Internet Protocol (IPv4):Header Format • The datagram has to be less then the defined MTU (L2). Otherwise a fragmentation is a must • To make the IP independent of the physical network, the maximum length of the IP datagram has to be equal to the MTU (65,535 bytes). Otherwise a fragmentation has to occur • at the host if the IP datagram > the host MTU. • at the router if the IP datagram > the router MTU. •Can we guarantee that the fragmented datagram travel using the same route? •NO
  • 8.
    Internet Protocol (IPv4):Header Format Data has to be always equal to MTU, if less then the MTU, then packet is padded with 0’s until it is equal to the MTU.
  • 9.
    Network Protocol: ICMP • The IP protocol has no error-reporting or error-correcting mechanism (unreliable and connectionless delivery). • The IP protocol also lacks a mechanism for host and management queries ( a host need to know if a router or another host is alive). • The Internet Control Message Protocol (ICMP) has been designed to compensate for the above two deficiencies. – It is a companion to the IP protocol.
  • 10.
    Network Protocol: ICMP:Encapsulation • ICMP is Layer 3 protocol. – It is crafted in the network layer itself. • ICMP Packets are encapsulated within the IP datagram. • The IP datagram is passed directly to Layer 2.
  • 11.
    Network Protocol: ICMP:Message Format • The Protocol field within the IP header is 1 to indicate it is an ICMP Message. • ICMP always reports error messages to the original source.
  • 12.
    Network Protocol: ICMP:Error Reporting • Error Messages are always sent back to the source, WHY? – The only information available in the datagram about the route is the source and destination IP. Important points about ICMP error messages: ❏ No ICMP error message will be generated in response to a datagram carrying an ICMP error message. ❏ No ICMP error message will be generated for a fragmented datagram that is not the first fragment. ❏ No ICMP error message will be generated for a datagram having a multicast address. ❏ No ICMP error message will be generated for a datagram having a special address such as 127.0.0.0 or 0.0.0.0.
  • 13.
    Network Protocol: ICMP:Error Reporting • Type 3: when a router cannot route a datagram, or a host cannot deliver a datagram, the datagram is discarded and the sender is notified through ICMP message type 3. •Type 4: when a router or a host discard a datagram due to congestion in the path from source to destination. Thus the sender is notified on the error and quenched to slow down the transmission. • Type 11: to notify the sender when a router discard a datagram with TTL =0 and/or when all fragments did not reach the destination within a certain time window. • Type 12: to notify the sender when a router or any host discarded a datagram because there is an error/ missing info from any field of the datagram. • Type 5: to notify the sender when he sends a datagram to the wrong router. The receiving router will forward the datagram to the correct router and notify the host to update his routing table.
  • 14.
    14 Network Protocol:ICMP: Types Type Code Meaning 0 0 echo reply 3 0 network unreachable 3 1 host is unreachable 3 3 port is unreachable 4 0 source quench 5 0 redirect 8 0 echo request 9/10 0 router discovery/advertisement 11 0 time exceed 12 0 parameter problem 13/14 0 time stamp request 17/18 0 network request/reply
  • 15.
    Network Protocol: ICMP:Echo Request/Reply • PING sends icmp type 8 echo request to a node and expects an icmp type 0 echo reply Send Reply 8 0 0 0
  • 16.
    Network Protocol: ICMP:Destination unreachable • Router is unable to deliver datagram, it can return the ICMP type 3 with failure code Destination unreachable Reply 3 0/1/3 Sent
  • 17.
    Network Protocol: ICMP:Source Quench • Router detected hosts were overloaded would send this message to hosts to reduce the rate at which subsequence message are sent Source quench 4 0 Sent