Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- """
- sudo mn -c
- chmod u+x topology.py
- sudo ./topology.py
- """
- from mininet.topo import Topo
- from mininet.cli import CLI
- from mininet.net import Mininet
- from mininet.util import dumpNodeConnections
- from mininet.log import setLogLevel
- from mininet.node import Ryu, RemoteController, OVSSwitch
- def test():
- topo = RingTopology()
- net = Mininet(topo=topo,
- controller=Ryu,
- autoStaticArp=True)
- net.start()
- print "Dumping host connections"
- dumpNodeConnections(net.hosts)
- # print "Testing network connectivity"
- # net.pingAll()
- net.stop()
- class RingTopology(Topo):
- def __init__(self):
- Topo.__init__(self)
- # Server
- server1 = self.addHost('server1', ip='10.0.0.1', vlan=2)
- server2 = self.addHost('server2', ip='10.0.0.2', vlan=2)
- server3 = self.addHost('server3', ip='10.0.0.3', vlan=2)
- # Client
- client1 = self.addHost('client1', ip='10.0.0.4', vlan=110)
- client2 = self.addHost('client2', ip='10.0.0.5', vlan=110)
- client3 = self.addHost('client3', ip='10.0.0.6', vlan=110)
- # Switch
- switch1 = self.addSwitch('switch1')
- switch2 = self.addSwitch('switch2')
- switch3 = self.addSwitch('switch3')
- self.addLink(switch1, server1)
- self.addLink(switch1, client1)
- self.addLink(switch2, server2)
- self.addLink(switch2, client2)
- self.addLink(switch3, server3)
- self.addLink(switch3, client3)
- self.addLink(switch1, switch2)
- self.addLink(switch2, switch3)
- self.addLink(switch3, switch1)
- if __name__ == '__main__':
- # Tell mininet to print useful information
- setLogLevel('info')
- test()
- topo = RingTopology()
- c0 = RemoteController('c0', ip='127.0.0.1', port=6633)
- net = Mininet(topo=topo,
- controller=c0,
- switch=OVSSwitch,
- autoStaticArp=True)
- net.start()
- CLI(net)
- net.stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement