Browse Source

Count bytes sent and received among relays and clients

Ian Goldberg 4 years ago
parent
commit
2feb5dd074
2 changed files with 2 additions and 1 deletions
  1. 0 1
      network.py
  2. 2 0
      relay.py

+ 0 - 1
network.py

@@ -205,7 +205,6 @@ class NetMsg:
         messages to have more accurate sizes, override this method in
         the subclass."""
         sz = len(pickle.dumps(self))
-        print('size',sz,type(self))
         return sz
 
 

+ 2 - 0
relay.py

@@ -143,10 +143,12 @@ class Channel(network.Connection):
 
     def send_msg(self, msg):
         """Send the given NetMsg on the channel."""
+        self.cellhandler.perfstats.bytes_sent += msg.size()
         self.peer.received(self.cellhandler.myaddr, msg)
 
     def received(self, peeraddr, msg):
         """Callback when a message is received from the network."""
+        self.cellhandler.perfstats.bytes_received += msg.size()
         if isinstance(msg, CircuitCellMsg):
             circid, cell = msg.circid, msg.cell
             self.circuithandlers[circid].received_cell(cell, peeraddr, self.peer)