3
\$\begingroup\$

There are a few older games (Quake III and Hexen II to name a couple) where the server assigns a port per player.

Are there performance advantages to this? I suspect there may be, since Carmack & Co.'s endeavours tend to lean in that direction.

I found this, which doesn't provide many different points of view... unfortunately the Book of Hook (link therein) has been down of late, and I don't know if it will ever become available again. What a waste of valuable oldschool knowledge. (If anyone knows where else this might be available, I would be indebted.)

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

Depending upon your requirements I can imagine following advantages:

  1. Independent buffer size for every port for incoming packets. As long as new packets come in and await the processing you are sure you won't face any massive packet loss if your buffer is full. Usually losses of 2-3 packets are not crucial, TCP will quickly have them resent and UDP-based protocols are usually tolerant to losses. If you have a single buffer than you are at risk that somebody will just "DDOS" your complete queue with packets leading to server overload and malfunction.
  2. Having different ports you can easily prioritize certain users: if somebody has 10 ms ping and another 170 it is clear that the first user might require responses much more often. You can also add some type of membership -- gold member can get more packets and hence a better reactive game etc.
  3. In case of cheating or hacking it is easier to track back the user if every user has a single port assigned to it. Else you have to look at every packet payload, that might be not as easy (especially if the information is encrypted).
\$\endgroup\$
3
  • \$\begingroup\$ Thanks Alexander, this is really helpful. Are you certain about the buffers? I'm surprised no-one on gamedev.net said anything about this. Very good point on the accountability front. \$\endgroup\$
    – Engineer
    Commented Dec 13, 2011 at 19:50
  • 1
    \$\begingroup\$ This is a common topic in optimizing network performance: the size of TCP buffer. This is normally constant per TCP socket, but many OS can increase or decrease it depending upon the transmission load. It is just easier to manage those buffers if you have different ports, for if it is the same port you have no a priori information about the socket to be opened (except for IP that might change). \$\endgroup\$ Commented Dec 13, 2011 at 19:52
  • \$\begingroup\$ Thanks Alex. Without seeing any particular downsides to one-socket-per-client, I've gone this route. Increased separation is usually a good thing, even beyond the points you've made above. \$\endgroup\$
    – Engineer
    Commented Dec 15, 2011 at 17:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .