20 inline ostream& operator<<(ostream& out,
21 const chrono::high_resolution_clock::time_point& t) {
22 return out << t.time_since_epoch().count();
28 #include "PacketStore.h"
31 using namespace chrono;
34 using std::unique_lock;
53 bool validQ(
int)
const;
62 bool setQLimits(
int,
int,
int);
65 bool enq(
int,
int, uint64_t);
66 int deq(
int&, uint64_t);
107 inline bool QuManager::validQ(
int qid)
const {
108 unique_lock lck(mtx);
109 return 1 <= qid && qid <= nQ && quInfo[qid].pktLim >= 0;
112 inline bool QuManager::setLinkRates(
int lnk, RateSpec& rs) {
113 unique_lock lck(mtx);
114 if (lnk < 1 || lnk > nL)
return false;
115 int br = max(rs.bitRateDown,1);
116 int pr = max(rs.pktRateDown,1);
117 br = min(br,8000000); pr = min(pr,1000000000);
118 lnkInfo[lnk].nsPerByte = 8000000/br;
119 lnkInfo[lnk].minDelta = 1000000000/pr;
123 inline bool QuManager::setQRates(
int qid, RateSpec& rs) {
124 unique_lock lck(mtx);
125 if (!validQ(qid))
return false;
126 int br = min(rs.bitRateDown,8000000);
127 int pr = min(rs.pktRateDown,1000000000);
128 quInfo[qid].nsPerByte = 8000000/br;
129 quInfo[qid].minDelta = 1000000000/pr;
133 inline bool QuManager::setQLimits(
int qid,
int np,
int nb) {
134 unique_lock lck(mtx);
135 if (!validQ(qid))
return false;
136 np = max(0,np); nb = max(0,nb);
137 quInfo[qid].pktLim = np;
138 quInfo[qid].byteLim = nb;