X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fnet%2FConnectionHandler.hpp;h=ff5e0e42204c8ab9998b83ac9630aae71e19d210;hb=a957788426ff011acf662e29ec5fc0525c1a578f;hp=76103fecdf11a5db2f36aaf1088e42c00f5d158b;hpb=225a7e66ed3f3f03ab458ab39c914ed55cd69600;p=blank.git diff --git a/src/net/ConnectionHandler.hpp b/src/net/ConnectionHandler.hpp index 76103fe..ff5e0e4 100644 --- a/src/net/ConnectionHandler.hpp +++ b/src/net/ConnectionHandler.hpp @@ -1,6 +1,7 @@ #ifndef BLANK_NET_CONNECTIONHANDLER_HPP_ #define BLANK_NET_CONNECTIONHANDLER_HPP_ +#include "CongestionControl.hpp" #include "Packet.hpp" #include @@ -13,14 +14,7 @@ class ConnectionHandler { public: ConnectionHandler(); - /// packet loss as factor - float PacketLoss() const noexcept { return packet_loss; } - /// smooth average round trip time in milliseconds - float RoundTripTime() const noexcept { return rtt; } - /// estimated kilobytes transferred per second - float Upstream() const noexcept { return tx_kbps; } - /// estimated kilobytes received per second - float Downstream() const noexcept { return rx_kbps; } + const CongestionControl &NetStat() const noexcept { return cc; } void PacketSent(std::uint16_t) noexcept; void PacketLost(std::uint16_t); @@ -34,12 +28,6 @@ public: virtual void OnTimeout() { } 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; - // called as soon as the remote end ack'd given packet virtual void OnPacketReceived(std::uint16_t) { } // called if the remote end probably didn't get given packet @@ -60,20 +48,7 @@ private: virtual void On(const Packet::Message &) { } private: - unsigned int packets_lost; - unsigned int packets_received; - float packet_loss; - - Uint32 stamps[16]; - std::size_t stamp_cursor; - std::uint16_t stamp_last; - float rtt; - - Uint32 next_sample; - std::size_t tx_bytes; - std::size_t rx_bytes; - float tx_kbps; - float rx_kbps; + CongestionControl cc; };