tip: 425
title: Speed up TCP connection establishment
author:wb_bupt@163.com
discussions to: https://github.com/tronprotocol/TIPs/issues/425
status: Final
type: Standards Track
category: Net
created: 2022-07-11
This TIP is to describe how to speed up TCP connection establishment.
With the increasing number of online nodes, the number of connections of many peers is full. If a connection is established with these nodes, the connection will be refused with the reason of too many peers, and it may take more than ten minutes to find a connection that can be established. This article details how to speed up TCP connection establishment.
Shorten the tcp connection establishment time, which can speed up the synchronization, and can reduce the block loss rate for SR.
- Too many connections may cause network congestion and packet delay, so the number of connections should be controlled within a range.
- After the number of connections is full, you can disconnect a connection according to a certain strategy, so as to quickly access the next connection.
- After reaching the maximum number of connections, the establishment of other connections needs to be rejected.
- There must be an actively established connection to prevent malicious attacks.
- Need to set a minimum threshold for the number of actively established connections.
maxConnections
The maximum number of connections, when the number of peer connections reaches this threshold, no other connection requests are accepted.
minConnections
The minimum number of connections, when the number of peer connections is lower than this threshold, you need to continue to establish connections.
minActiveConnections
Minimum number of actively initiated connections.
Start a thread to check the number of connections. When the number of connections is full, adopt a certain disconnection strategy to disconnect 1~2 nodes (this solution is recommended, the function is relatively independent, and the embedded main code is relatively small), the disconnection strategy can refer to described below.
- Filter trusted nodes. If all connected nodes are trusted nodes and exceed the maximum configuration
maxConnections
, there is no need to disconnect. - Filter actively established tcp connections.
- Filter peers that are acquiring blocks or transactions.
Optimize the connection configuration, set the minimum number of connections to 8.
Increase the maximum number of connections of the node. You can configure 10~20 full-nodes online to set their maximum number of connections to 50, increasing the number of available connections.