Statistics

- Added aggregation of total data sent and received by Server
This commit is contained in:
Joshua Kissoon 2014-05-06 09:27:40 +05:30
parent 899390b4a3
commit 2adfc9b277

View File

@ -176,6 +176,9 @@ public class KadServer
DatagramPacket pkt = new DatagramPacket(data, 0, data.length); DatagramPacket pkt = new DatagramPacket(data, 0, data.length);
pkt.setSocketAddress(to.getSocketAddress()); pkt.setSocketAddress(to.getSocketAddress());
socket.send(pkt); socket.send(pkt);
/* Lets inform the statistician that we've sent some data */
this.statistician.sentData(data.length);
} }
} }
@ -195,8 +198,8 @@ public class KadServer
DatagramPacket packet = new DatagramPacket(buffer, buffer.length); DatagramPacket packet = new DatagramPacket(buffer, buffer.length);
socket.receive(packet); socket.receive(packet);
//Statistics.dataReceived += packet.getLength(); /* Lets inform the statistician that we've received some data */
//System.out.println("Received packet of size: " + packet.getLength()); this.statistician.receivedData(packet.getLength());
/* We've received a packet, now handle it */ /* We've received a packet, now handle it */
try (ByteArrayInputStream bin = new ByteArrayInputStream(packet.getData(), packet.getOffset(), packet.getLength()); try (ByteArrayInputStream bin = new ByteArrayInputStream(packet.getData(), packet.getOffset(), packet.getLength());