/
chromiumQuicTests.py
executable file
·97 lines (73 loc) · 2.61 KB
/
chromiumQuicTests.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
#!/usr/bin/python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Host
from mininet.link import Link
from mininet.cli import CLI
from mininet.util import dumpNodeConnections
from mininet.util import ensureRoot
from subprocess import Popen, PIPE
from time import sleep, time
import sys
import os
import math
ensureRoot()
class QuicTester(Topo):
def __init__(self):
# Initialise topology
Topo.__init__(self)
# Add hosts and switches
client = self.addHost('client', ip='10.0.0.2', mac='00:00:00:00:00:02')
server = self.addHost('server', ip='10.0.0.1', mac='00:00:00:00:00:01')
# Add switch
s1 = self.addSwitch('s1')
# Add links
self.addLink(client, s1)
self.addLink(s1, server)
def set_all_IP(net, client, server):
client.sendCmd('ifconfig client-eth0 10.0.0.2 netmask 255.255.255.0')
client.waitOutput()
server.sendCmd('ifconfig server-eth0 10.0.0.1 netmask 255.255.255.0')
server.waitOutput()
def display_routes(net, client, server):
print 'client route...'
client.sendCmd('route -n')
print client.waitOutput()
print 'server route...'
server.sendCmd('route -n')
print server.waitOutput()
def run_quic(client, server):
print "Running quic client..."
client.sendCmd('cd /home/ubuntu/home/src_tarball/tarball/chromium/src/out/Debug && ./quic_client http://www.mit.edu/img/bckgrnd4.png >/tmp/client-stdout 2>/tmp/client-stderr &')
client.waitOutput()
print "Running quic server..."
server.sendCmd('cd /home/ubuntu/home/src_tarball/tarball/chromium/src/out/Debug && ./quic_server >/tmp/server-stdout 2>/tmp/server-stderr &')
server.waitOutput()
print "done."
def check_for_directory():
var = os.system("[ -d 'home/ubuntu/home/src_tarball/tarball/chromium/src/out/Debug/www.mit.edu/' ]&&echo True||echo False")
if var == False:
return False
return True
def run_quic_topology():
# remove old files
os.system( "rm /tmp/client-*")
os.system( "rm /tmp/server-*")
# kill old processes
os.system( "killall -q controller" )
os.system( "killall -q quic_client" )
os.system( "killall -q quic_server" )
topo = QuicTester()
net = Mininet(topo=topo, host=Host, link=Link)
net.start()
client = net.getNodeByName('client')
server = net.getNodeByName('server')
set_all_IP(net, client, server)
#Dump connections
dumpNodeConnections(net.hosts)
display_routes(net, client, server)
run_quic(client, server)
CLI(net)
net.stop()
#if check_for_directory():
run_quic_topology()