blob: 870bc3221dea47968d9b703a4c7f26de9ff606c7 [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
kelvin-onlab44147802015-07-27 17:57:31 -070022#!/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, **params ):
Jon Hall0946f652015-08-13 11:44:38 -070040 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 newName = '%s.%d' % ( intf, vlan )
46 intf.name = newName
47 self.nameToIntf[ newName ] = intf
48 return r
kelvin-onlab44147802015-07-27 17:57:31 -070049
50class IPv6Host( Host ):
51 def config( self, v6Addr='1000:1/64', **params ):
Jon Hall0946f652015-08-13 11:44:38 -070052 r = super( Host, self ).config( **params )
53 intf = self.defaultIntf()
54 self.cmd( 'ifconfig %s inet 0' % intf )
55 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
56 return r
kelvin-onlab44147802015-07-27 17:57:31 -070057
58class dualStackHost( Host ):
59 def config( self, v6Addr='2000:1/64', **params ):
Jon Hall0946f652015-08-13 11:44:38 -070060 r = super( Host, self ).config( **params )
61 intf = self.defaultIntf()
62 self.cmd( 'ip -6 addr add %s dev %s' % ( v6Addr, intf ) )
63 return r
kelvin-onlab44147802015-07-27 17:57:31 -070064
65class MyTopo( Topo ):
66
Jon Hall0946f652015-08-13 11:44:38 -070067 def __init__( self ):
68 # Initialize topology
69 Topo.__init__( self )
70 # Switch S5 Hosts
71 host1=self.addHost( 'h1', ip='10.1.0.2/24' )
72 host2=self.addHost( 'h2', cls=IPv6Host, v6Addr='1000::2/64' )
73 host3=self.addHost( 'h3', ip='10.1.0.3/24', cls=dualStackHost, v6Addr='2000::2/64' )
74 #VLAN hosts
75 host4=self.addHost( 'h4', ip='100.1.0.2/24', cls=VLANHost, vlan=100 )
76 host5=self.addHost( 'h5', ip='200.1.0.2/24', cls=VLANHost, vlan=200 )
77 #VPN-1 and VPN-2 Hosts
78 host6=self.addHost( 'h6', ip='11.1.0.2/24' )
79 host7=self.addHost( 'h7', ip='12.1.0.2/24' )
80 #Multicast Sender
81 host8=self.addHost( 'h8', ip='10.1.0.4/24' )
kelvin-onlab44147802015-07-27 17:57:31 -070082
Jon Hall0946f652015-08-13 11:44:38 -070083 # Switch S6 Hosts
84 host9=self.addHost( 'h9', ip='10.1.0.5/24' )
85 host10=self.addHost( 'h10', cls=IPv6Host, v6Addr='1000::3/64' )
86 host11=self.addHost( 'h11', ip='10.1.0.6/24', cls=dualStackHost, v6Addr='2000::3/64' )
87 #VLAN hosts
88 host12=self.addHost( 'h12', ip='100.1.0.3/24', cls=VLANHost, vlan=100 )
89 host13=self.addHost( 'h13', ip='200.1.0.3/24', cls=VLANHost, vlan=200 )
90 #VPN-1 and VPN-2 Hosts
91 host14=self.addHost( 'h14', ip='11.1.0.3/24' )
92 host15=self.addHost( 'h15', ip='12.1.0.3/24' )
93 #Multicast Receiver
94 host16=self.addHost( 'h16', ip='10.1.0.7/24' )
kelvin-onlab44147802015-07-27 17:57:31 -070095
Jon Hall0946f652015-08-13 11:44:38 -070096 # Switch S7 Hosts
97 host17=self.addHost( 'h17', ip='10.1.0.8/24' )
98 host18=self.addHost( 'h18', cls=IPv6Host, v6Addr='1000::4/64' )
99 host19=self.addHost( 'h19', ip='10.1.0.9/24', cls=dualStackHost, v6Addr='2000::4/64' )
100 #VLAN hosts
101 host20=self.addHost( 'h20', ip='100.1.0.4/24', cls=VLANHost, vlan=100 )
102 host21=self.addHost( 'h21', ip='200.1.0.4/24', cls=VLANHost, vlan=200 )
103 #VPN-1 and VPN-2 Hosts
104 host22=self.addHost( 'h22', ip='11.1.0.4/24' )
105 host23=self.addHost( 'h23', ip='12.1.0.4/24' )
106 #Multicast Receiver
107 host24=self.addHost( 'h24', ip='10.1.0.10/24' )
kelvin-onlab44147802015-07-27 17:57:31 -0700108
Jon Hall0946f652015-08-13 11:44:38 -0700109 s1 = self.addSwitch( 's1' )
110 s2 = self.addSwitch( 's2' )
111 s3 = self.addSwitch( 's3' )
112 s4 = self.addSwitch( 's4' )
113 s5 = self.addSwitch( 's5' )
114 s6 = self.addSwitch( 's6' )
115 s7 = self.addSwitch( 's7' )
kelvin-onlab44147802015-07-27 17:57:31 -0700116
Jon Hall0946f652015-08-13 11:44:38 -0700117 self.addLink(s5,host1)
118 self.addLink(s5,host2)
119 self.addLink(s5,host3)
120 self.addLink(s5,host4)
121 self.addLink(s5,host5)
122 self.addLink(s5,host6)
123 self.addLink(s5,host7)
124 self.addLink(s5,host8)
kelvin-onlab44147802015-07-27 17:57:31 -0700125
Jon Hall0946f652015-08-13 11:44:38 -0700126 self.addLink(s6,host9)
127 self.addLink(s6,host10)
128 self.addLink(s6,host11)
129 self.addLink(s6,host12)
130 self.addLink(s6,host13)
131 self.addLink(s6,host14)
132 self.addLink(s6,host15)
133 self.addLink(s6,host16)
kelvin-onlab44147802015-07-27 17:57:31 -0700134
Jon Hall0946f652015-08-13 11:44:38 -0700135 self.addLink(s7,host17)
136 self.addLink(s7,host18)
137 self.addLink(s7,host19)
138 self.addLink(s7,host20)
139 self.addLink(s7,host21)
140 self.addLink(s7,host22)
141 self.addLink(s7,host23)
142 self.addLink(s7,host24)
kelvin-onlab44147802015-07-27 17:57:31 -0700143
Jon Hall0946f652015-08-13 11:44:38 -0700144 self.addLink(s1,s2)
145 self.addLink(s1,s3)
146 self.addLink(s1,s4)
147 self.addLink(s1,s5)
148 self.addLink(s2,s3)
149 self.addLink(s2,s5)
150 self.addLink(s2,s6)
151 self.addLink(s3,s4)
152 self.addLink(s3,s6)
153 self.addLink(s4,s7)
154 topos = { 'mytopo': ( lambda: MyTopo() ) }
kelvin-onlab44147802015-07-27 17:57:31 -0700155
156# HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS
157
158def setupNetwork():
159 "Create network"
160 topo = MyTopo()
161 network = Mininet(topo=topo, autoSetMacs=True, controller=None)
162 network.start()
163 CLI( network )
164 network.stop()
165
166if __name__ == '__main__':
167 setLogLevel('info')
168 #setLogLevel('debug')
169 setupNetwork()