- By default, Windows 2000 has limited space for anonymous ports. This space is limited more by the low MailboxCacheTTL that is configured for the Microsoft TV mail service. (Anonymous ports are temporary ports that are assigned by a computer's IP stack; anonymous ports are assigned from a designated range of ports. Only ports 1024-5000 are used in Windows 2000.)
- The SO_REUSEADDR option on the sockets is not turned on, so the sockets cannot be reused immediately after being closed. The sockets must remain reserved in a TIME_WAIT state for four minutes. If you set the SO_REUSEADDR option, Windows permits multiple binds to the listening socket.
When the connection ends, the ephemeral port is available for reuse, although most IP stacks do not reuse that port number until the whole pool of ephemeral ports has been used. Therefore, if the client program reconnects, the client is assigned a different ephemeral port number for the client side of the new connection. In the case of the Microsoft TV mail service, a very low MailboxCacheTTL setting aggravates the situation because IMAP connections close and reopen frequently (on almost every request).
A port range of 4000 may seem large, but it is small for current computing demands when you consider that a TCP connection must expire through the TIME_WAIT state before it is really completed. For example, even if both sides of a connection properly close their ends of the connection, because of TCP's error control, each side must wait until the TIME_WAIT state is expired before the connection's resources really can be disposed.
The TIME_WAIT state is two times the maximum segment lifetime (MSL). (For this reason, the TIME_WAIT state is also known as the 2MSL state.) Typically, depending on the IP stack, the TIME_WAIT state is configured to be 240 seconds total. Therefore, you can have only 4000 connections per 240-second window and, in practice, these 4000 connections can be used up.
- Increase the port range that is used for anonymous ports to approximately 20,000 ports (for example) by modifying the MaxUserPort registry key. Windows uses the conventional BSD range of 1024 to 5000 for its anonymous (ephemeral) port range. You can set only the upper bound of the ephemeral port range. To modify the MaxUserPort registry key, follow these steps:
- Start Registry Editor (Regedt32.exe).
- Locate the MaxUserPort key in the registry:
- On the Edit menu, click Add Value, and then add the following registry value:
Value Name: MaxUserPort
Data Type: REG_DWORD
Value: 65534 (for example)
Valid Range: 5000-65534 (decimal)
Default: 0x1388 (5000 decimal)
- Quit Registry Editor.
- Change the timeout on the connections from 240 seconds (the default) to any length from 30 seconds to 300 seconds. Use the TcpTimedWaitDelay registry parameter to change this value. To do this, start Registry Editor (Regedt32.exe), locate the following key in the registry, and then modify the value:
Value Type: REG_DWORD-time in seconds
Valid Range: 30-300 (decimal)
Default: 0xF0 (240 decimal)
Description:This parameter determines the length of time that a connection stays in the TIME_WAIT state when the connection is being closed. While a connection is in the TIME_WAIT state, the socket pair cannot be reused. For more information, see RFC 793.
Article ID: 319502 - Last Review: Jun 19, 2014 - Revision: 1