Internet Layer, Internet Protocol, IP Datagran fragmentation, IPv4 Header Format

The Internet Layer (RFC 791) is the second layer in the TCP/IP protocol stack. The main functions of the internet layer are transmitting data to and from the Datalink layer, routing data to the correct destination network and device on the destination network, and handling packet errors and fragmentation. Routing is the process of selecting best path / paths in a network along which to send the IP Datagrams (name of the data packet generated by the Internet Protocol) efficiently. IPv4 Datagrams are encapsulated within an Ethernet Frame.

IP Datagram encapsulation within an Ethernet frame

IPv4 Datagram Encapsulated within an Ethernet Frame

The TCP/IP internet layer's functions are similar to the Layer 3 of the OSI model (Network Layer).

The major protocols included in the Internet layer are Internet Protocol (IP), Internet Control Message Protocol (ICMP), Address Resolution Protocol (ARP), Reverse Address Resolution Protocol (RARP) and Internet Group Management Protocol (IGMP).

Internet Protocol Version 4 (IPv4)

The Internet Protocol Version 4 (IPv4) implements two basic functions of network traffic 1) addressing of packets and 2) fragmentation of packets.

1) Routing of Internet Protocol Version 4 (IPv4) Datagrams. Routing is the process of selecting best path / paths in a network along which to send the Internet Protocol Version 4 (IPv4) Datagrams efficiently. The Internet Protocol Version 4 (IPv4) layer use the Internet Protocol Version 4 (IPv4) addresses (32 bit logical addresses represented in 4 octets) carried in the Internet Protocol Version 4 (IPv4) datagram header to transmit the IPv4 Datagrams toward their destination networks.

2) Fragmentation and Reassembly of Datagrams. To understand what is IPv4 Datagram Fragmentation, first we should know the term MTU (Maximum Transmission Unit). MTU is the size (in bytes) of the largest packet or frame that can pass through a specific device or NIC card. While travelling through the network to reach the destination, the Internet Protocol Version 4 (IPv4) datagrams may need to traverse different networks with heterogeneous MTUs. When a datagram is larger than the MTU of the network it need to traverse, it is divided into smaller fragments and are sent separately. At the destination computer the fragmented IPv4 Datagram is reconstructed and this process in called reassembly.

Internet Protocol (IPv4) Datagram Header

IPv4 Datagram Header Structure

Internet Protocol (IPv4) Datagram Header

Version: This 4-bit field indicates which version of Internet Protocol (IP) is being used. Here we are discussing about IPv4. The binary pattern for IPv4 is 0100. The possible values for Version field are as shown in the table below. IPv4 is moving away slowly from industry for IPv6.

IP Version Description
0 Reserved
1-3 Unassigned
4 IP Version 4
5 Stream IP Datagram mode (experimental protocol)
6 IP Version 6
8 The "P" internet protocol
10-14 Unassigned
15 Reserved

Note: The TP/IX, "P" Internet protocol, and TUBA were the major protocols considered for the replacement of IPv4, but the industry embraced "IP Version 6" as the replacement for "IP Version 4" all other protocols mentioned above only have historical status.

IHL (Internet Header Length): This 4-bit field gives length of the IPv4 header in 32-bit words. The minimum length of an IPv4 header is five 32-bit words. The header bit pattern is 0101.

Type of Service: The "Type of Service" (ToS) field in the Internet Protocol (IPv4) header is an eight bit field, which provides an indication of the Quality of Service (QoS) desired, such as precedence, delay, throughput, and reliability.

The first three bits, Bits 0-2 indicates the Precedence value. The following are the possible combinations and the corresponding values.

Bits Pattern Description
000 Routine
001 Priority
010 Immediate
011 Flash
100 Flash Override
110 Internetwork Control
111 Network Control

The fourth bit indicates "Delay". The bit value “0” indicates normal delay and the bit value "1" indicate low delay.

The fifth bit indicates "Throughput". The bit value “0” indicates normal throughput and the bit value "1" indicate high throughput.

The sixth bit indicate "Reliability". The bit value “0” indicates normal reliability and the bit value "1" indicate high reliability.

The seventh bit indicates "Minimize monetary cost". The bit value “0” indicates normal monetary cost and the bit value "1" indicate minimize monetary cost.

The eight bit is reserved for future use and is termed as MBZ (Must be Zero)

The four bits which represent the ToS values can be summarized as below.

ToS Code Meaning
1000 Minimum Delay
0100 Maximum throughput
0010 Maximum Reliability
0001 Minimum monetary cost
0000 Normal Service

Total Length: The "Total Length" is a 16-bit field which identifies the length (in bytes), of the Internet Protocol (IPv4) datagram. Total Length includes the length of IPv4 header and the Data it carries. The minimum-length of an IPv4 Datagram is 20 bytes (The minimum size of an IP header is 20 bytes and this is the case of an IPv4 header carrying no data) and the maximum is 65,535 bytes (maximum possible value for a 16 bit number is 65,535).

Identification: The Identification field in the Internet Protocol Version 4 (IPv4) header is a 16 bits field which indicates an identifying value assigned by the sender to aid in assembling the fragments of an IPv4 Datagram. When a Datagram is fragmented in to multiple Datagrams, IPv4 give all the fragments the same identification number and this number is used to identify IPv4 fragments at the receiving side.

Flags: The three bit "Flags" field indicates fragmentation possibilities. The first bit is unused and should always have a value of zero. The next bit is called the DF (Don't Fragment) flag. DF flag set to "0" indicate that the IPv4 Datagram can be fragmented and DF set to 1 indicate "Don't Fragment" the IPv4 Datagram. The next bit is the MF (More Fragments) flag, which indicates that more fragments are on the way. When MF is set to 0, no more fragments need to be sent or the Datagram never was fragmented.

Fragment Offset: This field indicates where in the actual IPv4 Datagram this fragment belongs. The fragment offset is measured in units of 8 octets (64 bits). The first fragment has offset zero.

IP Datagram Fragmentation

IPv4 Datagram Fragmentation

Consider the above figure. Network 1 and Network 3 has MTUs of 1500 bytes each and the MTU of Network 3 is only 1000 bytes. If Machine 1 sends a 1,500 byte Datagram (20-byte header and 1,480 bytes of data) to Machine 2, Router 1 must fragment the Datagram into two fragments, since the MTU for the Network 2 is only 1000 bytes.

1) The first fragment will contain 20 byte IPv4 header and 976 bytes of data. Also note that the Fragment offset is set to "0" (Since first fragment) and the MF (More Fragments) flag is set to "1".

2) The second fragment will contain a 20 byte IPv4 header and 504 bytes of data. The fragment offset is set to 122 (976/8 = 122) and the MF (More Fragments) flag is set to "0". When the IPv4 Datagram is fragmented to two, there is an additional 20 bytes of transfer which is the IPv4 Datagram header size of the second fragment.

Time to Live (TTL): TTL is an 8 bit field and TTL indicates the amount of time in seconds or router hops that the IPv4 Datagram can survive before being discarded. Every router examines and decrements this field by at least 1, or by the number of seconds the IPv4 Datagram is delayed inside the router. The Internet Protocol Version 4 (IPv4) Datagram is discarded when this field reaches zero.

In computer networking, Time to Live (TTL) field value is typically used to prevent routing loops.

Protocol: The 8-bit Protocol field indicates the protocol that will receive the data payload.

Header Checksum: This field holds a 16-bit calculated value to verify the validity of the header only. This field is recomputed in every router as the TTL field decrements.

Source IP Address: The 32 bit size IPv4 address of the device which send this Internet Protocol (IPv4) Datagram.

Destination IP Address: The 32 bit size IPv4 address of the device which is going to receive this IPv4 Datagram.

IP Options: This field supports a number of optional header settings primarily used for testing, debugging, and security.

Padding: The IPv4 Options field may vary in length. The Padding field provides additional zero bits so that the total header length is an exact multiple of 32 bits.

Data: This field in the IPv4 Datagram Header contains the real IPv4 data payload and the size may vary. Contains data generated by TCP or UDP (Transport layer protocols), ICMP, or IGMP.

You have learned Internet Protocol Version 4 (IPv4), Internet Protocol Version 4 (IPv4) Datagram Header, different fields in an IPv4 header, and IPv4 Datagram fragmentation. The different fields of an IPv4 header are Version, IHL, Type of Service, Total Length, Flags, Fragment offset, TTL (Time to Live), Protocol, Header Checksum, Source IPv4 Address, Destination IPv4 Address, IP Options, Padding and the Data Payload. Click "Next" to continue.

Related Tutorials
• TCP/IP Encapsulation and Decapsulation
• TCP/IP Datalink Layer
• Media Access Control (MAC) addresses
• IP Addresses