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
5 changes: 5 additions & 0 deletions src/turtle/p3turtle.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,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 @@ -1488,6 +1489,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 @@ -1689,6 +1691,7 @@ void p3turtle::handleTunnelRequest(RsTurtleOpenTunnelItem *item)
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 @@ -1893,6 +1896,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 @@ -2388,6 +2392,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
3 changes: 2 additions & 1 deletion src/turtle/p3turtle.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class TurtleTunnel
TurtlePeerId local_src ; // where packets come from. Direction to the source.
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.
uint32_t transfered_bytes ; // this one used for estimation
uint64_t total_bytes ; // total bytes transferred in this tunnel.
float speed_Bps ; // speed of the traffic through the tunnel

/* For ending/starting tunnels only. */
Expand Down