mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 19:22:37 +00:00
24 lines
486 B
C++
24 lines
486 B
C++
|
#include "LossStats.h"
|
||
|
#include "td/utils/misc.h"
|
||
|
|
||
|
#include <cmath>
|
||
|
|
||
|
namespace ton {
|
||
|
namespace rldp2 {
|
||
|
void LossStats::on_update(td::uint32 ack, td::uint32 lost) {
|
||
|
ack_ += ack;
|
||
|
lost_ += lost;
|
||
|
|
||
|
if (ack_ + lost_ > 1000) {
|
||
|
auto new_loss = td::clamp((double)lost_ / (ack_ + lost_), 0.001, 0.2);
|
||
|
if (fabs(new_loss - loss) > 5e-3) {
|
||
|
prob = LossSender(new_loss, 1e-9);
|
||
|
}
|
||
|
loss = new_loss;
|
||
|
ack_ = 0;
|
||
|
lost_ = 0;
|
||
|
}
|
||
|
}
|
||
|
} // namespace rldp2
|
||
|
} // namespace ton
|