Advertisement
Guest User

Untitled

a guest
May 27th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. """
  4. sudo mn -c
  5. chmod u+x topology.py
  6. sudo ./topology.py
  7. """
  8.  
  9. from mininet.topo import Topo
  10. from mininet.cli import CLI
  11. from mininet.net import Mininet
  12. from mininet.util import dumpNodeConnections
  13. from mininet.log import setLogLevel
  14. from mininet.node import Ryu, RemoteController, OVSSwitch
  15.  
  16.  
  17. def test():
  18. topo = RingTopology()
  19.  
  20. net = Mininet(topo=topo,
  21. controller=Ryu,
  22. autoStaticArp=True)
  23. net.start()
  24. print "Dumping host connections"
  25. dumpNodeConnections(net.hosts)
  26. # print "Testing network connectivity"
  27. # net.pingAll()
  28. net.stop()
  29.  
  30.  
  31. class RingTopology(Topo):
  32. def __init__(self):
  33. Topo.__init__(self)
  34. # Server
  35. server1 = self.addHost('server1', ip='10.0.0.1', vlan=2)
  36. server2 = self.addHost('server2', ip='10.0.0.2', vlan=2)
  37. server3 = self.addHost('server3', ip='10.0.0.3', vlan=2)
  38.  
  39. # Client
  40. client1 = self.addHost('client1', ip='10.0.0.4', vlan=110)
  41. client2 = self.addHost('client2', ip='10.0.0.5', vlan=110)
  42. client3 = self.addHost('client3', ip='10.0.0.6', vlan=110)
  43.  
  44. # Switch
  45. switch1 = self.addSwitch('switch1')
  46. switch2 = self.addSwitch('switch2')
  47. switch3 = self.addSwitch('switch3')
  48.  
  49. self.addLink(switch1, server1)
  50. self.addLink(switch1, client1)
  51.  
  52. self.addLink(switch2, server2)
  53. self.addLink(switch2, client2)
  54.  
  55. self.addLink(switch3, server3)
  56. self.addLink(switch3, client3)
  57.  
  58. self.addLink(switch1, switch2)
  59. self.addLink(switch2, switch3)
  60. self.addLink(switch3, switch1)
  61.  
  62.  
  63. if __name__ == '__main__':
  64. # Tell mininet to print useful information
  65. setLogLevel('info')
  66. test()
  67. topo = RingTopology()
  68. c0 = RemoteController('c0', ip='127.0.0.1', port=6633)
  69. net = Mininet(topo=topo,
  70. controller=c0,
  71. switch=OVSSwitch,
  72. autoStaticArp=True)
  73. net.start()
  74. CLI(net)
  75. net.stop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement