- The Internet Layer
- Internet Protocol
- Format of an IP Datagram
- Transmission of Datagrams
- Summary
Transmission of Datagrams
Datagrams from the Internet layer are sent to the Network Interface layer where the data is transmitted over the physical medium. The Network Interface layer transmits data in the form of frames. A datagram is packaged into a frame by the Network Interface layer (see Figure 3.4).
Figure 3.4 An IP datagram is encapsulated in a frame and transmitted over the cables.
However, there are a few factors that need to be considered while encapsulating a datagram within a frame. They are as follows:
-
The amount of data that can be transmitted in a single frame is called Maximum Transfer Unit (MTU) and varies with the network technology that is used. MTU size is measured in bytes. For example, the MTU for Ethernet is 1,500 bytes, whereas it is 4,352 bytes for FDDI. If a datagram cannot be accommodated in a single frame, it is divided or fragmented and sent in multiple frames. The process of dividing a datagram into multiple groups called fragments is called fragmentation.
-
The steps that are followed for fragmenting the datagram is depicted by using the following pseudocode:
if (Size of the datagram >= MTU) { if (allowfragmentation==true) { Fragment data } else { Discard data packets } else { Encapsulate the datagram into the frame and start transmission }
NOTE
IP datagrams have an option, called the Don't Fragment bit, in the Flags field that can be used to disallow fragmentation of the transmitted datagram. This can be done by setting the value of the Don't Fragment bit to 1, which is discussed later in this chapter.
- If data needs to be sent across two different networks, each working on a different technology, such as Ethernet or FDDI, encapsulating the datagram within a frame is not possible. This is because of the varying MTU values between each type of network. Therefore, the datagram might have to be fragmented. For example, if data is sent from an Ethernet network to a token ring network, data needs to be fragmented because the MTU for Ethernet is higher than that of token ring.
The process of combining all the fragments at the destination is called reassembling.
The fields in the datagram that are used for fragmentation are as follows:
Identification
Flags
Fragmentation Offset
Identification
The Identification field is used to identify a datagram. The size of the Identification field is 16 bits. A combination of the IP address and the number specified in this field is used to identify the datagram to which a component belongs. An identification number is created for a datagram and the same value is copied to the Identification field of all the fragments of the datagram.
The Identification field is used to identify all the fragments that are obtained by fragmenting a datagram. For example, if a datagram is split into five fragments, all the five fragments will have the same identification number. This will help the destination computer to reassemble all the fragments that belong to a datagram.
Flags
The Flag field has two functions. It helps in determining whether a datagram can be fragmented. It also indicates whether there are any more fragments following the current one. This field is also known as the More Fragment field.
The size of this field is 3 bits. The first bit is not used. The second bit is used to indicate whether fragmentation can be done. This field is called the Don't Fragment bit. If the value of this bit is set to 1, the datagram must not be fragmented. Otherwise, the datagram is fragmented, if necessary. If the datagram must be fragmented, but the value in the second bit is set to 1, the datagram is discarded.
The last bit in this field is used to indicate whether there are any fragments following the current one. If the value of this field is set to 0, it indicates that the current fragment is the last fragment in the datagram.
Fragmentation Offset
The Fragmentation Offset field is used by the destination to find out the position of a fragment with respect to the entire datagram. The size of the Fragmentation Offset field is 13 bits. This field, along with the Identification and Flag fields, is used by the destination to ensure that all the fragments that belong to a particular datagram are reassembled together. Even if one fragment is not delivered correctly, the entire datagram is discarded. If a datagram is discarded, an error message is sent to the Transport layer by ICMP.
Certain rules need to be followed during the process of fragmentation. They are as follows:
Only the data part of a datagram can be fragmented. The header occupies 2060 bytes and the remaining space is allotted for the data that needs to be sent. For example, if the total size of the datagram is 5,000 bytes, a minimum of 20 bytes are used to store the header information. Thus, of the 5,000 bytes allotted for the datagram, only 4,980 bytes are used to store the data. The size of a datagram must be divisible by 8. If the size of a datagram is 300 octets, only 296 bytes can be sent in the fragment and the rest should be sent in another fragment.
The Fragmentation Offset field is used to indicate the relative position of a fragment with respect to the other fragments of a datagram. The position of the datagram is not represented in terms of the exact position. It contains the number of octets that the fragment contains. The Fragmentation Offset is numbered starting from zero.
Consider a case in which fragments need to be created for a datagram of size 2,500 bytes and are to be sent through an Ethernet network. Assuming that the header size is 20 bytes, the size of data that needs to be fragmented is 2,50020, which is 2,480 bytes. MTU of an Ethernet network is 1,500, therefore two fragments need to be created for the data. One more point to note is that, in the 1,500 bytes that is provided as MTU, 20 bytes will be required to store the header information for the fragments. That is, only 1,480 bytes can be accommodated in one fragment. The remaining 1,000 bytes must be sent in the next fragment. The fragmentation offset field for the first fragment will be set to 0 and the value for the same in the second fragment will be 185 (1,480÷8). The destination computer also checks for the value in the More Fragment field to check if any more fragments are following the current one.
NOTE
If the number of bytes that need to be transferred is not in multiples of eight and is a few bytes less than the nearest multiple of eight, extra spaces are included in the data to ensure that the size of the data is divisible by eight. The exact length of the data can be found using the Total Length field and the Padding fields.
NOTE
Every destination computer has a predefined time by which all the fragments of an IP datagram need to arrive. The fragments received are retained in the memory of the destination computer until all the fragments of a datagram reach it. If all the fragments that belong to a particular datagram do not reach the destination in the time defined, an error message is sent to the sender using ICMP.
For more information on the error message sent to the sender, see "Internet Control Message Protocol," p. 61
Advantages of Fragmentation
IP, as mentioned earlier, is used to route data packets to the destination irrespective of the underlying hardware technology. IP implements this by supporting fragmentation. If the MTU is large enough to hold an entire datagram, the network traffic will be low and congestion will also be avoided. The sender can also determine the optimum size for avoiding fragmentation during the transmission of data. This function is carried out by TCP by a mechanism called path MTU discovery.
To learn more about path MTU discovery and TCP, see "Transmission Control and Data Flow," p. 73
IP Options
The IP Options field is not a mandatory field. Even without the information provided in this field, data can be transferred from the source to the destination. The IP Options field is only used for providing additional features, such as Record Route, Strict Source Route, and so on, during data transmission. The default size of the IP Options field is zero. The maximum size of this field is 40 bytes. The IP Options field is also responsible for the security of the datagrams. In addition, the field is used for testing and debugging a network. The length of the field is variable and depends on the IP options that are selected.
An IP datagram can consist of more than one IP option. An IP option can be represented in two forms. In the first form only one octet, called Option-Type, is used to represent the option. The second form includes three octets: Option-Type, Option-Length, and Option-Data. The second form requires three octets for each field. The Option-Length field is the sum of the length of the other fields in the option. The Option-Data field is used for storing data related to the Option-Type. The Option-Type is divided into three components: Copy, Option-Class, and Option-Number, which specify the operations that must be performed.
Copy
The Copy field is used to specify whether the option values must be copied to all the fragments. The size of the Copy field is 1 bit. If the value of this bit is set to 0, the option values need to be copied only to the first fragment. If the value in this field is set to 1, the options values must be copied to all the fragments.
Option-Class
The values that can be taken by the Option-Class field are 0 to 3. If the value in this field is 0, the datagram is used for network control. If the value in this field is 2, the datagram is used for debugging the network. Values 1 and 3 are reserved for future use.
Option-Number
The Option-Number field indicates the type of operation to be performed. The size of the Option-Number field is 5 bits. Two most commonly used options are Record Route and Strict Source Route. The values that can be taken by an Option-Type field are listed in Table 3.2.
Table 3.2 Various Options That Cab Provided in the IP Options Field of an IP Datagram
Option-Class |
Option-Number |
Option-Length |
Fields |
0 |
0 |
- |
End of Option |
0 |
1 |
- |
No Operation |
0 |
2 |
11 |
Security |
0 |
3 |
Variable |
Loose Source Routing |
0 |
9 |
Variable |
Strict Source Route |
0 |
7 |
Variable |
Record Route |
2 |
4 |
Variable |
Internet Timestamp |
NOTE
The End of Option field marks the end of all the options in an IP datagram.
NOTE
The No Operation field is used for handling the alignment between options in an IP datagram.
NOTE
The Security field is used to send security-related information.
The value of the Option-Class of the last option is 2, which indicates that it is used for debugging and measuring. However, the other values are used for network control.
In Strict Source Route and Loose Source Routing, the sender specifies the path that must be taken by a datagram. In Strict Source Route, the sender specifies a list of IP addresses that a source must take. There must be no deviation from the path that is specified by the sender. Like Strict Source Route, the sender specifies the list of IP addresses that a datagram must pass through in the case of Loose Source Routing also. The only difference between the former and the later is that in the case of Loose Source Routing, the path taken between two specified IP addresses can vary.
A router can also be made to track the path that is taken by a datagram. Thus, the route taken by a datagram is a dynamically growing route list. This is defined as the Record Route option. The Option-Data field is used to store the dynamically growing route list.
The Internet Timestamp option is used for debugging and measuring. This option is used to record timestamp values in the route taken by a datagram. The timestamp values can be used to find the time taken by a datagram to reach a destination. The values that are obtained can be used to measure the performance of the network.