0

I am reading this article and it talks about Multiplexing at the Transport Layer of the OSI model. I can't seem to find out what it means with 'multiplexing' at that layer? As multiplexing is a signal process, and at the Transport Layer, we're not concerned directly with signals.

Can anybody provide me with an explanation of multiplexing as used in the above mentioned article?

Tony The Lion
  • 383
  • 1
  • 2
  • 9

2 Answers2

1

The article referenced uses "multiplexing" to describe how multiple applications on the same host can share a network interface and yet the driver/kernel route packets to the correct application. The answer is that packet destinations are not indicated solely by the IP address, but by the port number as well.

Every sent packet has a port as part of it's source address. When your application specifies "any port," that just lets the OS assign one that is not in use. When the distant host sends a reply, it specifies not just the address, but the port as well, allowing your OS to determine in which socket queue the incoming packet should be placed. Even if you have two applications on one host sending packets to the same remote host, the local port numbers will be different.

mpez0
  • 1,512
  • 9
  • 9
  • The article linked is fairly weird, and really only applies to UDP sockets, bound non-exclusively for mux, and TCP socket on demux. – James Cape Feb 24 '10 at 05:00
0

So the first thing to note is that they're talking about ports as "layer 4 addresses" and multiplexing multiple application streams onto a single port, and demultiplexing multiple distinct transmissions on the receiver side.

As you'd expect, this only works with some caveats depending on the uniqueness of the ports/L4 addressing.

So a UDP socket bound in non-exclusive mode can have multiple applications which all send from the same L4 address/port. I don't remember anything in the BSD API on the receiver side to filter datagrams based on the source port, but I could be wrong---if there isn't, you're going to have to manually demux it on a higher level than the stack than L4, which isn't what the article is talking about.

With TCP, the server (bind()) socket can be combined with accept() to allow multiple simultaneous connections to the same L4 destination (port), but they must have different client (source) ports. I also don't know of any implementation of the BSD sockets API that will allow multiple TCP client sockets to bind to the same local port, because the TCP server (receiver) can only demux the stream because of differing source ports.

In other words, mux/demux at L4 with UDP or TCP only works in 50% of your cases, and never in both directions at the same time

James Cape
  • 1,067
  • 8
  • 16