-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimulator.py
More file actions
executable file
·78 lines (48 loc) · 1.28 KB
/
Copy pathSimulator.py
File metadata and controls
executable file
·78 lines (48 loc) · 1.28 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
#! /usr/bin/env python
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import dumpNodeConnections
from mininet.log import info, setLogLevel
from mininet.cli import CLI
from time import time, sleep
from select import poll, POLLIN
from subprocess import Popen, PIPE
class SingleSwitchTopo(Topo):
def build(self, n=2):
switch = self.addSwitch('s1')
for h in range(n):
host = self.addHost('h%s' % (h+1))
self.addLink(host, switch)
def simpleTest():
topo = SingleSwitchTopo(n=2)
net = Mininet(topo)
net.start()
h1, h2 = net.get('h1', 'h2')
print h1.IP
print h2.IP
print 'starting test'
#h1.cmd('while true; do date; sleep 1; done > date.out &')
net.pingAll()
h1.cmd('sudo ./HTTPServer.py 10.0.0.1 80 10 10 TCP IPv4 &' )
h2.cmd('sudo ./HTTPClient.py 10.0.0.2 8000 10 10 TCP IPv4 &' )
sleep(100)
print 'stopping test'
print "Reading output"
f = open('rcvr.out')
writef = open('boys.txt', "w")
lineno = 1
for line in f.readlines():
print "%d: %s" % (lineno, line.strip())
writef.write("%d: %s\n" % (lineno, line.strip()))
lineno+=1
f.close()
writef.close()
net.stop()
def deployTest():
topo = SingleSwitchTopo(n=4)
net = Mininet(topo)
net.start()
CLI(net)
if __name__ == '__main__':
deployTest()
# simpleTest();