Connection Multiplexing Explained with Examples

Connection or session multiplexing occurs at the Transport layer. It allows multiple applications to send and receive data simultaneously. It assigns a unique number to each session or connection to keep it separate from others. This unique number is known as a port number.

In each session or connection, two port numbers are used: the source port and destination port. The source port number identifies the session or connection, while the destination port number identifies the application that processes the data at the destination host. To assign the source and destination port numbers, TCP and UDP use two fields in the segment header: the source port and destination port fields. The port number field is 16 bits long, allowing a total of 65536 (0-65535) port numbers.

Port numbers are divided into three categories: well-known, registered, and dynamically assigned.

Port type Range Description
Well-known 0 to 1023 IANA assigns these numbers to applications commonly used on the Internet, such as DNS and HTTP.
Registered 1024 to 49151 IANA assigns these numbers to proprietary applications, such as Shockwave and Oracle.
Dynamically assigned 49152 to 65535 The sending device assigns these numbers to the sessions.

Well-known and registered port numbers are used in the destination port field, while dynamically assigned port numbers are used in the source port field.

At the transport layer, the source host assigns a separate port number to each session from a pool of dynamically assigned port numbers. When it initiates a new session, it picks a currently unused dynamic port number from 49152 to 65535 and assigns it to the session. All segments sent through this session use the assigned port number as the source port. For the destination port number, the destination application's port is used.

At the destination host, the transport layer, upon receiving segments from the source host, checks the destination port field in each segment to determine which application should process it. After processing, when the destination application returns the data, the transport layer at the destination host uses the same port numbers in reverse. It uses the port number of the application that processed the segment as the source port, and the port number from which the segment was received as the destination port.

Let’s take an example. A host wants to access a website. So it initiates a TCP session. The transport layer assigns a dynamic port number, 50000, to this session. Since this session is initiated to communicate with a web server that uses the HTTP protocol to serve websites, and the HTTP protocol uses port 80, the destination port is 80.

Upon receiving segments from the source host, the transport layer at the web server checks the destination port number in the segment headers. From the destination port number, it knows that the source wants to communicate with an application that uses the HTTP protocol. While responding to this host, it uses destination port 5000 and source port 80.

source port and destination port

Now, suppose the host wants to access another website from the same or another web server. So it initiates a new session. Since it’s a new session, the transport layer assigns a new port number. The new port number allows it to keep its segments separate from the existing session.

session multiplexing

If only one host accesses remote hosts, port numbers are sufficient to multiplex sessions. But if there is more than one host, session multiplexing can’t be done solely based on port numbers.

Let’s take an example. Two hosts want to access a web server simultaneously. So they both initiate sessions. Spouse, they both assign the same port number, 50000, to their sessions. Now, how will the web server know which segment is coming from which host?

To address such a situation, an IP address and a port number are used for multiplexing. Since both hosts have different IP addresses, the destination host can easily differentiate their sessions even though they both use the same source and destination port numbers. The following figure illustrates this. In this example, two hosts, 1.1.1.1 and 2.2.2.2, access two web servers, 10.10.10.10 and 20.20.20.20, simultaneously using the same source port numbers.

connection multiplexing or application mapping

In this way, to make a connection or session unique or to allow a host to connect to multiple applications simultaneously, three components are used together: a transport-layer protocol, a source port number, and a destination IP address. To refer to these three things together, the technical term socket is used.

For example, in the figure above, the host 2.2.2.2 is using the socket (10.10.10.10, TCP, 50000) to connect to the web server 10.10.10.10, while to connect to the web server 20.20.20.20, it uses the socket (20.20.20.20, TCP, 5001).

In the same way, the host 1.1.1.1 is using the socket (10.10.10.10, TCP, 50000) to connect with the web server 10.10.10.10, while to connect with the web server 20.20.20.20, it is using the socket (20.20.20.20, TCP, 5001).

Both transport-layer protocols, TCP and UDP, use socket-based multiplexing to deliver data to the correct application at the source and destination hosts.

This tutorial is part of the tutorial series "Networking reference models explained in detail with examples". Other parts of this series are the following.
Chapter 1   What is a Networking Model Explained
Chapter 2   OSI Model Advantages and Basic Purpose Explained
Chapter 3   Difference between original and modern TCP/IP models
Chapter 4   Similarities and Differences between the OSI and TCP/IP models
Chapter 5   Adjacent-layer and same-layer interactions
Chapter 6   Data Encapsulation and De-encapsulation Explained
Chapter 7   OSI Seven Layers Model Explained with Examples
Chapter 8   TCP/IP Reference Model Explained
Chapter 9   Application layer in the OSI and TCP IP layers models
Chapter 10  Presentation layer and Session layer of the OSI model
Chapter 11  The Transport Layer Explained
Chapter 12  Segmentation Explained with TCP and UDP Headers
Chapter 13  Connection Multiplexing Explained with Examples
Chapter 14  TCP Features and Functions Explained with Examples
Chapter 15  The Network Layer Explained
Chapter 16  The Data Link and Physical layers Explained

Conclusion

TCP and UDP rely on port numbers and sockets to enable multiple simultaneous connections and ensure data is delivered to the correct applications. By combining IP addresses, port numbers, and transport protocols, the source and destination devices enable reliable, efficient session multiplexing across modern networks.

ComputerNetworkingNotes CCNA Study Guide Connection Multiplexing Explained with Examples

We do not accept any kind of Guest Post. Except Guest post submission, for any other query (such as adverting opportunity, product advertisement, feedback, suggestion, error reporting and technical issue) or simply just say to hello mail us ComputerNetworkingNotes@gmail.com