diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 3abc216dcb..ed490c1737 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -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) ; @@ -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) { @@ -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 ; @@ -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 @@ -2347,6 +2351,7 @@ void p3turtle::getInfo( std::vector >& 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(); diff --git a/libretroshare/src/turtle/p3turtle.h b/libretroshare/src/turtle/p3turtle.h index ad60cf7f2e..49f84d741f 100644 --- a/libretroshare/src/turtle/p3turtle.h +++ b/libretroshare/src/turtle/p3turtle.h @@ -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. */ diff --git a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp index b866ae9948..7387359e7c 100644 --- a/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp +++ b/retroshare-gui/src/gui/statistics/TurtleRouterDialog.cpp @@ -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 m1, std::vector m2) + { return ( strtoul(m1[6].c_str(), NULL, 0) > strtoul(m2[6].c_str(), NULL, 0) ); } void TurtleRouterDialog::updateDisplay() { @@ -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) ; } @@ -170,8 +173,20 @@ void TurtleRouterDialog::updateTunnelRequests( const std::vector= 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);