Advertisement
Guest User

project.py

a guest
Jan 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. """Custom topology example
  2. Two directly connected switches plus a host for each switch:
  3. host --- switch --- switch --- host
  4. Adding the 'topos' dict with a key/value pair to generate our newly defined
  5. topology enables one to pass in '--topo=mytopo' from the command line.
  6. """
  7. from mininet.topo import Topo
  8.  
  9. class MyTopo( Topo ):
  10. "Simple topology example."
  11. def __init__( self ):
  12. "Create custom topo."
  13.  
  14. # Initialize topology
  15. Topo.__init__( self )
  16.  
  17. # Add hosts
  18. h1 = self.addHost("h1")
  19. h2 = self.addHost("h2")
  20.  
  21.  
  22. #add switches
  23. switch = self.addSwitch("s0")
  24.  
  25. # Add links
  26. self.addLink( switch, h1)
  27. self.addLink( switch, h2)
  28.  
  29.  
  30. topos = { 'mytopo': ( lambda: MyTopo() ) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement