12. IPv4 (Internet Protocol version 4)
/

- Layer 3 header contains the information needed to route information
/
- Numbers indicate bits. 8 bits = 1 byte. There are 4 bytes in total.
VERSION: LENGTH is 4 bits. Identifies version of IP used (IPv4 or IPv6).
- IPv4 = 0100 in Binary (Decimal 4).
- IPv6 = 0110 in Binary (Decimal 6)
INTERNET HEADER LENGTH (IHL): LENGTH is 4 bits. Final field of IPv4 Header (Options) is varies in length so this field is necessary to indicate the total length of the header.
- Identifies the length of the header in 4-BYTE INCREMENTS.(for every 4 bytes) i.e if value is 5 (minimum value) (5 * 4-bytes = 20 bytes). That means the length of the header is 20 bytes. (i.e the IP packet without ip options field - Empty OPTIONS Field.)
- The MAXIMUM value is 15 (15 * 4-bytes = 60 bytes). MINIMUM IPv4 HEADER LENGTH = 20 Bytes! (without the options field) MAXIMUM IPv4 HEADER LENGTH = 60 Bytes! (with options field)
DSCP (Differentiated Services Code Point): LENGTH is 6 bits. Used for QoS (Quality of Service). Used to prioritize delay-sensitive data (streaming voice, video, etc.). Identifies which traffic needs priority.
ECN (Explicit Congestion Notification): LENGTH is 2 bits. Provides end-to-end (between two endpoints) notification of network congestion WITHOUT dropping packets. (normally if the network is super busy (congestion) this is signalled by dropping packets). However, it’s an optional feature that requires both endpoints, as well as the underlying network infrastructure to support it.
TOTAL LENGTH: LENGTH is 16 bits (2 bytes). Indicates the TOTAL length of the packet (L3 Header + L4 Segment). Measured in bytes (not 4-byte increments like IHL). Minimum value of 20 Bytes (IPv4 Header with NO encapsulated data). Maximum value of 65,535 (MAXIMUM 16-bit value) = 2^16 (16 binary bits sets to 1)
IDENTIFICATION: LENGTH is 16 bits. 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. Packets are fragmented if larger than the MTU (Maximum Transmission Unit). The MTU is usually 1500 bytes (Max size of an Ethernet frame). Fragments are reassembled by the receiving host.
FLAGS: LENGTH is 3 bits. Used to control/identify fragments. determines whether a packet can be fragmented, if it's part of a larger fragmented datagram, or if it's the last fragment.
- Bit 0: Reserved, always set to 0.
- Bit 1: Don't Fragment (DF bit), used to indicate a packet that should not be fragmented.
- Bit 2: More Fragments (MF bit), set to 1 if there are more fragments in the packet, set to 0 for the last fragment or NO fragments.
FRAGMENT OFFSET: LENGTH is 13 bits. Used to indicate the position of the fragment within the original, unfragmented IP Packet. Allows fragmented packets to be reassembled even if the fragments arrive out of order.
TIME TO LIVE (TTL): LENGTH is 8 bits. A router will drop a packet with a TTL of 0. Used to prevent infinite loops. Originally designed to indicate a packets maximum lifetime in seconds. In practice, indicates a 'hop count': each time the packet arrives at a router, the router decreases the TTL by 1. Recommended default TTL is 64.
PROTOCOL: LENGTH is 8 bits. Indicates the protocol of the encapsulated Layer 4 PDU.
- Value of 1 : ICMP.
- Value of 6 : TCP.
- Value of 17 : UDP.
- Value of 89 : OSPF (open Shortest Path First): Dynamic Routing Protocol.
HEADER CHECKSUM: LENGTH is 16 bits . A 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 in this field of a header. If they do not match, the router drops the packet. Used to check for ERRORS only in the IPv4 Header. IP relies on the encapsulated protocol to detect errors in the encapsulated data. Both TCP and UDP have their own checksum fields to detect errors in the encapsulated data.
SOURCE and DESTINATION: LENGTH is 32 bits each.
- SOURCE IP = IPv4 ADDRESS of the Sender of the Packet.
- DESTINATION IP = IPv4 ADDRESS of the intended Receiver of the Packet.
OPTIONS: LENGTH is 0-320 bits. Optional / Rarely Used. If the IHL field is greater than 5, it means that Options are present.