News for hackers. Stuff that matters.
Re:One Million Concurrent TCP connections by Rickasaurus on Friday September 23, 2011 @12:24AM (#3028818)
This may be a dumb question (I'm not a networks guy) but how do you maintain so many connections with just 65535 ports? Can you have more than one connection per port?
Re:One Million Concurrent TCP connections by caf on Friday September 23, 2011 @12:40AM (#3028849)
The server generally only ever uses one port, no matter how many clients are connected. It is the tuple of (client IP, client port, server IP, server port) that must be unique for each TCP connection - so the limit of 65535 ports is only relevant for how many connections a single client can make to a single server.
Re:One Million Concurrent TCP connections by nathanappere on Friday September 23, 2011 @06:17AM (#3029464)
I believe this is incorrect. The server usually listen on one port, but everytime it does an accept, a different random port is used, and the client start talking to the server on that new port.
Re:One Million Concurrent TCP connections by caf on Friday September 23, 2011 @06:33AM (#3029497)
This is a surprisingly common misconception. When you accept, you get a new socket. but it is on the same local port. You can readily see this by running 'netstat' on a busy server.
Re:One Million Concurrent TCP connections by ay on Friday September 23, 2011 @08:41AM (#3029773)
Another way to see that there are no magic "dynamically selected" potrs is to run on the server "tcpdump src x.x.x.x or dst x.x.x.x" where the x.x.x.x is your client address - and check the outputs - the packets will have ports in them.

Alternatively one can read RFC793 or, better, Stevens' "TCP/IP Illustrated".

Re:One Million Concurrent TCP connections by nathanappere on Friday September 23, 2011 @11:08AM (#3030218)
Just checked it and you're right. I believed I had encoutered the behaviour I described but I do not remember in which context. Anyway glad I learned something!
Re:One Million Concurrent TCP connections by dsl on Friday September 23, 2011 @07:32PM (#3031997)
FTP.
Re:One Million Concurrent TCP connections by pavelkaroukin on Friday September 23, 2011 @01:03PM (#3030698)
I believe this comes from how FTP protocol works which do it to some extent and the reason why it do not work trough firewalls well without using passive mode.
Re:One Million Concurrent TCP connections by tybris on Friday September 23, 2011 @08:02AM (#3029684)
By that logic, you would have to open every single port on your firewall if you wanted to set up a web server. Fortunately, your OS just looks at the client IP/port to distinguish multiple TCP streams.
Re:One Million Concurrent TCP connections by richardw on Friday September 23, 2011 @01:07AM (#3028897)
You can have multiple connections on the same port from the same client. E.g. all connections via HTTP commonly go over the same port and a single browser usually has 2-4 simultaneous connections to the server. They don't use multiple ports to achieve this.
Re:One Million Concurrent TCP connections by caf on Friday September 23, 2011 @01:12AM (#3028912)
They use multiple ports on the client side to achieve this - the "client port" part of the tuple varies.
Re:One Million Concurrent TCP connections by pacala on Friday September 23, 2011 @12:26AM (#3028822)
There is one unique connection per (address, port) pair.
Re:One Million Concurrent TCP connections by huhtenberg on Friday September 23, 2011 @12:36AM (#3028841)
Actually, the quintet of [protocol, src_ip, src_port, dst_ip, dst_port] is what's unique (protocol being TCP or UDP)
Re:One Million Concurrent TCP connections by pacala on Friday September 23, 2011 @01:41AM (#3028980)
Good point. Each unique client (address, port) can get a separate connection on a given/fixed server (address, port).
Re:One Million Concurrent TCP connections by Rickasaurus on Friday September 23, 2011 @12:27AM (#3028825)
Ahh I see, you just give one box a ton of IPs. Thanks :)
Re:One Million Concurrent TCP connections by kornholi on Friday September 23, 2011 @12:34AM (#3028839)
No, the pair uses the client IP which means the client can have as many connections to your server as number of ephemeral ports allowed. There is no limit on connections except ram AFAIK.
Re:One Million Concurrent TCP connections by stonemetal on Friday September 23, 2011 @08:21AM (#3029725)
Not sure why you got down voted, last time this topic came up the author was using EC2 instances for test clients, it took them 17 or so to get the number of connections to their server that they wanted. When the server IP, server port part of the 4 tuple is constant, it takes quite a few client IPs to turn 64K ports into a million.