Multiplexing & Demultiplexing in UDP
Connectionless refers to multiplexing and demultiplexing with UDP. Let's dive right in.
We'll cover the following
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 port numbers exist. However, they start from port so they exist in the range of .
- Out of these, the port numbers are well-known and are reserved for certain standard protocols. Port , for instance, is reserved for HTTP whereas port 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.
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!
Ports - are termed as ephemeral ports.
True
False
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.