diff --git a/libretroshare/src/pqi/pqi_base.h b/libretroshare/src/pqi/pqi_base.h index 53ea1e73d..38c4a33b9 100644 --- a/libretroshare/src/pqi/pqi_base.h +++ b/libretroshare/src/pqi/pqi_base.h @@ -58,11 +58,13 @@ class RsBwRates { public: RsBwRates() - :mRateIn(0), mRateOut(0), mMaxRateIn(0), mMaxRateOut(0) {return;} + :mRateIn(0), mRateOut(0), mMaxRateIn(0), mMaxRateOut(0), mQueueIn(0), mQueueOut(0) {return;} float mRateIn; float mRateOut; float mMaxRateIn; float mMaxRateOut; + int mQueueIn; + int mQueueOut; }; @@ -86,6 +88,7 @@ virtual void getRates(RsBwRates &rates) return; } +virtual int getQueueSize(bool /* in */) { return 0;} virtual float getRate(bool in) { if (in) diff --git a/libretroshare/src/pqi/pqihandler.cc b/libretroshare/src/pqi/pqihandler.cc index f91926eda..5a8303ed5 100644 --- a/libretroshare/src/pqi/pqihandler.cc +++ b/libretroshare/src/pqi/pqihandler.cc @@ -742,6 +742,8 @@ int pqihandler::ExtractRates(std::map &ratemap, RsBw total.mMaxRateOut = getMaxRate(false); total.mRateIn = 0; total.mRateOut = 0; + total.mQueueIn = 0; + total.mQueueOut = 0; /* Lock once rates have been retrieved */ RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/ @@ -756,6 +758,8 @@ int pqihandler::ExtractRates(std::map &ratemap, RsBw total.mRateIn += peerRates.mRateIn; total.mRateOut += peerRates.mRateOut; + total.mQueueIn += peerRates.mQueueIn; + total.mQueueOut += peerRates.mQueueOut; ratemap[it->first] = peerRates; diff --git a/libretroshare/src/pqi/pqiperson.cc b/libretroshare/src/pqi/pqiperson.cc index 80f9cfb49..c8e8e7475 100644 --- a/libretroshare/src/pqi/pqiperson.cc +++ b/libretroshare/src/pqi/pqiperson.cc @@ -452,6 +452,23 @@ pqiconnect *pqiperson::getKid(uint32_t type) } } +void pqiperson::getRates(RsBwRates &rates) +{ + // get the rate from the active one. + if ((!active) || (activepqi == NULL)) + return; + activepqi -> getRates(rates); +} + +int pqiperson::getQueueSize(bool in) +{ + // get the rate from the active one. + if ((!active) || (activepqi == NULL)) + return 0; + return activepqi -> getQueueSize(in); +} + + float pqiperson::getRate(bool in) { // get the rate from the active one. diff --git a/libretroshare/src/pqi/pqiperson.h b/libretroshare/src/pqi/pqiperson.h index 17c822778..2f01f71fa 100644 --- a/libretroshare/src/pqi/pqiperson.h +++ b/libretroshare/src/pqi/pqiperson.h @@ -136,6 +136,8 @@ virtual int tick(); int notifyEvent(NetInterface *ni, int event); // PQInterface for rate control overloaded.... +virtual int getQueueSize(bool in); +virtual void getRates(RsBwRates &rates); virtual float getRate(bool in); virtual void setMaxRate(bool in, float val); virtual void setRateCap(float val_in, float val_out); diff --git a/libretroshare/src/pqi/pqistreamer.cc b/libretroshare/src/pqi/pqistreamer.cc index 3dd999ffd..50d159b0f 100644 --- a/libretroshare/src/pqi/pqistreamer.cc +++ b/libretroshare/src/pqi/pqistreamer.cc @@ -924,3 +924,18 @@ void pqistreamer::inReadBytes(int inb) return; } +int pqistreamer::getQueueSize(bool in) +{ + if (in) + return incoming.size(); + return out_pkt.size(); +} + +void pqistreamer::getRates(RsBwRates &rates) +{ + RateInterface::getRates(rates); + rates.mQueueIn = incoming.size(); + rates.mQueueOut = out_pkt.size(); +} + + diff --git a/libretroshare/src/pqi/pqistreamer.h b/libretroshare/src/pqi/pqistreamer.h index 188c207f5..2e3e58d31 100644 --- a/libretroshare/src/pqi/pqistreamer.h +++ b/libretroshare/src/pqi/pqistreamer.h @@ -59,7 +59,8 @@ class pqistreamer: public PQInterface virtual int status(); time_t getLastIncomingTS(); // Time of last data packet, for checking a connection is alive. - + virtual void getRates(RsBwRates &rates); + virtual int getQueueSize(bool in); // extracting data. private: /* Implementation */ diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index 70243b161..ef9c10e84 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -146,6 +146,9 @@ class RsConfigDataRates mAllowedOut = 0; mAllowedTs = 0; + + mQueueIn = 0; + mQueueOut = 0; } /* all in kB/s */ @@ -160,6 +163,9 @@ class RsConfigDataRates float mAllowedOut; time_t mAllowedTs; + + int mQueueIn; + int mQueueOut; }; diff --git a/libretroshare/src/services/p3bwctrl.cc b/libretroshare/src/services/p3bwctrl.cc index 5d4ae6c44..9f157587a 100644 --- a/libretroshare/src/services/p3bwctrl.cc +++ b/libretroshare/src/services/p3bwctrl.cc @@ -225,6 +225,9 @@ int p3BandwidthControl::getTotalBandwidthRates(RsConfigDataRates &rates) rates.mAllowedOut = 0; rates.mAllowedTs = 0; + rates.mQueueIn = mTotalRates.mQueueIn; + rates.mQueueOut = mTotalRates.mQueueOut; + return 1; } @@ -248,6 +251,9 @@ int p3BandwidthControl::getAllBandwidthRates(std::mapsecond.mAllowedOut / 1000.0; rates.mAllowedTs = bit->second.mLastRecvd; + rates.mQueueIn = bit->second.mRates.mQueueIn; + rates.mQueueOut = bit->second.mRates.mQueueOut; + ratemap[bit->first] = rates; } return true ;