mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Added Low Pass Filter to Relay Bandwidth Check... To allow brief bits over the peak.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-dhtmods@4774 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3d4feaaaf7
commit
54c0524764
@ -223,11 +223,19 @@ int UdpRelayReceiver::checkRelays()
|
||||
std::list<UdpRelayAddrSet> eraseList;
|
||||
std::map<UdpRelayAddrSet, UdpRelayProxy>::iterator rit;
|
||||
time_t now = time(NULL);
|
||||
|
||||
#define BANDWIDTH_FILTER_K (0.8)
|
||||
|
||||
for(rit = mRelays.begin(); rit != mRelays.end(); rit++)
|
||||
{
|
||||
/* calc bandwidth */
|
||||
rit->second.mBandwidth = rit->second.mDataSize / (float) (now - rit->second.mLastBandwidthTS);
|
||||
//rit->second.mBandwidth = rit->second.mDataSize / (float) (now - rit->second.mLastBandwidthTS);
|
||||
// Switch to a Low-Pass Filter to average it out.
|
||||
float instantBandwidth = rit->second.mDataSize / (float) (now - rit->second.mLastBandwidthTS);
|
||||
|
||||
rit->second.mBandwidth *= (BANDWIDTH_FILTER_K);
|
||||
rit->second.mBandwidth += (1.0 - BANDWIDTH_FILTER_K) * instantBandwidth;
|
||||
|
||||
rit->second.mDataSize = 0;
|
||||
rit->second.mLastBandwidthTS = now;
|
||||
|
||||
@ -238,6 +246,18 @@ int UdpRelayReceiver::checkRelays()
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// ONLY A WARNING.
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
if (instantBandwidth > rit->second.mBandwidthLimit)
|
||||
{
|
||||
std::cerr << "UdpRelayReceiver::checkRelays() ";
|
||||
std::cerr << "Warning instantBandwidth: " << instantBandwidth;
|
||||
std::cerr << " Exceeding Limit: " << rit->second.mBandwidthLimit;
|
||||
std::cerr << " for Relay: " << rit->first;
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rit->second.mBandwidth > rit->second.mBandwidthLimit)
|
||||
{
|
||||
#ifdef DEBUG_UDP_RELAY
|
||||
|
Loading…
Reference in New Issue
Block a user