Fix: #292 RTT display showing 0 or 1 instead of actual milliseconds

- Convert srtt from seconds to milliseconds before sending in Heartbeat
  (srtt is stored in seconds but Ping field expects milliseconds)
- Add input validation in RttEstimator::update_from_sample to filter
  abnormal RTT values (<=0 or >30000ms)
This commit is contained in:
yuanyuanxiang
2026-01-25 20:56:40 +01:00
parent b4c47ba553
commit 53515820ea
2 changed files with 7 additions and 2 deletions

View File

@@ -1008,7 +1008,7 @@ int AuthKernelManager::SendHeartbeat()
ActivityWindow checker;
auto s = checker.Check();
Heartbeat a(s, m_nNetPing.srtt);
Heartbeat a(s, (int)(m_nNetPing.srtt * 1000)); // srtt是秒转为毫秒
a.HasSoftware = SoftwareCheck(m_settings.DetectSoftware);
iniFile THIS_CFG;

View File

@@ -102,6 +102,11 @@ struct RttEstimator {
void update_from_sample(double rtt_ms)
{
// 过滤异常值RTT应在合理范围内 (0, 30000] 毫秒
if (rtt_ms <= 0 || rtt_ms > 30000) {
return;
}
const double alpha = 1.0 / 8;
const double beta = 1.0 / 4;
@@ -158,7 +163,7 @@ public:
ActivityWindow checker;
auto s = checker.Check();
Heartbeat a(s, m_nNetPing.srtt);
Heartbeat a(s, (int)(m_nNetPing.srtt * 1000)); // srtt是秒转为毫秒
a.HasSoftware = SoftwareCheck(m_settings.DetectSoftware);