1 #ifndef BLANK_NET_CONGESTIONCONTROL_HPP_
2 #define BLANK_NET_CONGESTIONCONTROL_HPP_
10 class CongestionControl {
15 /// packet loss as factor
16 float PacketLoss() const noexcept { return packet_loss; }
17 /// smooth average round trip time in milliseconds
18 float RoundTripTime() const noexcept { return rtt; }
19 /// estimated kilobytes transferred per second
20 float Upstream() const noexcept { return tx_kbps; }
21 /// estimated kilobytes received per second
22 float Downstream() const noexcept { return rx_kbps; }
24 void PacketSent(std::uint16_t) noexcept;
25 void PacketLost(std::uint16_t) noexcept;
26 void PacketReceived(std::uint16_t) noexcept;
28 void PacketIn(const UDPpacket &) noexcept;
29 void PacketOut(const UDPpacket &) noexcept;
32 void UpdatePacketLoss() noexcept;
33 void UpdateRTT(std::uint16_t) noexcept;
34 bool SamplePacket(std::uint16_t) const noexcept;
35 int HeadDiff(std::uint16_t) const noexcept;
36 void UpdateStats() noexcept;
39 const unsigned int packet_overhead;
40 const unsigned int sample_skip;
42 unsigned int packets_lost;
43 unsigned int packets_received;
47 std::size_t stamp_cursor;
48 std::uint16_t stamp_last;