mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-26 07:59:35 -05:00
added control over TR forward rate, so that we can experiment with it on large bandwidth servers
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4918 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
f6c88667c4
commit
fd83e5950f
@ -125,6 +125,9 @@ class RsTurtle
|
|||||||
// Convenience function.
|
// Convenience function.
|
||||||
virtual bool isTurtlePeer(const std::string& peer_id) const = 0 ;
|
virtual bool isTurtlePeer(const std::string& peer_id) const = 0 ;
|
||||||
|
|
||||||
|
// Hardcore handles
|
||||||
|
virtual void setMaxTRForwardRate(int max_tr_up_rate) = 0 ;
|
||||||
|
virtual int getMaxTRForwardRate() const = 0 ;
|
||||||
protected:
|
protected:
|
||||||
FileSharingStrategy _sharing_strategy ;
|
FileSharingStrategy _sharing_strategy ;
|
||||||
};
|
};
|
||||||
|
@ -89,6 +89,8 @@ static const uint32_t MAX_ALLOWED_SR_IN_CACHE = 120 ; /// maximum number of s
|
|||||||
static const float depth_peer_probability[7] = { 1.0f,0.99f,0.9f,0.7f,0.4f,0.15f,0.1f } ;
|
static const float depth_peer_probability[7] = { 1.0f,0.99f,0.9f,0.7f,0.4f,0.15f,0.1f } ;
|
||||||
static const int TUNNEL_REQUEST_PACKET_SIZE = 50 ;
|
static const int TUNNEL_REQUEST_PACKET_SIZE = 50 ;
|
||||||
static const int MAX_TR_FORWARD_PER_SEC = 20 ;
|
static const int MAX_TR_FORWARD_PER_SEC = 20 ;
|
||||||
|
static const int MAX_TR_FORWARD_PER_SEC_UPPER_LIMIT = 100 ;
|
||||||
|
static const int MAX_TR_FORWARD_PER_SEC_LOWER_LIMIT = 10 ;
|
||||||
static const int DISTANCE_SQUEEZING_POWER = 8 ;
|
static const int DISTANCE_SQUEEZING_POWER = 8 ;
|
||||||
|
|
||||||
p3turtle::p3turtle(p3LinkMgr *lm,ftServer *fs)
|
p3turtle::p3turtle(p3LinkMgr *lm,ftServer *fs)
|
||||||
@ -110,6 +112,7 @@ p3turtle::p3turtle(p3LinkMgr *lm,ftServer *fs)
|
|||||||
|
|
||||||
_traffic_info.reset() ;
|
_traffic_info.reset() ;
|
||||||
_sharing_strategy = SHARE_ENTIRE_NETWORK ;
|
_sharing_strategy = SHARE_ENTIRE_NETWORK ;
|
||||||
|
_max_tr_up_rate = MAX_TR_FORWARD_PER_SEC ;
|
||||||
}
|
}
|
||||||
|
|
||||||
int p3turtle::tick()
|
int p3turtle::tick()
|
||||||
@ -552,66 +555,83 @@ RsSerialiser *p3turtle::setupSerialiser()
|
|||||||
{
|
{
|
||||||
RsSerialiser *rss = new RsSerialiser ;
|
RsSerialiser *rss = new RsSerialiser ;
|
||||||
rss->addSerialType(new RsTurtleSerialiser) ;
|
rss->addSerialType(new RsTurtleSerialiser) ;
|
||||||
|
rss->addSerialType(new RsGeneralConfigSerialiser());
|
||||||
|
|
||||||
return rss ;
|
return rss ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3turtle::saveList(bool& cleanup, std::list<RsItem*>&)
|
bool p3turtle::saveList(bool& cleanup, std::list<RsItem*>& lst)
|
||||||
{
|
{
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
std::cerr << "p3turtle: saving list..." << std::endl ;
|
std::cerr << "p3turtle: saving list..." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
cleanup = true ;
|
cleanup = true ;
|
||||||
;
|
|
||||||
#ifdef TO_REMOVE
|
|
||||||
RsTurtleSearchResultItem *item = new RsTurtleSearchResultItem ;
|
|
||||||
item->PeerId("") ;
|
|
||||||
|
|
||||||
for(std::map<TurtleFileHash,TurtleFileHashInfo>::const_iterator it(_incoming_file_hashes.begin());it!=_incoming_file_hashes.end();++it)
|
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
||||||
{
|
RsTlvKeyValue kv;
|
||||||
TurtleFileInfo finfo ;
|
kv.key = "TURTLE_CONFIG_MAX_TR_RATE" ;
|
||||||
finfo.name = it->second.name ;
|
|
||||||
finfo.size = it->second.size ;
|
std::ostringstream s ;
|
||||||
finfo.hash = it->first ;
|
s << _max_tr_up_rate;
|
||||||
#ifdef P3TURTLE_DEBUG
|
kv.value = s.str() ;
|
||||||
std::cerr << " Saving item " << finfo.name << ", " << finfo.hash << ", " << finfo.size << std::endl ;
|
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||||
#endif
|
|
||||||
|
lst.push_back(vitem) ;
|
||||||
|
|
||||||
item->result.push_back(finfo) ;
|
|
||||||
}
|
|
||||||
lst.push_back(item) ;
|
|
||||||
#endif
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
bool p3turtle::loadList(std::list<RsItem*>& load)
|
||||||
bool p3turtle::loadList(std::list<RsItem*> load)
|
|
||||||
{
|
{
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
std::cerr << "p3turtle: loading list..." << std::endl ;
|
std::cerr << "p3turtle: loading list..." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
for(std::list<RsItem*>::const_iterator it(load.begin());it!=load.end();++it)
|
for(std::list<RsItem*>::const_iterator it(load.begin());it!=load.end();++it)
|
||||||
{
|
{
|
||||||
RsTurtleSearchResultItem *item = dynamic_cast<RsTurtleSearchResultItem*>(*it) ;
|
|
||||||
|
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
assert(item!=NULL) ;
|
assert(item!=NULL) ;
|
||||||
#endif
|
#endif
|
||||||
if(item == NULL)
|
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet*>(*it) ;
|
||||||
continue ;
|
|
||||||
|
|
||||||
for(std::list<TurtleFileInfo>::const_iterator it2(item->result.begin());it2!=item->result.end();++it2)
|
if(vitem != NULL)
|
||||||
|
for(std::list<RsTlvKeyValue>::const_iterator kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
||||||
|
if(kit->key == "TURTLE_CONFIG_MAX_TR_RATE")
|
||||||
{
|
{
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef CHAT_DEBUG
|
||||||
std::cerr << " Restarting tunneling for: " << it2->hash << " " << it2->size << " " << it2->name << std::endl ;
|
std::cerr << "Loaded config default nick name for chat: " << kit->value << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
monitorFileTunnels(it2->name,it2->hash,it2->size) ;
|
std::istringstream is(kit->value) ;
|
||||||
|
|
||||||
|
int val ;
|
||||||
|
is >> val ;
|
||||||
|
|
||||||
|
setMaxTRForwardRate(val) ;
|
||||||
}
|
}
|
||||||
delete item ;
|
|
||||||
|
delete vitem ;
|
||||||
}
|
}
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
#endif
|
int p3turtle::getMaxTRForwardRate() const
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
return _max_tr_up_rate ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void p3turtle::setMaxTRForwardRate(int val)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
|
if(val > MAX_TR_FORWARD_PER_SEC_UPPER_LIMIT || val < MAX_TR_FORWARD_PER_SEC_LOWER_LIMIT)
|
||||||
|
std::cerr << "Warning: MAX_TR_FORWARD_PER_SEC value " << val << " read in config file is off limits [" << MAX_TR_FORWARD_PER_SEC_LOWER_LIMIT << "..." << MAX_TR_FORWARD_PER_SEC_UPPER_LIMIT << "]. Ignoring!" << std::endl;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_max_tr_up_rate = val ;
|
||||||
|
std::cerr << "p3turtle: Set max tr up rate to " << val << std::endl;
|
||||||
|
}
|
||||||
|
IndicateConfigChanged() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------------//
|
// -----------------------------------------------------------------------------------//
|
||||||
@ -1591,7 +1611,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)
|
|||||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||||
_traffic_info_buffer.tr_dn_Bps += static_cast<RsTurtleItem*>(item)->serial_size() ;
|
_traffic_info_buffer.tr_dn_Bps += static_cast<RsTurtleItem*>(item)->serial_size() ;
|
||||||
|
|
||||||
float distance_to_maximum = std::min(100.0f,_traffic_info.tr_up_Bps/(float)(TUNNEL_REQUEST_PACKET_SIZE*MAX_TR_FORWARD_PER_SEC)) ;
|
float distance_to_maximum = std::min(100.0f,_traffic_info.tr_up_Bps/(float)(TUNNEL_REQUEST_PACKET_SIZE*_max_tr_up_rate)) ;
|
||||||
float corrected_distance = pow(distance_to_maximum,DISTANCE_SQUEEZING_POWER) ;
|
float corrected_distance = pow(distance_to_maximum,DISTANCE_SQUEEZING_POWER) ;
|
||||||
forward_probability = pow(depth_peer_probability[std::min((uint16_t)6,item->depth)],corrected_distance) ;
|
forward_probability = pow(depth_peer_probability[std::min((uint16_t)6,item->depth)],corrected_distance) ;
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
@ -2157,7 +2177,7 @@ void p3turtle::getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const
|
|||||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||||
info = _traffic_info ;
|
info = _traffic_info ;
|
||||||
|
|
||||||
float distance_to_maximum = std::min(100.0f,info.tr_up_Bps/(float)(TUNNEL_REQUEST_PACKET_SIZE*MAX_TR_FORWARD_PER_SEC)) ;
|
float distance_to_maximum = std::min(100.0f,info.tr_up_Bps/(float)(TUNNEL_REQUEST_PACKET_SIZE*_max_tr_up_rate)) ;
|
||||||
info.forward_probabilities.clear() ;
|
info.forward_probabilities.clear() ;
|
||||||
|
|
||||||
for(int i=0;i<=6;++i)
|
for(int i=0;i<=6;++i)
|
||||||
|
@ -250,14 +250,6 @@ class p3turtle: public p3Service, /*public pqiMonitor,*/ public RsTurtle,/* publ
|
|||||||
|
|
||||||
virtual void getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const ;
|
virtual void getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const ;
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
|
||||||
/************* from pqiMonitor *******************/
|
|
||||||
/// Informs the turtle router that some peers are (dis)connected. This should initiate digging new tunnels,
|
|
||||||
/// and closing other tunnels.
|
|
||||||
///
|
|
||||||
virtual void statusChange(const std::list<pqipeer> &plist);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************* from pqiMonitor *******************/
|
/************* from pqiMonitor *******************/
|
||||||
|
|
||||||
/// This function does many things:
|
/// This function does many things:
|
||||||
@ -271,13 +263,17 @@ class p3turtle: public p3Service, /*public pqiMonitor,*/ public RsTurtle,/* publ
|
|||||||
/************* from p3Config *******************/
|
/************* from p3Config *******************/
|
||||||
virtual RsSerialiser *setupSerialiser() ;
|
virtual RsSerialiser *setupSerialiser() ;
|
||||||
virtual bool saveList(bool& cleanup, std::list<RsItem*>&) ;
|
virtual bool saveList(bool& cleanup, std::list<RsItem*>&) ;
|
||||||
virtual bool loadList(std::list<RsItem*>& /*load*/) { return true; }
|
virtual bool loadList(std::list<RsItem*>& /*load*/) ;
|
||||||
|
|
||||||
/************* Communication with ftserver *******************/
|
/************* Communication with ftserver *******************/
|
||||||
/// Does the turtle router manages tunnels to this peer ? (this is not a
|
/// Does the turtle router manages tunnels to this peer ? (this is not a
|
||||||
/// real id, but a fake one, that the turtle router is capable of connecting with a tunnel id).
|
/// real id, but a fake one, that the turtle router is capable of connecting with a tunnel id).
|
||||||
virtual bool isTurtlePeer(const std::string& peer_id) const ;
|
virtual bool isTurtlePeer(const std::string& peer_id) const ;
|
||||||
|
|
||||||
|
/// sets/gets the max number of forwarded tunnel requests per second.
|
||||||
|
virtual void setMaxTRForwardRate(int max_tr_up_rate) ;
|
||||||
|
virtual int getMaxTRForwardRate() const ;
|
||||||
|
|
||||||
/// Examines the peer id, finds the turtle tunnel in it, and respond yes if the tunnel is ok and operational.
|
/// Examines the peer id, finds the turtle tunnel in it, and respond yes if the tunnel is ok and operational.
|
||||||
bool isOnline(const std::string& peer_id) const ;
|
bool isOnline(const std::string& peer_id) const ;
|
||||||
|
|
||||||
@ -418,6 +414,8 @@ class p3turtle: public p3Service, /*public pqiMonitor,*/ public RsTurtle,/* publ
|
|||||||
TurtleTrafficStatisticsInfoOp _traffic_info ; // used for recording speed
|
TurtleTrafficStatisticsInfoOp _traffic_info ; // used for recording speed
|
||||||
TurtleTrafficStatisticsInfoOp _traffic_info_buffer ; // used as a buffer to collect bytes
|
TurtleTrafficStatisticsInfoOp _traffic_info_buffer ; // used as a buffer to collect bytes
|
||||||
|
|
||||||
|
float _max_tr_up_rate ;
|
||||||
|
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
// debug function
|
// debug function
|
||||||
void dumpState() ;
|
void dumpState() ;
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include <retroshare/rsiface.h>
|
#include <retroshare/rsiface.h>
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
|
#include <retroshare/rsturtle.h>
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
@ -42,6 +43,7 @@ ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
|
|||||||
connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
|
connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
|
||||||
connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
|
connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
|
||||||
connect( ui.allowTunnelConnectionCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTunnelConnection(bool) ) );
|
connect( ui.allowTunnelConnectionCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleTunnelConnection(bool) ) );
|
||||||
|
connect( ui._max_tr_up_per_sec_SB, SIGNAL( valueChanged( int ) ), this, SLOT( updateMaxTRUpRate(int) ) );
|
||||||
|
|
||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||||
@ -74,6 +76,11 @@ ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ServerPage::updateMaxTRUpRate(int b)
|
||||||
|
{
|
||||||
|
rsTurtle->setMaxTRForwardRate(b) ;
|
||||||
|
}
|
||||||
|
|
||||||
void ServerPage::toggleIpDetermination(bool b)
|
void ServerPage::toggleIpDetermination(bool b)
|
||||||
{
|
{
|
||||||
rsPeers->allowServerIPDetermination(b) ;
|
rsPeers->allowServerIPDetermination(b) ;
|
||||||
@ -185,6 +192,8 @@ void ServerPage::load()
|
|||||||
ui.dynDNS -> setText(QString::fromStdString(detail.dyndns));
|
ui.dynDNS -> setText(QString::fromStdString(detail.dyndns));
|
||||||
|
|
||||||
ui.showDiscStatusBar->setChecked(Settings->getStatusBarFlags() & STATUSBAR_DISC);
|
ui.showDiscStatusBar->setChecked(Settings->getStatusBarFlags() & STATUSBAR_DISC);
|
||||||
|
|
||||||
|
ui._max_tr_up_per_sec_SB->setValue(rsTurtle->getMaxTRForwardRate()) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Loads the settings for this page */
|
/** Loads the settings for this page */
|
||||||
|
@ -46,6 +46,7 @@ private slots:
|
|||||||
void toggleUPnP();
|
void toggleUPnP();
|
||||||
void toggleIpDetermination(bool) ;
|
void toggleIpDetermination(bool) ;
|
||||||
void toggleTunnelConnection(bool) ;
|
void toggleTunnelConnection(bool) ;
|
||||||
|
void updateMaxTRUpRate(int) ;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ServerPage ui;
|
Ui::ServerPage ui;
|
||||||
|
@ -831,6 +831,75 @@ behind a firewall or a VPN.</string>
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="tab_3">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>Turtle router</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QTextBrowser" name="textBrowser">
|
||||||
|
<property name="html">
|
||||||
|
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||||
|
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||||
|
p, li { white-space: pre-wrap; }
|
||||||
|
</style></head><body style=" font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;">
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Warning</span></p>
|
||||||
|
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-weight:600;"></p>
|
||||||
|
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;"> </span>This tab contains hard-core parameters which are unlikely to need modification. Dont change them unless you really know what you're doing. </p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>Max average tunnel request forwarded per second:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="_max_tr_up_per_sec_SB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>This value controls how many tunnel request your peer can forward per second.
|
||||||
|
|
||||||
|
If you have a large internet bandwidth, you may raise this up to 30-40, to allow
|
||||||
|
statisticlly longuer tunnels to pass. Be very careful though, since this generates
|
||||||
|
many small packets that can significantly slow down your own file transfer.
|
||||||
|
|
||||||
|
The default value is 20.</string>
|
||||||
|
</property>
|
||||||
|
<property name="minimum">
|
||||||
|
<number>5</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>20</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user