Advertisement
Guest User

Untitled

a guest
Aug 3rd, 2015
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. from mininet.net import Mininet
  4. from mininet.node import Controller, RemoteController, OVSController
  5. from mininet.node import CPULimitedHost, Host, Node
  6. from mininet.node import OVSKernelSwitch, UserSwitch
  7. from mininet.node import IVSSwitch
  8. from mininet.cli import CLI
  9. from mininet.log import setLogLevel, info
  10. from mininet.link import TCLink, Intf
  11. from subprocess import call
  12.  
  13. def myNetwork():
  14.  
  15. net = Mininet( topo=None,
  16. build=False,
  17. ipBase='10.0.0.0/8')
  18.  
  19. info( '*** Adding controller\n' )
  20. c0=net.addController(name='c0',
  21. controller=Controller,
  22. protocol='tcp',
  23. ip='10.10.10.10',
  24. port=6633)
  25.  
  26. info( '*** Add switches\n')
  27. s3 = net.addSwitch('s3', cls=OVSKernelSwitch)
  28. s2 = net.addSwitch('s2', cls=OVSKernelSwitch)
  29. s1 = net.addSwitch('s1', cls=OVSKernelSwitch, failMode='standalone')
  30.  
  31. info( '*** Add hosts\n')
  32. h1 = net.addHost('h1', cls=Host, ip='10.0.0.1', defaultRoute=None)
  33.  
  34. info( '*** Add links\n')
  35. net.addLink(s1, h1)
  36. net.addLink(s2, s1)
  37. net.addLink(s1, s3)
  38.  
  39. info( '*** Starting network\n')
  40. net.build()
  41. info( '*** Starting controllers\n')
  42. for controller in net.controllers:
  43. controller.start()
  44.  
  45. info( '*** Starting switches\n')
  46. net.get('s3').start([c0])
  47. net.get('s2').start([c0])
  48. net.get('s1').start([])
  49.  
  50. info( '*** Post configure switches and hosts\n')
  51.  
  52. CLI(net)
  53. net.stop()
  54.  
  55. if __name__ == '__main__':
  56. setLogLevel( 'info' )
  57. myNetwork()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement