fork download
  1. # !/usr/bin/python
  2.  
  3. '''
  4.  
  5.  
  6.  
  7. from mininet.topo import Topo
  8. from mininet.cli import CLI
  9. from mininet.net import Mininet
  10. from mininet.link import TCLink
  11. from mininet.util import irange,dumpNodeConnections
  12. from mininet.node import Controller, RemoteController
  13.  
  14. class CustomTopo(Topo):
  15. def __init__(self, link1, link2, link3, fanout=2, **opts):
  16. Topo.__init__(self, **opts)
  17. self.fanout = fanout
  18.  
  19. coreSw = self.addSwitch('c1')
  20. for i in irange(1, fanout):
  21. aggregation_sw = self.addSwitch('a%s' %i)
  22. self.addLink(coreSw, aggregation_sw, **link1)
  23.  
  24. for j in irange(1, fanout):
  25. edgeSwNumber = fanout * (i-1) + j
  26. edge_sw = self.addSwitch('e%s' %edgeSwNumber)
  27. self.addLink(aggregation_sw, edge_sw, **link2)
  28.  
  29. for k in irange(1, fanout):
  30. hostNumber = fanout * (edgeSwNumber - 1 )+ k
  31. host = self.addHost('h%s' %hostNumber)
  32. self.addLink(edge_sw, host, **link3)
  33.  
  34. topos = { 'custom': ( lambda: CustomTopo() ) }
  35.  
  36. def SimpleTest():
  37. "Set up link parameters"
  38. print ">>>> Setting link parameters"
  39.  
  40. ">> core to aggregation switches"
  41. link1 = {'bw':50, 'delay':'5ms'}
  42.  
  43. ">> aggregation to edge switches"
  44. link2 = {'bw':30, 'delay':'10ms'}
  45.  
  46. ">> edge switches to hosts"
  47. link3 = {'bw':10, 'delay':'15ms'}
  48. "Creating network and run simple performance test"
  49.  
  50. print ">>>> Creating Custom Topology"
  51. topo = CustomTopo(link1, link2, link3, fanout=3)
  52.  
  53. print ">>>> Starting Mininet"
  54. net = Mininet(topo=topo, link=TCLink )
  55.  
  56. net.start()
  57. dumpNodeConnections(net.hosts)
  58. h1 = net.get('h1')
  59. h27 = net.get('h27')
  60. print ">>>> Initiating Test Sequence"
  61.  
  62. # Start pings
  63. outputString = h1.cmd('ping', '-c6', h27.IP())
  64. print outputString
  65.  
  66. CLI(net)
  67. net.stop()
  68.  
  69. if __name__ == '__main__':
  70. SimpleTest()
  71.  
  72. your code goes here
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python2.7/py_compile.py", line 117, in compile
    raise py_exc
py_compile.PyCompileError:   File "prog.py", line 72
    '''



from mininet.topo import Topo
from mininet.cli import CLI
from mininet.net import Mininet
from mininet.link import TCLink
from mininet.util import irange,dumpNodeConnections
from mininet.node import Controller, RemoteController

class CustomTopo(Topo):
    def __init__(self, link1, link2, link3, fanout=2, **opts):
        Topo.__init__(self, **opts)
        self.fanout = fanout

        coreSw = self.addSwitch('c1')
        for i in irange(1, fanout):
            aggregation_sw = self.addSwitch('a%s' %i)
            self.addLink(coreSw, aggregation_sw, **link1)
            
            for j in irange(1, fanout):
                edgeSwNumber = fanout * (i-1) + j
                edge_sw = self.addSwitch('e%s' %edgeSwNumber)
                self.addLink(aggregation_sw, edge_sw, **link2)
                
                for k in irange(1, fanout):
                    hostNumber = fanout * (edgeSwNumber - 1 )+ k
                    host = self.addHost('h%s' %hostNumber)
                    self.addLink(edge_sw, host, **link3)

topos = { 'custom': ( lambda: CustomTopo() ) }
	
def SimpleTest():
    "Set up link parameters"
    print ">>>> Setting link parameters"
    
    ">> core to aggregation switches"
    link1 = {'bw':50, 'delay':'5ms'}
    
    ">> aggregation to edge switches"
    link2 = {'bw':30, 'delay':'10ms'}
    
    ">> edge switches to hosts"
    link3 = {'bw':10, 'delay':'15ms'}
    "Creating network and run simple performance test"

    print ">>>> Creating Custom Topology"
    topo = CustomTopo(link1, link2, link3, fanout=3)

    print ">>>> Starting Mininet"
    net = Mininet(topo=topo, link=TCLink )

    net.start()
    dumpNodeConnections(net.hosts)
    h1 = net.get('h1')
    h27 = net.get('h27')
    print ">>>> Initiating Test Sequence"

    # Start pings
    outputString = h1.cmd('ping', '-c6', h27.IP())
    print outputString

    CLI(net)
    net.stop()

if __name__ == '__main__':
    SimpleTest()

 your code goes here
       



                             
                           
                               
                               
                                                   
                                                     

                       
                                                              
                                   
                            

                                     
                                   
                                                     
                                                         
            
                                       
                                                 
                                                             
                                                              
                
                                           
                                                                
                                                          
                                                        

                                              
	
                 
                            
                                        
    
                                     
                                    
    
                                     
                                     
    
                               
                                     
                                                      

                                         
                                                    

                                 
                                          

               
                                  
                      
                        
                                         

                 
                                                  
                      

            
              

                          
                

                   ^
SyntaxError: EOF while scanning triple-quoted string literal

stdout
Standard output is empty