Layer 3 (Network Layer) – Responsible for routing packets between networks
IPv4 packet = IPv4 header + payload
🔹 IPv4 Header Fields
Field | Bits | Description |
---|---|---|
Version | 4 | IP version: 4 for IPv4 (0100), 6 for IPv6 (0110) |
IHL (Internet Header Length) | 4 | Header size in 4-byte blocks. Min: 5 (20 bytes), Max: 15 (60 bytes) |
DSCP (Differentiated Services Code Point) | 6 | Used for QoS (prioritize video, VoIP) |
ECN (Explicit Congestion Notification) | 2 | Optional, informs about congestion without dropping packets |
Total Length | 16 | Total packet size (header + data). Max: 65,535 bytes |
Identification | 16 | Used for fragment reassembly – same ID across all fragments of one original packet |
Flags | 3 | Fragmentation control: Bit 0 = Reserved Bit 1 = DF (Don’t Fragment) Bit 2 = MF (More Fragments) |
Fragment Offset | 13 | Order of fragment in the original packet |
TTL (Time To Live) | 8 | Prevents routing loops. Each router decrements TTL by 1. Packet is dropped when TTL = 0 |
Protocol | 8 | Encapsulated protocol:1 = ICMP6 = TCP17 = UDP89 = OSPF |
Header Checksum | 16 | For IPv4 header error-checking only. Recalculated at each router |
Source IP Address | 32 | IP address of sender |
Destination IP Address | 32 | IP address of receiver |
Options | 0–320 | Optional field, rarely used. Present only if IHL > 5 |
🧩 IPv4 Fragmentation
- Reason: When IP packet exceeds MTU (usually 1500 bytes)
- All fragments carry their own IPv4 header
- Identification field stays the same across fragments
- Flags & Offset help reassemble them at the destination
- MF (More Fragments) =
1
for all except last fragment - Offset = position in the original packet
- MF (More Fragments) =
🛡️ Error Handling & Routing
- TTL ensures no infinite loops
- Header Checksum ensures header wasn’t corrupted in transit
- If checksum is incorrect → packet dropped
🧠 Quick Facts
- IPv4 Header Min Size: 20 bytes
- IPv4 Header Max Size: 60 bytes (if Options used)
- Protocol field allows routers to identify the payload (TCP, UDP, ICMP etc.)
- DSCP/ECN are used for advanced traffic control and congestion management
📌 These are personal study notes. Please read the full disclaimer for more information.
Category: Uncategorized