IPv4 Header
Review
IP, used at Layer3 - helps send data between devices on separate networks - known as Routing.
PDUs
Data
Data + L4 header (TCP, UDP) = Segment
Segment + L3 header (IP) = Packet
Packet + L2 header + L2 trailer = Frame
Segment
Data
Packet
Segment
Frame
Packet
IPv4 header structure

Version
Length : 4 bits (half octet).
Identifies the version of IP used.
IPv4 = 4 (0100).
IPv6 = 6 (0110).
Experimental protocol, Internet Stream Protocol uses IP value of 5 (not publicly used).
We are focussing on IPv4, so the field is always 4.
IPv6 header has a different structure. So if the value is 6, the header will be of different structure.
IHL
Internet Header Length
Length : 4 bits (half octet).
The Options field is variable in length, so IHL is necessary to indicate the total length of the header.
Identifies the length in 4-byte increments (value 5 = 20 bytes).
Minimum value = 5 (20 bytes - minimum length of the IPv4 header, length of the IP packet without any options at the end).
Maximum value = 15 (maximum value of 4 bits - 1111), or 60 bytes (so maximum length of options = 40 bytes).
DSCP
Differentiated Services Code Point.
Length : 6 bits.
Used for QOS (Quality of Service).
Used to prioritize delay-sensitive data (streaming video, voice etc).
Used to identify which traffic should receive priority treatment.
ECN
Explicit Congestion Notification.
Length : 2 bits.
Provides end-to-end notification (a way to signal) of network congestion without dropping packets (normally if the network is super busy / congested, it is signalled by dropping packets).
Optional feature that requires both endpoints, underlying network infrastructure to support it.
Total Length
Length : 16 bits (2 octets).
Indicates the total length of the packet (L3 header + L4 segment).
Different from IHL field, which indicates only the length of IPv4 header.
Measured in bytes (not in 4-byte increments like IHL).
Minimum value = 20 (20 bytes - minimum-sized IPv4 header with no encapsulated data).
Maximum value = 65,535 (maximum value of 16 bits).
The standard PING command on a Cisco router will send 100-byte pings.
Identification
Length : 16 bits (2 octets).
If a packet is fragmented due to being too large, this field is used to identify which packet the fragment belongs to.
All fragments of the same packet will have their own IPv4 header with the same value in this field (so it can be reassembled to make the original packet).
Packets are fragmented if larger than Maximum Transmission Unit - MTU (1500 bytes - maximum payload size of an Ethernet frame).
Fragments are reassembled by the receiving host.
Flags
Length : 3 bits
Used to control and identify fragments.
1st bit (bit 0) : Reserved bit - always set to 0 (not set).
2nd bit (bit 1) : Don't Fragment bit (DF-bit). If set to 1 - packet should not be fragmented.
3rd bit (bit 2) : More fragments bit (MF-bit). Set to 1, if there are more fragments in the packet. Set to 0 for the last fragment and also to unfragmented packets.
If you send PING that is larger than the MTU and set the DF-bit (R1#ping 192.168.1.2 df-bit, the pings will fail. They were too large to be sent unfragmented, but also not allowed to be fragmented.
Fragment Offset
Length : 13 bits.
Used to indicate the position of the fragment within the original, unfragmented IP packet.
Allows fragmented packets to be reassembled even if they arrive out of order.
Lets the receiver know the original order of the fragments.
1st fragment has an offset of 0.
TTL
Time To Live. Originally designed to indicate the packet's maximum lifetime in seconds. In practice, it indicates 'hop counts'.
Length : 8 bits.
Each time the packet arrives at a router on the way to it destination, the router decreases the TTL by 1.
A router will drop a packet with a TTL of 0.
Used to prevent infinite loops. If a poor routing configuration causes a packet to be continually sent around in a loop, never reaching its destination, if enough traffic like this accumulates, causes congestion leading to network failure.
Recommended default TTL is 64.
Protocol
Length : 8 bits.
Indicates the protocol of the encapsulated Layer4 PDU.
Value of 6 : TCP Value of 17 : UDP Value of 1 : ICMP Value of 89 : OSPF
Header Checksum
Length : 16 bits.
Calculated checksum used to check for errors in the IPv4 header.
When a router receives a packet, it calculates the checksum of the header and compares it to the one on this field of the header. If they do not match, an error has occured in the transmission and the router drops the packet.
Used to check for errors only in the IPv4 header, not in the encapsulated data. IP relies on the encapsulated protocol to detect errors in the encapsulated data (TCP and UDP have their own checksum fields).
Source & Destination IP
Length : 32 bits.
Source IP - IPv4 address of the sender.
Destination IP - IPv4 address of the receiver.
Options
Length : 0 to 320 bits (40 bytes).
Optional and rarely used.
If IHL field > 5, Options are present.
Last updated