blob: 71907ea15156e178c7c507c414520261927271ad [file] [log] [blame]
pingping-lin117a43b2015-09-08 17:40:53 -07001#!/usr/bin/python
2
3"""
4Set up the SDN-IP topology as same as it on Internet2
5"""
6
7"""
8AS 64513, (SDN AS)
9AS 64514, reachable by 10.0.4.1
10AS 64515, reachable by 10.0.5.1
11AS 64516, reachable by 10.0.6.1
12"""
13
14from mininet.net import Mininet
pingping-lin117a43b2015-09-08 17:40:53 -070015from mininet.log import setLogLevel, info
16from mininet.cli import CLI
alisone4121a92016-11-22 16:31:36 -080017from mininet.node import Host, RemoteController
pingping-lin117a43b2015-09-08 17:40:53 -070018from mininet.topo import Topo
19from mininet.util import quietRun
pingping-lin117a43b2015-09-08 17:40:53 -070020
21QUAGGA_DIR = '/usr/lib/quagga'
22QUAGGA_RUN_DIR = '/usr/local/var/run/quagga'
Jon Hallfabd7e52016-04-19 19:20:59 -070023QUAGGA_CONFIG_DIR = '~/OnosSystemTest/TestON/tests/USECASE/USECASE_SdnipFunction/dependencies/'
pingping-lin5bb663b2015-09-24 11:47:50 -070024# onos1IP = '10.254.1.201'
pingping-lin117a43b2015-09-08 17:40:53 -070025numSw = 39
26
alisone4121a92016-11-22 16:31:36 -080027class VLANHost( Host ):
28 def config( self, vlan=100, intfName=None, **params ):
29 r = super( Host, self ).config( **params )
30 intf = self.intf( intfName )
31 self.cmd( 'ifconfig %s inet 0' % intf )
32 self.cmd( 'vconfig add %s %d' % ( intf, vlan ) )
33 self.cmd( 'ifconfig %s.%d inet %s' % ( intf, vlan, params['ip'] ) )
34 newName = '%s.%d' % ( intf, vlan )
35 intf.name = newName
36 self.nameToIntf[ newName ] = intf
37 return r
38
pingping-lin117a43b2015-09-08 17:40:53 -070039
40class SDNTopo( Topo ):
41 "SDN Topology"
42
43 def __init__( self, *args, **kwargs ):
44
45 Topo.__init__( self, *args, **kwargs )
46
47 # BGP peer hosts
alisone4121a92016-11-22 16:31:36 -080048 p64514 = self.addHost( 'p64514' )
49 p64515 = self.addHost( 'p64515' )
50 p64516 = self.addHost( 'p64516' )
51
52 p64517 = self.addHost( 'p64517', cls=VLANHost, vlan=20 )
53 p64518 = self.addHost( 'p64518', cls=VLANHost, vlan=20 )
54 p64519 = self.addHost( 'p64519', cls=VLANHost, vlan=10 )
55 p64520 = self.addHost( 'p64520', cls=VLANHost, vlan=10 )
pingping-lin117a43b2015-09-08 17:40:53 -070056
57 '''
58 sw1 = self.addSwitch( 'SEAT', dpid = '00000000000000a1' )
59 sw2 = self.addSwitch( 'PORT', dpid = '00000000000000a2' )
60 sw3 = self.addSwitch( 'SUNN', dpid = '00000000000000a3' )
61 sw4 = self.addSwitch( 'RENO', dpid = '00000000000000a4' )
62 sw5 = self.addSwitch( 'LOSA', dpid = '00000000000000a5' )
63 sw6 = self.addSwitch( 'MISS', dpid = '00000000000000a6' )
64 sw7 = self.addSwitch( 'LASV', dpid = '00000000000000a7' )
65 sw8 = self.addSwitch( 'SALT', dpid = '00000000000000a8' )
66 sw9 = self.addSwitch( 'PHOE', dpid = '00000000000000a9' )
67 sw10 = self.addSwitch( 'TUCS', dpid = '0000000000000a10' )
68 sw11 = self.addSwitch( 'DENV', dpid = '0000000000000a11' )
69 sw12 = self.addSwitch( 'ELPA', dpid = '0000000000000a12' )
70 sw13 = self.addSwitch( 'MINN', dpid = '0000000000000a13' )
71 sw14 = self.addSwitch( 'KANS', dpid = '0000000000000a14' )
72 sw15 = self.addSwitch( 'TULS', dpid = '0000000000000a15' )
73 sw16 = self.addSwitch( 'DALL', dpid = '0000000000000a16' )
74 sw17 = self.addSwitch( 'HOUH', dpid = '0000000000000a17' )
75 sw18 = self.addSwitch( 'COLU', dpid = '0000000000000a18' )
76 sw19 = self.addSwitch( 'JCSN', dpid = '0000000000000a19' )
77 sw20 = self.addSwitch( 'BATO', dpid = '0000000000000a20' )
78 sw21 = self.addSwitch( 'EQCH', dpid = '0000000000000a21' )
79 sw22 = self.addSwitch( 'STAR', dpid = '0000000000000a22' )
80 sw23 = self.addSwitch( 'CHIC', dpid = '0000000000000a23' )
81 sw24 = self.addSwitch( 'INDI', dpid = '0000000000000a24' )
82 sw25 = self.addSwitch( 'CINC', dpid = '0000000000000a25' )
83 sw26 = self.addSwitch( 'LOUI', dpid = '0000000000000a26' )
84 sw27 = self.addSwitch( 'ATLA', dpid = '0000000000000a27' )
85 sw28 = self.addSwitch( 'JACK', dpid = '0000000000000a28' )
86 sw29 = self.addSwitch( 'CLEV', dpid = '0000000000000a29' )
87 sw30 = self.addSwitch( 'PITT', dpid = '0000000000000a30' )
88 sw31 = self.addSwitch( 'ASHB', dpid = '0000000000000a31' )
89 sw32 = self.addSwitch( 'WASH', dpid = '0000000000000a32' )
90 sw33 = self.addSwitch( 'RALE', dpid = '0000000000000a33' )
91 sw34 = self.addSwitch( 'CHAR', dpid = '0000000000000a34' )
92 sw35 = self.addSwitch( 'ALBA', dpid = '0000000000000a35' )
93 sw36 = self.addSwitch( 'BOST', dpid = '0000000000000a36' )
94 sw37 = self.addSwitch( 'HART', dpid = '0000000000000a37' )
95 sw38 = self.addSwitch( 'NEWY', dpid = '0000000000000a38' )
96 sw39 = self.addSwitch( 'PHIL', dpid = '0000000000000a39' )
97 '''
98 sw1 = self.addSwitch( 'sw1', dpid = '00000000000000a1' )
99 sw2 = self.addSwitch( 'sw2', dpid = '00000000000000a2' )
100 sw3 = self.addSwitch( 'sw3', dpid = '00000000000000a3' )
101 sw4 = self.addSwitch( 'sw4', dpid = '00000000000000a4' )
102 sw5 = self.addSwitch( 'sw5', dpid = '00000000000000a5' )
103 sw6 = self.addSwitch( 'sw6', dpid = '00000000000000a6' )
104 sw7 = self.addSwitch( 'sw7', dpid = '00000000000000a7' )
105 sw8 = self.addSwitch( 'sw8', dpid = '00000000000000a8' )
106 sw9 = self.addSwitch( 'sw9', dpid = '00000000000000a9' )
107 sw10 = self.addSwitch( 'sw10', dpid = '0000000000000a10' )
108 sw11 = self.addSwitch( 'sw11', dpid = '0000000000000a11' )
109 sw12 = self.addSwitch( 'sw12', dpid = '0000000000000a12' )
110 sw13 = self.addSwitch( 'sw13', dpid = '0000000000000a13' )
111 sw14 = self.addSwitch( 'sw14', dpid = '0000000000000a14' )
112 sw15 = self.addSwitch( 'sw15', dpid = '0000000000000a15' )
113 sw16 = self.addSwitch( 'sw16', dpid = '0000000000000a16' )
114 sw17 = self.addSwitch( 'sw17', dpid = '0000000000000a17' )
115 sw18 = self.addSwitch( 'sw18', dpid = '0000000000000a18' )
116 sw19 = self.addSwitch( 'sw19', dpid = '0000000000000a19' )
117 sw20 = self.addSwitch( 'sw20', dpid = '0000000000000a20' )
118 sw21 = self.addSwitch( 'sw21', dpid = '0000000000000a21' )
119 sw22 = self.addSwitch( 'sw22', dpid = '0000000000000a22' )
120 sw23 = self.addSwitch( 'sw23', dpid = '0000000000000a23' )
121 sw24 = self.addSwitch( 'sw24', dpid = '0000000000000a24' )
122 sw25 = self.addSwitch( 'sw25', dpid = '0000000000000a25' )
123 sw26 = self.addSwitch( 'sw26', dpid = '0000000000000a26' )
124 sw27 = self.addSwitch( 'sw27', dpid = '0000000000000a27' )
125 sw28 = self.addSwitch( 'sw28', dpid = '0000000000000a28' )
126 sw29 = self.addSwitch( 'sw29', dpid = '0000000000000a29' )
127 sw30 = self.addSwitch( 'sw30', dpid = '0000000000000a30' )
128 sw31 = self.addSwitch( 'sw31', dpid = '0000000000000a31' )
129 sw32 = self.addSwitch( 'sw32', dpid = '0000000000000a32' )
130 sw33 = self.addSwitch( 'sw33', dpid = '0000000000000a33' )
131 sw34 = self.addSwitch( 'sw34', dpid = '0000000000000a34' )
132 sw35 = self.addSwitch( 'sw35', dpid = '0000000000000a35' )
133 sw36 = self.addSwitch( 'sw36', dpid = '0000000000000a36' )
134 sw37 = self.addSwitch( 'sw37', dpid = '0000000000000a37' )
135 sw38 = self.addSwitch( 'sw38', dpid = '0000000000000a38' )
136 sw39 = self.addSwitch( 'sw39', dpid = '0000000000000a39' )
137
138
139 # Add a layer2 switch for control plane connectivity
140 # This switch isn't part of the SDN topology
141 # We'll use the ovs-controller to turn this into a learning switch
142 swCtl100 = self.addSwitch( 'swCtl100', dpid = '0000000000000100' )
143
144
145 # BGP speaker hosts
alisone4121a92016-11-22 16:31:36 -0800146 spk1 = self.addHost( 'spk1' )
147 spk2 = self.addHost( 'spk2', cls=VLANHost, vlan=20 )
148 spk3 = self.addHost( 'spk3', cls=VLANHost, vlan=10 )
pingping-lin117a43b2015-09-08 17:40:53 -0700149
150 root = self.addHost( 'root', inNamespace = False , ip = '0' )
151
152 # hosts behind each AS
alisone4121a92016-11-22 16:31:36 -0800153 h64514 = self.addHost( 'h64514' )
154 h64515 = self.addHost( 'h64515' )
155 h64516 = self.addHost( 'h64516' )
pingping-lin117a43b2015-09-08 17:40:53 -0700156
alisone4121a92016-11-22 16:31:36 -0800157 #VLAN hosts behind each AS
158 h64517 = self.addHost( 'h64517', cls=VLANHost, vlan=20 )
159 h64518 = self.addHost( 'h64518', cls=VLANHost, vlan=20 )
160 h64519 = self.addHost( 'h64519', cls=VLANHost, vlan=10 )
161 h64520 = self.addHost( 'h64520', cls=VLANHost, vlan=10 )
162
163 self.addLink( 'spk1', sw24 )
164 self.addLink( 'spk2', sw24 )
165 self.addLink( 'spk3', sw24 )
pingping-lin117a43b2015-09-08 17:40:53 -0700166
167 # connect all switches
168 self.addLink( sw1, sw2 )
169 self.addLink( sw1, sw6 )
170 self.addLink( sw1, sw8 )
171 self.addLink( sw2, sw3 )
172 self.addLink( sw3, sw4 )
173 self.addLink( sw3, sw5 )
174 self.addLink( sw4, sw8 )
175 self.addLink( sw5, sw7 )
176 self.addLink( sw5, sw9 )
177 self.addLink( sw6, sw13 )
178 self.addLink( sw7, sw8 )
179 self.addLink( sw8, sw11 )
180 self.addLink( sw9, sw10 )
181 self.addLink( sw10, sw12 )
182 self.addLink( sw11, sw12 )
183 self.addLink( sw11, sw14 )
184 self.addLink( sw12, sw17 )
185 self.addLink( sw13, sw14 )
186 self.addLink( sw13, sw21 )
187 self.addLink( sw14, sw15 )
188 self.addLink( sw14, sw18 )
189 self.addLink( sw14, sw23 )
190 self.addLink( sw15, sw16 )
191 self.addLink( sw16, sw17 )
192 self.addLink( sw17, sw19 )
193 self.addLink( sw17, sw20 )
194 self.addLink( sw18, sw23 )
195 self.addLink( sw19, sw27 )
196 self.addLink( sw20, sw28 )
197 self.addLink( sw21, sw22 )
198 self.addLink( sw21, sw29 )
199 self.addLink( sw22, sw23 )
200 self.addLink( sw23, sw24 )
201 self.addLink( sw23, sw31 )
202 self.addLink( sw24, sw25 )
203 self.addLink( sw25, sw26 )
204 self.addLink( sw26, sw27 )
205 self.addLink( sw27, sw28 )
206 self.addLink( sw27, sw34 )
207 self.addLink( sw29, sw30 )
208 self.addLink( sw29, sw35 )
209 self.addLink( sw30, sw31 )
210 self.addLink( sw31, sw32 )
211 self.addLink( sw32, sw33 )
212 self.addLink( sw32, sw39 )
213 self.addLink( sw33, sw34 )
214 self.addLink( sw35, sw36 )
215 self.addLink( sw36, sw37 )
216 self.addLink( sw37, sw38 )
217 self.addLink( sw38, sw39 )
218
219 # connection between switches and peers
alisone4121a92016-11-22 16:31:36 -0800220 self.addLink( p64514, sw32 )
221 self.addLink( p64515, sw8 )
222 self.addLink( p64516, sw28 )
223
224 self.addLink( p64517, sw7 )
225 self.addLink( p64518, sw9 )
226 self.addLink( p64519, sw5 )
227 self.addLink( p64520, sw5 ) # should be sw5
pingping-lin117a43b2015-09-08 17:40:53 -0700228
229 # connection between BGP peer and hosts behind the BGP peer
alisone4121a92016-11-22 16:31:36 -0800230 self.addLink( p64514, h64514 )
231 self.addLink( p64515, h64515 )
232 self.addLink( p64516, h64516 )
233
234 self.addLink( p64517, h64517 )
235 self.addLink( p64518, h64518 )
236 self.addLink( p64519, h64519 )
237 self.addLink( p64520, h64520 )
238
pingping-lin117a43b2015-09-08 17:40:53 -0700239
240 # Internal Connection To Hosts
alisone4121a92016-11-22 16:31:36 -0800241 self.addLink( swCtl100, p64514 )
242 self.addLink( swCtl100, p64515 )
243 self.addLink( swCtl100, p64516 )
244
245 self.addLink( swCtl100, p64517 )
246 self.addLink( swCtl100, p64518 )
247 self.addLink( swCtl100, p64519 )
248 self.addLink( swCtl100, p64520 )
249
250 self.addLink( swCtl100, spk1 )
251 self.addLink( swCtl100, spk2 )
252 self.addLink( swCtl100, spk3 )
pingping-lin117a43b2015-09-08 17:40:53 -0700253
254
alisone4121a92016-11-22 16:31:36 -0800255 # add h64514 to control plane for ping test
256 self.addLink( swCtl100, h64514 )
257 self.addLink( swCtl100, h64517 )
258 self.addLink( swCtl100, h64519 )
pingping-lin117a43b2015-09-08 17:40:53 -0700259 self.addLink( swCtl100, root )
260
261
262def startsshd( host ):
263 "Start sshd on host"
264 info( '*** Starting sshd\n' )
265 name, intf, ip = host.name, host.defaultIntf(), host.IP()
266 banner = '/tmp/%s.banner' % name
267 host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) )
268 host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' )
269 info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' )
270
271def startsshds ( hosts ):
272 for h in hosts:
273 startsshd( h )
274
275def stopsshd():
276 "Stop *all* sshd processes with a custom banner"
277 info( '*** Shutting down stale sshd/Banner processes ',
278 quietRun( "pkill -9 -f Banner" ), '\n' )
279
280def startquagga( host, num, config_file ):
281 info( '*** Starting Quagga on %s\n' % host )
pingping-lin950b50d2015-09-14 12:00:08 -0700282 host.cmd( "cd %s" % QUAGGA_CONFIG_DIR )
pingping-lin117a43b2015-09-08 17:40:53 -0700283 zebra_cmd = \
284 '%s/zebra -d -f ./zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid'\
285 % ( QUAGGA_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num )
286 quagga_cmd = '%s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' \
287 % ( QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num )
288
289 print zebra_cmd
290 print quagga_cmd
291
292 host.cmd( zebra_cmd )
293 host.cmd( quagga_cmd )
294
295def startquaggahost5( host, num ):
296 info( '*** Starting Quagga on %s\n' % host )
297 zebra_cmd = \
298 '%s/zebra -d -f ./zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' \
299 % ( QUAGGA_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num )
300 quagga_cmd = \
301 '%s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid'\
302 % ( QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num )
303
304 host.cmd( zebra_cmd )
305 host.cmd( quagga_cmd )
306
pingping-lin117a43b2015-09-08 17:40:53 -0700307def stopquagga():
308 quietRun( 'sudo pkill -9 -f bgpd' )
309 quietRun( 'sudo pkill -9 -f zebra' )
310
311def sdn1net():
312 topo = SDNTopo()
313 info( '*** Creating network\n' )
314 # time.sleep( 30 )
315 net = Mininet( topo = topo, controller = RemoteController )
316
317
alisone4121a92016-11-22 16:31:36 -0800318 spk1, spk2, spk3, p64514, p64515, p64516, p64517, p64518, p64519, p64520 = \
319 net.get( 'spk1', 'spk2', 'spk3',
320 'p64514', 'p64515', 'p64516', 'p64517', 'p64518', 'p64519', 'p64520' )
pingping-lin117a43b2015-09-08 17:40:53 -0700321
322 # Adding addresses to host64513_1 interface connected to sw24
323 # for BGP peering
alisone4121a92016-11-22 16:31:36 -0800324 spk1.setMAC( '00:00:00:00:00:01', 'spk1-eth0' )
325 spk1.cmd( 'ip addr add 10.0.4.101/24 dev spk1-eth0' )
326 spk1.cmd( 'ip addr add 10.0.5.101/24 dev spk1-eth0' )
327 spk1.cmd( 'ip addr add 10.0.6.101/24 dev spk1-eth0' )
328 spk1.defaultIntf().setIP( '10.1.4.101/24' )
329 spk1.defaultIntf().setMAC( '00:00:00:00:00:01' )
pingping-lin117a43b2015-09-08 17:40:53 -0700330
alisone4121a92016-11-22 16:31:36 -0800331 spk2.setMAC( '00:00:00:00:00:02', 'spk2-eth0.20' )
332 spk2.cmd( 'ip addr add 10.0.7.101/24 dev spk2-eth0.20' )
333 spk2.cmd( 'ip addr add 10.0.8.101/24 dev spk2-eth0.20' )
334 spk2.defaultIntf().setIP( '10.1.7.101/24' )
335 spk2.defaultIntf().setMAC( '00:00:00:00:00:02' )
336
337 spk3.setMAC( '00:00:00:00:00:03', 'spk3-eth0.10' )
338 spk3.cmd( 'ip addr add 10.0.9.101/24 dev spk3-eth0.10' )
339 spk3.cmd( 'ip addr add 10.0.20.101/24 dev spk3-eth0.10' )
340 spk3.defaultIntf().setIP( '10.1.9.101/24' )
341 spk3.defaultIntf().setMAC( '00:00:00:00:00:03' )
342
343 p64517.config( vlan=20, intfName="p64517-eth1", ip="7.0.0.254" )
344 p64518.config( vlan=20, intfName="p64518-eth1", ip="8.0.0.254" )
345 p64519.config( vlan=10, intfName="p64519-eth1", ip="9.0.0.254" )
346 p64520.config( vlan=10, intfName="p64520-eth1", ip="20.0.0.254" )
pingping-lin117a43b2015-09-08 17:40:53 -0700347
348 # Net has to be start after adding the above link
349 net.start()
350
351 # setup configuration on the interface connected to switch
alisone4121a92016-11-22 16:31:36 -0800352 p64514.cmd( "ifconfig p64514-eth0 10.0.4.1 up" )
353 p64514.setMAC( '00:00:00:00:00:04', 'p64514-eth0' )
354 p64515.cmd( "ifconfig p64515-eth0 10.0.5.1 up" )
355 p64515.setMAC( '00:00:00:00:00:05', 'p64515-eth0' )
356 p64516.cmd( "ifconfig p64516-eth0 10.0.6.1 up" )
357 p64516.setMAC( '00:00:00:00:00:06', 'p64516-eth0' )
358
359 p64517.cmd( "ifconfig p64517-eth0.20 10.0.7.1 up" )
360 p64517.setMAC( '00:00:00:00:00:07', 'p64517-eth0.20' )
361 p64518.cmd( "ifconfig p64518-eth0.20 10.0.8.1 up" )
362 p64518.setMAC( '00:00:00:00:00:08', 'p64518-eth0.20' )
363
364 p64519.cmd( "ifconfig p64519-eth0.10 10.0.9.1 up" )
365 p64519.setMAC( '00:00:00:00:00:09', 'p64519-eth0.10' )
366 p64520.cmd( "ifconfig p64520-eth0.10 10.0.20.1 up" )
367 p64520.setMAC( '00:00:00:00:00:20', 'p64520-eth0.10' )
pingping-lin117a43b2015-09-08 17:40:53 -0700368
369 # setup configuration on the interface connected to hosts
alisone4121a92016-11-22 16:31:36 -0800370 p64514.setIP( "4.0.0.254", 8, "p64514-eth1" )
371 p64514.setMAC( '00:00:00:00:00:44', 'p64514-eth1' )
372 p64515.setIP( "5.0.0.254", 8, "p64515-eth1" )
373 p64515.setMAC( '00:00:00:00:00:55', 'p64515-eth1' )
374 p64516.setIP( "6.0.0.254", 8, "p64516-eth1" )
375 p64516.setMAC( '00:00:00:00:00:66', 'p64516-eth1' )
376
377 p64517.setIP( "7.0.0.254", 8, "p64517-eth1.20" )
378 p64517.setMAC( '00:00:00:00:00:77', 'p64517-eth1.20' )
379 p64518.setIP( "8.0.0.254", 8, "p64518-eth1.20" )
380 p64518.setMAC( '00:00:00:00:00:88', 'p64518-eth1.20' )
381
382 p64519.setIP( "9.0.0.254", 8, "p64519-eth1.10" )
383 p64519.setMAC( '00:00:00:00:00:99', 'p64519-eth1.10' )
384 p64520.setIP( "20.0.0.254", 8, "p64520-eth1.10" )
385 p64520.setMAC( '00:00:00:00:00:20', 'p64520-eth1.10' )
386
pingping-lin117a43b2015-09-08 17:40:53 -0700387
388 # enable forwarding on BGP peer hosts
alisone4121a92016-11-22 16:31:36 -0800389 p64514.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
390 p64515.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
391 p64516.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
392
393 p64517.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
394 p64518.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
395 p64519.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
396 p64520.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' )
pingping-lin117a43b2015-09-08 17:40:53 -0700397
398 # config interface for control plane connectivity
alisone4121a92016-11-22 16:31:36 -0800399 p64514.setIP( "192.168.0.4", 24, "p64514-eth2" )
400 p64515.setIP( "192.168.0.5", 24, "p64515-eth2" )
401 p64516.setIP( "192.168.0.6", 24, "p64516-eth2" )
402
403 p64517.setIP( "192.168.0.7", 24, "p64517-eth2" )
404 p64518.setIP( "192.168.0.8", 24, "p64518-eth2" )
405 p64519.setIP( "192.168.0.9", 24, "p64519-eth2" )
406 p64520.setIP( "192.168.0.20", 24, "p64520-eth2" )
pingping-lin117a43b2015-09-08 17:40:53 -0700407
408 # Setup hosts in each non-SDN AS
alisone4121a92016-11-22 16:31:36 -0800409 h64514, h64515, h64516, h64517, h64518, h64519, h64520 = \
410 net.get( 'h64514', 'h64515', 'h64516', 'h64517', 'h64518', 'h64519', 'h64520' )
411 h64514.cmd( 'ifconfig h64514-eth0 4.0.0.1 up' )
412 h64514.cmd( 'ip route add default via 4.0.0.254' )
413 h64514.setIP( '192.168.0.44', 24, 'h64514-eth1' ) # for control plane
414 h64515.cmd( 'ifconfig h64515-eth0 5.0.0.1 up' )
415 h64515.cmd( 'ip route add default via 5.0.0.254' )
416 h64516.cmd( 'ifconfig h64516-eth0 6.0.0.1 up' )
417 h64516.cmd( 'ip route add default via 6.0.0.254' )
pingping-lin117a43b2015-09-08 17:40:53 -0700418
alisone4121a92016-11-22 16:31:36 -0800419 h64517.cmd( 'ifconfig h64517-eth0.20 7.0.0.1 up' )
420 h64517.cmd( 'ip route add default via 7.0.0.254' )
421 h64517.setIP( '192.168.0.77', 24, 'h64517-eth1' ) # for control plane
422 h64518.cmd( 'ifconfig h64518-eth0.20 8.0.0.1 up' )
423 h64518.cmd( 'ip route add default via 8.0.0.254' )
424
425 h64519.cmd( 'ifconfig h64519-eth0.10 9.0.0.1 up' )
426 h64519.cmd( 'ip route add default via 9.0.0.254' )
427 h64519.setIP( '192.168.0.99', 24, 'h64519-eth1' ) # for control plane
428 h64520.cmd( 'ifconfig h64520-eth0.10 20.0.0.1 up' )
429 h64520.cmd( 'ip route add default via 20.0.0.254' )
pingping-lin117a43b2015-09-08 17:40:53 -0700430
431 # set up swCtl100 as a learning
432 swCtl100 = net.get( 'swCtl100' )
433 swCtl100.cmd( 'ovs-vsctl set-controller swCtl100 none' )
434 swCtl100.cmd( 'ovs-vsctl set-fail-mode swCtl100 standalone' )
435
436 # connect all switches to controller
pingping-lin5bb663b2015-09-24 11:47:50 -0700437 '''
pingping-lin117a43b2015-09-08 17:40:53 -0700438 for i in range ( 1, numSw + 1 ):
439 swX = net.get( 'sw%s' % ( i ) )
Charles Chan029be652015-08-24 01:46:10 +0800440 swX.cmd( 'ovs-vsctl set-controller sw%s tcp:%s:6653' % ( i, onos1IP ) )
pingping-lin5bb663b2015-09-24 11:47:50 -0700441 '''
alisone4121a92016-11-22 16:31:36 -0800442 # Start Quagga as the external BGP routers
pingping-lin117a43b2015-09-08 17:40:53 -0700443 '''
444 for i in range ( 64514, 64516 + 1 ):
445 startquagga( 'peer%s' % ( i ), i, 'quagga%s.conf' % ( i ) )
446 '''
alisone4121a92016-11-22 16:31:36 -0800447 startquagga( p64514, 64514, 'quagga64514.conf' )
448 startquagga( p64515, 64515, 'quagga64515.conf' )
449 startquagga( p64516, 64516, 'quagga64516.conf' )
pingping-lin117a43b2015-09-08 17:40:53 -0700450
alisone4121a92016-11-22 16:31:36 -0800451 startquagga( p64517, 64517, 'quagga64517.conf' )
452 startquagga( p64518, 64518, 'quagga64518.conf' )
453 startquagga( p64519, 64519, 'quagga64519.conf' )
454 startquagga( p64520, 64520, 'quagga64520.conf' )
pingping-lin117a43b2015-09-08 17:40:53 -0700455
alisone4121a92016-11-22 16:31:36 -0800456 # start Quagga as the BGP speaker
457 startquagga( spk1, 64513, 'quagga-sdn.conf' )
458 startquagga( spk2, 64512, 'quagga-sdn2.conf' )
459 startquagga( spk3, 64511, 'quagga-sdn3.conf' )
pingping-lin117a43b2015-09-08 17:40:53 -0700460
461 root = net.get( 'root' )
alisone4121a92016-11-22 16:31:36 -0800462
pingping-lin117a43b2015-09-08 17:40:53 -0700463 root.intf( 'root-eth0' ).setIP( '1.1.1.2/24' )
464 root.cmd( 'ip addr add 192.168.0.100/24 dev root-eth0' )
465
alisone4121a92016-11-22 16:31:36 -0800466 spk1.intf( 'spk1-eth1' ).setIP( '1.1.1.1/24' )
467 spk2.intf( 'spk2-eth1' ).setIP( '1.1.1.3/24' )
468 spk3.intf( 'spk3-eth1' ).setIP( '1.1.1.5/24' )
pingping-lin117a43b2015-09-08 17:40:53 -0700469
470 stopsshd()
471
alisone4121a92016-11-22 16:31:36 -0800472 hosts = [ p64514, p64515, p64516, p64517, p64518, p64519, p64520,
473 h64514, h64517, h64519 ];
pingping-lin117a43b2015-09-08 17:40:53 -0700474 startsshds( hosts )
475 #
pingping-lin5bb663b2015-09-24 11:47:50 -0700476 '''
pingping-lin117a43b2015-09-08 17:40:53 -0700477 forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', onos1IP )
478 root.cmd( 'ssh -nNT -o "PasswordAuthentication no" \
479 -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, onos1IP ) )
480
pingping-lin5bb663b2015-09-24 11:47:50 -0700481 '''
pingping-lin117a43b2015-09-08 17:40:53 -0700482 # time.sleep( 3000000000 )
483 CLI( net )
484
485
486 stopsshd()
487 stopquagga()
488 net.stop()
489
490if __name__ == '__main__':
pingping-lin950b50d2015-09-14 12:00:08 -0700491 setLogLevel( 'debug' )
pingping-lin117a43b2015-09-08 17:40:53 -0700492 sdn1net()