SHARE
TWEET

Untitled

a guest Jun 27th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. from mininet.net import Mininet
  3. from utils.FloodlightController import FloodlightController
  4. from mininet.log import setLogLevel
  5. import os,time
  6.  
  7. if __name__ == '__main__':
  8.     #setLogLevel( 'info' )
  9.     net = Mininet(controller=FloodlightController)
  10.     #net.addController("controller1")
  11.  
  12.     num_nodes = 8
  13.     for i in range(1,num_nodes):
  14.         net.addHost("h%d"%i)
  15.     for i in range(2,num_nodes):
  16.         net.addLink("h%d"%i, "h%d"%(i-1))
  17.  
  18.     net.start()
  19.     net.pingAll()
  20.     net.stop()
  21.      
  22. *** Ping: testing ping reachability
  23. h1 -> h2 X X X X X
  24. h2 -> h1 X X X X X
  25. h3 -> X X X X X X
  26. h4 -> X X X X X X
  27. h5 -> X X X X X X
  28. h6 -> X X X X X X
  29. h7 -> X X X X X X
  30. *** Results: 95% dropped (2/42 received)
  31.      
  32. #!/usr/bin/python
  33.  
  34. from mininet.net import Mininet
  35. from mininet.log import setLogLevel
  36. import os,time
  37.  
  38. if __name__ == '__main__':
  39.     #setLogLevel( 'info' )
  40.     net = Mininet()
  41.  
  42.     num_nodes = 8
  43.     hosts=[None] * num_nodes
  44.  
  45.     for i in range(1,num_nodes):
  46.         hosts[i]=net.addHost("h%d"%i)
  47.     for i in range(2,num_nodes,2):
  48.         net.addLink(hosts[i], hosts[i-1])
  49.     for i in range(3,num_nodes,2):
  50.         net.addLink(hosts[i], hosts[i-1])
  51.  
  52.     net.start()
  53.     net.pingAll()
  54.     net.stop()
  55.      
  56. h1 -> h2 X X X X X
  57.     h2 -> h1 X X X X X
  58.     h3 -> X X h4 X X X
  59.     h4 -> X X h3 X X X
  60.     h5 -> X X X X h6 X
  61.     h6 -> X X X X h5 X
  62.     h7 -> X X X X X X
  63.      
  64. host.cmd('sysctl -w net.ipv4.ip_forward=1')
  65.      
  66. #!/usr/bin/python
  67.  
  68. from mininet.net import Mininet
  69. from mininet.log import output
  70.  
  71. if __name__ == '__main__':
  72.  
  73.     net = Mininet()
  74.  
  75.     num_nodes = 8
  76.  
  77.     # from 1 to num_nodes
  78.     for i in range(1,num_nodes+1):
  79.         net.addHost('h%d'%i,ip=None)
  80.  
  81.     # from 1 to num_nodes-1 because the index starts from zero
  82.     for i in range(1,num_nodes):
  83.  
  84.         h1 = net.hosts[i-1]
  85.         h2 = net.hosts[i]
  86.  
  87.         net.addLink(h2, h1, intfName1 = '%s-eth0'%h2.name, intfName2 = '%s-eth1'%h1.name)
  88.         h2.intf('%s-eth0'%h2.name).setIP('10.0.%d.1'%i, 24)
  89.         h1.intf('%s-eth1'%h1.name).setIP('10.0.%d.2'%i, 24)
  90.  
  91.     net.start()
  92.  
  93.     # Ping forward and backward nodes
  94.     for i in range(0,num_nodes):
  95.         node = net.hosts[i]
  96.  
  97.         fwdNode, bwNode = None, None
  98.  
  99.         output('%s -> '%node.name)
  100.  
  101.         if i!=0:
  102.             bwNode = net.hosts[i-1]
  103.             bwIP = bwNode.IP('%s-eth1'%bwNode.name)
  104.             result = node.cmd('ping -c1 %s'%bwIP)
  105.             sent, received = net._parsePing(result)
  106.  
  107.             output(('%s '%bwNode.name) if received else 'X ')
  108.  
  109.         if i!=7:
  110.             fwdNode = net.hosts[i+1]
  111.             fwdIP = fwdNode.IP('%s-eth0'%fwdNode.name)
  112.             result = node.cmd('ping -c1 %s'%fwdIP)
  113.             sent, received = net._parsePing(result)
  114.  
  115.             output(('%s '%fwdNode.name) if received else 'X ')
  116.  
  117.         output('n')
  118.  
  119.     net.stop()
  120.      
  121. h1 -> h2
  122. h2 -> h1 h3
  123. h3 -> h2 h4
  124. h4 -> h3 h5
  125. h5 -> h4 h6
  126. h6 -> h5 h7
  127. h7 -> h6 h8
  128. h8 -> h7
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top