Calculate path-aware ETCP throughput over a sliding one second window

This commit is contained in:
evgeny committed 2026-10-30 21:15:21 +01:00
1 parent 88897333b9
commit d707a86590
2 files changed
+10

No files matched your search

+1
View File
@@ -21,6 +21,7 @@ struct call_history_rx {
struct call_history_tx {
uint64_t at_ms, queued_bytes, inflight_bytes, transport_bytes;
uint64_t peer_id, tx_epoch, wire_tx_bytes; /* Текущий путь звонка: разность счётчиков только при одинаковых peer/epoch. */
double wire_bytes_per_sec; /* Среднее за последние <=1с; -1 — нет пары измерений одного пути. */
};
struct call_audio_history {
uint64_t now_ms;
+9
View File
@@ -59,5 +59,14 @@ public:
const auto& p = tx[(txNext + CALL_HISTORY_POINTS - txUsed + i) % CALL_HISTORY_POINTS];
if (p.at_ms <= now && now - p.at_ms < CALL_HISTORY_MS) out.tx[out.tx_count++] = p;
}
for (unsigned i = 0; i < out.tx_count; ++i) {
auto& p = out.tx[i]; unsigned first = i; p.wire_bytes_per_sec = -1;
while (first && p.peer_id && out.tx[first - 1].peer_id == p.peer_id && out.tx[first - 1].tx_epoch == p.tx_epoch
&& p.at_ms - out.tx[first - 1].at_ms <= 1000 && out.tx[first].at_ms - out.tx[first - 1].at_ms <= 150)
--first;
const auto& previous = out.tx[first];
if (first < i && p.at_ms > previous.at_ms && p.wire_tx_bytes >= previous.wire_tx_bytes)
p.wire_bytes_per_sec = (p.wire_tx_bytes - previous.wire_tx_bytes) * 1000.0 / (p.at_ms - previous.at_ms);
}
}
};