blob: 03d2eae8021660639211a08ad09d67091acf0b31 [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 2015 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
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080023"""
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
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080038class VLANHost( Host ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070039
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080040 def config( self, vlan=100, v6Addr='3000::1/64', **params ):
41 r = super( Host, self ).config( **params )
42 intf = self.defaultIntf()
43 self.cmd( 'ifconfig %s inet 0' % intf )
44 self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070045 self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params[ 'ip' ] ) )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080046 self.cmd( 'ip -6 addr add %s dev %s.%d' % ( v6Addr, intf, vlan ) )
47 newName = '%s.%d' % ( intf, vlan )
48 intf.name = newName
49 self.nameToIntf[ newName ] = intf
50 return r
51
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070052
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080053class IPv6Host( Host ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070054
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080055 def config( self, v6Addr='1000::1/64', **params ):
56 r = super( Host, self ).config( **params )
57 intf = self.defaultIntf()
58 self.cmd( 'ifconfig %s inet 0' % intf )
59 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
60 return r
61
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070062
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080063class dualStackHost( Host ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070064
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080065 def config( self, v6Addr='2000:1/64', **params ):
66 r = super( Host, self ).config( **params )
67 intf = self.defaultIntf()
68 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
69 return r
70
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070071
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080072class MyTopo( Topo ):
73
74 def __init__( self ):
75 # Initialize topology
76 Topo.__init__( self )
77 # Switch S5 Hosts
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070078 host1 = self.addHost( 'h1', cls=IPv6Host, v6Addr='10:1:0::1/64' )
79 host2 = self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080080 # Dual Stack Host
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070081 host3 = self.addHost( 'h3', cls=dualStackHost, v6Addr='2000::2/64' )
82 host4 = self.addHost( 'h4', cls=IPv6Host, v6Addr='3000::2/64' )
83 # VLAN
84 host5 = self.addHost( 'h5', cls=VLANHost, v6Addr='4000::2/64' )
85 host6 = self.addHost( 'h6', cls=IPv6Host, v6Addr='11:1:0::2/64' )
86 host7 = self.addHost( 'h7', cls=IPv6Host, v6Addr='12:1:0::2/64' )
87 host8 = self.addHost( 'h8', cls=IPv6Host, v6Addr='10:1:0::4/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080088
89 # Switch S6 Hosts
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070090 host9 = self.addHost( 'h9', cls=IPv6Host, v6Addr='10:1:0::5/64' )
91 host10 = self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080092 # Dual Stack Host
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070093 host11 = self.addHost( 'h11', cls=dualStackHost, v6Addr='2000::3/64' )
94 host12 = self.addHost( 'h12', cls=IPv6Host, v6Addr='3000::3/64' )
95 host13 = self.addHost( 'h13', cls=IPv6Host, v6Addr='4000::3/64' )
96 host14 = self.addHost( 'h14', cls=IPv6Host, v6Addr='11:1:0::3/64' )
97 host15 = self.addHost( 'h15', cls=IPv6Host, v6Addr='12:1:0::3/64' )
98 host16 = self.addHost( 'h16', cls=IPv6Host, v6Addr='10:1:0::7/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080099
100 # Switch S7 Hosts
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700101 host17 = self.addHost( 'h17', cls=IPv6Host, v6Addr='10:1:0::8/64' )
102 host18 = self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
103 host19 = self.addHost( 'h19', cls=IPv6Host, v6Addr='10:1:0::9/64' )
104 host20 = self.addHost( 'h20', cls=IPv6Host, v6Addr='100:1:0::4/64' )
105 host21 = self.addHost( 'h21', cls=IPv6Host, v6Addr='200:1:0::4/64' )
106 host22 = self.addHost( 'h22', cls=IPv6Host, v6Addr='11:1:0::4/64' )
107 host23 = self.addHost( 'h23', cls=IPv6Host, v6Addr='12:1:0::4/64' )
108 # VLAN
109 host24 = self.addHost( 'h24', cls=VLANHost, v6Addr='4000::5/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800110
111 s1 = self.addSwitch( 's1' )
112 s2 = self.addSwitch( 's2' )
113 s3 = self.addSwitch( 's3' )
114 s4 = self.addSwitch( 's4' )
115 s5 = self.addSwitch( 's5' )
116 s6 = self.addSwitch( 's6' )
117 s7 = self.addSwitch( 's7' )
118
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700119 self.addLink( s5, host1 )
120 self.addLink( s5, host2 )
121 self.addLink( s5, host3 )
122 self.addLink( s5, host4 )
123 self.addLink( s5, host5 )
124 self.addLink( s5, host6 )
125 self.addLink( s5, host7 )
126 self.addLink( s5, host8 )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800127
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700128 self.addLink( s6, host9 )
129 self.addLink( s6, host10 )
130 self.addLink( s6, host11 )
131 self.addLink( s6, host12 )
132 self.addLink( s6, host13 )
133 self.addLink( s6, host14 )
134 self.addLink( s6, host15 )
135 self.addLink( s6, host16 )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800136
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700137 self.addLink( s7, host17 )
138 self.addLink( s7, host18 )
139 self.addLink( s7, host19 )
140 self.addLink( s7, host20 )
141 self.addLink( s7, host21 )
142 self.addLink( s7, host22 )
143 self.addLink( s7, host23 )
144 self.addLink( s7, host24 )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800145
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700146 self.addLink( s1, s2 )
147 self.addLink( s1, s3 )
148 self.addLink( s1, s4 )
149 self.addLink( s1, s5 )
150 self.addLink( s2, s3 )
151 self.addLink( s2, s5 )
152 self.addLink( s2, s6 )
153 self.addLink( s3, s4 )
154 self.addLink( s3, s6 )
155 self.addLink( s4, s7 )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800156 topos = { 'mytopo': ( lambda: MyTopo() ) }
157
158# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
159
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700160
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800161def setupNetwork():
162 "Create network"
163 topo = MyTopo()
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700164 network = Mininet( topo=topo, autoSetMacs=True, controller=None )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800165 network.start()
166 CLI( network )
167 network.stop()
168
169if __name__ == '__main__':
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700170 setLogLevel( 'info' )
171 # setLogLevel( 'debug' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800172 setupNetwork()