Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
191 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import sys | ||
import time | ||
import logging | ||
from watchdog.observers import Observer | ||
from watchdog.events import FileSystemEventHandler | ||
import os | ||
class NewSnapshotEventHandler(FileSystemEventHandler): | ||
def __init__(self): | ||
self.flow1_start = False | ||
self.flow2_start = False | ||
|
||
def on_modified(self, event): | ||
if event.is_directory is True: | ||
return | ||
with open("./parameters_convergence.txt", "r") as f: | ||
param = f.read() | ||
lines = param.split("\n") | ||
for line in lines: | ||
# if line == "reset": | ||
# os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair3.UIUCScheduling.emulab.net \"killall appclient && echo "">/local/rate_pcc\"") | ||
# os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair3.UIUCScheduling.emulab.net \"killall appclient && echo "">/local/rate_pcc\"") | ||
# os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair4.UIUCScheduling.emulab.net \"killall iperf && echo ""> /local/rate_tcp\"") | ||
# os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair4.UIUCScheduling.emulab.net \"killall iperf && echo ""> /local/rate_tcp\"") | ||
# return | ||
if line != "": | ||
flow_name = line.split(" ")[0] | ||
action = line.split(" ")[1] | ||
if flow_name == "flow1": | ||
if self.flow1_start and action == "stop": | ||
os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair3.UIUCScheduling.emulab.net \"killall appclient\"") | ||
os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair4.UIUCScheduling.emulab.net \"killall iperf\"") | ||
self.flow1_start = False | ||
if not self.flow1_start and action == "start": | ||
os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair3.UIUCScheduling.emulab.net \"~/demo_run_pcc_convergence.sh 3 &\"") | ||
os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair4.UIUCScheduling.emulab.net \"~/demo_run_tcp_convergence.sh 3 &\"") | ||
self.flow1_start = True | ||
if flow_name == "flow2": | ||
if self.flow2_start and action == "stop": | ||
os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair3.UIUCScheduling.emulab.net \"killall appclient\"") | ||
os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair4.UIUCScheduling.emulab.net \"killall iperf\"") | ||
self.flow2_start = False | ||
if not self.flow2_start and action == "start": | ||
os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair3.UIUCScheduling.emulab.net \"~/demo_run_pcc_convergence.sh 4 &\"") | ||
os.system("ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair4.UIUCScheduling.emulab.net \"~/demo_run_tcp_convergence.sh 4 &\"") | ||
self.flow2_start = True | ||
|
||
|
||
if __name__ == "__main__": | ||
path = '.' | ||
event_handler = NewSnapshotEventHandler() | ||
observer = Observer() | ||
observer.daemon = True | ||
observer.schedule(event_handler, path, recursive=False) | ||
observer.start() | ||
try: | ||
while True: | ||
time.sleep(1) | ||
except KeyboardInterrupt: | ||
observer.stop() | ||
observer.join() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import matplotlib.pyplot as plt | ||
import copy | ||
import matplotlib.animation as animation | ||
import time | ||
import os | ||
|
||
f, axarr = plt.subplots(2, 1, sharey=True, sharex=True) | ||
|
||
base_time_line = -1 | ||
which_flow = 0 | ||
|
||
time_offset = {} | ||
base_line = {} | ||
base_line["rate_tcp1"] = -1 | ||
base_line["rate_tcp2"] = -1 | ||
base_line["rate_pcc1"] = -1 | ||
base_line["rate_pcc1"] = -1 | ||
dataArray = {} | ||
|
||
def greater(a,b): | ||
if a == -1: | ||
return True | ||
if b == -1: | ||
return False | ||
return a>b | ||
|
||
def animate_together(i): | ||
os.system("scp modong2@sender1.demopair3.uiucscheduling.emulab.net:/local/rate_pcc /home/mo/pcc/convergence/rate_pcc1") | ||
os.system("scp modong2@sender2.demopair3.uiucscheduling.emulab.net:/local/rate_pcc /home/mo/pcc/convergence/rate_pcc2") | ||
os.system("scp modong2@sender1.demopair4.uiucscheduling.emulab.net:/local/rate_tcp /home/mo/pcc/convergence/rate_tcp1") | ||
os.system("scp modong2@sender2.demopair4.uiucscheduling.emulab.net:/local/rate_tcp /home/mo/pcc/convergence/rate_tcp2") | ||
|
||
pullData_tcp1 = open("rate_tcp1", "r") | ||
line = pullData_tcp1.readline() | ||
if line != "": | ||
base_line["tcp1"] = int(line) | ||
|
||
for k in range(6): | ||
pullData_tcp1.readline() | ||
dataArray["tcp1"] = pullData_tcp1.read().split("\n") | ||
pullData_tcp1.close() | ||
|
||
pullData_tcp2 = open("rate_tcp2", "r") | ||
line = pullData_tcp2.readline() | ||
if line != "": | ||
base_line["tcp2"] = int(line) | ||
|
||
for k in range(6): | ||
pullData_tcp2.readline() | ||
dataArray["tcp2"] = pullData_tcp2.read().split("\n") | ||
pullData_tcp2.close() | ||
|
||
pullData_pcc1 = open("rate_pcc1", "r") | ||
line = pullData_pcc1.readline() | ||
if line != "": | ||
base_line["pcc1"] = int(line) | ||
dataArray["pcc1"] = pullData_pcc1.read().split("\n") | ||
pullData_pcc1.close() | ||
|
||
|
||
pullData_pcc2 = open("rate_pcc2", "r") | ||
line = pullData_pcc2.readline() | ||
if line != "": | ||
base_line["pcc2"] = int(line) | ||
dataArray["pcc2"] = pullData_pcc2.read().split("\n") | ||
pullData_pcc2.close() | ||
base_point = -1 | ||
|
||
for flow in base_line: | ||
if greater(base_point, base_line[flow]): | ||
base_point = base_line[flow] | ||
|
||
time_offset= copy.deepcopy(base_line) | ||
for flow in time_offset: | ||
time_offset[flow] = time_offset[flow] - base_point | ||
|
||
axarr[1].clear() | ||
axarr[1].set_xlabel("Time (s)") | ||
axarr[1].set_ylabel("Throughput (Mbit/s)") | ||
axarr[0].set_title("TCP convergence demo") | ||
axarr[0].clear() | ||
axarr[0].set_xlabel("Time (s)") | ||
axarr[0].set_ylabel("Throughput (Mbit/s)") | ||
axarr[0].set_title("PCC convergence demo") | ||
|
||
for flow in dataArray: | ||
xar = [] | ||
yar = [] | ||
if flow == "tcp1" or flow == "tcp2": | ||
for eachLine in dataArray[flow]: | ||
if eachLine != "": | ||
tmp = eachLine.split(" ") | ||
y = tmp[len(tmp)-2] | ||
yar.append(float(y)) | ||
for k in range(len(dataArray[flow])-1): | ||
xar.append(k+time_offset[flow]) | ||
axarr[1].plot(xar, yar) | ||
else: | ||
for eachLine in dataArray[flow]: | ||
if eachLine != "": | ||
x, y = eachLine.split(' ') | ||
xar.append(float(x) + time_offset[flow]) | ||
yar.append(float(y)) | ||
axarr[0].plot(xar, yar) | ||
|
||
|
||
ani = animation.FuncAnimation(f, animate_together, interval=2000) | ||
f.set_size_inches(8,6) | ||
mng = plt.get_current_fig_manager() | ||
plt.show() | ||
mng.frame.Maximize(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
flow1 stop | ||
flow2 stop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair3.UIUCScheduling.emulab.net "killall appclient" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair3.UIUCScheduling.emulab.net "rm /local/rate_pcc && touch /local/rate_pcc" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair3.UIUCScheduling.emulab.net "killall appclient" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair3.UIUCScheduling.emulab.net "rm /local/rate_pcc && touch /local/rate_pcc" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair4.UIUCScheduling.emulab.net "killall iperf" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@sender1.demopair4.UIUCScheduling.emulab.net "rm /local/rate_tcp && touch /local/rate_tcp" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair4.UIUCScheduling.emulab.net "killall iperf" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@sender2.demopair4.UIUCScheduling.emulab.net "rm /local/rate_tcp && touch /local/rate_tcp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
for i in {1..4..1} | ||
do | ||
for j in {3..4..1} | ||
do | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@receiver$i.demopair$j.uiucscheduling.emulab.net "killall iperf" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@receiver$i.demopair$j.uiucscheduling.emulab.net "~/demo_receiver_run.sh &" | ||
ssh -t -t -o StrictHostKeyChecking=no modong2@receiver$i.demopair$j.uiucscheduling.emulab.net "nohup python ~/run_iperf.py &" | ||
done | ||
done |