-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathred_plot_results.py
More file actions
executable file
·190 lines (152 loc) · 4.84 KB
/
red_plot_results.py
File metadata and controls
executable file
·190 lines (152 loc) · 4.84 KB
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
#!/usr/bin/env python
from util.helper import *
import glob
import sys
from collections import defaultdict
nruns = 10 # Number of runs for your experiment
nfiles = 0
font = {'size' : 20}
def first(lst):
return map(lambda e: e[0], lst)
def second(lst):
return map(lambda e: e[1], lst)
def avg(lst):
return sum(lst)/len(lst)
def median(lst):
l = len(lst)
lst.sort()
return lst[l/2]
def parse_one_column_data(filename):
l1 = []
lines = open(filename).read().split('\n')
for l in lines:
k = l[0:3]
if l.strip() == "" or k.isalpha():
continue
l1.append(float(l.split(',')[0]))
return l1
def parse_two_column_data(filename):
l1 = []
l2 = []
lines = open(filename).read().split("\n")
for l in lines:
k = l[0:3]
if l.strip() == "" or k.isalpha():
continue
l1.append(float(l.split(',')[0]))
l2 .append(float(l.split(',')[1]))
return l1, l2
def parse_four_column_data(filename):
l1 = []
l2 = []
l3 = []
l4 = []
lines = open(filename).read().split("\n")
for l in lines:
k = l[0:3]
if l.strip() == "" or k.isalpha():
continue
l1.append(float(l.split(',')[0]))
l2.append(float(l.split(',')[1]))
l3.append(float(l.split(',')[2]))
l4.append(float(l.split(',')[3]))
return l1, l2, l3, l4
def plot_debug():
testlog = 'test/tp_log'
tp = parse_one_column_data(testlog)
plt.figure(num=None, figsize=(12,4))
plt.plot(range(0,len(tp)), tp, lw=1, c='black')
plt.xlabel('Interval (10ms)')
plt.ylabel('Throughput (bytes)')
plt.title('Bursty traffic generation')
print 'Saving to test/bursty_plot'
plt.savefig('test/bursty_plot', dpi=300)
plt.close()
def plot_sim1():
redlog = 'sim1/redlog'
dtlog = 'sim1/dtlog'
red_throughput, red_qlen = parse_two_column_data(redlog)
dt_throughput, dt_qlen = parse_two_column_data(dtlog)
plt.figure(num=None, figsize=(8,4))
plt.scatter(red_throughput, red_qlen, s=60, c='r', marker='^', label='RED')
plt.scatter(dt_throughput, dt_qlen, s=60, c='b', marker='s', label='DropTail')
#first(plot_quido), second(plot_quido), lw=2, label="RTT*C/$\sqrt{n}$")
plt.xlim((0, 1))
plt.legend(loc=2)
plt.xlabel("Throughput")
plt.ylabel("Average queue length (pkts)")
print "Saving to sim1/sim1plot"
plt.savefig('sim1/sim1plot')
plt.close()
def plot_sim2():
redlog = 'sim2/redlog'
dtlog = 'sim2/dtlog'
m.rc('font', **font) # set font size for all plots
""" Plot RED data """
red_bufsize, red_tp, red_n5_tp, red_qlen = parse_four_column_data(redlog)
red_n5_tp = [z*100 for z in red_n5_tp]
plt.figure(1, figsize=(12, 24))
plt.subplot2grid((4,1), (0,0), rowspan=2)
plt.plot(red_bufsize, red_n5_tp, lw=6, c='black')
f = open(redlog + 'tp', 'r')
lines = f.readlines()
f.close()
i = 0
for line in lines:
plt.scatter([red_bufsize[i]]*10,
[100*float(line.split(',')[z]) for z in range(0,10)],
c='black')
i += 1
plt.ylim(0, 4)
plt.xlim(2, 15)
plt.xlabel('Minimum Threshold')
plt.ylabel('Node 5 Throughput (%)')
plt.subplot2grid((4,1), (2,0))
plt.plot(red_bufsize, red_qlen, lw=6, c='black')
plt.ylim(0, 15)
plt.xlim(2, 15)
plt.xlabel('Minimum Threshold')
plt.ylabel('Average Queue (in packets)')
plt.subplot2grid((4,1), (3,0))
plt.plot(red_bufsize, red_tp, lw=6, c='black')
plt.ylim(0, 1)
plt.xlim(2, 15)
plt.xlabel('Minimum Threshold')
plt.ylabel('Average Link Utilization')
print 'Saving to sim2/redplot'
plt.savefig('sim2/redplot')
plt.close()
""" Plot DropTail data """
dt_bufsize, dt_tp, dt_n5_tp, dt_qlen = parse_four_column_data(dtlog)
dt_n5_tp = [z*100 for z in dt_n5_tp]
plt.figure(1, figsize=(12, 24))
plt.subplot2grid((4,1), (0,0), rowspan=2)
plt.plot(dt_bufsize, dt_n5_tp, lw=6, c='black')
f = open(dtlog + 'tp', 'r')
lines = f.readlines()
f.close()
i = 0
for line in lines:
plt.scatter([dt_bufsize[i]]*10,
[100*float(line.split(',')[z]) for z in range(0,10)],
c='black')
i += 1
plt.ylim(0, 4)
plt.xlim(7, 23)
plt.xlabel('Buffer Size')
plt.ylabel('Node 5 Throughput (%)')
plt.subplot2grid((4,1), (2,0))
plt.plot(dt_bufsize, dt_qlen, lw=6, c='black')
plt.ylim(0, 15)
plt.xlim(7, 23)
plt.xlabel('Buffer Size')
plt.ylabel('Average Queue (in packets)')
plt.subplot2grid((4,1), (3,0))
plt.plot(dt_bufsize, dt_tp, lw=6, c='black')
plt.ylim(0, 1)
plt.xlim(7, 23)
plt.xlabel('Buffer Size')
plt.ylabel('Average Link Utilization')
print 'Saving to sim2/sim2plot'
plt.savefig('sim2/dtplot')
plt.close()