调整退避速度

This commit is contained in:
lbl8603
2024-06-25 22:47:19 +08:00
parent ac162eba66
commit 382d5b61ba
2 changed files with 7 additions and 4 deletions
+2 -2
View File
@@ -323,9 +323,9 @@ impl Punch {
let max_k1 = 60;
//全局最多发送max_k2个包
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);
if nat_info.public_port_range < max_k1 * 3 {
+5 -2
View File
@@ -1,5 +1,6 @@
use std::collections::HashMap;
use std::net::Ipv4Addr;
use std::ops::{Div, Mul};
use std::sync::mpsc::{sync_channel, Receiver, SyncSender};
use std::sync::Arc;
use std::thread;
@@ -249,9 +250,11 @@ fn punch0(
.lock()
.get(&info.virtual_ip)
.cloned()
.unwrap_or(0);
.unwrap_or(0)
.mul(2)
.div(3);
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 punch_count == 0 {
continue;