Multiplexing and Demultiplexing in Transport Layer
Multiplexing and demultiplexing in transport layer means extending the host-to-host delivery service provided by the network layer to a process-to-process delivery service for applications running on the hosts.
A multiplexing-demultiplexing service is needed for all computer networks.
At the destination host, the transport layer receives segments from the network layer just below. The transport layer has the responsibility of delivering the data in these segments to the appropriate application process running in the host. Let’s take a look at an example.
Suppose you are sitting in front of your computer, and you are downloading web pages while running one FTP session and two Telnet sessions.
You therefore have four network application processes running – two Telnet processes, one FTP process, and one HTTP process. When the transport layer in your computer receives data from the network layer below, it needs to direct the received data to one of these four processes. Let’s now examine how this is done.
We know that a process can have one or more sockets, doors through which data passes from the network to the process and vice versa.
Thus as shown in the figure below, the transport layer in the receiving host does not actually deliver directly to a process, but instead to an intermediary socket. Because at any given time there can be more than one socket in the receiving host, each socket has a unique identifier. The format of the identifier depends on whether the socket is a UDP or a TCP socket.
Now let’s consider how a receiving host directs an incoming transport-layer segment to the appropriate socket. Each transport layer segment has a set of fields in the segment for this purpose. At the receiving end, the transport layer examines these fields to identify the receiving socket and then directs the segment to that socket. This job of delivering the data in a transport-layer segment to the correct socket is called demultiplexing . The job of gathering data chunks at the source host from different sockets, encapsulating each data chunk with header information to create segments, and passing the segments to the network layer is called multiplexing .
Note that the transport layer in the middle host (in the above figure) must demultiplex segments arriving from the network layer below to either process P1 or P2 above; this is done by directing the arriving segment’s data to the corresponding process’s socket. The transport layer in the middle host must also gather outgoing data from these sockets, form transport layer segments, and pass these segments down the network layer. Although we have introduced multiplexing and demultiplexing in the context of internet transport protocols, it’s important to realize that they are concerns whenever a single protocol at one layer (at the transport layer or elsewhere) is used by multiple protocols at the next higher layer.
To illustrate the demultiplexing job, recall the household analogy in the previous session. Each of the kids is identified by his or her name. When Bill receives a batch of mail from the mail carrier, he performs a demultiplexing operation by observing to whom the letters are addressed and then hand delivering the mail to his brothers and sisters. Ann performs a multiplexing operation when she collects letters from her brothers and sisters and gives the collected mail to the mail person.
Now that we understand the multiplexing and demultiplexing in transport layer , let us examine how it is actually done in a host. From the discussion above, we know that transport layer multiplexing requires that :
- sockets have unique identifiers, &
- each segment have special fields that indicate the sockets to which the segment is to be delivered.
These special fields, as shown in the figure below, are :
- The source port number field , &
- The destination port number field .
Each port number is a 16-bit number, ranging from 0 to 65535. The port numbers ranging from 0 to 1023 are called well-known port numbers and are restricted, which means that they are reserved for use by well-known application protocols such as HTTP (which uses port number 80) and FTP (which uses port number 21).
The list of well-known port numbers is given in RFC 1700 and is updated at http://www.iana.org [RFC 3232].
When we develop a new application we must assign the application a port number.
It should now be clear how the transport layer could implement the demultiplexing service: Each socket in the host could be assigned a port number, and when a segment arrives at the host, the transport layer examines the destination port number in the segment and directs the segment to the corresponding socket. The segment’s data then passes through the socket into the attached process. This is basically how UDP does it. However, in case of TCP it is more subtle.