-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyNetwork2.py
70 lines (52 loc) · 1.96 KB
/
MyNetwork2.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
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host
from mininet.node import OVSKernelSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
def MyNetwork2():
net= Mininet(topo=None, build=False , ipBase='10.0.0.0/8' , link=TCLink)
info("****Adding Controller")
poxController = net.addController(name='poxController' ,
controller=RemoteController ,
ip='127.0.0.1',
port=6636)
info('****Now Adding Four Switches')
switch1=net.addSwitch('switch1')
switch2=net.addSwitch('switch2')
switch3=net.addSwitch('switch3')
switch4=net.addSwitch('switch4')
info('****Now Adding Eight Hosts')
host1=net.addHost('h1', ip='10.0.0.1/8')
host2=net.addHost('h2', ip='10.0.0.2/8')
host3=net.addHost('h3', ip='10.0.0.3/8')
host4=net.addHost('h4', ip='10.0.0.4/8')
host5=net.addHost('h5', ip='10.0.0.5/8')
host6=net.addHost('h6', ip='10.0.0.6/8')
host7=net.addHost('h7', ip='10.0.0.7/8')
host8=net.addHost('h8', ip='10.0.0.8/8')
net.addLink(switch1,switch2)
net.addLink(switch2,switch3)
net.addLink(switch3,switch4)
net.addLink(host1,switch1)
net.addLink(host2,switch1)
net.addLink(host3,switch2)
net.addLink(host4,switch2)
net.addLink(host5,switch3)
net.addLink(host6,switch3)
net.addLink(host7,switch4)
net.addLink(host8,switch4)
net.build()
for controller in net.controllers:
controller.start()
net.get('switch1').start([poxController])
net.get('switch2').start([poxController])
net.get('switch3').start([poxController])
net.get('switch4').start([poxController])
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel('info')
MyNetwork2()