forked from quietbamboo/PacketTraceExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.cpp
36 lines (32 loc) · 990 Bytes
/
client.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// client.cpp
// PacketTraceExplorer
//
// Created by Junxian Huang on 12/20/12.
// Copyright (c) 2012 Junxian Huang. All rights reserved.
//
#include "client.h"
client_bw::client_bw(double _current_start, double _step) {
current_start = _current_start;
step = _step;
current_bytes = 0;
}
void client_bw::add_packet(int payload, double ts) {
if (ts - current_start < step) {
current_bytes += payload;
} else {
//
double tp = (double)current_bytes * 8.0 / step / 1000000.0;
cout << "CLIENT_BW time " << (current_start + step) << " " << tp << " Mbps" << endl;
//this packet starts the new sample
while (ts - current_start >= step) {
if (tp > 0) {
tp = 0;
} else {
cout << "CLIENT_BW time " << (current_start + step) << " " << tp << " Mbps" << endl;
}
current_start += step;
}
current_bytes = payload;
}
}