mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 07:29:33 -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.
|
||||
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:
|
||||
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 int TUNNEL_REQUEST_PACKET_SIZE = 50 ;
|
||||
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 ;
|
||||
|
||||
p3turtle::p3turtle(p3LinkMgr *lm,ftServer *fs)
|
||||
@ -110,6 +112,7 @@ p3turtle::p3turtle(p3LinkMgr *lm,ftServer *fs)
|
||||
|
||||
_traffic_info.reset() ;
|
||||
_sharing_strategy = SHARE_ENTIRE_NETWORK ;
|
||||
_max_tr_up_rate = MAX_TR_FORWARD_PER_SEC ;
|
||||
}
|
||||
|
||||
int p3turtle::tick()
|
||||
@ -552,66 +555,83 @@ RsSerialiser *p3turtle::setupSerialiser()
|
||||
{
|
||||
RsSerialiser *rss = new RsSerialiser ;
|
||||
rss->addSerialType(new RsTurtleSerialiser) ;
|
||||
rss->addSerialType(new RsGeneralConfigSerialiser());
|
||||
|
||||
return rss ;
|
||||
}
|
||||
|
||||
bool p3turtle::saveList(bool& cleanup, std::list<RsItem*>&)
|
||||
bool p3turtle::saveList(bool& cleanup, std::list<RsItem*>& lst)
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "p3turtle: saving list..." << std::endl ;
|
||||
#endif
|
||||
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)
|
||||
{
|
||||
TurtleFileInfo finfo ;
|
||||
finfo.name = it->second.name ;
|
||||
finfo.size = it->second.size ;
|
||||
finfo.hash = it->first ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " Saving item " << finfo.name << ", " << finfo.hash << ", " << finfo.size << std::endl ;
|
||||
#endif
|
||||
RsConfigKeyValueSet *vitem = new RsConfigKeyValueSet ;
|
||||
RsTlvKeyValue kv;
|
||||
kv.key = "TURTLE_CONFIG_MAX_TR_RATE" ;
|
||||
|
||||
std::ostringstream s ;
|
||||
s << _max_tr_up_rate;
|
||||
kv.value = s.str() ;
|
||||
vitem->tlvkvs.pairs.push_back(kv) ;
|
||||
|
||||
lst.push_back(vitem) ;
|
||||
|
||||
item->result.push_back(finfo) ;
|
||||
}
|
||||
lst.push_back(item) ;
|
||||
#endif
|
||||
return true ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
bool p3turtle::loadList(std::list<RsItem*> load)
|
||||
bool p3turtle::loadList(std::list<RsItem*>& load)
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << "p3turtle: loading list..." << std::endl ;
|
||||
#endif
|
||||
for(std::list<RsItem*>::const_iterator it(load.begin());it!=load.end();++it)
|
||||
{
|
||||
RsTurtleSearchResultItem *item = dynamic_cast<RsTurtleSearchResultItem*>(*it) ;
|
||||
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
assert(item!=NULL) ;
|
||||
#endif
|
||||
if(item == NULL)
|
||||
continue ;
|
||||
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet*>(*it) ;
|
||||
|
||||
for(std::list<TurtleFileInfo>::const_iterator it2(item->result.begin());it2!=item->result.end();++it2)
|
||||
{
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
std::cerr << " Restarting tunneling for: " << it2->hash << " " << it2->size << " " << it2->name << std::endl ;
|
||||
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 CHAT_DEBUG
|
||||
std::cerr << "Loaded config default nick name for chat: " << kit->value << std::endl ;
|
||||
#endif
|
||||
monitorFileTunnels(it2->name,it2->hash,it2->size) ;
|
||||
}
|
||||
delete item ;
|
||||
std::istringstream is(kit->value) ;
|
||||
|
||||
int val ;
|
||||
is >> val ;
|
||||
|
||||
setMaxTRForwardRate(val) ;
|
||||
}
|
||||
|
||||
delete vitem ;
|
||||
}
|
||||
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 ******/
|
||||
_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) ;
|
||||
forward_probability = pow(depth_peer_probability[std::min((uint16_t)6,item->depth)],corrected_distance) ;
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
@ -2157,7 +2177,7 @@ void p3turtle::getTrafficStatistics(TurtleTrafficStatisticsInfo& info) const
|
||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||
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() ;
|
||||
|
||||
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 ;
|
||||
|
||||
#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 *******************/
|
||||
|
||||
/// This function does many things:
|
||||
@ -271,13 +263,17 @@ class p3turtle: public p3Service, /*public pqiMonitor,*/ public RsTurtle,/* publ
|
||||
/************* from p3Config *******************/
|
||||
virtual RsSerialiser *setupSerialiser() ;
|
||||
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 *******************/
|
||||
/// 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).
|
||||
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.
|
||||
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_buffer ; // used as a buffer to collect bytes
|
||||
|
||||
float _max_tr_up_rate ;
|
||||
|
||||
#ifdef P3TURTLE_DEBUG
|
||||
// debug function
|
||||
void dumpState() ;
|
||||
|
@ -30,6 +30,7 @@
|
||||
|
||||
#include <retroshare/rsiface.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
#include <retroshare/rsturtle.h>
|
||||
|
||||
#include <QTimer>
|
||||
|
||||
@ -42,6 +43,7 @@ ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
|
||||
connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
|
||||
connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(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);
|
||||
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
|
||||
@ -74,6 +76,11 @@ ServerPage::ServerPage(QWidget * parent, Qt::WFlags flags)
|
||||
#endif
|
||||
}
|
||||
|
||||
void ServerPage::updateMaxTRUpRate(int b)
|
||||
{
|
||||
rsTurtle->setMaxTRForwardRate(b) ;
|
||||
}
|
||||
|
||||
void ServerPage::toggleIpDetermination(bool b)
|
||||
{
|
||||
rsPeers->allowServerIPDetermination(b) ;
|
||||
@ -185,6 +192,8 @@ void ServerPage::load()
|
||||
ui.dynDNS -> setText(QString::fromStdString(detail.dyndns));
|
||||
|
||||
ui.showDiscStatusBar->setChecked(Settings->getStatusBarFlags() & STATUSBAR_DISC);
|
||||
|
||||
ui._max_tr_up_per_sec_SB->setValue(rsTurtle->getMaxTRForwardRate()) ;
|
||||
}
|
||||
|
||||
/** Loads the settings for this page */
|
||||
|
@ -46,6 +46,7 @@ private slots:
|
||||
void toggleUPnP();
|
||||
void toggleIpDetermination(bool) ;
|
||||
void toggleTunnelConnection(bool) ;
|
||||
void updateMaxTRUpRate(int) ;
|
||||
|
||||
private:
|
||||
Ui::ServerPage ui;
|
||||
|
@ -831,6 +831,75 @@ behind a firewall or a VPN.</string>
|
||||
</item>
|
||||
</layout>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
Loading…
Reference in New Issue
Block a user