Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- from functools import partial
- from mininet.node import RemoteController, Switch
- from mininet.cli import CLI
- from mininet.link import Intf
- from mininet.topo import Topo
- from mininet.net import Mininet
- from mininet.util import dumpNodeConnections
- from mininet.log import setLogLevel
- class LinearSwitch(Topo):
- "Single switch connected to n hosts."
- def build(self, n=3):
- for i in range(n):
- self.addSwitch('s%d' % (i + 1))
- for i in range(n - 1):
- self.addLink('s%d' % (i + 1), 's%d' % (i + 2))
- # Intf('eth2', node=Switch('s1'))
- # Intf('eth3', node=Switch('s%d' % n))
- def simpleTest():
- "Create and test a simple network"
- topo = LinearSwitch(n=3)
- net = Mininet(topo=topo, controller=partial(RemoteController, ip="172.18.0.3", port=6633))
- Intf('eth2', net.switches[0])
- Intf('eth3', net.switches[-1])
- net.start()
- print "Dumping host connections"
- dumpNodeConnections(net.hosts)
- # print "Testing network connectivity"
- # net.pingAll()
- CLI(net)
- net.stop()
- if __name__ == '__main__':
- # Tell mininet to print useful information
- setLogLevel('info')
- simpleTest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement