-
Notifications
You must be signed in to change notification settings - Fork 1
/
mininet_env.py
44 lines (35 loc) · 1.12 KB
/
mininet_env.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
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import RemoteController
from mininet.term import makeTerm
if '__main__' == __name__:
net=Mininet(controller=RemoteController)
c0 = net.addController('c0',ip='10.0.2.15',port=6633)
s1 = net.addSwitch('s1', protocols="OpenFlow13")
s2 = net.addSwitch('s2', protocols="OpenFlow13")
s3 = net.addSwitch('s3', protocols="OpenFlow13")
s4 = net.addSwitch('s4', protocols="OpenFlow13")
h1 = net.addHost('h1',mac='00:00:00:00:00:01')
h2 = net.addHost('h2',mac='00:00:00:00:00:02')
h3 = net.addHost('h3',mac='00:00:00:00:00:03')
h4 = net.addHost('h4',mac='00:00:00:00:00:04')
h5 = net.addHost('h5',mac='00:00:00:00:00:05')
net.addLink(s1, h1)
net.addLink(s2, h2)
net.addLink(s3, h3)
net.addLink(s3, h4)
net.addLink(s1, s2,port1=30,port2=30)
net.addLink(s1, s3,port1=40,port2=30)
net.addLink(s2, s3,port1=40,port2=40)
net.addLink(s4, h5)
net.addLink(s1, s4,port1=50,port2=30)
net.build()
c0.start()
s1.start([c0])
s2.start([c0])
s3.start([c0])
s4.start([c0])
net.terms.append(makeTerm(s1))
net.terms.append(makeTerm(s2))
CLI(net)
net.stop()