blob: 9227e18758380251c42a9bc9163a84f7e15e304c [file] [log] [blame]
pingping-linea32cf82015-10-08 22:37:37 -07001#!/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"""
pingping-linea32cf82015-10-08 22:37:37 -070024Set up the SDN-IP topology as same as it on Internet2
25"""
pingping-linea32cf82015-10-08 22:37:37 -070026"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070027AS 64513, ( SDN AS )
pingping-linea32cf82015-10-08 22:37:37 -070028AS 64514, reachable by 10.0.4.1, 10.0.14.1
29AS 64515, reachable by 10.0.5.1, 10.0.15.1
30AS 64516, reachable by 10.0.6.1, 10.0.16.1
31"""
pingping-linea32cf82015-10-08 22:37:37 -070032from mininet.net import Mininet
33from mininet.node import Controller, RemoteController
34from mininet.log import setLogLevel, info
35from mininet.cli import CLI
alison62006dd2016-12-15 16:21:28 -080036from mininet.node import Host, RemoteController
pingping-linea32cf82015-10-08 22:37:37 -070037from mininet.topo import Topo
38from mininet.util import quietRun
39from mininet.moduledeps import pathCheck
40
41import os.path
42import time
43from subprocess import Popen, STDOUT, PIPE
44
45QUAGGA_DIR = '/usr/lib/quagga'
46QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
Jon Hallfabd7e52016-04-19 19:20:59 -070047QUAGGA_CONFIG_DIR = '~/OnosSystemTest/TestON/tests/USECASE/USECASE_SdnipFunctionCluster/dependencies/'
pingping-linea32cf82015-10-08 22:37:37 -070048numSw = 39
49
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070050# net = Mininet( controller=RemoteController )
51
52
alison62006dd2016-12-15 16:21:28 -080053class VLANHost( Host ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070054
alison62006dd2016-12-15 16:21:28 -080055 def config( self, vlan=100, intfName=None, **params ):
56 r = super( Host, self ).config( **params )
57 intf = self.intf( intfName )
58 self.cmd( 'ifconfig %s inet 0' % intf )
59 self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070060 self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params[ 'ip' ] ) )
alison62006dd2016-12-15 16:21:28 -080061 newName = '%s.%d' % ( intf, vlan )
62 intf.name = newName
63 self.nameToIntf[ newName ] = intf
64 return r
65
pingping-linea32cf82015-10-08 22:37:37 -070066
67class SDNTopo( Topo ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070068
pingping-linea32cf82015-10-08 22:37:37 -070069 "SDN Topology"
70
71 def __init__( self, *args, **kwargs ):
72
73 Topo.__init__( self, *args, **kwargs )
74
75 # BGP peer hosts
alison62006dd2016-12-15 16:21:28 -080076 p64514 = self.addHost( 'p64514' )
77 p64515 = self.addHost( 'p64515' )
78 p64516 = self.addHost( 'p64516' )
79
80 p64517 = self.addHost( 'p64517', cls=VLANHost, vlan=20 )
81 p64518 = self.addHost( 'p64518', cls=VLANHost, vlan=20 )
82 p64519 = self.addHost( 'p64519', cls=VLANHost, vlan=10 )
83 p64520 = self.addHost( 'p64520', cls=VLANHost, vlan=10 )
pingping-linea32cf82015-10-08 22:37:37 -070084
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070085 """
86 sw1 = self.addSwitch( 'SEAT', dpid='00000000000000a1' )
87 sw2 = self.addSwitch( 'PORT', dpid='00000000000000a2' )
88 sw3 = self.addSwitch( 'SUNN', dpid='00000000000000a3' )
89 sw4 = self.addSwitch( 'RENO', dpid='00000000000000a4' )
90 sw5 = self.addSwitch( 'LOSA', dpid='00000000000000a5' )
91 sw6 = self.addSwitch( 'MISS', dpid='00000000000000a6' )
92 sw7 = self.addSwitch( 'LASV', dpid='00000000000000a7' )
93 sw8 = self.addSwitch( 'SALT', dpid='00000000000000a8' )
94 sw9 = self.addSwitch( 'PHOE', dpid='00000000000000a9' )
95 sw10 = self.addSwitch( 'TUCS', dpid='0000000000000a10' )
96 sw11 = self.addSwitch( 'DENV', dpid='0000000000000a11' )
97 sw12 = self.addSwitch( 'ELPA', dpid='0000000000000a12' )
98 sw13 = self.addSwitch( 'MINN', dpid='0000000000000a13' )
99 sw14 = self.addSwitch( 'KANS', dpid='0000000000000a14' )
100 sw15 = self.addSwitch( 'TULS', dpid='0000000000000a15' )
101 sw16 = self.addSwitch( 'DALL', dpid='0000000000000a16' )
102 sw17 = self.addSwitch( 'HOUH', dpid='0000000000000a17' )
103 sw18 = self.addSwitch( 'COLU', dpid='0000000000000a18' )
104 sw19 = self.addSwitch( 'JCSN', dpid='0000000000000a19' )
105 sw20 = self.addSwitch( 'BATO', dpid='0000000000000a20' )
106 sw21 = self.addSwitch( 'EQCH', dpid='0000000000000a21' )
107 sw22 = self.addSwitch( 'STAR', dpid='0000000000000a22' )
108 sw23 = self.addSwitch( 'CHIC', dpid='0000000000000a23' )
109 sw24 = self.addSwitch( 'INDI', dpid='0000000000000a24' )
110 sw25 = self.addSwitch( 'CINC', dpid='0000000000000a25' )
111 sw26 = self.addSwitch( 'LOUI', dpid='0000000000000a26' )
112 sw27 = self.addSwitch( 'ATLA', dpid='0000000000000a27' )
113 sw28 = self.addSwitch( 'JACK', dpid='0000000000000a28' )
114 sw29 = self.addSwitch( 'CLEV', dpid='0000000000000a29' )
115 sw30 = self.addSwitch( 'PITT', dpid='0000000000000a30' )
116 sw31 = self.addSwitch( 'ASHB', dpid='0000000000000a31' )
117 sw32 = self.addSwitch( 'WASH', dpid='0000000000000a32' )
118 sw33 = self.addSwitch( 'RALE', dpid='0000000000000a33' )
119 sw34 = self.addSwitch( 'CHAR', dpid='0000000000000a34' )
120 sw35 = self.addSwitch( 'ALBA', dpid='0000000000000a35' )
121 sw36 = self.addSwitch( 'BOST', dpid='0000000000000a36' )
122 sw37 = self.addSwitch( 'HART', dpid='0000000000000a37' )
123 sw38 = self.addSwitch( 'NEWY', dpid='0000000000000a38' )
124 sw39 = self.addSwitch( 'PHIL', dpid='0000000000000a39' )
125 """
126 sw1 = self.addSwitch( 'sw1', dpid='00000000000000a1' )
127 sw2 = self.addSwitch( 'sw2', dpid='00000000000000a2' )
128 sw3 = self.addSwitch( 'sw3', dpid='00000000000000a3' )
129 sw4 = self.addSwitch( 'sw4', dpid='00000000000000a4' )
130 sw5 = self.addSwitch( 'sw5', dpid='00000000000000a5' )
131 sw6 = self.addSwitch( 'sw6', dpid='00000000000000a6' )
132 sw7 = self.addSwitch( 'sw7', dpid='00000000000000a7' )
133 sw8 = self.addSwitch( 'sw8', dpid='00000000000000a8' )
134 sw9 = self.addSwitch( 'sw9', dpid='00000000000000a9' )
135 sw10 = self.addSwitch( 'sw10', dpid='0000000000000a10' )
136 sw11 = self.addSwitch( 'sw11', dpid='0000000000000a11' )
137 sw12 = self.addSwitch( 'sw12', dpid='0000000000000a12' )
138 sw13 = self.addSwitch( 'sw13', dpid='0000000000000a13' )
139 sw14 = self.addSwitch( 'sw14', dpid='0000000000000a14' )
140 sw15 = self.addSwitch( 'sw15', dpid='0000000000000a15' )
141 sw16 = self.addSwitch( 'sw16', dpid='0000000000000a16' )
142 sw17 = self.addSwitch( 'sw17', dpid='0000000000000a17' )
143 sw18 = self.addSwitch( 'sw18', dpid='0000000000000a18' )
144 sw19 = self.addSwitch( 'sw19', dpid='0000000000000a19' )
145 sw20 = self.addSwitch( 'sw20', dpid='0000000000000a20' )
146 sw21 = self.addSwitch( 'sw21', dpid='0000000000000a21' )
147 sw22 = self.addSwitch( 'sw22', dpid='0000000000000a22' )
148 sw23 = self.addSwitch( 'sw23', dpid='0000000000000a23' )
149 sw24 = self.addSwitch( 'sw24', dpid='0000000000000a24' )
150 sw25 = self.addSwitch( 'sw25', dpid='0000000000000a25' )
151 sw26 = self.addSwitch( 'sw26', dpid='0000000000000a26' )
152 sw27 = self.addSwitch( 'sw27', dpid='0000000000000a27' )
153 sw28 = self.addSwitch( 'sw28', dpid='0000000000000a28' )
154 sw29 = self.addSwitch( 'sw29', dpid='0000000000000a29' )
155 sw30 = self.addSwitch( 'sw30', dpid='0000000000000a30' )
156 sw31 = self.addSwitch( 'sw31', dpid='0000000000000a31' )
157 sw32 = self.addSwitch( 'sw32', dpid='0000000000000a32' )
158 sw33 = self.addSwitch( 'sw33', dpid='0000000000000a33' )
159 sw34 = self.addSwitch( 'sw34', dpid='0000000000000a34' )
160 sw35 = self.addSwitch( 'sw35', dpid='0000000000000a35' )
161 sw36 = self.addSwitch( 'sw36', dpid='0000000000000a36' )
162 sw37 = self.addSwitch( 'sw37', dpid='0000000000000a37' )
163 sw38 = self.addSwitch( 'sw38', dpid='0000000000000a38' )
164 sw39 = self.addSwitch( 'sw39', dpid='0000000000000a39' )
pingping-linea32cf82015-10-08 22:37:37 -0700165
166 # Add a layer2 switch for control plane connectivity
167 # This switch isn't part of the SDN topology
168 # We'll use the ovs-controller to turn this into a learning switch
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700169 swCtl100 = self.addSwitch( 'swCtl100', dpid='0000000000000100' )
pingping-linea32cf82015-10-08 22:37:37 -0700170
171 # BGP speaker hosts
alison62006dd2016-12-15 16:21:28 -0800172 spk1 = self.addHost( 'spk1' )
173 spk2 = self.addHost( 'spk2' )
174 spk3 = self.addHost( 'spk3', cls=VLANHost, vlan=10 )
175 spk4 = self.addHost( 'spk4', cls=VLANHost, vlan=20 )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700176 root = self.addHost( 'root', inNamespace=False, ip='0' )
pingping-linea32cf82015-10-08 22:37:37 -0700177
178 # hosts behind each AS
alison62006dd2016-12-15 16:21:28 -0800179 h64514 = self.addHost( 'h64514' )
180 h64515 = self.addHost( 'h64515' )
181 h64516 = self.addHost( 'h64516' )
pingping-linea32cf82015-10-08 22:37:37 -0700182
alison62006dd2016-12-15 16:21:28 -0800183 # VLAN hosts behind each AS
184 h64517 = self.addHost( 'h64517', cls=VLANHost, vlan=20 )
185 h64518 = self.addHost( 'h64518', cls=VLANHost, vlan=20 )
186 h64519 = self.addHost( 'h64519', cls=VLANHost, vlan=10 )
187 h64520 = self.addHost( 'h64520', cls=VLANHost, vlan=10 )
188
189 self.addLink( 'spk1', sw24 )
190 self.addLink( 'spk2', sw24 )
191 self.addLink( 'spk3', sw24 )
192 self.addLink( 'spk4', sw24 )
pingping-linea32cf82015-10-08 22:37:37 -0700193
194 # connect all switches
195 self.addLink( sw1, sw2 )
196 self.addLink( sw1, sw6 )
197 self.addLink( sw1, sw8 )
198 self.addLink( sw2, sw3 )
199 self.addLink( sw3, sw4 )
200 self.addLink( sw3, sw5 )
201 self.addLink( sw4, sw8 )
202 self.addLink( sw5, sw7 )
203 self.addLink( sw5, sw9 )
204 self.addLink( sw6, sw13 )
205 self.addLink( sw7, sw8 )
206 self.addLink( sw8, sw11 )
207 self.addLink( sw9, sw10 )
208 self.addLink( sw10, sw12 )
209 self.addLink( sw11, sw12 )
210 self.addLink( sw11, sw14 )
211 self.addLink( sw12, sw17 )
212 self.addLink( sw13, sw14 )
213 self.addLink( sw13, sw21 )
214 self.addLink( sw14, sw15 )
215 self.addLink( sw14, sw18 )
216 self.addLink( sw14, sw23 )
217 self.addLink( sw15, sw16 )
218 self.addLink( sw16, sw17 )
219 self.addLink( sw17, sw19 )
220 self.addLink( sw17, sw20 )
221 self.addLink( sw18, sw23 )
222 self.addLink( sw19, sw27 )
223 self.addLink( sw20, sw28 )
224 self.addLink( sw21, sw22 )
225 self.addLink( sw21, sw29 )
226 self.addLink( sw22, sw23 )
227 self.addLink( sw23, sw24 )
228 self.addLink( sw23, sw31 )
229 self.addLink( sw24, sw25 )
230 self.addLink( sw25, sw26 )
231 self.addLink( sw26, sw27 )
232 self.addLink( sw27, sw28 )
233 self.addLink( sw27, sw34 )
234 self.addLink( sw29, sw30 )
235 self.addLink( sw29, sw35 )
236 self.addLink( sw30, sw31 )
237 self.addLink( sw31, sw32 )
238 self.addLink( sw32, sw33 )
239 self.addLink( sw32, sw39 )
240 self.addLink( sw33, sw34 )
241 self.addLink( sw35, sw36 )
242 self.addLink( sw36, sw37 )
243 self.addLink( sw37, sw38 )
244 self.addLink( sw38, sw39 )
245
246 # connection between switches and peers
alison62006dd2016-12-15 16:21:28 -0800247 self.addLink( p64514, sw32 )
248 self.addLink( p64515, sw8 )
249 self.addLink( p64516, sw28 )
250
251 self.addLink( p64517, sw7 )
252 self.addLink( p64518, sw9 )
253 self.addLink( p64519, sw5 )
254 self.addLink( p64520, sw5 )
pingping-linea32cf82015-10-08 22:37:37 -0700255
256 # connection between BGP peer and hosts behind the BGP peer
alison62006dd2016-12-15 16:21:28 -0800257 self.addLink( p64514, h64514 )
258 self.addLink( p64515, h64515 )
259 self.addLink( p64516, h64516 )
260
261 self.addLink( p64517, h64517 )
262 self.addLink( p64518, h64518 )
263 self.addLink( p64519, h64519 )
264 self.addLink( p64520, h64520 )
pingping-linea32cf82015-10-08 22:37:37 -0700265
266 # Internal Connection To Hosts
alison62006dd2016-12-15 16:21:28 -0800267 self.addLink( swCtl100, p64514 )
268 self.addLink( swCtl100, p64515 )
269 self.addLink( swCtl100, p64516 )
pingping-linea32cf82015-10-08 22:37:37 -0700270
alison62006dd2016-12-15 16:21:28 -0800271 self.addLink( swCtl100, p64517 )
272 self.addLink( swCtl100, p64518 )
273 self.addLink( swCtl100, p64519 )
274 self.addLink( swCtl100, p64520 )
pingping-linea32cf82015-10-08 22:37:37 -0700275
alison62006dd2016-12-15 16:21:28 -0800276 self.addLink( swCtl100, spk1 )
277 self.addLink( swCtl100, spk2 )
278 self.addLink( swCtl100, spk3 )
279 self.addLink( swCtl100, spk4 )
280
281 # add h64514 to control plane for ping test
282 self.addLink( swCtl100, h64514 )
283 self.addLink( swCtl100, h64517 )
284 self.addLink( swCtl100, h64519 )
285
pingping-linea32cf82015-10-08 22:37:37 -0700286 self.addLink( swCtl100, root )
287 self.addLink( swCtl100, root )
288 self.addLink( swCtl100, root )
289
290
291def startsshd( host ):
292 "Start sshd on host"
293 info( '*** Starting sshd\n' )
294 name, intf, ip = host.name, host.defaultIntf(), host.IP()
295 banner = '/tmp/%s.banner' % name
296 host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
297 host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
298 info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
299
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700300
301def startsshds( hosts ):
pingping-linea32cf82015-10-08 22:37:37 -0700302 for h in hosts:
303 startsshd( h )
304
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700305
pingping-linea32cf82015-10-08 22:37:37 -0700306def stopsshd():
307 "Stop *all* sshd processes with a custom banner"
308 info( '*** Shutting down stale sshd/Banner processes ',
309 quietRun( "pkill -9 -f Banner" ), '\n' )
310
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700311
pingping-linea32cf82015-10-08 22:37:37 -0700312def startquagga( host, num, config_file ):
313 info( '*** Starting Quagga on %s\n' % host )
314 host.cmd( "cd %s" % QUAGGA_CONFIG_DIR )
315 zebra_cmd = \
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700316 '%s/zebra -d -f ./zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid'\
pingping-linea32cf82015-10-08 22:37:37 -0700317 % ( QUAGGA_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num )
318 quagga_cmd = '%s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' \
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700319 % ( QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num )
pingping-linea32cf82015-10-08 22:37:37 -0700320
321 print zebra_cmd
322 print quagga_cmd
323
324 host.cmd( zebra_cmd )
325 host.cmd( quagga_cmd )
326
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700327"""
pingping-linea32cf82015-10-08 22:37:37 -0700328def startQuaggaFromTeston( host, num, config_file ):
329 global net
330 h = net.get( str( host ) )
331 startquagga( h, num, config_file )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700332"""
pingping-linea32cf82015-10-08 22:37:37 -0700333def startquaggahost5( host, num ):
334 info( '*** Starting Quagga on %s\n' % host )
335 zebra_cmd = \
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700336 '%s/zebra -d -f ./zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' \
337 % ( QUAGGA_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num )
pingping-linea32cf82015-10-08 22:37:37 -0700338 quagga_cmd = \
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700339 '%s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid'\
pingping-linea32cf82015-10-08 22:37:37 -0700340 % ( QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num )
341
342 host.cmd( zebra_cmd )
343 host.cmd( quagga_cmd )
344
345
346def stopquagga():
347 quietRun( 'sudo pkill -9 -f bgpd' )
348 quietRun( 'sudo pkill -9 -f zebra' )
349
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700350
pingping-linea32cf82015-10-08 22:37:37 -0700351def sdn1net():
352 topo = SDNTopo()
353 info( '*** Creating network\n' )
354
355 # global net
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700356 net = Mininet( topo=topo, controller=RemoteController )
pingping-linea32cf82015-10-08 22:37:37 -0700357
alison62006dd2016-12-15 16:21:28 -0800358 spk1, spk2, spk3, spk4, p64514, p64515, p64516, p64517, p64518, p64519, p64520 = \
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700359 net.get( 'spk1', 'spk2', 'spk3', 'spk4',
360 'p64514', 'p64515', 'p64516', 'p64517', 'p64518', 'p64519', 'p64520' )
pingping-linea32cf82015-10-08 22:37:37 -0700361
362 # Adding addresses to speakers' interface connected to sw24
363 # for BGP peering
alison62006dd2016-12-15 16:21:28 -0800364 spk1.setMAC( '00:00:00:00:00:01', 'spk1-eth0' )
365 spk1.cmd( 'ip addr add 10.0.4.101/24 dev spk1-eth0' )
366 spk1.cmd( 'ip addr add 10.0.5.101/24 dev spk1-eth0' )
367 spk1.cmd( 'ip addr add 10.0.6.101/24 dev spk1-eth0' )
pingping-linea32cf82015-10-08 22:37:37 -0700368
alison62006dd2016-12-15 16:21:28 -0800369 spk1.defaultIntf().setIP( '10.0.4.101/24' )
370 spk1.defaultIntf().setMAC( '00:00:00:00:00:01' )
pingping-linea32cf82015-10-08 22:37:37 -0700371
alison62006dd2016-12-15 16:21:28 -0800372 spk2.setMAC( '00:00:00:00:00:02', 'spk2-eth0' )
373 spk2.cmd( 'ip addr add 10.0.14.101/24 dev spk2-eth0' )
374 spk2.cmd( 'ip addr add 10.0.15.101/24 dev spk2-eth0' )
375 spk2.cmd( 'ip addr add 10.0.16.101/24 dev spk2-eth0' )
pingping-linea32cf82015-10-08 22:37:37 -0700376
alison62006dd2016-12-15 16:21:28 -0800377 spk2.defaultIntf().setIP( '10.0.14.101/24' )
378 spk2.defaultIntf().setMAC( '00:00:00:00:00:02' )
379
380 spk3.setMAC( '00:00:00:00:00:03', 'spk3-eth0.10' )
381 spk3.cmd( 'ip addr add 10.0.9.101/24 dev spk3-eth0.10' )
382 spk3.cmd( 'ip addr add 10.0.20.101/24 dev spk3-eth0.10' )
383 spk3.defaultIntf().setIP( '10.1.9.101/24' )
384 spk3.defaultIntf().setMAC( '00:00:00:00:00:03' )
385
386 spk4.setMAC( '00:00:00:00:00:04', 'spk4-eth0.20' )
387 spk4.cmd( 'ip addr add 10.0.7.101/24 dev spk4-eth0.20' )
388 spk4.cmd( 'ip addr add 10.0.8.101/24 dev spk4-eth0.20' )
389 spk4.defaultIntf().setIP( '10.1.7.101/24' )
390 spk4.defaultIntf().setMAC( '00:00:00:00:00:04' )
391
392 p64517.config( vlan=20, intfName="p64517-eth1", ip="7.0.0.254" )
393 p64518.config( vlan=20, intfName="p64518-eth1", ip="8.0.0.254" )
394 p64519.config( vlan=10, intfName="p64519-eth1", ip="9.0.0.254" )
395 p64520.config( vlan=10, intfName="p64520-eth1", ip="20.0.0.254" )
pingping-linea32cf82015-10-08 22:37:37 -0700396
397 # Net has to be start after adding the above link
398 net.start()
399
400 # setup configuration on the interface connected to switch
alison62006dd2016-12-15 16:21:28 -0800401 p64514.cmd( "ifconfig p64514-eth0 10.0.4.1 up" )
402 p64514.cmd( "ip addr add 10.0.14.1/24 dev p64514-eth0" )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700403 p64514.setMAC( '00:00:00:00:00:14', 'p64514-eth0' ) # do not repeat spk4's MAC addr
alison62006dd2016-12-15 16:21:28 -0800404 p64515.cmd( "ifconfig p64515-eth0 10.0.5.1 up" )
405 p64515.cmd( "ip addr add 10.0.15.1/24 dev p64515-eth0" )
406 p64515.setMAC( '00:00:00:00:00:05', 'p64515-eth0' )
407 p64516.cmd( "ifconfig p64516-eth0 10.0.6.1 up" )
408 p64516.cmd( "ip addr add 10.0.16.1/24 dev p64516-eth0" )
409 p64516.setMAC( '00:00:00:00:00:06', 'p64516-eth0' )
410
411 p64517.cmd( "ifconfig p64517-eth0.20 10.0.7.1 up" )
412 p64517.setMAC( '00:00:00:00:00:07', 'p64517-eth0.20' )
413 p64518.cmd( "ifconfig p64518-eth0.20 10.0.8.1 up" )
414 p64518.setMAC( '00:00:00:00:00:08', 'p64518-eth0.20' )
415
416 p64519.cmd( "ifconfig p64519-eth0.10 10.0.9.1 up" )
417 p64519.setMAC( '00:00:00:00:00:09', 'p64519-eth0.10' )
418 p64520.cmd( "ifconfig p64520-eth0.10 10.0.20.1 up" )
419 p64520.setMAC( '00:00:00:00:00:20', 'p64520-eth0.10' )
pingping-linea32cf82015-10-08 22:37:37 -0700420
421 # setup configuration on the interface connected to hosts
alison62006dd2016-12-15 16:21:28 -0800422 p64514.setIP( "4.0.0.254", 8, "p64514-eth1" )
423 p64514.setMAC( '00:00:00:00:00:44', 'p64514-eth1' )
424 p64515.setIP( "5.0.0.254", 8, "p64515-eth1" )
425 p64515.setMAC( '00:00:00:00:00:55', 'p64515-eth1' )
426 p64516.setIP( "6.0.0.254", 8, "p64516-eth1" )
427 p64516.setMAC( '00:00:00:00:00:66', 'p64516-eth1' )
428
429 p64517.setIP( "7.0.0.254", 8, "p64517-eth1.20" )
430 p64517.setMAC( '00:00:00:00:00:77', 'p64517-eth1.20' )
431 p64518.setIP( "8.0.0.254", 8, "p64518-eth1.20" )
432 p64518.setMAC( '00:00:00:00:00:88', 'p64518-eth1.20' )
433
434 p64519.setIP( "9.0.0.254", 8, "p64519-eth1.10" )
435 p64519.setMAC( '00:00:00:00:00:99', 'p64519-eth1.10' )
436 p64520.setIP( "20.0.0.254", 8, "p64520-eth1.10" )
437 p64520.setMAC( '00:00:00:00:00:20', 'p64520-eth1.10' )
pingping-linea32cf82015-10-08 22:37:37 -0700438
439 # enable forwarding on BGP peer hosts
alison62006dd2016-12-15 16:21:28 -0800440 p64514.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
441 p64515.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
442 p64516.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
443
444 p64517.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
445 p64518.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
446 p64519.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
447 p64520.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
pingping-linea32cf82015-10-08 22:37:37 -0700448
449 # config interface for control plane connectivity
alison62006dd2016-12-15 16:21:28 -0800450 p64514.setIP( "192.168.0.4", 24, "p64514-eth2" )
451 p64515.setIP( "192.168.0.5", 24, "p64515-eth2" )
452 p64516.setIP( "192.168.0.6", 24, "p64516-eth2" )
453
454 p64517.setIP( "192.168.0.7", 24, "p64517-eth2" )
455 p64518.setIP( "192.168.0.8", 24, "p64518-eth2" )
456 p64519.setIP( "192.168.0.9", 24, "p64519-eth2" )
457 p64520.setIP( "192.168.0.20", 24, "p64520-eth2" )
pingping-linea32cf82015-10-08 22:37:37 -0700458
459 # Setup hosts in each non-SDN AS
alison62006dd2016-12-15 16:21:28 -0800460 h64514, h64515, h64516, h64517, h64518, h64519, h64520 = \
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700461 net.get( 'h64514', 'h64515', 'h64516', 'h64517', 'h64518', 'h64519', 'h64520' )
alison62006dd2016-12-15 16:21:28 -0800462 h64514.cmd( 'ifconfig h64514-eth0 4.0.0.1 up' )
463 h64514.cmd( 'ip route add default via 4.0.0.254' )
464 h64514.setIP( '192.168.0.44', 24, 'h64514-eth1' ) # for control plane
465 h64515.cmd( 'ifconfig h64515-eth0 5.0.0.1 up' )
466 h64515.cmd( 'ip route add default via 5.0.0.254' )
467 h64516.cmd( 'ifconfig h64516-eth0 6.0.0.1 up' )
468 h64516.cmd( 'ip route add default via 6.0.0.254' )
469
470 h64517.cmd( 'ifconfig h64517-eth0.20 7.0.0.1 up' )
471 h64517.cmd( 'ip route add default via 7.0.0.254' )
472 h64517.setIP( '192.168.0.77', 24, 'h64517-eth1' ) # for control plane
473 h64518.cmd( 'ifconfig h64518-eth0.20 8.0.0.1 up' )
474 h64518.cmd( 'ip route add default via 8.0.0.254' )
475
476 h64519.cmd( 'ifconfig h64519-eth0.10 9.0.0.1 up' )
477 h64519.cmd( 'ip route add default via 9.0.0.254' )
478 h64519.setIP( '192.168.0.99', 24, 'h64519-eth1' ) # for control plane
479 h64520.cmd( 'ifconfig h64520-eth0.10 20.0.0.1 up' )
480 h64520.cmd( 'ip route add default via 20.0.0.254' )
pingping-linea32cf82015-10-08 22:37:37 -0700481
pingping-linea32cf82015-10-08 22:37:37 -0700482 # set up swCtl100 as a learning
483 swCtl100 = net.get( 'swCtl100' )
484 swCtl100.cmd( 'ovs-vsctl set-controller swCtl100 none' )
485 swCtl100.cmd( 'ovs-vsctl set-fail-mode swCtl100 standalone' )
486
487 # connect all switches to controller
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700488 """
pingping-linea32cf82015-10-08 22:37:37 -0700489 onos1IP = "10.128.4.52"
490 onos2IP = "10.128.4.53"
491 onos3IP = "10.128.4.54"
492 for i in range ( 1, numSw + 1 ):
493 swX = net.get( 'sw%s' % ( i ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700494 swX.cmd( 'ovs-vsctl set-controller sw%s tcp:%s:6653 tcp:%s:6653 tcp:%s:6653' % ( i, onos1IP, onos2IP, onos3IP ) )
495 """
pingping-linea32cf82015-10-08 22:37:37 -0700496 # Start Quagga on border routers
alison62006dd2016-12-15 16:21:28 -0800497 startquagga( p64514, 64514, 'quagga64514.conf' )
498 startquagga( p64515, 64515, 'quagga64515.conf' )
499 startquagga( p64516, 64516, 'quagga64516.conf' )
500
501 startquagga( p64517, 64517, 'quagga64517.conf' )
502 startquagga( p64518, 64518, 'quagga64518.conf' )
503 startquagga( p64519, 64519, 'quagga64519.conf' )
504 startquagga( p64520, 64520, 'quagga64520.conf' )
pingping-linea32cf82015-10-08 22:37:37 -0700505
506 # start Quagga in SDN network
alison62006dd2016-12-15 16:21:28 -0800507 startquagga( spk1, 64513, 'quagga-sdn.conf' )
508 startquagga( spk2, 64512, 'quagga-sdn-speaker2.conf' )
509 startquagga( spk3, 64511, 'quagga-sdn3.conf' )
510 startquagga( spk4, 64510, 'quagga-sdn4.conf' )
pingping-linea32cf82015-10-08 22:37:37 -0700511
512 root = net.get( 'root' )
513 root.intf( 'root-eth0' ).setIP( '1.1.1.2/24' )
514 root.cmd( 'ip addr add 192.168.0.100/24 dev root-eth0' )
515
516 root.intf( 'root-eth1' ).setIP( '1.1.1.4/24' )
517 root.cmd( 'ip addr add 192.168.0.101/24 dev root-eth1' )
518
519 root.intf( 'root-eth2' ).setIP( '1.1.1.6/24' )
520 root.cmd( 'ip addr add 192.168.0.102/24 dev root-eth2' )
521
alison62006dd2016-12-15 16:21:28 -0800522 spk1.intf( 'spk1-eth1' ).setIP( '1.1.1.1/24' )
523 spk2.intf( 'spk2-eth1' ).setIP( '1.1.1.3/24' )
524 spk3.intf( 'spk3-eth1' ).setIP( '1.1.1.5/24' )
525 spk4.intf( 'spk4-eth1' ).setIP( '1.1.1.7/24' )
pingping-linea32cf82015-10-08 22:37:37 -0700526
pingping-linea32cf82015-10-08 22:37:37 -0700527 stopsshd()
528
alison62006dd2016-12-15 16:21:28 -0800529 hosts = [ p64514, p64515, p64516, p64517, p64518, p64519, p64520,
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700530 h64514, h64517, h64519 ]
pingping-linea32cf82015-10-08 22:37:37 -0700531 startsshds( hosts )
532
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700533 """
pingping-linea32cf82015-10-08 22:37:37 -0700534 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', onos1IP )
535 root.cmd( 'ssh -nNT -o "PasswordAuthentication no" \
536 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, onos1IP ) )
537
538 forwarding2 = '%s:2000:%s:2000' % ( '1.1.1.4', onos2IP )
539 root.cmd( 'ssh -nNT -o "PasswordAuthentication no" \
540 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding2, onos2IP ) )
541
542 forwarding3 = '%s:2000:%s:2000' % ( '1.1.1.6', onos3IP )
543 root.cmd( 'ssh -nNT -o "PasswordAuthentication no" \
544 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding3, onos3IP ) )
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -0700545 """
pingping-linea32cf82015-10-08 22:37:37 -0700546 CLI( net )
547
548 stopsshd()
549 stopquagga()
550 net.stop()
551
552
553if __name__ == '__main__':
554 setLogLevel( 'debug' )
555 sdn1net()