diff --git a/libraries/networking/src/udt/ConnectionStats.cpp b/libraries/networking/src/udt/ConnectionStats.cpp index 394448afec..0b53e35618 100644 --- a/libraries/networking/src/udt/ConnectionStats.cpp +++ b/libraries/networking/src/udt/ConnectionStats.cpp @@ -21,8 +21,8 @@ ConnectionStats::ConnectionStats() { } ConnectionStats::Stats ConnectionStats::sample() { - Stats sample; - std::swap(sample, _currentSample); + Stats sample = _currentSample; + _currentSample = Stats(); auto now = duration_cast(high_resolution_clock::now().time_since_epoch()); sample.endTime = now; @@ -81,12 +81,57 @@ void ConnectionStats::recordReceivedTimeoutNAK() { ++_total.receivedTimeoutNAKs; } -void ConnectionStats::recordSentPackets() { + +void ConnectionStats::recordSentPackets(int payload, int total) { ++_currentSample.sentPackets; ++_total.sentPackets; + + _currentSample.sentUtilBytes += payload; + _total.sentUtilBytes += payload; + + _currentSample.sentBytes += total; + _total.sentBytes += total; } -void ConnectionStats::recordReceivedPackets() { +void ConnectionStats::recordReceivedPackets(int payload, int total) { ++_currentSample.recievedPackets; ++_total.recievedPackets; -} \ No newline at end of file + + _currentSample.recievedUtilBytes += payload; + _total.recievedUtilBytes += payload; + + _currentSample.sentBytes += total; + _total.recievedBytes += total; +} + +void ConnectionStats::recordUnreliableSentPackets(int payload, int total) { + ++_currentSample.sentUnreliablePackets; + ++_total.sentUnreliablePackets; + + _currentSample.sentUnreliableUtilBytes += payload; + _total.sentUnreliableUtilBytes += payload; + + _currentSample.sentUnreliableBytes += total; + _total.sentUnreliableBytes += total; +} + +void ConnectionStats::recordUnreliableReceivedPackets(int payload, int total) { + ++_currentSample.recievedUnreliablePackets; + ++_total.recievedUnreliablePackets; + + _currentSample.recievedUnreliableUtilBytes += payload; + _total.recievedUnreliableUtilBytes += payload; + + _currentSample.sentUnreliableBytes += total; + _total.recievedUnreliableBytes += total; +} + +void ConnectionStats::recordRetransmition() { + ++_currentSample.retransmissions; + ++_total.retransmissions; +} + +void ConnectionStats::recordDrop() { + ++_currentSample.drops; + ++_total.drops; +} diff --git a/libraries/networking/src/udt/ConnectionStats.h b/libraries/networking/src/udt/ConnectionStats.h index df7dfd1545..aa3687e481 100644 --- a/libraries/networking/src/udt/ConnectionStats.h +++ b/libraries/networking/src/udt/ConnectionStats.h @@ -36,6 +36,20 @@ public: int sentPackets { 0 }; int recievedPackets { 0 }; + int sentUtilBytes { 0 }; + int recievedUtilBytes { 0 }; + int sentBytes { 0 }; + int recievedBytes { 0 }; + + int sentUnreliablePackets { 0 }; + int recievedUnreliablePackets { 0 }; + int sentUnreliableUtilBytes { 0 }; + int recievedUnreliableUtilBytes { 0 }; + int sentUnreliableBytes { 0 }; + int recievedUnreliableBytes { 0 }; + + int retransmissions { 0 }; + int drops { 0 }; }; ConnectionStats(); @@ -54,8 +68,14 @@ public: void recordSentTimeoutNAK(); void recordReceivedTimeoutNAK(); - void recordSentPackets(); - void recordReceivedPackets(); + void recordSentPackets(int payload, int total); + void recordReceivedPackets(int payload, int total); + + void recordUnreliableSentPackets(int payload, int total); + void recordUnreliableReceivedPackets(int payload, int total); + + void recordRetransmition(); + void recordDrop(); private: Stats _currentSample;