Devin Lim | e6fe3c4 | 2017-10-18 16:28:40 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | """ |
| 4 | Copyright 2015 Open Networking Foundation ( ONF ) |
| 5 | |
| 6 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 7 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 8 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 9 | |
| 10 | TestON is free software: you can redistribute it and/or modify |
| 11 | it under the terms of the GNU General Public License as published by |
| 12 | the Free Software Foundation, either version 2 of the License, or |
| 13 | ( at your option ) any later version. |
| 14 | |
| 15 | TestON is distributed in the hope that it will be useful, |
| 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | GNU General Public License for more details. |
| 19 | |
| 20 | You should have received a copy of the GNU General Public License |
| 21 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 22 | """ |
| 23 | """ |
| 24 | Custom topology for Mininet |
| 25 | """ |
| 26 | from mininet.topo import Topo |
| 27 | from mininet.net import Mininet |
| 28 | from mininet.node import Host, RemoteController |
| 29 | from mininet.node import Node |
| 30 | from mininet.link import TCLink |
| 31 | from mininet.cli import CLI |
| 32 | from mininet.log import setLogLevel |
| 33 | from mininet.util import dumpNodeConnections |
| 34 | from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch ) |
| 35 | |
| 36 | |
| 37 | class MyTopo( Topo ): |
| 38 | |
| 39 | def __init__( self ): |
| 40 | # Initialize topology |
| 41 | Topo.__init__( self ) |
| 42 | |
| 43 | host1 = self.addHost( 'h1', ip='10.1.0.1/24' ) |
| 44 | host2 = self.addHost( 'h2', ip='10.1.0.2/24' ) |
| 45 | host3 = self.addHost( 'h3', ip='10.1.0.3/24' ) |
| 46 | host4 = self.addHost( 'h4', ip='10.1.0.4/24' ) |
| 47 | host5 = self.addHost( 'h5', ip='10.1.0.5/24' ) |
| 48 | host6 = self.addHost( 'h6', ip='10.1.0.6/24' ) |
| 49 | host7 = self.addHost( 'h7', ip='10.1.0.7/24' ) |
| 50 | host8 = self.addHost( 'h8', ip='10.1.0.8/24' ) |
| 51 | |
| 52 | s1 = self.addSwitch( 's1' ) |
| 53 | s2 = self.addSwitch( 's2' ) |
| 54 | s3 = self.addSwitch( 's3' ) |
| 55 | s4 = self.addSwitch( 's4' ) |
| 56 | s5 = self.addSwitch( 's5' ) |
| 57 | s6 = self.addSwitch( 's6' ) |
| 58 | s7 = self.addSwitch( 's7' ) |
| 59 | s8 = self.addSwitch( 's8' ) |
| 60 | |
| 61 | self.addLink( s1, host1 ) |
| 62 | self.addLink( s2, host2 ) |
| 63 | self.addLink( s3, host3 ) |
| 64 | self.addLink( s4, host4 ) |
| 65 | self.addLink( s5, host5 ) |
| 66 | self.addLink( s6, host6 ) |
| 67 | self.addLink( s7, host7 ) |
| 68 | self.addLink( s8, host8 ) |
| 69 | |
| 70 | self.addLink( s1, s2 ) |
| 71 | self.addLink( s2, s3 ) |
| 72 | self.addLink( s3, s4 ) |
| 73 | self.addLink( s4, s5 ) |
| 74 | self.addLink( s5, s6 ) |
| 75 | self.addLink( s6, s7 ) |
| 76 | self.addLink( s3, s8 ) |
| 77 | self.addLink( s8, s4 ) |
| 78 | |
| 79 | topos = { 'mytopo': ( lambda: MyTopo() ) } |
| 80 | |
| 81 | # HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS |
| 82 | |
| 83 | |
| 84 | def setupNetwork(): |
| 85 | "Create network" |
| 86 | topo = MyTopo() |
| 87 | network = Mininet( topo=topo, autoSetMacs=True, controller=None ) |
| 88 | network.start() |
| 89 | CLI( network ) |
| 90 | network.stop() |
| 91 | |
| 92 | if __name__ == '__main__': |
| 93 | setLogLevel( 'info' ) |
| 94 | # setLogLevel( 'debug' ) |
| 95 | setupNetwork() |