Skip to main content

What is demultiplexing?

Demultiplexing is a process at the transport layer, in which incoming data from the network is distributed to the right applications.

More simply: demultiplexing is when the OS figures out which application to hand the received data to.


Why demultiplexing is needed

When a packet arrives at a computer:

  • it arrives at a single IP address
  • through a single network interface

But there are many applications. Demultiplexing solves the task of:

which program to pass this data to


How demultiplexing works

1. A segment/datagram arrives

The transport layer receives data from the network.


2. The header fields are analyzed

The OS looks at:

  • the protocol (TCP or UDP)
  • the destination port
  • (for TCP, also the IP addresses and the source port)

3. The data is delivered to the right socket

Based on this information:

  • a socket is selected
  • the data is delivered to a specific process

Demultiplexing in TCP and UDP

UDP

  • the choice is made mainly by:
    • the destination port
    • the protocol
  • one socket can receive messages from different senders

TCP

  • the connection is defined by the exact pair:

    (source IP, source port, destination IP, destination port)
  • this lets a server:

    • serve thousands of clients
    • on the same port

Relationship to multiplexing

Important for the interview.

  • Multiplexing - combining data from different applications when sending
  • Demultiplexing - parsing incoming data and delivering it to the right applications

These are two sides of the same mechanism.


What is important to remember

  • demultiplexing is a function of the transport layer
  • it is based on ports and sockets
  • without it, applications could not work in parallel

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.