Pv4 Header

The best way to understand IPv4 is to know the IPv4 header and all its fields. Segments from TCP or the User Datagram Protocol (UDP) are passed on to IP for processing. The IP header is appended to the TCP or UDP segment. The TCP or UDP segment then becomes the IP data. The IPv4 header is 20 bytes in length when it uses no optional fields. The IP header includes the addresses of the sending host and destination host. It also includes the upper-layer protocol, a field for prioritization, and a field for fragmentation. Figure 7-1 shows the IP header format.

Figure 7-1 IP Header

0 12 3

01234567890123456789012345678901

0 12 3

01234567890123456789012345678901

Version 1 IHL | Type of Service

Total Length

Identification

flags 1 Fragment Offset

Time to Live | Protocol

Header Checksum

Source Address

Destination Address

IP Options Field

Padding

The following is a description of each field in the IP header:

■ Version—This field is 4 bits in length. It indicates the IP header's format, based on the version number. Version 4 is the current version; therefore, this field is set to 0100 (4 in binary) for IPv4 packets. This field is set to 0110 (6 in binary) in IPv6 networks.

■ IHL—Internet header length. This field is 4 bits in length. It indicates the length of the header in 32-bit words (4 bytes) so that the beginning of the data can be found in the IP header. The minimum value for a valid header (five 32-bit words) is 5 (0101).

■ ToS—Type of Service. This field is 8 bits in length. Quality of Service (QoS) parameters such as IP precedence or DSCP are found in this field. These are explained further in this chapter.

■ Total length—This field is 16 bits in length. It represents the length of the datagram or packet in bytes, including the header and data. The maximum length of an IP packet can be 216 - 1 = 65,535 bytes. Routers use this field to determine whether fragmentation is necessary by comparing the total length with the outgoing MTU.

■ Identification—This field is 16 bits in length. It identifies fragments for reassembly.

■ Flags—This field is 3 bits in length. It indicates whether the packet can be fragmented and whether more fragments follow. Bit 0 is reserved and set to 0. Bit 1 indicates May Fragment

(0) or Do Not Fragment (1). Bit 2 indicates Last Fragment (0) or More Fragments to follow

■ Fragment offset—This field is 13 bits in length. It indicates (in bytes) where in the packet this fragment belongs. The first fragment has an offset of 0.

■ Time to live—This field is 8 bits in length. It indicates the maximum time the packet is to remain on the network. Each router decrements this field by 1 for loop avoidance. If this field is 0, the packet must be discarded. This scheme permits routers to discard undeliverable packets.

■ Protocol—This field is 8 bits in length. It indicates the upper-layer protocol. The Internet Assigned Numbers Authority (IANA) is responsible for assigning IP protocol values. Table 7-2 shows some key protocol numbers. A full list can be found at http://www.iana.org/ assignments/protocol-numbers.

Table 7-2 IP Protocol Numbers

Protocol Number

Protocol

1

Internet Control Message Protocol (ICMP)

2

Internet Group Management Protocol (IGMP)

6

Transmission Control Protocol (TCP)

17

User Datagram Protocol (UDP)

88

Enhanced IGRP (EIGRP)

89

Open Shortest Path First (OSPF)

103

Protocol-Independent Multicast (PIM)

■ Header checksum—This field is 16 bits in length. The checksum does not include the data portion of the packet in the calculation. The checksum is recomputed and verified at each point the IP header is processed.

■ Source address—This field is 32 bits in length. It is the sender's IP address.

■ Destination address—This field is 32 bits in length. It is the receiver's IP address.

■ IP options—This field is variable in length. The options provide for control functions that are useful in some situations but unnecessary for the most common communications. Specific options are security, loose source routing, strict source routing, record route, and timestamp.

■ Padding—This field is variable in length. It ensures that the IP header ends on a 32-bit boundary.

Table 7-3 summarizes the fields of the IP header.

Table 7-3 IPv4 Header Fields

Responses

  • telma
    What is the size of ipv4 header?
    20 days ago
  • The size of an IPv4 header is typically 20 bytes, but can range from 20 to 60 bytes depending on the options included in the header.
    • Ralf
      Which protocol number represents icmpv6?
      21 days ago
    • Protocol number 58 represents ICMPv6.

      Field

      Length

      Description

      Version

      4 bits

      Indicates the IP header's format, based on the version number. Set to 0100 for IPv4.

      IHL

      4 bits

      Length of the header in 32-bit words.

      ToS

      8 bits

      QoS parameters.

      Total length

      16 bits

      Length of the packet in bytes, including header and data.

      Identification

      16 bits

      Identifies a fragment.

      Flags

      3 bits

      Indicates whether a packet is fragmented and whether more fragments follow.

      Fragment offset

      13 bits

      Location of the fragment in the total packet.

      Time to live

      8 bits

      Decremented by 1 by each router. When this is 0, the router discards the packet.

      Protocol

      8 bits

      Indicates the upper-layer protocol.

      Header checksum

      16 bits

      Checksum of the IP header; does not include the data portion.

      Source address

      32 bits

      IP address of the sending host.

      Destination address

      32 bits

      IP address of the destination host.

      IP options

      Variable

      Options for security, loose source routing, record route, and timestamp.

      Padding

      Variable

      Added to ensure that the header ends in a 32-bit boundary.

      Continue reading here: ToS

      Was this article helpful?

      0 0