X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnet%2FCongestionControl.hpp;h=ea71c55abe7c8625a42c31edf48f0fe8e01b2e45;hb=1a237f316ee603e2130dc46b9f7d75a169763543;hp=73d1d859ec0aaed8cafdcd8ba448786a7b047e0f;hpb=a957788426ff011acf662e29ec5fc0525c1a578f;p=blank.git diff --git a/src/net/CongestionControl.hpp b/src/net/CongestionControl.hpp index 73d1d85..ea71c55 100644 --- a/src/net/CongestionControl.hpp +++ b/src/net/CongestionControl.hpp @@ -9,9 +9,19 @@ namespace blank { class CongestionControl { +public: + enum Mode { + GOOD, + BAD, + UGLY, + }; + public: CongestionControl(); + /// get recommended mode of operation + Mode GetMode() const noexcept { return mode; } + /// packet loss as factor float PacketLoss() const noexcept { return packet_loss; } /// smooth average round trip time in milliseconds @@ -30,11 +40,19 @@ public: private: void UpdatePacketLoss() noexcept; + void UpdateRTT(std::uint16_t) noexcept; bool SamplePacket(std::uint16_t) const noexcept; - int HeadDiff(std::uint16_t) const noexcept; + void UpdateStats() noexcept; + void UpdateMode() noexcept; + void CheckUpgrade(Mode) noexcept; + void ChangeMode(Mode) noexcept; + void KeepMode() noexcept; + + Mode Conditions() const noexcept; + private: const unsigned int packet_overhead; const unsigned int sample_skip; @@ -54,6 +72,16 @@ private: float tx_kbps; float rx_kbps; + Mode mode; + float bad_rtt; + float bad_loss; + float ugly_rtt; + float ugly_loss; + Uint32 mode_entered; + Uint32 mode_reset; + Uint32 mode_keep_time; + Uint32 mode_step; + }; }