Rich Freeman on 3 May 2014 13:19:32 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] udp ports


On Sat, May 3, 2014 at 11:23 AM, Sam Gleske <sam.mxracer@gmail.com> wrote:
> On Sat, May 3, 2014 at 10:16 AM, Rich Freeman <r-plug@thefreemanclan.net>
> wrote:
>>
>> I'm open to correction here if I have things wrong, but this
>> limitation really only applies to programs listening for a connection.
>>  That is, you can't have more than 64k different listening sockets at
>> a time.
>
>
> You're incorrect.  In order to open a socket connection you need a source
> port and a destination port.  So you as a client open a port in your 65535
> ports (usually an arbitrarily high number) for receiving communication from
> the server.  TCP multiplexing is still involved with receiving server
> communication on a client.  Short answer is yes you're limited by the
> combination of listening sockets and receive ports for data from server to
> client communications.

I agree that you're limited by the combination of ports on the client
and server, but that means 64k^2 "connections" PER IP, or a total of
64k^2*2^32 connections if you have the maximum number of "connections"
open with every single host on the internet.

The term "connection" is a bit inaccurate though, as there is no
actual connection.  An application can bind to a port and accept udp
packets, and an application can send packets from a port (though as
far as I'm aware, doing so does not in any way reserve the port if it
is transmit-only - so 14 different applications could all send packets
from a particular UDP port).  When packets are received they contain
the source IP and port, so an application can keep track of up to 64k
different streams of packets from any particular IP.

Now, I'm not sure if the linux implementation of UDP falls short of
this ideal, or if I'm missing something subtle.  However, it is just
fine for 75 different computers to all send packets to your DNS server
at the same time, and this only consumes one port on your DNS server.
Even with TCP you can have 75 incoming connections to port 80 on your
webserver from different hosts at the same time.  What you can't have
is 75 different TCP connections from the same source port on one host
to the same destination port on your local host.  For UDP that
limitation doesn't necessarily exist, since it is stateless.

Does that make sense?

Rich
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug