Ephemeral Port Limits
Every time you open a connection to another machine you need to have a port both at the local machine and the remote machine for exchanging data. The port at the remote machine is typically well known in the sense that the port number is a fixed number or published through some mechanism that doesn't change very frequently. This allows the service that is listening on the port to have a well known address. The port at the local machine can be any port number and often you don't care what that number is. Every time you make a new connection the port number can change.
These short lived port allocations are typically called ephemeral ports and are allocated using a wildcard request. Your request is just for any free ephemeral port rather than for a specific port number. On older Windows systems the default range allowed for ephemeral ports was 1025 to 5000 giving you a little bit less than 4000 free ports. In rare cases there may be no free ephemeral ports available, which will cause the connection open to fail or timeout. This would be unlikely on a client machine but is more likely to take place on a middle-tier machine that is creating connections for every client request that is processed.
On Windows Vista and Server 2008 the default range of ephemeral ports is now 49152 to 65535 giving you a little bit more than 16000 free ports. It would now be very unlikely for all of the ephemeral ports to be in use. You would probably want to start caching and reusing connections faster than the operating system recycled ports once you have that many ports in use. However, you can change this ephemeral port range if you need more ports or if the range conflicts with a port number used by your application.
The basic command for changing the ephemeral port range looks like this.
netsh int ipv4 set dynamicport tcp start=49152 num=16384
You can use ipv6 instead of ipv4 and udp instead of tcp depending on the protocols used by your application. A similar command shows what your current ephemeral port range is.
netsh int ipv4 show dynamicport tcp
Next time: Hosted Service Shutdown
Comments
- Anonymous
September 21, 2008
Today's post wraps up the series on cross-domain policy files with some side stories that you probably