A Web-Based Introduction to Computer Networks for Non-Majors

What concepts is this applet illustrating?


As mentioned in the Preliminaries section, all of the networks that form the Internet are able to communicate with each other because they all use the same series of protocols. The two most well-known of these protocols are the Transmission Control Protocol (TCP) and the Internet Protocol (IP). Consequently, this family of protocols is called the TCP/IP protocols. These protocols are implemented by software that resides on each of the computers on the Internet and are organized into layers. Thus, they are called the TCP/IP protocol stack. Each time that your computer wants to send a packet to another computer, your packet must go down through the series of protocol layers on your computer. Each of these protocol layers modifies your packet and then passes the packet on to the software which is the next protocol layer. When your packet reaches the destination computer, the packet must go up through the same series of protocol layers to be transformed into its final version.

Because the packet is being modified at each layer, the packet has a different name at each layer. The name used generically for the packet at any layer is packet. The term packet is used at the application layer. The term segment is used at the transport layer. The term datagram is used at the network layer. The term frame is used at the data link layer.

Since the Internet is an internetwork there exist connections between adjacent networks. These connections are usually specialized computers called routers. As your packet moves across the Internet towards the destination computer, the packet has to pass through the routers connecting the networks the packet is traversing. At each router the packet has to pass through some of the protocols in the TCP/IP protocol stack, but not all of them. Your packet has to move part of the way up through the protocol layers on the router to remove the features specific to the network the packet is leaving. The packet then moves down through the protocol layers on that router to add the features specific to the network the packet is entering.

The Java applet above illustrates this process of a packet moving down through the protocol layers on the sending computer (the source computer), up and then down the protocol layers on any routers it encounters on its journey, and finally up through the protocol layers on the receiving computer (the destination computer). The protocol layers have standard names which are shown. We will not attempt to explain the exact function of each layer. However, the later sections of these notes have been chosen to illustrate some of the concepts that occur at each level. For example, both name resolution and the implementation of the web are done at the application layer, ensuring reliable data transfer as we discuss it is done at the transport layer, and media access in Ethernet local area networks is done at the data link layer.

This applet illustrates the basic process of protocol layer traversal by the packet moving down the source machine's protocol stack, up through the protocol stack the router has for the first network, down through the protocol stack the router has for the second network, and finally up through the protocol stack on the destination machine. Different colors are used to indicate the different layers being traversed. Beyond this basic concept the applet illustrates three additional concepts.

Router Stops At Network Layer

The first concept (which is clear from the layout of the applet) is that the packet only needs to go up through the network layer on the router. A router need only contain up through the network layer because the network layer is responsible for choosing the path through the Internet that the packet will follow. Choosing the path is called routing. The router is called a router because the network layer on the router is involved in the routing decision (that is, choosing which route or path the packet should follow). The one protocol at the network layer is called IP (Internet Protocol) and is one of the most important protocols in the TCP/IP protocol stack.

Encapsulation and Deencapsulation

The second concept is that of encapsulation and deencapsulation. As a packet moves down through the protocol layers on the source machine and down through the protocol layers on a router one of the transformations that the packet undergoes is called encapsulation. Encapsulation means that the original packet is encapsulated or wrapped by a header (and for some layers, a trailer) resulting in a larger packet. Each protocol layer does encapsulation to add the information specific to that layer to the packet. Similarly, as the packet goes up through the protocol layers on a router and on the destination machine, these headers are removed in a process called deencapsulation. The bottom left part of the applet window is a table listing the size of the applet packet and the sizes of each of the headers. The applet illustrates this concept by showing each header being added to the packet or being removed from the packet by the appropriate protocol layer. Furthermore, each header is shown in the color of the corresponding protocol layer.

Fragmentation and Reassembly

The third concept is that of fragmentation and reassembly. Each network has a maximum size of packet that can be sent across the network. Different types of networks may have different maximum sizes. This size is called the Maximum Transmission Unit (MTU). More precisely the MTU is the maximum size of the payload of the frame that is sent across the network. The payload of the frame does not include the frame header. The size of the message that originates at the application layer can be arbitrarily large. The transport layer prepends the transport header to create a segment which is then passed to the network layer. The network layer prepends the network layer to create a datagram which it then wants to pass to the data link layer. However, that datagram is the payload of the data link layer frame. Thus, if that datagram is larger then the MTU there is a problem.

The solution is that the network layer must divide its datagram into fragments with each fragment no larger than the MTU. Each fragment must be a datagram in that it has a network layer header. Thus, what happens is that the segment passed down to the network layer from the transport layer is divided into the payloads for each of the fragments. Each fragment is then turned into a datagram by prepending a network layer header. The entire fragment (including the network layer header) cannot be larger than the MTU of the network.

The applet simulation uses a message size of 2000 bytes and a transport layer header of 20 bytes. Thus, the segment being passed to the network layer on the source machine is 2020 bytes. If the MTU of the first network is 3000 bytes than no fragmentation is needed. The source machine network layer simply prepends the network layer header of 20 bytes and passes the datagram to the source machine data link layer. The source machine data link layer prepends its frame header of 16 bytes and then a frame of 2056 bytes goes across the network. This scenario happens with the default setting of the MTU of the first link being 3000 bytes.

If the MTU of the first network is changed to 1500 bytes by selecting the 1500 byte radio button, then the network layer on the source machine has to fragment. As the applet simulation shows two fragments result. The first fragment has a 20 bytes network layer header followed by 1480 bytes of the segments received from the transport layer. That 1480 bytes starts with the 20 bytes of the transport layer header and then the first 1460 bytes of the application layer message. The total size of the first fragment is 1500 bytes since that is the size of MTU for the first link. In other words, that is the maximum payload that can be put in a frame. Thus, the total size of the first frame is 1516 bytes.

Since the segment received from the transport layer was 2020 bytes, there still are 540 bytes of that segment to transmit. Notice that 540 bytes of that segment left to transmit do not include a copy of the tranport layer header. The transport layer header is the first part of the segment so it only appears in the first fragment. Thus, a second fragment is created that has 20 bytes for the network layer header and then 540 bytes for the rest of the fragment. Thus, the total size of the second fragment is 560 bytes. Thus, the total size of the second frame is 576 bytes.

Fragmentation need not only occur in order to traverse the first network. For example, set the MTU of the first network to 3000 bytes and set the MTU of the second network to 1000 bytes. In this case, only one frame is sent across the first network; i.e. no fragmentation. However, the network layer in the router has to create fragments in order to satisfy the MTU of the second network. Thus, the fragmentation might have to be done either by the source machine's network layer or the network layer of any of the routers. The fragments generated by the router's network layer have 1000 bytes in the first fragment (20 bytes for the network layer header, and the first 980 bytes of the transport layer segment (which contains first 20 bytes for the transport layer header and then 960 bytes of the application layer message)), 1000 bytes in the second fragment (20 bytes for the network layer header and the second 980 bytes of the transport layer segment), and 80 bytes in the third fragment (20 bytes for the network layer header and then the last 60 bytes of the application layer message).

Fragmentation may occur at multiple points during a packet's traversal of the internetwork. For example, set the MTU of the first network to 1500 bytes and set the MTU of the second network to 1000 bytes. In this case, the source machine network layer fragments the packet into two fragments. The first of these two fragments results in the network layer of the router receiving a first datagram that is 1500 bytes. This is larger than the MTU of the second network so that network layer must fragment that first fragment into two fragments.

The first of the resulting datagram is 1000 bytes (20 bytes for the network layer header and 980 bytes for the first part of the payload from the original first datagram; of these 980 bytes, the first 20 bytes are the transport layer header). The second of the resulting datagrams is 520 bytes since it contains 20 bytes for a new network layer header plus the 500 bytes remaining from the original first diagram. Notice that original second fragment is not effected.

If the network layer of the destination machine receives multiple fragments for a single original datagram, then that network layer is responsible for merging those fragments into a single datagram before passing it up to the transport layer on the destination machine. This merging is called reassembly.

It would be possible in some cases to do reassembly at a router instead of or in addition to at the destination machine. This would occur if the outgoing network for the router has a MTU is large enough so that two consecutive fragments could be merged and still be smaller than the outgoing network's MTU. For example, in the applet simulation if original message (at the application layer) is 2000 bytes, the MTU of the first network is 500 bytes, and the MTU of the second network is 3000 bytes, then clearly the router could merge some of the fragments arriving from the first network.

The decision that has been adopted in the Internet is not to do reassembly at the routers. Reassembly only occurs at the destination machine. The reason for this decision is that it is important to make the routers as fast as possible and doing reassembly at the routers would slow the routers. Reducing the number of fragments on the outgoing network is not a large enough advantage to overcome the disadvantage of slowing the routers.