mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
Added Bandwidth Monitoring service to libretroshare to help debug Lag.
- p3bwctrl.h/.cc & rsbwctrlitems.h/.cc - New Interface in pqihandler to extract the data. - New Interface in rsconfig to display in GUI. - Added extra debugging in pqistreamer for catching big outqueues. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5241 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
0d3d1ebc18
commit
48a1c66c60
16 changed files with 880 additions and 31 deletions
|
@ -53,6 +53,19 @@ int fixme(char *str, int n);
|
|||
* For controlling data rates.
|
||||
* #define DEBUG_RATECAP 1
|
||||
*/
|
||||
|
||||
class RsBwRates
|
||||
{
|
||||
public:
|
||||
RsBwRates()
|
||||
:mRateIn(0), mRateOut(0), mMaxRateIn(0), mMaxRateOut(0) {return;}
|
||||
float mRateIn;
|
||||
float mRateOut;
|
||||
float mMaxRateIn;
|
||||
float mMaxRateOut;
|
||||
};
|
||||
|
||||
|
||||
class RateInterface
|
||||
{
|
||||
|
||||
|
@ -64,6 +77,15 @@ public:
|
|||
|
||||
virtual ~RateInterface() { return; }
|
||||
|
||||
virtual void getRates(RsBwRates &rates)
|
||||
{
|
||||
rates.mRateIn = bw_in;
|
||||
rates.mRateOut = bw_out;
|
||||
rates.mMaxRateIn = bwMax_in;
|
||||
rates.mMaxRateOut = bwMax_out;
|
||||
return;
|
||||
}
|
||||
|
||||
virtual float getRate(bool in)
|
||||
{
|
||||
if (in)
|
||||
|
|
|
@ -735,6 +735,37 @@ RsRawItem *pqihandler::GetRsRawItem()
|
|||
|
||||
static const float MIN_RATE = 0.01; // 10 B/s
|
||||
|
||||
// NEW extern fn to extract rates.
|
||||
int pqihandler::ExtractRates(std::map<std::string, RsBwRates> &ratemap, RsBwRates &total)
|
||||
{
|
||||
total.mMaxRateIn = getMaxRate(true);
|
||||
total.mMaxRateOut = getMaxRate(false);
|
||||
total.mRateIn = 0;
|
||||
total.mRateOut = 0;
|
||||
|
||||
/* Lock once rates have been retrieved */
|
||||
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
||||
|
||||
std::map<std::string, SearchModule *>::iterator it;
|
||||
for(it = mods.begin(); it != mods.end(); it++)
|
||||
{
|
||||
SearchModule *mod = (it -> second);
|
||||
|
||||
RsBwRates peerRates;
|
||||
mod -> pqi -> getRates(peerRates);
|
||||
|
||||
total.mRateIn += peerRates.mRateIn;
|
||||
total.mRateOut += peerRates.mRateOut;
|
||||
|
||||
ratemap[it->first] = peerRates;
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// internal fn to send updates
|
||||
int pqihandler::UpdateRates()
|
||||
{
|
||||
|
|
|
@ -88,14 +88,14 @@ class pqihandler: public P3Interface, public pqiQoS
|
|||
virtual RsRawItem *GetRsRawItem();
|
||||
|
||||
// rate control.
|
||||
//indiv rate is deprecated
|
||||
//void setMaxIndivRate(bool in, float val);
|
||||
//float getMaxIndivRate(bool in);
|
||||
void setMaxRate(bool in, float val);
|
||||
float getMaxRate(bool in);
|
||||
|
||||
void getCurrentRates(float &in, float &out);
|
||||
|
||||
// TESTING INTERFACE.
|
||||
int ExtractRates(std::map<std::string, RsBwRates> &ratemap, RsBwRates &totals);
|
||||
|
||||
bool drawFromQoS_queue() ;
|
||||
|
||||
protected:
|
||||
|
@ -137,25 +137,6 @@ class pqihandler: public P3Interface, public pqiQoS
|
|||
float ticks_per_sec ;
|
||||
};
|
||||
|
||||
//inline void pqihandler::setMaxIndivRate(bool in, float val)
|
||||
//{
|
||||
// RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
||||
// if (in)
|
||||
// rateIndiv_in = val;
|
||||
// else
|
||||
// rateIndiv_out = val;
|
||||
// return;
|
||||
//}
|
||||
//
|
||||
//inline float pqihandler::getMaxIndivRate(bool in)
|
||||
//{
|
||||
// RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
||||
// if (in)
|
||||
// return rateIndiv_in;
|
||||
// else
|
||||
// return rateIndiv_out;
|
||||
//}
|
||||
|
||||
inline void pqihandler::setMaxRate(bool in, float val)
|
||||
{
|
||||
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
||||
|
|
|
@ -849,6 +849,24 @@ void pqistreamer::outSentBytes(int outb)
|
|||
pqioutput(PQL_DEBUG_ALL, pqistreamerzone, out);
|
||||
}
|
||||
|
||||
/*** One theory for the massive delays - is that the queue here is filling up ****/
|
||||
//#define DEBUG_LAG 1
|
||||
#ifdef DEBUG_LAG
|
||||
|
||||
#define MIN_PKTS_FOR_MSG 100
|
||||
if (out_pkt.size() > MIN_PKTS_FOR_MSG)
|
||||
{
|
||||
std::cerr << "pqistreamer::outSentBytes() for: " << PeerId();
|
||||
std::cerr << " End of Write and still " << out_pkt.size() << " pkts left";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
totalSent += outb;
|
||||
currSent += outb;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue