Skip to content

Latest commit

 

History

History
42 lines (33 loc) · 2.65 KB

tip-425.md

File metadata and controls

42 lines (33 loc) · 2.65 KB
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

Simple Summary

This TIP is to describe how to speed up TCP connection establishment.

Abstract

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.

Motivation

Shorten the tcp connection establishment time, which can speed up the synchronization, and can reduce the block loss rate for SR.

Rationale

  1. Too many connections may cause network congestion and packet delay, so the number of connections should be controlled within a range.
  2. 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.
  3. After reaching the maximum number of connections, the establishment of other connections needs to be rejected.
  4. There must be an actively established connection to prevent malicious attacks.
  5. Need to set a minimum threshold for the number of actively established connections.

Specification

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.

Implementation

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.

  1. Filter trusted nodes. If all connected nodes are trusted nodes and exceed the maximum configuration maxConnections, there is no need to disconnect.
  2. Filter actively established tcp connections.
  3. 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.