blob: 5e9f75026897370593f2b0496a0d1e1fc4a16657 [file] [log] [blame]
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001# !/usr/bin/python
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07003Copyright 2016 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07004
5Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
6the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
7or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg>
8
9 TestON is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 2 of the License, or
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070012 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070013
14 TestON is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with TestON. If not, see <http://www.gnu.org/licenses/>.
21"""
22
kavitha Alagesan373e0552016-11-22 05:22:05 +053023"""
24Custom topology for Mininet
25"""
26from mininet.topo import Topo
27from mininet.net import Mininet
28from mininet.node import Host, RemoteController
29from mininet.node import Node
30from mininet.node import CPULimitedHost
31from mininet.link import TCLink
32from mininet.cli import CLI
33from mininet.log import setLogLevel
34from mininet.util import dumpNodeConnections
35from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
36
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070037
kavitha Alagesan373e0552016-11-22 05:22:05 +053038class MyTopo( Topo ):
39
40 def __init__( self, **opts ):
41 # Initialize topology
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070042 Topo.__init__( self, **opts )
kavitha Alagesan373e0552016-11-22 05:22:05 +053043
44 # IPv4 hosts
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070045 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' )
kavitha Alagesan373e0552016-11-22 05:22:05 +053049
50 s1 = self.addSwitch( 's1' )
51
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070052 self.addLink( s1, host1 )
53 self.addLink( s1, host2 )
54 self.addLink( s1, host3 )
55 self.addLink( s1, host4 )
kavitha Alagesan373e0552016-11-22 05:22:05 +053056
57 topos = { 'mytopo': ( lambda: MyTopo() ) }
58
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070059
kavitha Alagesan373e0552016-11-22 05:22:05 +053060def setupNetwork():
61 "Create network"
62 topo = MyTopo()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070063 network = Mininet( topo=topo, autoSetMacs=True, autoStaticArp=True, controller=None )
kavitha Alagesan373e0552016-11-22 05:22:05 +053064 network.start()
65 CLI( network )
66 network.stop()
67
68if __name__ == '__main__':
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070069 setLogLevel( 'info' )
70 # setLogLevel( 'debug' )
kavitha Alagesan373e0552016-11-22 05:22:05 +053071 setupNetwork()