调整退避速度
This commit is contained in:
@@ -323,9 +323,9 @@ impl Punch {
|
|||||||
let max_k1 = 60;
|
let max_k1 = 60;
|
||||||
//全局最多发送max_k2个包
|
//全局最多发送max_k2个包
|
||||||
let mut max_k2: usize = rand::thread_rng().gen_range(600..800);
|
let mut max_k2: usize = rand::thread_rng().gen_range(600..800);
|
||||||
if count > 1 {
|
if count > 2 {
|
||||||
//递减探测规模
|
//递减探测规模
|
||||||
max_k2 = max_k2.mul(4).div(3).div(count).max(max_k1 as usize);
|
max_k2 = max_k2.mul(2).div(count).max(max_k1 as usize);
|
||||||
}
|
}
|
||||||
let port = nat_info.public_ports.get(0).map(|e| *e).unwrap_or(0);
|
let port = nat_info.public_ports.get(0).map(|e| *e).unwrap_or(0);
|
||||||
if nat_info.public_port_range < max_k1 * 3 {
|
if nat_info.public_port_range < max_k1 * 3 {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::net::Ipv4Addr;
|
use std::net::Ipv4Addr;
|
||||||
|
use std::ops::{Div, Mul};
|
||||||
use std::sync::mpsc::{sync_channel, Receiver, SyncSender};
|
use std::sync::mpsc::{sync_channel, Receiver, SyncSender};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
@@ -249,9 +250,11 @@ fn punch0(
|
|||||||
.lock()
|
.lock()
|
||||||
.get(&info.virtual_ip)
|
.get(&info.virtual_ip)
|
||||||
.cloned()
|
.cloned()
|
||||||
.unwrap_or(0);
|
.unwrap_or(0)
|
||||||
|
.mul(2)
|
||||||
|
.div(3);
|
||||||
let p2p_num = context.route_table.p2p_num(&info.virtual_ip);
|
let p2p_num = context.route_table.p2p_num(&info.virtual_ip);
|
||||||
let mut max_punch_interval = 70;
|
let mut max_punch_interval = 50;
|
||||||
if p2p_num > 0 {
|
if p2p_num > 0 {
|
||||||
if punch_count == 0 {
|
if punch_count == 0 {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user