Networking – What happens when a router runs out of port numbers

networkingrouterwireless-networking

I noticed while looking at the site ipchicken (http://www.ipchicken.com/) that when I go on there from my desktop or my phone or the university wifi, it gives me a "Remote Port". There's a range of port numbers (it never seems to go above 65,000 or so). But what if I write a program that listens on every single port? Will the router run out of ports? Will it block new people from connecting? What happens when a router runs out of internal port numbers?

Best Answer

  • Ports in TCP or UDP protocols are stored in 16-bit integer, so it is only 65535 ports possible to use.

    If you use every port on your computer, than any application which needs a socket (connection) will not have it. Functions like listen() or connect() will result in error until there will be free port to use.

    If you use every port in router (with NAT) than every new connection will be buffered or dropped. If router is just a router, not a gateway with NAT, the problem with ports will not exist, because transport layer (4th layer in ISO/OSI model) is not analyzed.

  • Related Question