Multiplexing and Demultiplexing in the Transport Layer

 

Multiplexing and Demultiplexing in the Transport Layer

Introduction

One of the important functions of the Transport Layer is to support communication between multiple application processes running simultaneously on a computer. This is achieved through two complementary operations:

  • Multiplexing – Performed at the sender.
  • Demultiplexing – Performed at the receiver.

These mechanisms enable many applications to share the same network connection efficiently while ensuring that each message reaches the correct application process.


What is Multiplexing?

Definition

Multiplexing is the process by which the Transport Layer accepts data from multiple application processes, adds the appropriate transport-layer information (such as port numbers), and combines them into transport-layer packets for transmission through the network.

It is called many-to-one communication because many application processes send their data to a single transport layer.


Working of Multiplexing

Suppose a user is simultaneously:

  • Browsing the web
  • Sending an email
  • Downloading a file

Each application generates its own data.

The transport layer receives all these messages, adds the appropriate source and destination port numbers, and forwards them one by one to the network layer.

Diagram

          Application Layer

        Web Browser (HTTP)
               │
        Email Client (SMTP)
               │
         FTP Client
               │
         DNS Client
               │
               ▼
        -------------------
        Transport Layer
       (Multiplexing)
        -------------------
               │
               ▼
          Network Layer

Here, many application processes share a single transport layer.


Example of Multiplexing

Consider a user performing three tasks simultaneously:

ApplicationSource PortDestination Port
Web Browser5200080
Email Client5300025
FTP Client5400021

The transport layer creates three transport packets.

Packet 1

Src Port = 52000
Dest Port = 80
Data = HTTP Request


Packet 2

Src Port = 53000
Dest Port = 25
Data = Email


Packet 3

Src Port = 54000
Dest Port = 21
Data = FTP Request

All three packets are then sent through the same network interface.


Advantages of Multiplexing

  • Multiple applications can communicate simultaneously.
  • Efficient utilization of the network.
  • Allows sharing of the same transport protocol.
  • Reduces communication overhead.

What is Demultiplexing?

Definition

Demultiplexing is the reverse process of multiplexing. The Transport Layer receives packets from the network layer, examines the destination port number, and delivers each packet to the correct application process.

It is called one-to-many communication because one transport layer distributes packets to many application processes.


Working of Demultiplexing

At the receiver,

  1. The transport layer receives packets.
  2. It reads the destination port number.
  3. It identifies the appropriate application.
  4. It delivers the message to that application.

Diagram

            Network Layer
                  │
                  ▼
        -------------------
        Transport Layer
      (Demultiplexing)
        -------------------
          │      │      │
          ▼      ▼      ▼
      Web     Email    FTP
     Server   Server  Server

Thus, the transport layer delivers each packet to its correct destination process.


Example of Demultiplexing

Suppose the destination computer receives three packets.

Packet 1

Destination Port = 80

Delivered to

HTTP Server

Packet 2

Destination Port = 25

Delivered to

SMTP Server

Packet 3

Destination Port = 21

Delivered to

FTP Server

The operating system uses the destination port number to identify the correct application.


Complete Multiplexing and Demultiplexing Process

                 Sender Computer

   Web Browser
        │
   Email Client
        │
   FTP Client
        │
        ▼
 -------------------------
 |   Transport Layer     |
 |    Multiplexing       |
 -------------------------
          │
          ▼
      Network Layer
          │
      Internet
          │
          ▼
      Network Layer
 -------------------------
 |   Transport Layer     |
 |   Demultiplexing      |
 -------------------------
      │       │       │
      ▼       ▼       ▼
 Web Server  Mail    FTP
             Server  Server

             Receiver Computer


Figure 3.8 shows communication between a client and two servers. Three client processes are running at the client site, P1, P2, and P3. The processes P1 and P3 need to send requests to the corresponding server process running in a server. The client process P2 needs to send a request to the corresponding server process running at another server. The transport layer at the client site accepts three messages from the three processes and creates three packets. It acts as a multiplexer. The packets 1 and 3 use the same logical channel to reach the transport layer of the first server. When they arrive at the server, the transport layer does the job of a demultiplexer and distributes the messages to two different processes. The transport layer at the second server receives packet 2 and delivers it to the corresponding process. Note that we still have demultiplexing although there is only one message.



Role of Port Numbers

Port numbers are the key to multiplexing and demultiplexing.

During Multiplexing

The transport layer adds:

  • Source Port Number
  • Destination Port Number

Example

Source Port      = 52000
Destination Port = 80

During Demultiplexing

The transport layer examines:

Destination Port = 80

and delivers the packet to

HTTP Server

Without port numbers, the operating system would not know which application should receive the data.


Real-Life Analogy

Imagine a post office.

Multiplexing

Many people send letters to the post office.

Person A
Person B
Person C
      │
      ▼
   Post Office

The post office collects all the letters and sends them through the transportation system.

This is similar to multiplexing.


Demultiplexing

At the destination city,

Post Office
      │
 ┌────┼─────┐
 │    │     │
 ▼    ▼     ▼
House A House B House C

The post office sorts the letters and delivers each one to the correct house.

This is similar to demultiplexing.


Multiplexing vs Demultiplexing

FeatureMultiplexingDemultiplexing
MeaningMany processes send data to one transport layerOne transport layer delivers data to many processes
CommunicationMany-to-OneOne-to-Many
Performed AtSenderReceiver
PurposeCollect data from multiple applicationsDeliver data to the correct application
Uses Port NumbersAdds source and destination port numbersExamines destination port number

Importance of Multiplexing and Demultiplexing

  • Supports multitasking.
  • Allows multiple applications to use the network simultaneously.
  • Efficiently utilizes network resources.
  • Enables process-to-process communication.
  • Ensures data reaches the correct application.
  • Essential for TCP and UDP communication.

Summary

  • Multiplexing is the process by which the Transport Layer collects data from multiple application processes, adds transport-layer headers (including port numbers), and sends the packets to the network layer. It is a many-to-one operation.
  • Demultiplexing is the reverse process, in which the Transport Layer receives packets from the network layer, examines the destination port number, and delivers each packet to the appropriate application process. It is a one-to-many operation.
  • Together, multiplexing and demultiplexing enable multiple applications to communicate simultaneously over the same network while ensuring that each message is delivered to the correct destination process.

Comments

Popular posts from this blog

Computer Networks PCCST501 Semester 5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Computer Networks

Introduction to Local Area Network (LAN)