Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions libretroshare/src/turtle/p3turtle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,7 @@ void p3turtle::routeGenericTunnelItem(RsTurtleGenericTunnelItem *item)
tunnel.time_stamp = time(NULL) ;

tunnel.transfered_bytes += RsTurtleSerialiser().size(item);
tunnel.total_bytes += RsTurtleSerialiser().size(item);

if(item->PeerId() == tunnel.local_dst)
item->setTravelingDirection(RsTurtleGenericTunnelItem::DIRECTION_CLIENT) ;
Expand Down Expand Up @@ -1453,6 +1454,7 @@ void p3turtle::sendTurtleData(const RsPeerId& virtual_peer_id,RsTurtleGenericTun
tunnel.time_stamp = time(NULL) ;

tunnel.transfered_bytes += ss ;
tunnel.total_bytes += ss ;

if(tunnel.local_src == _own_id)
{
Expand Down Expand Up @@ -1670,14 +1672,15 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)

sendItem(res_item) ;

// Note in the tunnels list that we have an ending tunnel here.
TurtleTunnel tt ;
tt.local_src = item->PeerId() ;
tt.hash = item->file_hash ;
tt.local_dst = _own_id ; // this means us
tt.time_stamp = time(NULL) ;
tt.transfered_bytes = 0 ;
tt.speed_Bps = 0.0f ;
// Note in the tunnels list that we have an ending tunnel here.
TurtleTunnel tt ;
tt.local_src = item->PeerId() ;
tt.hash = item->file_hash ;
tt.local_dst = _own_id ; // this means us
tt.time_stamp = time(NULL) ;
tt.transfered_bytes = 0 ;
tt.total_bytes = 0 ;
tt.speed_Bps = 0.0f ;

_local_tunnels[t_id] = tt ;

Expand Down Expand Up @@ -1853,6 +1856,7 @@ void p3turtle::handleTunnelResult(RsTurtleTunnelOkItem *item)
tunnel.hash.clear() ;
tunnel.time_stamp = time(NULL) ;
tunnel.transfered_bytes = 0 ;
tunnel.total_bytes = 0 ;
tunnel.speed_Bps = 0.0f ;

#ifdef P3TURTLE_DEBUG
Expand Down Expand Up @@ -2347,6 +2351,7 @@ void p3turtle::getInfo( std::vector<std::vector<std::string> >& hashes_info,
tunnel.push_back(it->second.hash.toStdString()) ;
tunnel.push_back(printNumber(now-it->second.time_stamp) + " secs ago") ;
tunnel.push_back(printFloatNumber(it->second.speed_Bps,false)) ; //
tunnel.push_back(printNumber(it->second.total_bytes)) ;
}

search_reqs_info.clear();
Expand Down
1 change: 1 addition & 0 deletions libretroshare/src/turtle/p3turtle.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ class TurtleTunnel
TurtlePeerId local_dst ; // where packets should go. Direction to the destination.
uint32_t time_stamp ; // last time the tunnel was actually used. Used for cleaning old tunnels.
uint32_t transfered_bytes ; // total bytes transferred in this tunnel.
uint64_t total_bytes ;
float speed_Bps ; // speed of the traffic through the tunnel

/* For ending/starting tunnels only. */
Expand Down
21 changes: 18 additions & 3 deletions retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ void TurtleRouterDialog::processSettings(bool bLoad)
}

bool sr_Compare( TurtleSearchRequestDisplayInfo m1, TurtleSearchRequestDisplayInfo m2) { return m1.age < m2.age; }
bool tun_Compare( std::vector<std::string> m1, std::vector<std::string> m2)
{ return ( strtoul(m1[6].c_str(), NULL, 0) > strtoul(m2[6].c_str(), NULL, 0) ); }

void TurtleRouterDialog::updateDisplay()
{
Expand All @@ -108,7 +110,8 @@ void TurtleRouterDialog::updateDisplay()
rsTurtle->getInfo(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;

std::sort(search_reqs_info.begin(),search_reqs_info.end(),sr_Compare) ;

std::sort(tunnels_info.begin(),tunnels_info.end(),tun_Compare) ;

updateTunnelRequests(hashes_info,tunnels_info,search_reqs_info,tunnel_reqs_info) ;

}
Expand Down Expand Up @@ -170,8 +173,20 @@ void TurtleRouterDialog::updateTunnelRequests( const std::vector<std::vector<std
while(num >= 800.0f && k<4)
num /= 1024.0f,++k;
sprintf(tmp,"%3.2f %s",num,units[k].c_str()) ;

QString str = tr("Tunnel id") + ": " + QString::fromUtf8(tunnels_info[i][0].c_str()) + "\t" + tr("Speed") + ": " + QString::fromStdString(tmp) + "\t " + tr("last transfer") + ": " + QString::fromStdString(tunnels_info[i][4])+ "\t" + QString::fromUtf8(tunnels_info[i][2].c_str()) + " -> " + QString::fromUtf8(tunnels_info[i][1].c_str());

float num2 = strtoull(tunnels_info[i][6].c_str(), NULL, 0);
char tmp2[100] ;
std::string units2[4] = { "B","KB","MB","GB" } ;
int k2=0 ;
while(num2 >= 800.0f && k2<4)
num2 /= 1024.0f,++k2;
sprintf(tmp2,"%3.2f %s",num2,units2[k2].c_str()) ;

QString str = tr("Tunnel id") + ": " + QString::fromUtf8(tunnels_info[i][0].c_str())
+ "\t Traffic: " + QString("%1").arg(QString::fromStdString(tmp2),-10)
+ "\t" + tr("Speed") + ": " + QString("%1").arg(QString::fromStdString(tmp),-10)
+ "\t " + tr("last transfer") + ": " + QString("%1").arg(QString::fromStdString(tunnels_info[i][4]),-11)
+ "\t" + QString::fromUtf8(tunnels_info[i][2].c_str()) + " -> " + QString::fromUtf8(tunnels_info[i][1].c_str());
stl.clear() ;
stl.push_back(str) ;
QTreeWidgetItem *item = new QTreeWidgetItem(stl);
Expand Down