forked from hundeboll/riddler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot.py
executable file
·199 lines (154 loc) · 6.96 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/bin/env python2
import argparse
import cPickle as pickle
import plot_data as data
import plot_graph as graph
parser = argparse.ArgumentParser(description="Riddler Plotting Tools")
parser.add_argument("--config", default="plot_defaults")
(args,dummy) = parser.parse_known_args()
try:
c = __import__(args.config)
defaults = dict((k, v) for k,v in c.__dict__.iteritems() if not k.startswith('__'))
except ImportError:
print("Unable to load config file: {0}".format(args.config))
sys.exit(1)
parser.add_argument("--data")
parser.add_argument("--out")
parser.add_argument("--hide", action='store_true')
parser.add_argument("--plots")
parser.set_defaults(**defaults)
args = parser.parse_args()
class plot:
def __init__(self, args):
self.args = args
self.aggregated_throughput = {}
self.data = data.data(args.data)
self.graph = graph.graph()
def plot(self):
if self.data.profile == 'udp_rates':
# For each source
for node in self.data.sources:
self.plot_udp_rate_source(node)
# For each relay
for node in self.data.relays:
self.plot_udp_rate_relay(node)
self.plot_udp_rate_system()
self.plot_udp_mac_capture()
elif self.data.profile == 'udp_ratios':
for node in self.data.sources:
self.plot_udp_ratio_source(node)
for node in self.data.relays:
self.plot_udp_ratio_relay(node)
elif self.data.profile == 'tcp_algos':
for node in self.data.sources:
self.plot_tcp_source(node)
for node in self.data.relays:
self.plot_tcp_relay(node)
elif self.data.profile == 'tcp_windows':
for node in self.data.sources:
self.plot_tcp_window_source(node)
for node in self.data.relays:
self.plot_tcp_window_relay(node)
elif self.data.profile == 'rlnc':
for node in self.data.sources:
self.plot_rlnc_throughput(node, "helper", "dest")
def show_plots(self):
if not self.args.hide:
self.graph.show(self.args.plots)
if self.args.out:
self.graph.save_figs(self.args.out)
def plot_udp_rate_source(self, node):
if self.args.plots not in ('all', 'system', node):
return
for coding in (False, True):
data = self.data.udp_source_data(node, coding)
if self.args.plots in ('all', node):
self.graph.plot_throughput(node, data, coding)
self.graph.plot_cpu(node, data, coding)
#self.graph.plot_power(node, data, coding)
self.graph.plot_delay(node, data, coding)
self.graph.plot_tx_retries(node, data, coding)
if coding:
self.graph.plot_tx_packets(data, node)
def plot_udp_rate_relay(self, node):
if self.args.plots not in ('all', 'system', node):
return
for coding in (False, True):
data = self.data.udp_relay_data(node, coding)
if coding:
self.graph.plot_tx_packets(data, node)
if self.args.plots in ('all', node) and coding:
self.graph.plot_coded(node, data)
self.graph.plot_udp_rx_coded_diff(node, data)
if self.args.plots in ('all', node):
#self.graph.plot_power(node, data, coding)
self.graph.plot_udp_mac_capture_rx(node, data, coding)
self.graph.plot_cpu(node, data, coding)
self.graph.plot_tx_retries(node, data, coding)
def plot_udp_rate_system(self):
if self.args.plots not in ('all', 'system'):
return
for coding in (False, True):
source_agg,source_avg = self.data.get_system_data('udp_sources', coding)
relay_agg,relay_avg = self.data.get_system_data('udp_relays', coding)
self.graph.plot_udp_system_throughput(source_agg, coding)
self.graph.plot_udp_system_delay(source_avg, coding)
self.graph.plot_system_cpu(source_avg, relay_avg, coding)
self.graph.plot_udp_system_retries(source_avg, relay_avg, coding)
self.graph.plot_system_tx(source_agg, relay_agg, coding, self.data.run_info)
if coding:
self.graph.plot_coded("system", relay_avg)
#self.graph.plot_udp_system_power(source_agg, relay_agg, coding)
#self.graph.plot_udp_system_power_per_bit(source_agg, relay_agg, coding)
def plot_udp_mac_capture(self):
if self.args.plots not in ('all', 'system'):
return
#for coding in (False, True):
# data = self.data.udp_mac_capture(coding)
# self.graph.plot_udp_mac_capture(data, coding)
def plot_udp_ratio_source(self, node):
if self.args.plots not in ('all', 'system', node):
return
for coding in (False, True):
data = self.data.udp_ratio_source_data(node, coding)
if self.args.plots in ('all', node):
self.graph.plot_udp_ratio_throughput(node, data, coding)
def plot_udp_ratio_relay(self, node):
if self.args.plots not in ('all', 'system', node):
return
for coding in (False, True):
data = self.data.udp_ratio_relay_data(node, coding)
self.graph.plot_udp_ratio_power(node, data, coding)
if self.args.plots in ('all', node) and coding:
self.graph.plot_udp_ratio_coded(node, data)
def plot_tcp_source(self, node):
if self.args.plots not in ('all', 'system', node):
return
for coding in (False, True):
data = self.data.tcp_source_data(node, coding)
self.graph.plot_tcp_throughput(node, data, coding)
def plot_tcp_relay(self, node):
pass
def plot_tcp_window_source(self, node):
if self.args.plots not in ('all', 'system', node):
return
for coding in (False, True):
data = self.data.tcp_window_source_data(node, coding)
self.graph.plot_tcp_window_throughput(node, data, coding)
def plot_tcp_window_relay(self, node):
pass
def plot_rlnc_throughput(self, source, helper, dest):
gs = self.data.arg("gen_size")
for coding in ('noloss', 'loss', 'helper', 'nohelper'):
s_data = self.data.rlnc_source_data(source, coding)
d_data = self.data.rlnc_dest_data(dest, coding)
h_data = self.data.rlnc_helper_data(helper, coding)
self.graph.plot_rlnc_throughput(s_data, d_data, coding, gs)
self.graph.plot_rlnc_transmissions(s_data, h_data, d_data, coding, gs)
if coding in ("helper", "nohelper"):
self.graph.plot_rlnc_requests(source, s_data, coding, gs)
self.graph.plot_rlnc_requests(dest, d_data, coding, gs)
if __name__ == "__main__":
p = plot(args)
p.plot()
p.show_plots()