Commit c1cd8c92 authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

initial commit

parents
This diff is collapsed.
#!/usr/bin/env python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
from subprocess import call
def myNetwork():
net = Mininet( topo=None,
build=False,
ipBase='172.16.0.0/16')
info( '*** Adding controller\n' )
c1=net.addController(name='c1',
controller=Controller,
protocol='tcp',
port=6634)
c2=net.addController(name='c2',
controller=Controller,
protocol='tcp',
port=6635)
c0=net.addController(name='c0',
controller=RemoteController,
ip='127.0.0.1',
protocol='tcp',
port=6633)
info( '*** Add switches\n')
s10 = net.addSwitch('s10', cls=OVSKernelSwitch, failMode='standalone')
s9 = net.addSwitch('s9', cls=OVSKernelSwitch, failMode='standalone')
s11 = net.addSwitch('s11', cls=OVSKernelSwitch, failMode='standalone')
s4 = net.addSwitch('s4', cls=OVSKernelSwitch, dpid='4')
s3 = net.addSwitch('s3', cls=OVSKernelSwitch, dpid='3')
s7 = net.addSwitch('s7', cls=OVSKernelSwitch, dpid='7')
s8 = net.addSwitch('s8', cls=OVSKernelSwitch, dpid='8')
s1 = net.addSwitch('s1', cls=OVSKernelSwitch, dpid='1')
s2 = net.addSwitch('s2', cls=OVSKernelSwitch, dpid='2')
s5 = net.addSwitch('s5', cls=OVSKernelSwitch, dpid='5')
info( '*** Add hosts\n')
h10 = net.addHost('h10', cls=Host, ip='172.16.0.10', defaultRoute='via 172.16.0.249')
h6 = net.addHost('h6', cls=Host, ip='172.16.0.6', defaultRoute='via 172.16.0.251')
h12 = net.addHost('h12', cls=Host, ip='172.16.0.12', defaultRoute='via 172.16.0.248')
h1 = net.addHost('h1', cls=Host, ip='172.16.0.1', defaultRoute='via 172.16.0.254')
h11 = net.addHost('h11', cls=Host, ip='172.16.0.11', defaultRoute='via 172.16.0.248')
h13 = net.addHost('h13', cls=Host, ip='172.16.0.13', defaultRoute='via 172.16.0.248')
a1 = net.addHost('a1', cls=Host, ip='172.16.0.5', defaultRoute='via 172.16.0.252')
h7 = net.addHost('h7', cls=Host, ip='172.16.0.7', defaultRoute='via 172.16.0.250')
h2 = net.addHost('h2', cls=Host, ip='172.16.0.2', defaultRoute='via 172.16.0.253')
h8 = net.addHost('h8', cls=Host, ip='172.16.0.8', defaultRoute='via 172.16.0.250')
h3 = net.addHost('h3', cls=Host, ip='172.16.0.3', defaultRoute='via 172.16.0.252')
h4 = net.addHost('h4', cls=Host, ip='172.16.0.4', defaultRoute='via 172.16.0.252')
a2 = net.addHost('a2', cls=Host, ip='172.16.0.9', defaultRoute='via 172.16.0.250')
info( '*** Add links\n')
net.addLink(h2, s4)
net.addLink(s4, s1)
net.addLink(s1, h1)
net.addLink(s1, s5)
net.addLink(s5, h3)
net.addLink(s5, s9)
net.addLink(s9, h4)
net.addLink(s9, a1)
net.addLink(h6, s2)
net.addLink(s2, s7)
net.addLink(s10, s7)
net.addLink(s7, h7)
net.addLink(s10, a2)
net.addLink(s10, h8)
net.addLink(h10, s3)
net.addLink(s3, s8)
net.addLink(s8, h11)
net.addLink(s8, s11)
net.addLink(s11, h12)
net.addLink(s11, h13)
net.addLink(s3, s2)
net.addLink(s2, s1)
info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
for controller in net.controllers:
controller.start()
info( '*** Starting switches\n')
net.get('s10').start([])
net.get('s9').start([])
net.get('s11').start([])
net.get('s4').start([c1])
net.get('s3').start([c2])
net.get('s7').start([c0])
net.get('s8').start([c2])
net.get('s1').start([c1])
net.get('s2').start([c0])
net.get('s5').start([c1])
info( '*** Post configure switches and hosts\n')
s4.cmd('ifconfig s4 172.16.0.253')
s3.cmd('ifconfig s3 172.16.0.249')
s7.cmd('ifconfig s7 172.16.0.250')
s8.cmd('ifconfig s8 172.16.0.248')
s1.cmd('ifconfig s1 172.16.0.254')
s2.cmd('ifconfig s2 172.16.0.251')
s5.cmd('ifconfig s5 172.16.0.252')
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()
This diff is collapsed.
#!/usr/bin/env python
from mininet.net import Mininet
from mininet.node import Controller, RemoteController, OVSController
from mininet.node import CPULimitedHost, Host, Node
from mininet.node import OVSKernelSwitch, UserSwitch
from mininet.node import IVSSwitch
from mininet.cli import CLI
from mininet.log import setLogLevel, info
from mininet.link import TCLink, Intf
from subprocess import call
def myNetwork():
net = Mininet( topo=None,
build=False,
ipBase='172.16.0.0/16')
info( '*** Adding controller\n' )
c0=net.addController(name='c0',
controller=RemoteController,
ip='127.0.0.1',
protocol='tcp',
port=6633)
info( '*** Add switches\n')
s8 = net.addSwitch('s8', cls=OVSKernelSwitch, dpid='8')
s11 = net.addSwitch('s11', cls=OVSKernelSwitch, failMode='standalone')
s1 = net.addSwitch('s1', cls=OVSKernelSwitch, dpid='1')
s2 = net.addSwitch('s2', cls=OVSKernelSwitch, dpid='2')
s10 = net.addSwitch('s10', cls=OVSKernelSwitch, failMode='standalone')
s9 = net.addSwitch('s9', cls=OVSKernelSwitch, failMode='standalone')
s5 = net.addSwitch('s5', cls=OVSKernelSwitch, dpid='5')
s3 = net.addSwitch('s3', cls=OVSKernelSwitch, dpid='3')
s4 = net.addSwitch('s4', cls=OVSKernelSwitch, dpid='4')
s7 = net.addSwitch('s7', cls=OVSKernelSwitch, dpid='7')
info( '*** Add hosts\n')
h7 = net.addHost('h7', cls=Host, ip='172.16.0.7', defaultRoute='via 172.16.0.250')
h2 = net.addHost('h2', cls=Host, ip='172.16.0.2', defaultRoute='via 172.16.0.253')
h8 = net.addHost('h8', cls=Host, ip='172.16.0.8', defaultRoute='via 172.16.0.250')
h3 = net.addHost('h3', cls=Host, ip='172.16.0.3', defaultRoute='via 172.16.0.252')
a2 = net.addHost('a2', cls=Host, ip='172.16.0.9', defaultRoute='via 172.16.0.250')
h10 = net.addHost('h10', cls=Host, ip='172.16.0.10', defaultRoute='via 172.16.0.249')
h6 = net.addHost('h6', cls=Host, ip='172.16.0.6', defaultRoute='via 172.16.0.251')
h12 = net.addHost('h12', cls=Host, ip='172.16.0.12', defaultRoute='via 172.16.0.248')
h1 = net.addHost('h1', cls=Host, ip='172.16.0.1', defaultRoute='via 172.16.0.254')
h4 = net.addHost('h4', cls=Host, ip='172.16.0.4', defaultRoute='via 172.16.0.252')
h11 = net.addHost('h11', cls=Host, ip='172.16.0.11', defaultRoute='via 172.16.0.248')
h13 = net.addHost('h13', cls=Host, ip='172.16.0.13', defaultRoute='via 172.16.0.248')
a1 = net.addHost('a1', cls=Host, ip='172.16.0.5', defaultRoute='via 172.16.0.252')
info( '*** Add links\n')
net.addLink(h2, s4)
net.addLink(s4, s1)
net.addLink(s1, h1)
net.addLink(s1, s5)
net.addLink(s5, h3)
net.addLink(s5, s9)
net.addLink(s9, h4)
net.addLink(s9, a1)
net.addLink(h6, s2)
net.addLink(s2, s7)
net.addLink(s10, s7)
net.addLink(s7, h7)
net.addLink(s10, a2)
net.addLink(s10, h8)
net.addLink(h10, s3)
net.addLink(s3, s8)
net.addLink(s8, h11)
net.addLink(s8, s11)
net.addLink(s11, h12)
net.addLink(s11, h13)
net.addLink(s3, s2)
net.addLink(s2, s1)
info( '*** Starting network\n')
net.build()
info( '*** Starting controllers\n')
for controller in net.controllers:
controller.start()
info( '*** Starting switches\n')
net.get('s8').start([c0])
net.get('s11').start([])
net.get('s1').start([c0])
net.get('s2').start([c0])
net.get('s10').start([])
net.get('s9').start([])
net.get('s5').start([c0])
net.get('s3').start([c0])
net.get('s4').start([c0])
net.get('s7').start([c0])
info( '*** Post configure switches and hosts\n')
s8.cmd('ifconfig s8 172.16.0.248')
s1.cmd('ifconfig s1 172.16.0.254')
s2.cmd('ifconfig s2 172.16.0.251')
s5.cmd('ifconfig s5 172.16.0.252')
s3.cmd('ifconfig s3 172.16.0.249')
s4.cmd('ifconfig s4 172.16.0.253')
s7.cmd('ifconfig s7 172.16.0.250')
CLI(net)
net.stop()
if __name__ == '__main__':
setLogLevel( 'info' )
myNetwork()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment