blob: a5336f0ceb24314572b6a0c9c00b3d4bb7afada8 [file] [log] [blame]
YPZhangcb86c5b2016-01-27 17:38:12 -08001#!/usr/bin/python
2
3"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07004Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07005
6Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
7the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
8or 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
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070013 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070014
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"""
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070023"""
YPZhangcb86c5b2016-01-27 17:38:12 -080024Custom 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.link import TCLink
31from mininet.cli import CLI
32from mininet.log import setLogLevel
33from mininet.util import dumpNodeConnections
34from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
35
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070036
YPZhangcb86c5b2016-01-27 17:38:12 -080037class MyTopo( Topo ):
38
39 def __init__( self ):
40 # Initialize topology
41 Topo.__init__( self )
42
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070043 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' )
YPZhangcb86c5b2016-01-27 17:38:12 -080050
51 s1 = self.addSwitch( 's1' )
52 s2 = self.addSwitch( 's2' )
53 s3 = self.addSwitch( 's3' )
54 s4 = self.addSwitch( 's4' )
55 s5 = self.addSwitch( 's5' )
56 s6 = self.addSwitch( 's6' )
57 s7 = self.addSwitch( 's7' )
58 s8 = self.addSwitch( 's8' )
59
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070060 self.addLink( s1, host1 )
61 self.addLink( s2, host2 )
62 self.addLink( s3, host3 )
63 self.addLink( s4, host4 )
64 self.addLink( s5, host5 )
65 self.addLink( s6, host6 )
66 self.addLink( s7, host7 )
YPZhangcb86c5b2016-01-27 17:38:12 -080067
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070068 self.addLink( s1, s2 )
69 self.addLink( s2, s3 )
70 self.addLink( s3, s4 )
71 self.addLink( s4, s5 )
72 self.addLink( s5, s6 )
73 self.addLink( s6, s7 )
74 self.addLink( s4, s8 )
75 self.addLink( s8, s5 )
YPZhangcb86c5b2016-01-27 17:38:12 -080076
77 topos = { 'mytopo': ( lambda: MyTopo() ) }
78
79# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
80
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070081
YPZhangcb86c5b2016-01-27 17:38:12 -080082def setupNetwork():
83 "Create network"
84 topo = MyTopo()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070085 network = Mininet( topo=topo, autoSetMacs=True, controller=None )
YPZhangcb86c5b2016-01-27 17:38:12 -080086 network.start()
87 CLI( network )
88 network.stop()
89
90if __name__ == '__main__':
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070091 setLogLevel( 'info' )
92 # setLogLevel( 'debug' )
YPZhangcb86c5b2016-01-27 17:38:12 -080093 setupNetwork()