1 #ifndef BLANK_NET_CONGESTIONCONTROL_HPP_
2 #define BLANK_NET_CONGESTIONCONTROL_HPP_
10 class CongestionControl {
22 /// get recommended mode of operation
23 Mode GetMode() const noexcept { return mode; }
24 /// according to current mode, drop this many unimportant packets
25 unsigned int SuggestedPacketSkip() const noexcept { return (1 << mode) - 1; }
27 /// packet loss as factor
28 float PacketLoss() const noexcept { return packet_loss; }
29 /// smooth average round trip time in milliseconds
30 float RoundTripTime() const noexcept { return rtt; }
31 /// estimated kilobytes transferred per second
32 float Upstream() const noexcept { return tx_kbps; }
33 /// estimated kilobytes received per second
34 float Downstream() const noexcept { return rx_kbps; }
36 void PacketSent(std::uint16_t) noexcept;
37 void PacketLost(std::uint16_t) noexcept;
38 void PacketReceived(std::uint16_t) noexcept;
40 void PacketIn(const UDPpacket &) noexcept;
41 void PacketOut(const UDPpacket &) noexcept;
44 void UpdatePacketLoss() noexcept;
46 void UpdateRTT(std::uint16_t) noexcept;
47 bool SamplePacket(std::uint16_t) const noexcept;
49 void UpdateStats() noexcept;
51 void UpdateMode() noexcept;
52 void CheckUpgrade(Mode) noexcept;
53 void ChangeMode(Mode) noexcept;
54 void KeepMode() noexcept;
56 Mode Conditions() const noexcept;
59 const unsigned int packet_overhead;
60 const unsigned int sample_skip;
62 unsigned int packets_lost;
63 unsigned int packets_received;
67 std::size_t stamp_cursor;
68 std::uint16_t stamp_last;
84 Uint32 mode_keep_time;