--- id: 1777370971-DYNV aliases: - IPv4 Header tags: - Cisco - CCNA --- # IPv4 Header ## OSI Model - [[PDU]]s Application Data ↓ Data + L4 Header = Segment ↓ Segment + L3 Header = Packet ↓ Packet + L2 Header + L2 Trailer = Frame We will focus on the Packet for this lesson ## IPV4 header ### Version Field length: 4 bits (half of on octet) - identifies the version of IP used. - IPv4 = 4 (0b0100) - IPv4 = 6 (0b0110) ### Internet Header Length (IHL) length: 4 bits (half of on octet) - The final field of the IPv4 header (Options) is variable in length, so this field is necessary to indicate the total length of the header - identifies the lenght of the header in **4 byte increments** - Value of 5 = 5*4 bytes = 20 bytes - minimum value is 5 (= 20 bytes) - **Minimum IPv4 Header Length = 20 bytes** - Maximum value is 15 (15*4 bytes = 60 bytes) - **Maximum IPv4 Header Length = 60 bytes** ### DSCP field - Length: 6 bits - Differentiated Services Code Point - Used for Qos (Quality of Service) - Used to prioritize delay-sensitive dta (streaming voice, video, etc..) ### ECN field Explicit Congestion Notification - Length: 2 bits - Provides end-to-end (between two endpoints) notification of network congestion **without dropping packets** - Optional feature that requires both endpoints, as well as the underlying network infrastructure, to support it. ### Total Length field Length: 16 bits - Indicates the total lenght of the packet (L3 header+ L4 segment) - Measured in bytes (**not 4-byte increments like IHL**) - Minimum value of 20 (=IPv4 header with no encapsulated data) - Maximum value of 65,535 (maximum 16-bit value) ### Identification field Length: 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 - Fragments are reassembled by the receiving host ### Flags field Length: 3bits - Used to control/identify fragments. - 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 *Unfragemented packets will always have their MF bit set to 0* ### Fragment Offset field 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 the fragments arrive out of order ### Time to live field Length: 8 bits - A router will drop a packet with a TTL of - - Used to prevent infinite loops - Originlly designed to indicte the packet's maximum lifetime in second - 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 field Length: 8 bits - Indicates the protocol of the encapsulated L4PDU - Value of 6: [[TCP]] - Value of 17: [[UDP]] - Value of 1: [[ICMP]] - Value of 89 : [[OSPF]] dynamic routing protocol ### Header Checksum field Lenght 16bits - A calculaed 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 the 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/Destination IP address fields Length 32 bits(each) - Source IP Address = IPv4 address of the sender of the packet - Destination IP Address = IPv4 address of the intended receiver of the packet ### Options fields Length: 0 - 320 bits - Rarely used. - If the IHL field is greater than 5, it means that Options are present ## Review - IPv4 Packet structure - Fields of the IPv4 header