The Internet Protocol: IPV4 Packets
Now that we have clarified the allocation of IPv4 addresses and the utilization of the longest prefix match to forward IPv4 packets, we can have a more detailed look at IPv4 by starting with the format of the IPv4 packets.
The IPv4 packet format was defined in RFC 791. Apart from a few clarifications and some backward compatibility changes, the IPv4 packet format did not change significantly since the publication of RFC 791. All IPv4 packets use a 20-byte header as shown below. Some IPv4 packets contain an optional header extension that is described later.
IPv4 Packet Header
Fields of The Header
The main fields of the IPv4 header are:
- A 4 bit version that indicates the version of IP used to build the header. Using a version field in the header allows the network layer protocol to evolve.
- A 4 bit IP Header Length (IHL) that indicates the length of the IP header in 32-bit words. This field allows IPv4 to use options if required, but as it is encoded as a 4 bits field, the IPv4 header cannot be longer than 64 bytes.
- An 8 bit DS field that is used for Quality of Service.
- A 16 bit length field that indicates the total length of the entire IPv4 packet (header and payload) in bytes. This implies that an IPv4 packet cannot be longer than 65535 bytes.
- Identification every packet has an identification number which is useful when reassembling and fragmenting a packet.
- Flags. There are three flags in IP headers. We’ll discuss their usage in the next lesson:
- Don’t Fragment
- More Fragments
- Reserved (must be zero)
- Fragment Offset: This is useful when reassembling a packet from its fragments. More details can be found in the next lesson.
- Time To Live: This number is decremented at each hop. When it becomes 0, the packet is considered to have been in the network for too long and is dropped.
- An 8 bits Protocol field that indicates the transport layer protocol that must process the packet’s payload at the destination. Common values for this field are 6 for TCP and 17 for UDP.
- A 16 bit checksum that protects only the IPv4 header against transmission errors.
- A 32 bit source address field that contains the IPv4 address of the source host.
- A 32 bit destination address field that contains the IPv4 address of the destination host.
- Options this field is not used very often. It’s often used to test out experimental features.
- IP Data: They payload. This payload is not part of the checksum.
The other fields of the IPv4 header are used for very specific purposes. We’ll look at a few in this lesson.
Handling Forwarding Loops with TTL
The first is the 8 bit Time To Live (TTL) field. This field is used by IPv4 to avoid the risk of having an IPv4 packet caught in an infinite loop due to a transient or permanent error in routing tables.
Consider, for example, the forwarding loop depicted in the figure below. Destination D uses address 11.0.0.56. If S sends a packet towards this destination, the packet is forwarded to router B which forwards it to router C that forwards it back to router A, and so on.
The TTL field of the IPv4 header ensures that even if there are forwarding loops in the network, packets will not loop forever.
Hosts send their IPv4 packets with a positive TTL (usually or more). When a router receives an IPv4 packet, it first decrements the TTL by one. If the TTL becomes , the packet is discarded and a message is sent back to the packet’s source.
Handling Data Link Layer Heterogeneity
A second problem for IPv4 is the heterogeneity of the data link layer. IPv4 is used above many very different data link layers. Each of which has its own characteristics. For example, each data link layer is characterized by a maximum frame size or Maximum Transmission Unit (MTU). The MTU of an interface is the largest IPv4 packet (including header) that it can send. The table below provides some common MTU sizes.
Data link layer | MTU |
---|---|
Ethernet | 1500 bytes |
IEEE 802.11 WiFi | 2304 bytes |
Token Ring (802.15.4) | 4464 bytes |
FDDI | 4352 bytes |
Quick Quiz!
An Internet Protocol with the version number is possible in theory.
True
False
In the next lesson, we’ll study IPv4 fragmentation!
Get hands-on with 1400+ tech skills courses.