3.2 Internet Protocol (IP)
IP is the network layer protocol used in TCP/IP networks. It contains logical addressing and information for the routing of packets throughout the internetwork, and provides for the transmission of blocks of data called datagrams (packets) from sources to destinations. The sources and destinations are identified by fixed-length IP addresses. The IP protocol also provides for the fragmentation and reassembly of long datagrams. IP is described in RFC 791.
3.2.1 IP Header
When segments from TCP are passed on to IP, an IP header is added to the data. The IP header includes a
number of fields including:
Version, which is a 4 bit field that indicates the format, based on the version number, of the IP header in binary.
IHL, which is also a 4 bit field. It indicates the length of the header in 32-bit words (4 bytes) so that the beginning of the data can be found. The minimum value for a correct header (five 32-bit words) is 0101.
Type of Service (ToS), which is an 8 bit filed that indicates quality of service (QoS) parameters. The format for this field is shown in the figure.
The three left-most bits are the precedence bits. Bit number:
These define values that QoS methods use and are described in Table 3.1. Bit 3 (D-bit) indicates Description: normal (o) or low (l) delay. Bit 4 (T-bit) ToS Field Format indicates normal (o) or high (l) throughput. Bit
5 (R-bit) indicates normal (o) or high (l) reliability. Bits 6 and 7 are reserved for future use.
- Total Length, which is a 16 bit field that 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 = 65535 bytes.
- Identification, which is another 16 bit field. It identifies fragments for reassembly.
- Flags, which is a 3 bit field that indicates if the packet can be fragmented and shows more or last fragments. Bit 0 is reserved and set to o. Bit 1 indicates May Fragment (o) or Do Not Fragment (l). Bit 2 indicates Last Fragment (o) or More Fragments (l) to follow.
- Time to Live, which is another 8 bit field. It indicates the maximum time the packet is to remain on the network. If this field is zero, the packet must be discarded. This scheme permits undeliverable packets to be discarded.
- Protocol, which is also an 8 bit field that indicates the upper-layer protocol. Appendix C shows some key protocol numbers.
- Header Checksum, which is a 16 bit field. The checksum is calculated for the IP header only, without the data. It is recomputed and verified at each point that the IP header is processed.
- Source Address, which is a 32 bit field that is the IP address of the sender, i.e., the sending host.
- Destination Address, which is a 32 bit field that is the IP address of the destination host.
- IP Options, which is a variable length field. Some options are: security, Loose Source Routing, Strict Source Routing, Record Route, and Timestamp.
- Padding, which is another variable length field. It ensures that the IP header ends on a 32-bit boundary.
|000||Routine. All normal traffic is set with this precedence.|
3.2.2 IP Fragmentation
Although the maximum length of an IP packet can be over 65,000 bytes, many lower-layer protocols do not support such large maximum transmission units (MTU). When the IP layer receives a packet to send, it first queries the outgoing interface to get its MTU. If the size of the packet is greater than the MTU of the interface, the packet is fragmented. When a packet is fragmented, it is not reassembled until it reaches the IP layer on the destination host.
Furthermore, any router in the path tot the destination host can fragment a packet, and any router in the path can further fragment an already fragmented packet. Each fragmented packet receives its own IP header and is routed independently from other packets.
If one or more fragments are lost, the entire packet must be retransmitted. Retransmission is the responsibility of the higher-layer protocol (such as TCP).
If the flags field in the IP header is set to Do Not Fragment (010) the packet, the packet is discarded if the outgoing MTU is smaller than the packet size.