Added new connection stats

This commit is contained in:
Atlante45 2015-07-31 10:41:16 -07:00
parent 4f8f9903c2
commit da7a8f6e2f
2 changed files with 72 additions and 7 deletions

View file

@ -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<microseconds>(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;
}
_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;
}

View file

@ -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;