COMPUTER NETWORK AND SECURITY

IPv4 Header Format:

The IPv4 header consists of 20 bytes (160 bits) minimum, and additional options may extend the header length.

  • Version (4 bits):
    • Indicates the IP version being used. For IPv4, this field is set to 4.
  • Header Length (4 bits):
    • Specifies the length of the IP header in 32-bit words. The minimum value is 5, indicating a 20-byte header. If options are present, the length may be larger.
  • Type of Service (8 bits):
    • Originally designed for specifying quality of service, the Type of Service (TOS) field is now often used as the Differentiated Services Code Point (DSCP) for QoS purposes.
  • Total Length (16 bits):
    • Indicates the total length of the IP packet, including both the header and the data.
  • Identification (16 bits):
    • Used for reassembly of fragmented packets. Each fragment of a packet has the same identification value.
  • Flags (3 bits):
    • The Flags field contains control bits related to fragmentation:
      • Bit 0 (Reserved): Must be set to 0.
      • Bit 1 (Don't Fragment - DF): If set to 1, indicates that the packet should not be fragmented.
      • Bit 2 (More Fragments - MF): If set to 1, indicates that more fragments follow.
  • Fragment Offset (13 bits):
    • Indicates the position of the fragment in the original unfragmented packet, measured in 8-byte units.
  • Time to Live (TTL - 8 bits):
    • Represents the maximum number of hops (routers) that the packet can traverse before being discarded.
  • Protocol (8 bits):
    • Specifies the higher-layer protocol to which the data should be passed (e.g., TCP, UDP, ICMP).
  • Header Checksum (16 bits):
    • Provides error-checking for the header. It is calculated over the entire header but excludes the checksum field itself.
  • Source IP Address (32 bits):
    • Specifies the IP address of the sender.
  • Destination IP Address (32 bits):
    • Specifies the IP address of the intended recipient.
  • Options (Variable):
    • This field is optional and may not be present. If present, it can include various options such as timestamp, record route, and others.

This is a simplified representation of the IPv4 header format. Actual headers may include options and padding. The options field allows for flexibility but is less commonly used due to its impact on packet size. The majority of IPv4 traffic uses a minimal 20-byte header without options.

 

IPv6 Header Format:


The IPv6 (Internet Protocol version 6) header is designed to be simpler and more efficient than the IPv4 header. IPv6 provides a larger address space and includes enhancements such as built-in security features. Here's an overview of the IPv6 header format:

The IPv6 header is 40 bytes in length and consists of the following fields:

  • Version (4 bits):
    • Indicates the IP version being used. For IPv6, this field is set to 6.
  • Traffic Class (8 bits):
    • Similar to the IPv4 Type of Service (TOS) field, the Traffic Class field is used for specifying the priority and class of service.
  • Flow Label (20 bits):
    • Designed to identify a flow of data, helping routers and switches to apply special handling for certain traffic.
  • Payload Length (16 bits):
    • Specifies the length of the payload (data) in the IPv6 packet, excluding the header length.
  • Next Header (8 bits):
    • Indicates the type of the next header following the IPv6 header. It specifies the protocol for the payload (e.g., TCP, UDP, ICMPv6).
  • Hop Limit (8 bits):
    • Similar to the IPv4 Time to Live (TTL) field, the Hop Limit field sets an upper limit on the number of routers (hops) the packet can traverse before being discarded.
  • Source IPv6 Address (128 bits):
    • Specifies the IPv6 address of the sender.
  • Destination IPv6 Address (128 bits):
    • Specifies the IPv6 address of the intended recipient.

The IPv6 header is simpler than the IPv4 header, and certain functionalities, such as fragmentation, have been moved to extension headers to streamline packet processing. Extension headers, when present, follow the IPv6 header and provide additional information or options.

IPv6 was designed to overcome the limitations of IPv4, including address exhaustion, and to better support modern networking requirements. Its increased address space and simplified header make it well-suited for the continued growth of the Internet and the deployment of new technologies.