TCP Parameter Optimization in Windows

Source: Internet
Author: User

TCP Parameters in Windows optimize the status and closing mode of TCP connections and Their Impact on Server and Client http://www.bkjia.com/net/201304/206071.html Generally, the Windows system parameters are improved by modifying the registry. The following describes the TCP Parameter Optimization Methods for Windows 2003, Windows XP, Windows 7, and Server. The optimization methods vary with the specific system environment and performance requirements, and the effects are also different. They are only personal suggestions. All optimization operations are implemented by modifying the Registry. You need to run the regedit command to enter the registry and create or modify parameters. After the modification, You need to restart the system to make it take effect. The following values are in hexadecimal notation. 1. The value of TCPWindowSize indicates the window size of TCP. TCP Receive Window (TCP Data receiving buffer) defines the maximum number of bytes that can be sent by the sending end without receiving confirmation from the receiving end. The larger the value, the less information will be returned, and the better the communication between the sending end and the receiving end. This value can reduce the possibility of timeout when the sender waits for the receiving end to return confirmation information, but this increases network traffic and reduces the effective throughput. TCP dynamically adjusts an integer multiple of the Maximum Segment length (MSS) (Maximum Segment Size) between the sending end and the receiving end. The MSS determines when the connection is established. Because the TCP Receive Window is adjusted to an integer multiple of the MSS, the proportion of TCP data segments with full length increases during data transmission, thus improving the network throughput. By default, TCP tries to optimize the window size based on MSS. The initial value is 16 KB and the maximum value is 64 KB. The maximum TCPWindowSize is usually 65535 bytes (64 KB), the maximum length of the Ethernet segment is 1460 bytes, and the maximum integer multiple below 1460 of 64 KB is 62420 bytes, therefore, you can set TCPWindowSize to 62420 in the registry as the applicable performance optimization value for high-bandwidth networks. The specific operation is as follows: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, and create or modify the REG_DWORD value named TCPWindowSize under the Parameters subkey, the value ranges from 0 to 65535 and is set to 62420. 2. to make more efficient use of the high-bandwidth network, TCP1323Opts can use a TCP window larger than the preceding TCP window. This feature is a new feature in Windows 2000 and Windows Server 2003, called TCP Window Scaling, it increases the limit of the previous 65535 bytes (64 KB) to 1073741824 bytes (1 GB ). For connections (such as satellite connections) with a high product of bandwidth and latency, you may need to increase the window size to more than 64 KB. Using TCP Window Scaling, the system can confirm the transmission of larger data volumes between information, increasing network throughput and performance. The time required for the round-trip communication between the sender and the receiver is called the Back-to-Loop Time (RTT ). TCP Window Scaling is valid only when both TCP connections are enabled. TCP has a timestamp option that increases the estimated RTT value by more frequent calculation. This option is particularly helpful in estimating the RTT value of a wide-area network connection over a longer distance, and adjust the TCP Retransmission timeout time more accurately. The timestamp is provided in the TCP Header in two regions. One record starts to resend and the other record receives the time. The timestamp is especially useful for TCP Window Scaling, that is, to confirm the transmission of large data packets before the message is received. The activation timestamp only adds 12 bytes to the header of each data packet, and has little impact on network traffic. Which of the following is more important for data integrity and data Throughput Maximization. In some environments, for example, video stream transmission requires a larger TCP window, which is the most important, while data integrity ranks second. In this environment, TCP Window Scaling does not open the timestamp. This feature is valid only when both the sender and receiver activate TCP Window Scaling and timestamp. However, if a timestamp is added during packet sending, after NAT, if the same port in front is used and the timestamp is greater than the timestamp in the SYN from the connection, the server ignores the SYN, indicating that the user cannot complete the TCP three handshakes normally. Initially, a small TCP window is generated, and the window size increases according to the internal algorithm. The specific operation is as follows: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, create or modify the REG_DWORD value named TCP1323Opts under the Parameters subkey, the specific meaning of this value is: 0 (default value) indicates disabling TCP Window Scaling and timestamp; 1 indicates only enabling TCP Window Scaling; 2 indicates only enabling timestamp; 3 indicates that TCP Window Scaling and timestamp are enabled simultaneously. After TCP1323Opts is set to activate TCP Window Scaling, you can increase the value of the preceding registry key TCPWindowSize to 1 GB. To achieve optimal performance, the value here should be set to a multiple of MSS. The recommended value is 256960 bytes. 3. For each TCP connection, the control variables are stored in a memory block called a TCP Control Block (TCB. The size of the TCB table is controlled by the MaxHashTableSize registry. In systems with many active connections, setting a large table can reduce the time for the system to locate the TCB table. Partitioning on a TCB table can reduce the competition for table access. By increasing the number of partitions, TCP performance will be optimized, especially in multi-processor systems. Registry entry NumTcbTablePartitions controls the number of partitions. The default value is the square of the number of processors. TCB is usually pre-configured in the memory to prevent repeated TCP connections and disconnections. It is a waste of time to locate TCB repeatedly. This buffer method promotes memory management, however, the number of TCP connections allowed at the same time is also limited. The registry entry MaxFreeTcbs determines the number of connections before the idle wait TCB is available again. It is often set to a value higher than the default value in the NT architecture to ensure that there is enough preset TCB. A new feature has been added since Windows 2000 to reduce the possibility of running TCB exceeding the preset. If the number of connections in the waiting state is greater than that set in MaxFreeTWTcbs, all connections that have waited for more than 60 seconds will be forcibly disabled and will be enabled again later. After this feature is merged into Windows 2000 Server and Windows Server 2003, MaxFreeTcbs will no longer be used to optimize performance. Specific Operation: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, and create or modify the REG_DWORD value named MaxHashTableSize under the Parameters subkey, the value ranges from 1 to 65536, and must be the Npower of 2. The default value is 512. We recommend that you set this value to 8192. Create or modify the REG_DWORD value named NumTcbTablePartitions under the Parameters subkey. The value ranges from 1 to 65536, and must be 2 to the Npower. The default value is the square of the number of processors, we recommend that you set it to 4 times the number of processor cores. 4. The value of TcpTimedWaitDelay indicates the waiting time before the system releases closed TCP connections and reuses its resources. The time interval is the TIME_WAIT State mentioned in the previous Blog (2MSL, which is twice the maximum data packet lifecycle ). If the system shows that a large number of connections are in the TIME_WAIT status, the concurrency and throughput will be seriously reduced. By reducing this value, the system can release closed connections more quickly, in this way, more resources are provided for new connections, especially for servers with high concurrency and short connections. The default value of this item is 240, that is, to release resources after 4 minutes. The minimum value supported by the system is 30, that is, the waiting time is 30 seconds. Specific Operation: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, and create or modify the REG_DWORD value named TcpTimedWaitDelay under the Parameters subkey, the value ranges from 0 to 300. We recommend that you set this value to 30. 5. The value of MaxUserPort indicates the maximum port number that can be allocated by TCP/IP when an application requests an available port from the system. If the system displays an exception during connection establishment, it may be caused by insufficient number of anonymous (temporary) ports, especially when the system opens a large number of ports to establish connections with Web Services, databases, or other remote resources. The default value of this item is 5000 in decimal format, which is also the minimum value allowed by the system. By default, Windows uses anonymous (temporary) ports to retain port numbers ranging from 1024 to 5000. To obtain a higher concurrency, we recommend that you set this value to at least 32768 or even a theoretical maximum of 65534, especially for the Client that simulates the high concurrency test environment. Specific Operation: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, and create or modify the REG_DWORD value named MaxUserPort under the Parameters subkey, the value ranges from 5000 to 65534. The default value is 5000. We recommend that you set this value to 65534. 6. The value of dynamic reserve enables the system to automatically adjust its configuration to accept a large number of sudden connection requests. If a large number of connection requests are received at the same time, the system's processing capability is exceeded, the dynamic reserve will automatically increase the number of temporary connections supported by the system (that is, the number of waiting connections requested by the Client and not processed by the Server, and the total number of TCP connections includes the number of established connections and the number of waiting connections ), this reduces the number of connection failures. When the system's processing capability and the number of supported temporary connections are insufficient, the Client's connection request will be rejected directly. By default, dynamic reserve is not enabled for Windows. You can enable and set it by performing the following operations: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ AFD \ Parameters registry subkey, create or modify the REG_DWORD values of the following names under the Parameters subkey. EnableDynamicBacklog. The value is 1, indicating that dynamic reserve is enabled. MinimumDynamicBacklog. The value is 128, indicating that the minimum number of temporary connections supported is 128. MaximumDynamicBacklog. The value is 2048, indicating that the maximum number of temporary connections supported is 2048. For highly concurrent short-connection servers, we recommend that you set the maximum value to 1024 or above. DynamicBacklogGrowthDelta, with a value of 128, indicates that the number of supported temporary connections is increased by 128, that is, when the number is insufficient, it increases by 128 until it reaches the set maximum value, such as 2048. 7. KeepAliveTime the value of KeepAliveTime controls the frequency at which the system tries to verify whether idle connections are still intact. If the connection is not active for a period of time, the system will send a signal to maintain the connection. If the network is normal and the receiver is active, it will respond. If you need to be sensitive to the loss of the receiver, that is, you need to identify whether the receiver is lost more quickly, please reduce this value. If idle connections that are not active for a long time appear frequently, but the number of lost receivers is less, you may need to increase the value to reduce the overhead. By default, if the idle connection is not active within 7200000 milliseconds (2 hours), the system will send a message to keep the connection. We recommend that you set the value to 1800000 ms, so that the lost connection will be detected within 30 minutes. Specific Operation: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, and create or modify the REG_DWORD value named KeepAliveTime under the Parameters subkey, set the appropriate number of milliseconds for this value. 8. The value of KeepAliveInterval indicates the frequency at which the system repeatedly sends the "keep connection" signal when the other party does not receive the response to the "keep connection" signal. If no response is received, the connection is dropped when the number of consecutive "keep connection" Signals exceeds the value of TcpMaxDataRetransmissions (described below. If the network environment is poor and a long response time is allowed, increase the value to reduce the overhead. If you need to verify whether the receiver has been lost as soon as possible, reduce the value or TcpMaxDataRetransmissions. By default, the system will wait 1000 milliseconds (1 second) until the "keep connection" signal is sent again without receiving a response. You can modify the parameters as needed: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, create or modify the REG_DWORD value named KeepAliveInterval under the Parameters subkey, and set the appropriate number of milliseconds for this value. 9. The value of TcpMaxDataRetransmissions indicates the number of times the TCP data is resold, and the system resends the data segment without a response on the existing connection. If the network environment is poor, you may need to increase the value to maintain effective communication and ensure that the receiver receives the data. If the network environment is good, or data is usually lost due to the loss of the receiver, this value can be reduced to reduce the time and cost of verifying whether the receiver is lost. By default, the system resends the data segment that does not return a response five times. You can modify the data segment as needed: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, create or modify the REG_DWORD value named TcpMaxDataRetransmissions under the Parameters subkey, the value ranges from 0 to 4294967295. The default value is 5. Set the value based on the actual situation. 10. The value of TcpMaxConnectRetransmisstions indicates the number of times the TCP connection is resold, and the non-confirmed connection request (SYN) is resold before TCP exits. For each attempt, the Retransmission timeout is twice that of the successful retransmission. In Windows Server 2003, the default timeout value is 2 and the default timeout value is 3 seconds (in the Registry key TCPInitialRTT ). The timeout time for slow WAN connections can be increased accordingly. Different environments may have different optimization settings, which need to be tested and determined in the actual environment. Do not set the timeout value too large. Otherwise, no network connection timeout will occur. Specific Operation: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters registry subkey, and create or modify the REG_DWORD value named TcpMaxConnectRetransmisstions under the Parameters subkey, the value ranges from 0 to 255. The default value is 2. Set the value based on the actual situation. Create or modify the REG_DWORD value named TCPInitialRTT under the Parameters subkey, and set the value according to the actual situation. 11. The value of TcpAckFrequency indicates the frequency at which the system sends response messages. If the value is 2, the system sends a response after receiving two segments, or send a response when one segment is received, but no other segment is received within 200 milliseconds. If the value is 3, then the system will send a response after receiving three segments, or when receiving one or two segments but not receiving any other segments within 200 milliseconds, and so on. If you want to shorten the response time by eliminating the response latency, we recommend that you set this value to 1. In this case, the system will immediately send a response to each segment. If the connection is mainly used to transmit a large amount of data, and the latency of 200 milliseconds is not important, this value can be reduced to reduce the response overhead. By default, the system sets this value to 2, that is, the system replies every other part. The valid range of this value is 0 to 255. 0 indicates that the default value is 2. You can modify the value as needed: browse to the HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ TCPIP \ Parameters \ Interfaces \ xx (xx is determined by the network adapter) registry subkey, create or modify the REG_DWORD value named TcpAckFrequency under the xx subkey. The value ranges from 1 to 13 and the default value is 2, set this value based on the number of segments to be sent to return a response. We recommend that you set the Mbps network to 5 and the Mbps network to 13.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.