Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame^] | 1 | """ |
| 2 | Copyright 2016 Open Networking Foundation (ONF) |
| 3 | |
| 4 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 5 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 6 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 20 | """ |
| 21 | |
kavitha Alagesan | 373e055 | 2016-11-22 05:22:05 +0530 | [diff] [blame] | 22 | #!/usr/bin/python |
| 23 | |
| 24 | """ |
| 25 | Custom topology for Mininet |
| 26 | """ |
| 27 | from mininet.topo import Topo |
| 28 | from mininet.net import Mininet |
| 29 | from mininet.node import Host, RemoteController |
| 30 | from mininet.node import Node |
| 31 | from mininet.node import CPULimitedHost |
| 32 | from mininet.link import TCLink |
| 33 | from mininet.cli import CLI |
| 34 | from mininet.log import setLogLevel |
| 35 | from mininet.util import dumpNodeConnections |
| 36 | from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch ) |
| 37 | |
| 38 | class MyTopo( Topo ): |
| 39 | |
| 40 | def __init__( self, **opts ): |
| 41 | # Initialize topology |
| 42 | Topo.__init__( self, **opts) |
| 43 | |
| 44 | # IPv4 hosts |
| 45 | host1=self.addHost( 'h1', ip='10.0.0.1/24' ) |
| 46 | host2=self.addHost( 'h2', ip='10.0.0.2/24' ) |
| 47 | host3=self.addHost( 'h3', ip='10.0.0.3/24' ) |
| 48 | host4=self.addHost( 'h4', ip='10.0.0.4/24' ) |
| 49 | |
| 50 | s1 = self.addSwitch( 's1' ) |
| 51 | |
| 52 | self.addLink(s1, host1) |
| 53 | self.addLink(s1, host2) |
| 54 | self.addLink(s1, host3) |
| 55 | self.addLink(s1, host4) |
| 56 | |
| 57 | topos = { 'mytopo': ( lambda: MyTopo() ) } |
| 58 | |
| 59 | def setupNetwork(): |
| 60 | "Create network" |
| 61 | topo = MyTopo() |
| 62 | network = Mininet(topo=topo, autoSetMacs=True, autoStaticArp=True, controller=None) |
| 63 | network.start() |
| 64 | CLI( network ) |
| 65 | network.stop() |
| 66 | |
| 67 | if __name__ == '__main__': |
| 68 | setLogLevel('info') |
| 69 | #setLogLevel('debug') |
| 70 | setupNetwork() |