Multiplexing happens at the sender:

Demultiplexing happens at the receiver:

image.png

Demultiplexing

Connectionless Demultiplexing

On creation of a UDP socket, a host-local port number must be specified - this is included in transport layer.

UDP sockets on destination are uniquely specified by pair of (destination IP address, destination port number).

On host receipt of UDP segment, the host checks the destination port number in the segment and directs the UDP segment to the socket with the matching port number.

Note in this example, the messages from different hosts have their messages written to the same receiver.

Note in this example, the messages from different hosts have their messages written to the same receiver.

Connection-Oriented Demultiplexing

TCP sockets are uniquely identified by the 4-tuple of: