Multiplexing & Demultiplexing in UDP

Connectionless refers to multiplexing and demultiplexing with UDP. Let's dive right in.

Ports

Here’s a quick refresher on what ports are because that needs to be crystal clear in order for you to understand multiplexing and demultiplexing.

  • Sockets, which are gateways to applications, are identified by a combination of an IP address and a 16-bit port number. That means 216=655362^{16}= 65536 port numbers exist. However, they start from port 00 so they exist in the range of 0655350-65535.
Press + to interact
Sockets have associated port numbers!
Sockets have associated port numbers!
  • Out of these, the port numbers 010230-1023 are well-known and are reserved for certain standard protocols. Port 8080, for instance, is reserved for HTTP whereas port 2222 is reserved for SSH.
  • Refer to page 16 of RFC 1700 for more details regarding what port number is assigned to what protocol.

Multiplexing & Demultiplexing in UDP

  • When a datagram is sent out from an application, the port number of the associated source and destination application is appended to it in the UDP protocol header.

  • When the datagram is received at the receiving host, it sends the datagram off to the relevant application’s socket based on destination port number.

  • If the source port and source IP address of two datagrams are different but the destination port and IP address are the same, the datagrams will still get sent to the same application.

Here are some slides to give you a quick overview of what happens.

Press + to interact
An application produces data
An application produces data
1 of 6

On Port Assignment in UDP

It’s far more common to let the port on the client-side of an application be assigned dynamically instead of choosing a particular port. This is because for communication, both parties must be able to identify each other. Since the client initiates communication to the server, it must know the port number of the application on the server. However, the server doesn’t need to know the client application’s port number in advance. When the first datagram from the client reaches the server, it will carry the client port number, which the server can use to send datagrams back to the client.

However, server-side applications generally do not use dynamically allocated ports! This is because they are running well-known protocols like HTTP and need to be bound to specific ports.

Quick Quiz!

1

Ports 00 - 10231023 are termed as ephemeral ports.

A)

True

B)

False

Question 1 of 30 attempted

Let’s look at the principles of reliable data transfer in the next lesson. This is key to building a good foundation for later lesson on TCP!

Get hands-on with 1400+ tech skills courses.