Advertisement
Guest User

Untitled

a guest
Apr 10th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.42 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import functools
  4.  
  5. from mininet.node import RemoteController, OVSSwitch
  6. from mininet.topo import Topo
  7. from mininet.net import Mininet
  8. from mininet.util import dumpNodeConnections
  9. from mininet.log import setLogLevel
  10.  
  11. class DiamondTopo( Topo ):
  12.     def build( self ):
  13.         s1 = self.addSwitch( 's1', mac='00:00:00:00:00:01' )
  14.         s2 = self.addSwitch( 's2', mac='00:00:00:00:00:02' )
  15.         s3 = self.addSwitch( 's3', mac='00:00:00:00:00:03' )
  16.        
  17.         h1 = self.addHost( 'h1', mac='00:00:00:00:ff:01' )
  18.         h2 = self.addHost( 'h2', mac='00:00:00:00:ff:02' )
  19.         h3 = self.addHost( 'h3', mac='00:00:00:00:ff:03' )
  20.        
  21.         self.addLink( s1, s2 )
  22.         self.addLink( s2, s3 )
  23.         self.addLink( s3, s1 )
  24.        
  25.         self.addLink( h1, s1 )
  26.         self.addLink( h2, s2 )
  27.         self.addLink( h3, s3 )
  28.  
  29. def simpleTest():
  30.     topo = DiamondTopo()
  31.    
  32.     testController = RemoteController( 'OpenDaylight', '192.168.150.131' )
  33.    
  34.     OVSSwitchOF13 = functools.partial( OVSSwitch, protocols='OpenFlow13' )
  35.     net = Mininet( topo, switch=OVSSwitchOF13, controller=testController )
  36.     net.start()
  37.    
  38.     print "Dumping host connections"
  39.     dumpNodeConnections( net.hosts )
  40.     print "Dumping switch connections"
  41.     dumpNodeConnections( net.switches )
  42.    
  43.     net.interact()
  44.  
  45. if __name__ == '__main__':
  46.     setLogLevel( 'info' )
  47.     simpleTest()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement