Guest User

Untitled

a guest
Nov 20th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. 'This example shows how to create multiple interfaces in stations'
  4.  
  5. from __future__ import print_function
  6. import sys, os
  7.  
  8. from mininet.node import OVSKernelSwitch, Controller, RemoteController
  9. from mininet.log import setLogLevel, info
  10. from mn_wifi.cli import CLI_wifi
  11. from mn_wifi.net import Mininet_wifi
  12.  
  13.  
  14. def topology(broadcast):
  15. "Create a network."
  16. if broadcast:
  17. net = Mininet_wifi(controller=Controller)
  18. else:
  19. net = Mininet_wifi(controller=RemoteController)
  20.  
  21. info("*** Creating nodes\n")
  22. s1 = net.addSwitch('s1')
  23. h1 = net.addHost('h1')
  24. h2 = net.addHost('h2')
  25. h3 = net.addHost('h3')
  26. c1 = net.addController('c1')
  27.  
  28. info("*** Configuring wifi nodes\n")
  29. net.configureWifiNodes()
  30.  
  31. info("*** Associating...\n")
  32. net.addLink(s1, h1, bw=10)
  33. net.addLink(s1, h1, bw=10)
  34. net.addLink(s1, h2)
  35. net.addLink(s1, h3)
  36.  
  37. info("*** Starting network\n")
  38. net.build()
  39. c1.start()
  40. s1.start([c1])
  41.  
  42. if broadcast:
  43. h1.cmd('modprobe bonding mode=3')
  44. else:
  45. h1.cmd('modprobe bonding mode=4')
  46. h1.cmd('ip link add bond0 type bond')
  47. h1.cmd('ip link set bond0 address 00:00:00:11:22:33')
  48. h1.cmd('ip link set h1-eth0 down')
  49. h1.cmd('ip link set h1-eth0 address 00:00:00:00:00:11')
  50. h1.cmd('ip link set h1-eth0 master bond0')
  51. h1.cmd('ip link set h1-eth1 down')
  52. h1.cmd('ip link set h1-eth1 address 00:00:00:00:00:22')
  53. h1.cmd('ip link set h1-eth1 master bond0')
  54. h1.cmd('ip addr add 10.0.0.1/8 dev bond0')
  55. h1.cmd('ip addr del 10.0.0.1/8 dev h1-eth0')
  56. h1.cmd('ip link set bond0 up')
  57.  
  58. info("*** Running CLI\n")
  59. CLI_wifi(net)
  60.  
  61. os.system('rmmod bonding')
  62.  
  63. info("*** Stopping network\n")
  64. net.stop()
  65.  
  66.  
  67. if __name__ == '__main__':
  68. setLogLevel('info')
  69. broadcast = True if '-b' in sys.argv else False
  70. topology(broadcast)
Add Comment
Please, Sign In to add comment