forked from securesocketfunneling/udt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
140 lines (122 loc) · 4.56 KB
/
plot.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/usr/bin/python
# This script parses the log file generated by the connected protocol FileLog logger
# How to use :
# python plot.py [file] [sampling] [first] [end]
# [file] the file log
# [sampling] frequency of logging in seconds
# [first] offset of the first point to be displayed in graph
# [end] offset of the last point to be displayed in graph
import sys
import numpy as np
import matplotlib.pyplot as plt
file = sys.argv[1]
sampling = float(sys.argv[2])
first = int(sys.argv[3])
if (len(sys.argv) > 4):
end = int(sys.argv[4])
else:
end = -1
# parse log file
with open(file) as f:
data = f.read()
data = data.split('\n')
x_range = range(first, len(data[0:end]))
x = [index * sampling for index in x_range]
sending_period = [row.split(' ')[0] for row in data[first:end]]
cc_window_flow_size = [row.split(' ')[1] for row in data[first:end]]
remote_arrival_speed = [row.split(' ')[2] for row in data[first:end]]
remote_link_capacity = [row.split(' ')[3] for row in data[first:end]]
rtt = [row.split(' ')[4] for row in data[first:end]]
rtt_var = [row.split(' ')[5] for row in data[first:end]]
ack_period = [row.split(' ')[6] for row in data[first:end]]
nack_count = [row.split(' ')[7] for row in data[first:end]]
ack_count = [row.split(' ')[8] for row in data[first:end]]
ack_sent_count = [row.split(' ')[9] for row in data[first:end]]
ack2_count = [row.split(' ')[10] for row in data[first:end]]
ack2_sent_count = [row.split(' ')[11] for row in data[first:end]]
multiplexer_sent_count = [row.split(' ')[12] for row in data[first:end]]
flow_sent_count = [row.split(' ')[13] for row in data[first:end]]
received_count = [row.split(' ')[14] for row in data[first:end]]
local_arrival_speed = [row.split(' ')[15] for row in data[first:end]]
local_link_capacity = [row.split(' ')[16] for row in data[first:end]]
remote_window_flow_size = [row.split(' ')[17] for row in data[first:end]]
mean_sending_period = np.mean(list(map(float, sending_period)))
print("Means :")
print(" * rtt : %d us" % (np.mean(list(map(float, rtt)))))
if (mean_sending_period > 0):
print(" * sending period : %d us" % mean_sending_period)
print(" * bandwidth : %d packets/sec ( %dMbits / sec)" % (1000000 / mean_sending_period , 1 / mean_sending_period * 1500 * 8))
print(" * congestion window flow size : %d packets" % (np.mean(list(map(float, cc_window_flow_size)))))
print(" * local arrival speed : %d packets/sec" % (np.mean(list(map(float, local_arrival_speed)))))
print(" * local link capacity : %d packets/sec" % (np.mean(list(map(float, local_link_capacity)))))
print(" * ack_sent_count : %d" % (np.mean(list(map(float, ack_sent_count)))))
print(" * ack2_sent_count : %d" % (np.mean(list(map(float, ack2_sent_count)))))
print("\n")
print(" * remote window flow size : %d packets" % (np.mean(list(map(float, remote_window_flow_size)))))
print(" * remote arrival speed : %d packets/sec" % (np.mean(list(map(float, remote_arrival_speed)))))
print(" * remote link capacity : %d packets/sec" % (np.mean(list(map(float, remote_link_capacity)))))
print(" * ack count : %d" % (np.mean(list(map(float, ack_count)))))
print(" * ack2 count : %d" % (np.mean(list(map(float, ack2_count)))))
y_client = [
sending_period,
cc_window_flow_size,
remote_arrival_speed,
remote_link_capacity,
rtt,
nack_count,
ack_count,
multiplexer_sent_count,
remote_window_flow_size
]
label_client = [
"sending period (us)",
"cc window flow size (pkt)",
"remote arrival speed (pkt/s)",
"remote link capacity (pkt/s)",
"rtt (us)",
"nack count",
"ack count",
"multiplexer sent",
"remote window flow"
]
y_server = [
local_arrival_speed,
local_link_capacity,
rtt,
rtt_var,
ack_period,
ack_sent_count,
ack2_count,
received_count
]
label_server = [
"local arrival speed (pkt/s)",
"local link capacity (pkt/s)",
"rtt (us)",
"rtt_var (us)",
"ack period (us)",
"ack sent",
"ack2 count",
"received_count"
]
# display sending statistics as graph
fig_client = plt.figure(1)
i = 1
for y_arr_client, label_arr_client in zip(y_client, label_client):
ax = fig_client.add_subplot(len(label_client)*100 + 10 + i)
ax.plot(x, y_arr_client, label=label_arr_client)
ax.set_ylim(bottom=0)
i = i + 1
fig_client.suptitle("stat client side")
ax.legend()
# display receiving statistics as graph
fig_server = plt.figure(2)
i = 1
for y_arr_server, label_arr_server in zip(y_server, label_server):
ax = fig_server.add_subplot(len(label_server)*100 + 10 + i)
ax.plot(x, y_arr_server, label=label_arr_server)
ax.set_ylim(bottom=0)
i = i + 1
fig_server.suptitle("stat server side")
ax.legend()
plt.show()