feat: 自适应并发调度 — 网络探测 + AIMD + 参数智能推导

扫描前自动探测网络环境(RTT、丢包率、fd limit),基于探测数据
推导 6 个关键参数,替代硬编码默认值:

- Timeout: median_RTT + 4σ(覆盖 99.9% 正常连接)
- ModuleThreadNum: target_concurrency / 30
- MaxRetries: ceil(log(0.01)/log(loss_rate))(全失败概率 <1%)
- ICMPRate: 环境基准 × fd 系数
- PocNum: 跟随 ModuleThreadNum
- DisablePing: 已有 ICMP 权限降级机制

线程池从单信号(资源耗尽率)升级为 AIMD + 慢启动:
- 慢启动:target/4 起步,500ms 翻倍
- 稳态 AIMD:健康 +5%,拥塞 ×0.5
- 双信号:资源耗尽率 + RTT 趋势(双 EMA)

用户 -t 显式指定时作为 ceiling,探测仍调整其他参数。

测试:单元 + 边界 + 集成 + 真实网络,core 包 580+ 用例全通过。
This commit is contained in:
ZacharyZcR
2026-06-12 09:46:02 +08:00
parent 683707fcd4
commit f883944b2b
21 changed files with 3287 additions and 251 deletions
+12
View File
@@ -164,6 +164,10 @@ func (s *ServiceScanStrategy) performHostScan(ctx context.Context, session *comm
totalAlive := 0
sawHosts := false
performedLiveness := false
envProfiled := false
// 系统能力探测(不需要网络目标)
sysProfile := ProbeSystem()
for {
hosts, err := iter.NextBatch(ctx, targetHostBatchSize(config))
@@ -185,6 +189,14 @@ func (s *ServiceScanStrategy) performHostScan(ctx context.Context, session *comm
continue
}
// 首批 alive hosts 出来后做网络探测,调整后续所有参数
if !envProfiled {
envProfiled = true
netProfile := ProbeNetwork(ctx, hosts, session)
ep := &EnvironmentProfile{Net: *netProfile, System: sysProfile}
ep.TuneConfig(config, session)
}
s.dispatchUDPPlugins(ctx, session, hosts, info, config, ch, wg)
s.scanHostBatch(ctx, session, hosts, info, pluginsToRun, isCustomMode, ch, wg)
}