From Robby Hemawan Pramudito, 4 Months ago, written in Python.
Embed
  1. from mininet.topo import Topo
  2.  
  3. class MyTopo( Topo ):
  4.     "Simple topology example."
  5.  
  6.     def build( self ):
  7.         "Create custom topo."
  8.  
  9.         # Add hosts and switches
  10.         h1 = self.addHost( 'h1' )
  11.         h2 = self.addHost( 'h2' )
  12.         h3 = self.addHost( 'h3' )
  13.         h4 = self.addHost( 'h4' )
  14.         sw1 = self.addSwitch( 'sw1' )
  15.         sw2 = self.addSwitch( 'sw2' )
  16.         sw3 = self.addSwitch( 'sw3' )
  17.  
  18.         # Add links
  19.         self.addLink( sw1, sw2 )
  20.         self.addLink( sw1, sw3 )
  21.         self.addLink( sw2, sw1 )
  22.         self.addLink( sw2, sw3 )
  23.         self.addLink( sw3, sw1 )
  24.         self.addLink( sw3, sw2 )
  25.         self.addLink( h1, sw1 )
  26.         self.addLink( h2, sw2 )
  27.         self.addLink( h3, sw2 )
  28.         self.addLink( h4, sw3 )
  29.  
  30.  
  31. topos = { 'mytopo': ( lambda: MyTopo() ) }