]> git.localhorst.tv Git - blank.git/blobdiff - src/net/CongestionControl.hpp
rate network conditions
[blank.git] / src / net / CongestionControl.hpp
index 73d1d859ec0aaed8cafdcd8ba448786a7b047e0f..ea71c55abe7c8625a42c31edf48f0fe8e01b2e45 100644 (file)
@@ -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;
+
 };
 
 }