-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweb_mirror_replay_quic.py
104 lines (90 loc) · 3.86 KB
/
web_mirror_replay_quic.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
#!/usr/bin/python
from mininet.cli import CLI
from mininet.log import lg
from mininet.node import Node
from mininet.topolib import TreeNet
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.node import Host
from mininet.link import Link
import os
import sys
import shutil
if (len(sys.argv) == 0):
ifile = 'serverips.txt'
else:
folder = str(sys.argv[1])
ifile = folder + '/' + folder + 'serverips.txt'
ip_addr=[]
for f in open(ifile):
ip_addr.append(f.strip())
current_working_dir=sys.argv[2]
site_to_fetch=sys.argv[3]
phantomjs_root=sys.argv[4]
#################################
class ProtoTester(Topo):
def __init__(self):
# Initialise topology
Topo.__init__(self)
# Create switch
s1 = self.addSwitch('s1')
# IP for client
client = self.addHost('client', ip='10.0.1.1', mac='00:00:00:00:00:01')
self.addLink(client, s1)
# IPs for sharded servers
server_list = []
for i in range(0,len(ip_addr)):
if i < 8:
server_list.append(self.addHost('server'+str(i), ip=ip_addr[i], mac='00:00:00:00:00:0'+str(i+2)))
if i > 7:
server_list.append(self.addHost('server'+str(i), ip=ip_addr[i], mac='00:00:00:00:00:'+str(i+2)))
# Add links
self.addLink(s1, server_list[i])
if __name__ == '__main__':
lg.setLogLevel( 'info')
# Configure and start NATted connectivity
os.system( "killall -q controller" )
os.system( "killall -q phantomjs" )
os.system( "/etc/init.d/apache2 stop" )
os.system( "killall -s9 apache2" )
os.system( "killall -s9 quic_server" )
os.system("rm -rf /tmp/myprofdir/")
os.system("mkdir /tmp/myprofdir")
topo = ProtoTester()
net = Mininet(topo=topo, host=Host, link=Link)
net.start()
# Set /32 netmask and route for client
client = net.getNodeByName('client')
client.sendCmd('ifconfig client-eth0 10.0.1.1 netmask 0.0.0.0')
client.waitOutput()
client.sendCmd('route add default dev client-eth0')
client.waitOutput()
# Set /32 netmask and route for all servers
#make folder for quic server to use (localhost:80)
if os.path.exists('/home/skype-alpha/July3rdGoogleMeeting/src/out/Release/localhost'):
shutil.rmtree('/home/skype-alpha/July3rdGoogleMeeting/src/out/Release/localhost')
os.makedirs('/home/skype-alpha/July3rdGoogleMeeting/src/out/Release/localhost')
os.system( 'cp -R /home/skype-alpha/July3rdGoogleMeeting/src/out/Release/' + folder + ' /home/skype-alpha/July3rdGoogleMeeting/src/out/Release/localhost/' +folder)
server_names = ['']*len(ip_addr)
for i in range(0,len(ip_addr)):
server_names[i] = net.getNodeByName('server'+str(i))
server_names[i].sendCmd('ifconfig server'+str(i)+'-eth0 '+ip_addr[i]+' netmask 0.0.0.0');
server_names[i].waitOutput()
server_names[i].sendCmd('route add default dev server'+str(i)+'-eth0')
server_names[i].waitOutput()
server_names[i].cmdPrint('nohup ' + '/home/skype-alpha/July3rdGoogleMeeting/src/out/Release/quic_server --quic_in_memory_cache_dir=/home/skype-alpha/July3rdGoogleMeeting/src/out/Release/localhost:93 --port=93' + ' --ip='+ip_addr[i]+' &')
server_names[i].waitOutput()
print "*** Hosts are running and can talk to each other"
print "*** Type 'exit' or control-D to shut down network"
#client.cmdPrint(phantomjs_root+'/bin/phantomjs '+phantomjs_root+'/examples/loadspeed.js '+site_to_fetch);
#client.waitOutput()
#client.sendCmd('su skype-alpha')
#client.waitOutput()
#client.cmdPrint('su skype-alpha')
#client.waitOutput()
#client.cmdPrint('python /home/skype-alpha/browser_automation/load_google.py')
#client.waitOutput()
CLI( net )
os.system( "cp /etc/hosts_original /etc/hosts" )
for u in range(0, len(ip_addr)):
os.system( "rm /etc/apache2/apache2" + str(u) + ".conf")