Computer Networks Essentials / Transport Layer

Multiplexing & Demultiplexing

๐Ÿค” Why Do We Need Multiplexing & Demultiplexing?

A single device can run many applications at the same time:

  • ๐ŸŒ Web browser

  • ๐Ÿ“ง Email client

  • ๐ŸŽฎ Online game

  • ๐Ÿ“‚ File download

๐Ÿ“Œ All these applications want to:

  • Send data โŒ

  • Receive data โŒ

  • Use the same network interface โŒ

๐Ÿ‘‰ How is this possible without confusion?

๐Ÿ’ก Answer: Multiplexing & Demultiplexing


๐Ÿง  Simple Definitions

๐Ÿ”€ Multiplexing

๐Ÿ“Œ Multiplexing is the process of combining data from multiple applications and sending it over the network through a single channel.

๐Ÿ” Demultiplexing

๐Ÿ“Œ Demultiplexing is the process of receiving data from the network and delivering it to the correct application.


๐Ÿง  One-Line Understanding

  • ๐Ÿ“ค Multiplexing โ†’ Many โ†’ One

  • ๐Ÿ“ฅ Demultiplexing โ†’ One โ†’ Many


๐Ÿง  Real-Life Analogy (Very Easy to Remember)

๐Ÿ“ฎ Post Office Example

  • Many letters from different people โ†’ Multiplexing

  • Post office sorts letters by address โ†’ Demultiplexing

๐Ÿ‘‰ Transport Layer works exactly the same way.


๐Ÿงญ Where Do Multiplexing & Demultiplexing Occur?

  • Performed at the Transport Layer

  • Uses:

    • Port numbers

    • IP addresses

    • Protocol (TCP/UDP)

๐Ÿ“Œ Network Layer does NOT handle applications.


๐Ÿ“ค Multiplexing (Sender Side)

๐Ÿง  What Happens at Sender?

1๏ธโƒฃ Multiple applications generate data

2๏ธโƒฃ Each application is assigned a port number

3๏ธโƒฃ Transport Layer:

  • Adds source & destination port

  • Creates segments

    4๏ธโƒฃ Segments are passed to Network Layer

๐Ÿ“Œ All data flows through one network connection.

๐Ÿง  Example

Application

Source Port

Browser

52345

Email

52346

File Transfer

52347

๐Ÿ‘‰ Transport Layer multiplexes them.


๐Ÿ“ฅ Demultiplexing (Receiver Side)

๐Ÿง  What Happens at Receiver?

1๏ธโƒฃ Segments arrive from Network Layer

2๏ธโƒฃ Transport Layer reads:

  • Destination port number

    3๏ธโƒฃ Data is delivered to:

  • Correct application

๐Ÿ“Œ Each application receives only its own data.

๐Ÿง  Example

Destination Port

Application

80

Web Server

25

Mail Server

21

FTP Server

๐Ÿ‘‰ Transport Layer demultiplexes data.


๐Ÿ”Œ Role of Ports in Multiplexing & Demultiplexing

๐Ÿ“Œ Ports are the key identifiers.

Without ports:

  • Data reaches device โœ”๏ธ

  • But not the correct application โŒ

๐Ÿ‘‰ Ports solve this problem.


๐Ÿง  Multiplexing & Demultiplexing

๐Ÿ”น TCP Characteristics

  • Connection-oriented

  • Uses socket pairs

๐Ÿ“Œ TCP identifies a connection using:

(Source IP,Source Port, Destination IP, Destination Port)

๐Ÿ‘‰ This ensures:

  • Reliable delivery

  • Correct application mapping

๐Ÿ”น UDP Characteristics

  • Connectionless

  • Simpler demultiplexing

๐Ÿ“Œ UDP uses:

  • Destination port

  • Destination IP

๐Ÿ‘‰ Faster but less strict.


โš–๏ธ TCP vs UDP (Multiplexing Perspective)

Feature

TCP

UDP

Connection

Required

Not required

Identification

4-tuple

Port-based

Reliability

High

Low

Complexity

High

Low


๐Ÿง  Why Transport Layer Handles This (Not Network Layer)

Layer

Responsibility

Network Layer

Deliver packet to correct device

Transport Layer

Deliver data to correct application

๐Ÿ“Œ Multiplexing & demultiplexing are application-level tasks.


๐Ÿ”„ End-to-End View (Complete Picture)

1๏ธโƒฃ Application generates data

2๏ธโƒฃ Transport Layer multiplexes

3๏ธโƒฃ Network Layer routes

4๏ธโƒฃ Transport Layer demultiplexes

5๏ธโƒฃ Application receives data


๐Ÿง  Common Mistake to Avoid

โŒ Multiplexing is done by Network Layer

โœ”๏ธ Multiplexing is done by Transport Layer


โญ Advantages of Multiplexing & Demultiplexing

  • Efficient use of network

  • Supports multiple applications

  • Prevents data confusion

  • Enables multitasking


โญ Memory Trick

  • MULTIplexing โ†’ MULTI apps โ†’ One channel

  • DEmultiplexing โ†’ DEliver to correct app


โญ One-Line Summary

๐Ÿ”น Multiplexing combines data from multiple applications, and demultiplexing delivers data to the correct application using port numbers.