-
Notifications
You must be signed in to change notification settings - Fork 7
/
topo_pox.py
executable file
·45 lines (38 loc) · 1.32 KB
/
topo_pox.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
#!/usr/bin/env python
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.link import TCLink
from mininet.cli import CLI
from mininet.util import quietRun
net = Mininet(link=TCLink);
# Add hosts and switches
h1 = net.addHost( 'h1', ip = '10.0.0.11', mac = '00:00:00:00:00:11' )
h2 = net.addHost( 'h2', ip = '10.0.0.22', mac = '00:00:00:00:00:22' )
h3 = net.addHost( 'h3', ip = '10.0.0.33', mac = '00:00:00:00:00:33')
h4 = net.addHost( 'h4', ip = '10.0.0.44', mac = '00:00:00:00:00:44')
s1 = net.addSwitch( 's1',ip = '10.0.0.1',mac = '00:00:00:00:00:01')
s2 = net.addSwitch( 's2',ip = '10.0.0.2', mac = '00:00:00:00:00:02' )
s3 = net.addSwitch( 's3',ip = '10.0.0.3', mac = '00:00:00:00:00:03' )
s4 = net.addSwitch( 's4',ip = '10.0.0.4', mac = '00:00:00:00:00:04' )
s5 = net.addSwitch( 's5',ip = '10.0.0.5', mac = '00:00:00:00:00:05')
# Add links
# set link speeds to 10Mbit/s
linkopts = dict(bw=10)
net.addLink( h1, s1)
net.addLink( h2, s2)
net.addLink( s1, s2)
net.addLink( s1, s3)
net.addLink( s1, s5)
net.addLink( s3, s4)
net.addLink( s4, s2)
net.addLink( s5, s2)
net.addLink( s4, h3)
net.addLink( s5, h4)
# Start
net.addController('c', controller=RemoteController,ip='127.0.0.1',port=6633)
net.build()
net.start()
# CLI
CLI( net )
# Clean up
net.stop()