-
Notifications
You must be signed in to change notification settings - Fork 51
/
live_plot_tcp_pcc.py
155 lines (139 loc) · 4.81 KB
/
live_plot_tcp_pcc.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
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import time
import os
f, axarr = plt.subplots(2, 1, sharey=True, sharex=False)
def animate_tcp(i):
os.system("scp [email protected]:/local/rate /home/mo/pcc/rate")
pullData = open("rate", "r")
for k in range(6):
pullData.readline()
dataArray = pullData.read().split("\n")
pullData.close()
xar = []
yar = []
for eachLine in dataArray:
if eachLine != "":
tmp = eachLine.split(" ")
y = tmp[len(tmp)-2]
yar.append(float(y))
for k in range(len(dataArray)-1):
xar.append(k*0.5)
ax1.clear()
ax1.plot(xar, yar)
def animate2(i):
os.system("scp [email protected]:/local/utility /home/mo/pcc/utility")
pullData = open("utility", "r")
dataArray = pullData.read().split("\n")
pullData.close()
xar = []
yar1 = []
yar2 = []
seq = 1
for eachLine in dataArray:
if eachLine != "":
y1 = eachLine.split('\t')[0]
y2 = eachLine.split('\t')[1]
xar.append(seq)
seq = seq + 1
yar1.append(float(y1))
yar2.append(float(y2))
ax1.clear()
ax1.plot(xar, yar1, xar, yar2)
def animate(i):
os.system("scp [email protected]:/local/rate /home/mo/pcc/rate")
pullData = open("rate", "r")
dataArray = pullData.read().split("\n")
pullData.close()
xar = []
yar = []
for eachLine in dataArray:
if eachLine != "":
x, y = eachLine.split(' ')
xar.append(float(x))
yar.append(float(y))
ax1.clear()
ax1.plot(xar, yar)
counter = 0
def animate_together(i):
global counter
#os.system("python ftpc.py sender1.demopair1.uiucscheduling.emulab.net 5050")
#os.system("python ftpc.py sender1.demopair2.uiucscheduling.emulab.net 5050")
counter = counter+1
if counter == 1:
print "clearing"
axarr[1].clear()
axarr[0].clear()
axarr[1].set_xlabel("Time (s)")
axarr[1].set_ylabel("Throughput (Mbit/s)")
axarr[1].set_title("TCP's performance")
axarr[0].set_xlabel("Time (s)")
axarr[0].set_ylabel("Throughput (Mbit/s)")
axarr[0].set_title("PCC's performance")
counter = 0
os.system("scp [email protected]:/local/rate_pcc /home/mo/pcc/")
os.system("scp [email protected]:/local/rate_tcp /home/mo/pcc/")
#os.system("scp [email protected]:/local/rate_pcc /home/mo/pcc/")
#os.system("scp [email protected]:/local/rate_tcp /home/mo/pcc/")
pullData_tcp = open("rate_tcp", "r")
for k in range(6):
pullData_tcp.readline()
dataArray_tcp = pullData_tcp.read().split("\n")
pullData_tcp.close()
xar = []
yar = []
for eachLine in dataArray_tcp:
if eachLine != "":
tmp = eachLine.split(" ")
y = tmp[len(tmp)-2]
yar.append(float(y))
for k in range(len(dataArray_tcp)-1):
xar.append(k)
tcp = axarr[1].plot(xar, yar)
plt.setp(tcp, color='b')
avg_tcp = 1.0
avg_pcc = 1.0
if len(yar)>5:
avg_tcp = sum(yar[-5:-1])/4
pullData = open("rate_pcc", "r")
dataArray = pullData.read().split("\n")
pullData.close()
xar = []
yar = []
#xar = [0, 0.5, 1, 1.5, 2.0, 2.5]
#yar = [0, 37.3, 39.3, 37.2, 40.3, 42.9]
count = 0
for eachLine in dataArray:
count = count+1
if count > -1:
if eachLine != "":
x, y = eachLine.split(' ')
xar.append(float(x))
yar.append(float(y))
if len(yar)>5:
avg_pcc = sum(yar[-5:-1])/4
if avg_tcp == 0:
avg_tcp = 0.00001
axarr[0].text(0.9, 1.1, 'improved by {:.2f}X'.format(avg_pcc/avg_tcp),
verticalalignment='center', horizontalalignment='center',
transform=axarr[0].transAxes,
color='red', fontsize=15)
axarr[0].text(0.8, 0.9, 'Tpt. {:.2f}Mps'.format(avg_pcc),
verticalalignment='center', horizontalalignment='center',
transform=axarr[0].transAxes,
color='blue', fontsize=15)
axarr[1].text(0.8, -0.3, 'Tpt. {:.2f}Mbps'.format(avg_tcp),
verticalalignment='center', horizontalalignment='center',
transform=axarr[0].transAxes,
color='blue', fontsize=15)
pcc = axarr[0].plot(xar, yar)
plt.setp(pcc, color='b')
axarr[1].clear()
axarr[1].set_xlabel("Time (s)")
axarr[1].set_ylabel("Throughput (Mbit/s)")
axarr[1].set_title("TCP's performance")
axarr[0].set_xlabel("Time (s)")
axarr[0].set_ylabel("Throughput (Mbit/s)")
axarr[0].set_title("PCC's performance")
ani = animation.FuncAnimation(f, animate_together, interval=2000)
plt.show()