GlennRC | a539137 | 2015-10-14 17:28:15 -0700 | [diff] [blame^] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | """ |
| 4 | Custom topology for Mininet |
| 5 | """ |
| 6 | from mininet.topo import Topo |
| 7 | from mininet.net import Mininet |
| 8 | from mininet.node import Host, RemoteController |
| 9 | from mininet.node import Node |
| 10 | from mininet.node import CPULimitedHost |
| 11 | from mininet.link import TCLink |
| 12 | from mininet.cli import CLI |
| 13 | from mininet.log import setLogLevel |
| 14 | from mininet.util import dumpNodeConnections |
| 15 | from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch ) |
| 16 | |
| 17 | class MyTopo( Topo ): |
| 18 | |
| 19 | def __init__( self ): |
| 20 | # Initialize topology |
| 21 | Topo.__init__( self ) |
| 22 | # Switch S5 Hosts |
| 23 | host1=self.addHost( 'h1', ip='10.1.0.1/24' ) |
| 24 | host2=self.addHost( 'h2', ip='10.1.0.2/24' ) |
| 25 | #host3=self.addHost( 'h3', ip='10.1.0.3/24', v6Addr='1000::3/64' ) |
| 26 | #host4=self.addHost( 'h4', ip='10.1.0.4/24', v6Addr='1000::4/64' ) |
| 27 | |
| 28 | s1 = self.addSwitch( 's1' ) |
| 29 | #s2 = self.addSwitch( 's2' ) |
| 30 | |
| 31 | self.addLink(s1, host1) |
| 32 | self.addLink(s1, host2) |
| 33 | #self.addLink(s1, host3) |
| 34 | #self.addLink(s1, host4) |
| 35 | |
| 36 | |
| 37 | topos = { 'mytopo': ( lambda: MyTopo() ) } |
| 38 | |
| 39 | def setupNetwork(): |
| 40 | "Create network" |
| 41 | topo = MyTopo() |
| 42 | network = Mininet(topo=topo, autoSetMacs=True, controller=None) |
| 43 | network.start() |
| 44 | CLI( network ) |
| 45 | network.stop() |
| 46 | |
| 47 | if __name__ == '__main__': |
| 48 | setLogLevel('info') |
| 49 | #setLogLevel('debug') |
| 50 | setupNetwork() |