17
Yarmouk University – Faculty of Information Technology and CS Computer Science Department Network Layer Protocols

Ip and icmp

Embed Size (px)

Citation preview

Yarmouk University – Faculty of Information Technology and CS Computer Science

Department

Network Layer Protocols

• 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)

Internet Protocol (IPv4)

- 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 FormatField 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 FormatField 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.

• 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

• 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: Encapsulation

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.

• 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 fragmenteddatagram that is not the first fragment.

❏ No ICMP error message will be generated for a datagram having amulticast address.

❏ No ICMP error message will be generated for a datagram having aspecial address such as 127.0.0.0 or 0.0.0.0.

Network Protocol: ICMP: Error Reporting

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

Type Code Meaning

0 0 echo reply3 0 network unreachable3 1 host is unreachable3 3 port is unreachable4 0 source quench5 0 redirect8 0 echo request

9/10 0 router discovery/advertisement11 0 time exceed12 0 parameter problem13/14 0 time stamp request17/18 0 network request/reply

Network Protocol: ICMP: Types

• PING sends icmp type 8 echo request to a node and expects an icmp type 0 echo reply

Network Protocol: ICMP: Echo Request/Reply

Send

Reply

8

0

0

0

• Router is unable to deliver datagram, it can return the ICMP type 3 with failure code

Network Protocol: ICMP: Destination unreachable

Destination unreachable Reply3

0/1/3

Sent

• Router detected hosts were overloaded would send this message to hosts to reduce the rate at which subsequence message are sent

Network Protocol: ICMP: Source Quench

Source quench4 0

Sent