#pragma once #include #include class VpnPeer; class CongestionController { public: struct LossBased { uint64_t bandwidth; // bytes per second uint64_t prev_tot_sent; // tot bytes sent during last update struct timespec prev_time; // last update time }; CongestionController(const VpnPeer& peer); const VpnPeer& get_peer() const { return _peer; } void update_lossbased(); uint64_t get_bandwidth() const { return _bandwidth; } uint64_t get_lossbased_bandwidth() const { return _loss_based.bandwidth; } private: // meth void update_params(); ///< called after an update private: const VpnPeer& _peer; LossBased _loss_based; uint64_t _bandwidth; // Bps uint32_t _last_seqno; // seqno at the last update time uint64_t _bucket_level, ///< implements a leaky bucket _bucket_max_level; // bandwidth * RTT struct timespec _last_bucket_update; };