-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
executable file
·41 lines (31 loc) · 1.05 KB
/
test.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
#!/usr/bin/python
import time
from mininet.net import init, Mininet
from mininet.topo import Topo, Node
from mininet.node import RemoteController
from mininet.log import lg, info, error, debug, output
from mininet.cli import CLI
from click import ClickKernelSwitch
def test_wget(ip="127.0.0.1",port="6633"):
net = Mininet(switch=ClickKernelSwitch,
controller=lambda n: RemoteController(n,
defaultIP=ip, port=int(port)))
net.addController('c0')
h1 = net.addHost('h1', ip='144.0.3.0')
h2 = net.addHost('h2', ip='132.0.2.0')
sw = net.addSwitch("click")
sw.linkAs(h1, "h1")
sw.linkAs(h2, "h2")
net.start()
net.staticArp()
output("Network ready\n")
time.sleep(3)
# Run a simple file transfer test
output(h1.cmd("./serve.sh"))
output(h2.cmd("wget 144.0.3.0"))
time.sleep(1)
net.stop()
if __name__ == "__main__":
print "Running wget test"
test_wget()
print "Wget test complete. Retrieved file should be in index.html"