blob: 91b2fc5bf843440080e77832347de17068c7631a [file] [log] [blame]
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07001"""
2Copyright 2015 Open Networking Foundation (ONF)
3
4Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
5the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
6or 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
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080022#!/usr/bin/python
23
24"""
25Custom topology for Mininet
26"""
27from mininet.topo import Topo
28from mininet.net import Mininet
29from mininet.node import Host, RemoteController
30from mininet.node import Node
31from mininet.node import CPULimitedHost
32from mininet.link import TCLink
33from mininet.cli import CLI
34from mininet.log import setLogLevel
35from mininet.util import dumpNodeConnections
36from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch )
37
38class VLANHost( Host ):
39 def config( self, vlan=100, v6Addr='3000::1/64', **params ):
40 r = super( Host, self ).config( **params )
41 intf = self.defaultIntf()
42 self.cmd( 'ifconfig %s inet 0' % intf )
43 self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
44 self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
45 self.cmd( 'ip -6 addr add %s dev %s.%d' % ( v6Addr, intf, vlan ) )
46 newName = '%s.%d' % ( intf, vlan )
47 intf.name = newName
48 self.nameToIntf[ newName ] = intf
49 return r
50
51class IPv6Host( Host ):
52 def config( self, v6Addr='1000::1/64', **params ):
53 r = super( Host, self ).config( **params )
54 intf = self.defaultIntf()
55 self.cmd( 'ifconfig %s inet 0' % intf )
56 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
57 return r
58
59class dualStackHost( Host ):
60 def config( self, v6Addr='2000:1/64', **params ):
61 r = super( Host, self ).config( **params )
62 intf = self.defaultIntf()
63 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
64 return r
65
66class MyTopo( Topo ):
67
68 def __init__( self ):
69 # Initialize topology
70 Topo.__init__( self )
71 # Switch S5 Hosts
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080072 host1=self.addHost( 'h1', cls=IPv6Host, v6Addr='10:1:0::1/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080073 host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
74 # Dual Stack Host
sathishmad953462015-12-03 17:42:07 +053075 host3=self.addHost( 'h3', cls=dualStackHost, v6Addr='2000::2/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080076 host4=self.addHost( 'h4', cls=IPv6Host, v6Addr='3000::2/64' )
sathishmad953462015-12-03 17:42:07 +053077 #VLAN
78 host5=self.addHost( 'h5', cls=VLANHost,v6Addr='4000::2/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080079 host6=self.addHost( 'h6', cls=IPv6Host, v6Addr='11:1:0::2/64' )
80 host7=self.addHost( 'h7', cls=IPv6Host, v6Addr='12:1:0::2/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080081 host8=self.addHost( 'h8', cls=IPv6Host, v6Addr='10:1:0::4/64' )
82
83 # Switch S6 Hosts
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080084 host9=self.addHost( 'h9', cls=IPv6Host, v6Addr='10:1:0::5/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080085 host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
86 # Dual Stack Host
sathishmad953462015-12-03 17:42:07 +053087 host11=self.addHost( 'h11', cls=dualStackHost, v6Addr='2000::3/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080088 host12=self.addHost( 'h12', cls=IPv6Host, v6Addr='3000::3/64' )
89 host13=self.addHost( 'h13', cls=IPv6Host, v6Addr='4000::3/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080090 host14=self.addHost( 'h14', cls=IPv6Host, v6Addr='11:1:0::3/64' )
91 host15=self.addHost( 'h15', cls=IPv6Host, v6Addr='12:1:0::3/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080092 host16=self.addHost( 'h16', cls=IPv6Host, v6Addr='10:1:0::7/64' )
93
94 # Switch S7 Hosts
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080095 host17=self.addHost( 'h17', cls=IPv6Host, v6Addr='10:1:0::8/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080096 host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080097 host19=self.addHost( 'h19', cls=IPv6Host, v6Addr='10:1:0::9/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -080098 host20=self.addHost( 'h20', cls=IPv6Host, v6Addr='100:1:0::4/64' )
99 host21=self.addHost( 'h21', cls=IPv6Host, v6Addr='200:1:0::4/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800100 host22=self.addHost( 'h22', cls=IPv6Host, v6Addr='11:1:0::4/64' )
101 host23=self.addHost( 'h23', cls=IPv6Host, v6Addr='12:1:0::4/64' )
sathishmad953462015-12-03 17:42:07 +0530102 # VLAN
103 host24=self.addHost( 'h24', cls=VLANHost, v6Addr='4000::5/64' )
Subhash Kumar Singhc73b3a72015-11-03 21:34:04 -0800104
105 s1 = self.addSwitch( 's1' )
106 s2 = self.addSwitch( 's2' )
107 s3 = self.addSwitch( 's3' )
108 s4 = self.addSwitch( 's4' )
109 s5 = self.addSwitch( 's5' )
110 s6 = self.addSwitch( 's6' )
111 s7 = self.addSwitch( 's7' )
112
113 self.addLink(s5,host1)
114 self.addLink(s5,host2)
115 self.addLink(s5,host3)
116 self.addLink(s5,host4)
117 self.addLink(s5,host5)
118 self.addLink(s5,host6)
119 self.addLink(s5,host7)
120 self.addLink(s5,host8)
121
122 self.addLink(s6,host9)
123 self.addLink(s6,host10)
124 self.addLink(s6,host11)
125 self.addLink(s6,host12)
126 self.addLink(s6,host13)
127 self.addLink(s6,host14)
128 self.addLink(s6,host15)
129 self.addLink(s6,host16)
130
131 self.addLink(s7,host17)
132 self.addLink(s7,host18)
133 self.addLink(s7,host19)
134 self.addLink(s7,host20)
135 self.addLink(s7,host21)
136 self.addLink(s7,host22)
137 self.addLink(s7,host23)
138 self.addLink(s7,host24)
139
140 self.addLink(s1,s2)
141 self.addLink(s1,s3)
142 self.addLink(s1,s4)
143 self.addLink(s1,s5)
144 self.addLink(s2,s3)
145 self.addLink(s2,s5)
146 self.addLink(s2,s6)
147 self.addLink(s3,s4)
148 self.addLink(s3,s6)
149 self.addLink(s4,s7)
150 topos = { 'mytopo': ( lambda: MyTopo() ) }
151
152# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
153
154def setupNetwork():
155 "Create network"
156 topo = MyTopo()
157 network = Mininet(topo=topo, autoSetMacs=True, controller=None)
158 network.start()
159 CLI( network )
160 network.stop()
161
162if __name__ == '__main__':
163 setLogLevel('info')
164 #setLogLevel('debug')
165 setupNetwork()