mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 08:59:37 -05:00
display session traffic
This commit is contained in:
parent
c19919962d
commit
7504964899
@ -192,7 +192,7 @@ class NetInterface;
|
|||||||
class PQInterface: public RateInterface
|
class PQInterface: public RateInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit PQInterface(const RsPeerId &id) :peerId(id) { return; }
|
explicit PQInterface(const RsPeerId &id) :peerId(id), traf_in(0), traf_out(0) { return; }
|
||||||
virtual ~PQInterface() { return; }
|
virtual ~PQInterface() { return; }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -234,6 +234,22 @@ class PQInterface: public RateInterface
|
|||||||
const sockaddr_storage & /*remote_peer_address*/)
|
const sockaddr_storage & /*remote_peer_address*/)
|
||||||
{ return 0; }
|
{ return 0; }
|
||||||
|
|
||||||
|
virtual uint64_t getTraffic(bool in)
|
||||||
|
{
|
||||||
|
uint64_t ret = 0;
|
||||||
|
if (in)
|
||||||
|
{
|
||||||
|
ret = traf_in;
|
||||||
|
traf_in = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
ret = traf_out;
|
||||||
|
traf_out = 0;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
uint64_t traf_in;
|
||||||
|
uint64_t traf_out;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
RsPeerId peerId;
|
RsPeerId peerId;
|
||||||
|
@ -87,6 +87,8 @@ pqihandler::pqihandler() : coreMtx("pqihandler")
|
|||||||
rateMax_in = 0.01;
|
rateMax_in = 0.01;
|
||||||
rateTotal_in = 0.0 ;
|
rateTotal_in = 0.0 ;
|
||||||
rateTotal_out = 0.0 ;
|
rateTotal_out = 0.0 ;
|
||||||
|
traffInSum = 0;
|
||||||
|
traffOutSum = 0;
|
||||||
last_m = time(NULL) ;
|
last_m = time(NULL) ;
|
||||||
nb_ticks = 0 ;
|
nb_ticks = 0 ;
|
||||||
mLastRateCapUpdate = 0 ;
|
mLastRateCapUpdate = 0 ;
|
||||||
@ -376,6 +378,9 @@ int pqihandler::UpdateRates()
|
|||||||
SearchModule *mod = (it -> second);
|
SearchModule *mod = (it -> second);
|
||||||
float crate_in = mod -> pqi -> getRate(true);
|
float crate_in = mod -> pqi -> getRate(true);
|
||||||
|
|
||||||
|
traffInSum += mod -> pqi -> getTraffic(true);
|
||||||
|
traffOutSum += mod -> pqi -> getTraffic(false);
|
||||||
|
|
||||||
#ifdef PQI_HDL_DEBUG_UR
|
#ifdef PQI_HDL_DEBUG_UR
|
||||||
if(crate_in > 0.0)
|
if(crate_in > 0.0)
|
||||||
std::cerr << " got in rate for peer " << it->first << " : " << crate_in << std::endl;
|
std::cerr << " got in rate for peer " << it->first << " : " << crate_in << std::endl;
|
||||||
@ -544,4 +549,8 @@ void pqihandler::locked_StoreCurrentRates(float in, float out)
|
|||||||
rateTotal_out = out;
|
rateTotal_out = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pqihandler::GetTraffic(uint64_t &in, uint64_t &out)
|
||||||
|
{
|
||||||
|
in = traffInSum;
|
||||||
|
out = traffOutSum;
|
||||||
|
}
|
||||||
|
@ -91,6 +91,10 @@ class pqihandler: public P3Interface, public pqiPublisher
|
|||||||
int ExtractRates(std::map<RsPeerId, RsBwRates> &ratemap, RsBwRates &totals);
|
int ExtractRates(std::map<RsPeerId, RsBwRates> &ratemap, RsBwRates &totals);
|
||||||
int ExtractTrafficInfo(std::list<RSTrafficClue> &out_lst, std::list<RSTrafficClue> &in_lst);
|
int ExtractTrafficInfo(std::list<RSTrafficClue> &out_lst, std::list<RSTrafficClue> &in_lst);
|
||||||
|
|
||||||
|
uint64_t traffInSum;
|
||||||
|
uint64_t traffOutSum;
|
||||||
|
void GetTraffic(uint64_t &in, uint64_t &out);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/* check to be overloaded by those that can
|
/* check to be overloaded by those that can
|
||||||
* generates warnings otherwise
|
* generates warnings otherwise
|
||||||
|
@ -647,6 +647,13 @@ float pqiperson::getRate(bool in)
|
|||||||
return activepqi -> getRate(in);
|
return activepqi -> getRate(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t pqiperson::getTraffic(bool in)
|
||||||
|
{
|
||||||
|
if ((!active) || (activepqi == NULL))
|
||||||
|
return 0;
|
||||||
|
return activepqi -> getTraffic(in);
|
||||||
|
}
|
||||||
|
|
||||||
void pqiperson::setMaxRate(bool in, float val)
|
void pqiperson::setMaxRate(bool in, float val)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mPersonMtx);
|
RS_STACK_MUTEX(mPersonMtx);
|
||||||
|
@ -149,6 +149,7 @@ public:
|
|||||||
virtual int getQueueSize(bool in);
|
virtual int getQueueSize(bool in);
|
||||||
virtual void getRates(RsBwRates &rates);
|
virtual void getRates(RsBwRates &rates);
|
||||||
virtual float getRate(bool in);
|
virtual float getRate(bool in);
|
||||||
|
virtual uint64_t getTraffic(bool in);
|
||||||
virtual void setMaxRate(bool in, float val);
|
virtual void setMaxRate(bool in, float val);
|
||||||
virtual void setRateCap(float val_in, float val_out);
|
virtual void setRateCap(float val_in, float val_out);
|
||||||
virtual int gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,
|
virtual int gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,
|
||||||
|
@ -221,6 +221,7 @@ float pqistreamer::getRate(bool b)
|
|||||||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||||
return RateInterface::getRate(b) ;
|
return RateInterface::getRate(b) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pqistreamer::setMaxRate(bool b,float f)
|
void pqistreamer::setMaxRate(bool b,float f)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||||
@ -1231,7 +1232,7 @@ void pqistreamer::outSentBytes_locked(uint32_t outb)
|
|||||||
mTotalSent += outb;
|
mTotalSent += outb;
|
||||||
mCurrSent += outb;
|
mCurrSent += outb;
|
||||||
mAvgSentCount += outb;
|
mAvgSentCount += outb;
|
||||||
|
PQInterface::traf_out += outb;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1248,7 +1249,7 @@ void pqistreamer::inReadBytes_locked(uint32_t inb)
|
|||||||
mTotalRead += inb;
|
mTotalRead += inb;
|
||||||
mCurrRead += inb;
|
mCurrRead += inb;
|
||||||
mAvgReadCount += inb;
|
mAvgReadCount += inb;
|
||||||
|
PQInterface::traf_in += inb;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,4 +564,8 @@ int p3ServerConfig::GetCurrentDataRates( float &inKb, float &outKb )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int p3ServerConfig::GetTrafficSum(uint64_t &inb, uint64_t &outb )
|
||||||
|
{
|
||||||
|
mPqiHandler->GetTraffic(inb, outb);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
@ -96,6 +96,7 @@ virtual bool setOperatingMode(const std::string &opModeStr);
|
|||||||
virtual int SetMaxDataRates( int downKb, int upKb );
|
virtual int SetMaxDataRates( int downKb, int upKb );
|
||||||
virtual int GetMaxDataRates( int &downKb, int &upKb );
|
virtual int GetMaxDataRates( int &downKb, int &upKb );
|
||||||
virtual int GetCurrentDataRates( float &inKb, float &outKb );
|
virtual int GetCurrentDataRates( float &inKb, float &outKb );
|
||||||
|
virtual int GetTrafficSum( uint64_t &inb, uint64_t &outb );
|
||||||
|
|
||||||
/********************* ABOVE is RsConfig Interface *******/
|
/********************* ABOVE is RsConfig Interface *******/
|
||||||
|
|
||||||
|
@ -726,9 +726,12 @@ void MainWindow::updateStatus()
|
|||||||
float downKb = 0;
|
float downKb = 0;
|
||||||
float upKb = 0;
|
float upKb = 0;
|
||||||
rsConfig->GetCurrentDataRates(downKb, upKb);
|
rsConfig->GetCurrentDataRates(downKb, upKb);
|
||||||
|
uint64_t down = 0;
|
||||||
|
uint64_t up = 0;
|
||||||
|
rsConfig->GetTrafficSum(down, up);
|
||||||
|
|
||||||
if (ratesstatus)
|
if (ratesstatus)
|
||||||
ratesstatus->getRatesStatus(downKb, upKb);
|
ratesstatus->getRatesStatus(downKb, down, upKb, up);
|
||||||
|
|
||||||
if(torstatus)
|
if(torstatus)
|
||||||
torstatus->getTorStatus();
|
torstatus->getTorStatus();
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "ratesstatus.h"
|
#include "ratesstatus.h"
|
||||||
#include <retroshare/rsiface.h>
|
#include <retroshare/rsiface.h>
|
||||||
|
#include "util/misc.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
@ -48,13 +49,13 @@ RatesStatus::RatesStatus(QWidget *parent)
|
|||||||
setLayout(hbox);
|
setLayout(hbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatesStatus::getRatesStatus(float downKb, float upKb)
|
void RatesStatus::getRatesStatus(float downKb, uint64_t down, float upKb, uint64_t upl)
|
||||||
{
|
{
|
||||||
/* set users/friends/network */
|
/* set users/friends/network */
|
||||||
|
|
||||||
QString normalText = QString("<strong>%1:</strong> %2 (kB/s) | <strong>%3:</strong> %4 (kB/s) ")
|
QString normalText = QString("<strong>%1:</strong> %2 kB/s (%3) | <strong>%4:</strong> %5 kB/s (%6)")
|
||||||
.arg(tr("Down")).arg(downKb, 0, 'f', 2)
|
.arg(tr("Down")).arg(downKb, 0, 'f', 2).arg(misc::friendlyUnit(down))
|
||||||
.arg(tr("Up")).arg(upKb, 0, 'f', 2);
|
.arg(tr("Up")).arg(upKb, 0, 'f', 2).arg(misc::friendlyUnit(upl));
|
||||||
QString compactText = QString("%1|%2").arg(downKb, 0, 'f', 2).arg(upKb, 0, 'f', 2);
|
QString compactText = QString("%1|%2").arg(downKb, 0, 'f', 2).arg(upKb, 0, 'f', 2);
|
||||||
|
|
||||||
if (statusRates) {
|
if (statusRates) {
|
||||||
|
@ -32,7 +32,7 @@ class RatesStatus : public QWidget
|
|||||||
public:
|
public:
|
||||||
RatesStatus(QWidget *parent = 0);
|
RatesStatus(QWidget *parent = 0);
|
||||||
|
|
||||||
void getRatesStatus(float downKb, float upKb);
|
void getRatesStatus(float downKb, uint64_t down, float upKb, uint64_t upl);
|
||||||
void setCompactMode(bool compact) {_compactMode = compact; }
|
void setCompactMode(bool compact) {_compactMode = compact; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user