diff --git a/src/cloud.rs b/src/cloud.rs index 75d19a6..935b76d 100644 --- a/src/cloud.rs +++ b/src/cloud.rs @@ -11,7 +11,7 @@ use std::os::unix::io::AsRawFd; use std::marker::PhantomData; use std::hash::BuildHasherDefault; use std::time::Instant; -use std::cmp::{min, max}; +use std::cmp::min; use fnv::FnvHasher; use libc::{SIGTERM, SIGQUIT, SIGINT}; @@ -376,11 +376,8 @@ impl GenericCloud

{ debug!("Send peer list to all peers"); let mut peer_num = self.peers.len(); // If the number of peers is high, send only a fraction of the full peer list to - // reduce the management traffic. The number of peers to send is the square root of the - // total number of peers. - if peer_num > 10 { - peer_num = max(10, min(255, (peer_num as f32).sqrt().ceil() as usize)); - } + // reduce the management traffic. The number of peers to send is limited by 20. + peer_num = min(peer_num, 20); // Select that many peers... let peers = self.peers.subset(peer_num); // ...and send them to all peers diff --git a/vpncloud.md b/vpncloud.md index 0824755..c349ab9 100644 --- a/vpncloud.md +++ b/vpncloud.md @@ -397,17 +397,17 @@ will follow: * **Closing message** (message type 3): This packet does not contain any more data. -Nodes are expected to send an **initial message** whenever they connect to a -node they were not connected to before. As a reply to this message, another -initial should be sent with stage 2. Also a **peer list** message should be -sent as a reply. +Nodes are expected to send an **initial message** with stage 0 whenever they +connect to a node they were not connected to before. As a reply to this message, +another initial should be sent with stage 1. Also a **peer list** message should +be sent as a reply. When connected, nodes should periodically send their **peer list** to all of their peers to spread this information and to avoid peer timeouts. To avoid the cubic growth of management traffic, nodes should at a certain -network size start sending partial peer lists instead of the full list. -A reasonable number would be the square root of the number of peers. -The subsets should be selected randomly. +network size start sending partial peer lists instead of the full list. A +reasonable number would be about 20 peers. The subsets should be selected +randomly. Nodes should remove peers from their peer list after a certain period of inactivity or when receiving a **closing message**. Before shutting down, nodes