pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 4 | Copyright 2015 Open Networking Foundation (ONF) |
| 5 | |
| 6 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 7 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 8 | or 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 |
| 13 | (at your option) any later version. |
| 14 | |
| 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 | """ |
| 23 | |
| 24 | """ |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 25 | Set up the SDN-IP topology as same as it on Internet2 |
| 26 | """ |
| 27 | |
| 28 | """ |
| 29 | AS 64513, (SDN AS) |
| 30 | AS 64514, reachable by 10.0.4.1 |
| 31 | AS 64515, reachable by 10.0.5.1 |
| 32 | AS 64516, reachable by 10.0.6.1 |
| 33 | """ |
| 34 | |
| 35 | from mininet.net import Mininet |
| 36 | from mininet.node import Controller, RemoteController |
| 37 | from mininet.log import setLogLevel, info |
| 38 | from mininet.cli import CLI |
| 39 | from mininet.topo import Topo |
| 40 | from mininet.util import quietRun |
| 41 | from mininet.moduledeps import pathCheck |
| 42 | |
| 43 | import os.path |
| 44 | import time |
| 45 | from subprocess import Popen, STDOUT, PIPE |
| 46 | |
| 47 | QUAGGA_DIR = '/usr/lib/quagga' |
| 48 | QUAGGA_RUN_DIR = '/usr/local/var/run/quagga' |
Jon Hall | fabd7e5 | 2016-04-19 19:20:59 -0700 | [diff] [blame] | 49 | QUAGGA_CONFIG_DIR = '~/OnosSystemTest/TestON/tests/USECASE/USECASE_SdnipFunction_fsfw/dependencies/' |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 50 | # onos1IP = '10.254.1.201' |
| 51 | numSw = 39 |
pingping-lin | 983c7a3 | 2015-12-15 16:20:45 -0800 | [diff] [blame] | 52 | vlanId = 8 |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 53 | |
| 54 | |
| 55 | class SDNTopo( Topo ): |
| 56 | "SDN Topology" |
| 57 | |
| 58 | def __init__( self, *args, **kwargs ): |
| 59 | |
| 60 | Topo.__init__( self, *args, **kwargs ) |
| 61 | |
| 62 | # BGP peer hosts |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 63 | pr64514 = self.addHost( 'pr64514' ) |
| 64 | pr64515 = self.addHost( 'pr64515' ) |
| 65 | pr64516 = self.addHost( 'pr64516' ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 66 | |
| 67 | ''' |
| 68 | sw1 = self.addSwitch( 'SEAT', dpid = '00000000000000a1' ) |
| 69 | sw2 = self.addSwitch( 'PORT', dpid = '00000000000000a2' ) |
| 70 | sw3 = self.addSwitch( 'SUNN', dpid = '00000000000000a3' ) |
| 71 | sw4 = self.addSwitch( 'RENO', dpid = '00000000000000a4' ) |
| 72 | sw5 = self.addSwitch( 'LOSA', dpid = '00000000000000a5' ) |
| 73 | sw6 = self.addSwitch( 'MISS', dpid = '00000000000000a6' ) |
| 74 | sw7 = self.addSwitch( 'LASV', dpid = '00000000000000a7' ) |
| 75 | sw8 = self.addSwitch( 'SALT', dpid = '00000000000000a8' ) |
| 76 | sw9 = self.addSwitch( 'PHOE', dpid = '00000000000000a9' ) |
| 77 | sw10 = self.addSwitch( 'TUCS', dpid = '0000000000000a10' ) |
| 78 | sw11 = self.addSwitch( 'DENV', dpid = '0000000000000a11' ) |
| 79 | sw12 = self.addSwitch( 'ELPA', dpid = '0000000000000a12' ) |
| 80 | sw13 = self.addSwitch( 'MINN', dpid = '0000000000000a13' ) |
| 81 | sw14 = self.addSwitch( 'KANS', dpid = '0000000000000a14' ) |
| 82 | sw15 = self.addSwitch( 'TULS', dpid = '0000000000000a15' ) |
| 83 | sw16 = self.addSwitch( 'DALL', dpid = '0000000000000a16' ) |
| 84 | sw17 = self.addSwitch( 'HOUH', dpid = '0000000000000a17' ) |
| 85 | sw18 = self.addSwitch( 'COLU', dpid = '0000000000000a18' ) |
| 86 | sw19 = self.addSwitch( 'JCSN', dpid = '0000000000000a19' ) |
| 87 | sw20 = self.addSwitch( 'BATO', dpid = '0000000000000a20' ) |
| 88 | sw21 = self.addSwitch( 'EQCH', dpid = '0000000000000a21' ) |
| 89 | sw22 = self.addSwitch( 'STAR', dpid = '0000000000000a22' ) |
| 90 | sw23 = self.addSwitch( 'CHIC', dpid = '0000000000000a23' ) |
| 91 | sw24 = self.addSwitch( 'INDI', dpid = '0000000000000a24' ) |
| 92 | sw25 = self.addSwitch( 'CINC', dpid = '0000000000000a25' ) |
| 93 | sw26 = self.addSwitch( 'LOUI', dpid = '0000000000000a26' ) |
| 94 | sw27 = self.addSwitch( 'ATLA', dpid = '0000000000000a27' ) |
| 95 | sw28 = self.addSwitch( 'JACK', dpid = '0000000000000a28' ) |
| 96 | sw29 = self.addSwitch( 'CLEV', dpid = '0000000000000a29' ) |
| 97 | sw30 = self.addSwitch( 'PITT', dpid = '0000000000000a30' ) |
| 98 | sw31 = self.addSwitch( 'ASHB', dpid = '0000000000000a31' ) |
| 99 | sw32 = self.addSwitch( 'WASH', dpid = '0000000000000a32' ) |
| 100 | sw33 = self.addSwitch( 'RALE', dpid = '0000000000000a33' ) |
| 101 | sw34 = self.addSwitch( 'CHAR', dpid = '0000000000000a34' ) |
| 102 | sw35 = self.addSwitch( 'ALBA', dpid = '0000000000000a35' ) |
| 103 | sw36 = self.addSwitch( 'BOST', dpid = '0000000000000a36' ) |
| 104 | sw37 = self.addSwitch( 'HART', dpid = '0000000000000a37' ) |
| 105 | sw38 = self.addSwitch( 'NEWY', dpid = '0000000000000a38' ) |
| 106 | sw39 = self.addSwitch( 'PHIL', dpid = '0000000000000a39' ) |
| 107 | ''' |
| 108 | sw1 = self.addSwitch( 'sw1', dpid = '00000000000000a1' ) |
| 109 | sw2 = self.addSwitch( 'sw2', dpid = '00000000000000a2' ) |
| 110 | sw3 = self.addSwitch( 'sw3', dpid = '00000000000000a3' ) |
| 111 | sw4 = self.addSwitch( 'sw4', dpid = '00000000000000a4' ) |
| 112 | sw5 = self.addSwitch( 'sw5', dpid = '00000000000000a5' ) |
| 113 | sw6 = self.addSwitch( 'sw6', dpid = '00000000000000a6' ) |
| 114 | sw7 = self.addSwitch( 'sw7', dpid = '00000000000000a7' ) |
| 115 | sw8 = self.addSwitch( 'sw8', dpid = '00000000000000a8' ) |
| 116 | sw9 = self.addSwitch( 'sw9', dpid = '00000000000000a9' ) |
| 117 | sw10 = self.addSwitch( 'sw10', dpid = '0000000000000a10' ) |
| 118 | sw11 = self.addSwitch( 'sw11', dpid = '0000000000000a11' ) |
| 119 | sw12 = self.addSwitch( 'sw12', dpid = '0000000000000a12' ) |
| 120 | sw13 = self.addSwitch( 'sw13', dpid = '0000000000000a13' ) |
| 121 | sw14 = self.addSwitch( 'sw14', dpid = '0000000000000a14' ) |
| 122 | sw15 = self.addSwitch( 'sw15', dpid = '0000000000000a15' ) |
| 123 | sw16 = self.addSwitch( 'sw16', dpid = '0000000000000a16' ) |
| 124 | sw17 = self.addSwitch( 'sw17', dpid = '0000000000000a17' ) |
| 125 | sw18 = self.addSwitch( 'sw18', dpid = '0000000000000a18' ) |
| 126 | sw19 = self.addSwitch( 'sw19', dpid = '0000000000000a19' ) |
| 127 | sw20 = self.addSwitch( 'sw20', dpid = '0000000000000a20' ) |
| 128 | sw21 = self.addSwitch( 'sw21', dpid = '0000000000000a21' ) |
| 129 | sw22 = self.addSwitch( 'sw22', dpid = '0000000000000a22' ) |
| 130 | sw23 = self.addSwitch( 'sw23', dpid = '0000000000000a23' ) |
| 131 | sw24 = self.addSwitch( 'sw24', dpid = '0000000000000a24' ) |
| 132 | sw25 = self.addSwitch( 'sw25', dpid = '0000000000000a25' ) |
| 133 | sw26 = self.addSwitch( 'sw26', dpid = '0000000000000a26' ) |
| 134 | sw27 = self.addSwitch( 'sw27', dpid = '0000000000000a27' ) |
| 135 | sw28 = self.addSwitch( 'sw28', dpid = '0000000000000a28' ) |
| 136 | sw29 = self.addSwitch( 'sw29', dpid = '0000000000000a29' ) |
| 137 | sw30 = self.addSwitch( 'sw30', dpid = '0000000000000a30' ) |
| 138 | sw31 = self.addSwitch( 'sw31', dpid = '0000000000000a31' ) |
| 139 | sw32 = self.addSwitch( 'sw32', dpid = '0000000000000a32' ) |
| 140 | sw33 = self.addSwitch( 'sw33', dpid = '0000000000000a33' ) |
| 141 | sw34 = self.addSwitch( 'sw34', dpid = '0000000000000a34' ) |
| 142 | sw35 = self.addSwitch( 'sw35', dpid = '0000000000000a35' ) |
| 143 | sw36 = self.addSwitch( 'sw36', dpid = '0000000000000a36' ) |
| 144 | sw37 = self.addSwitch( 'sw37', dpid = '0000000000000a37' ) |
| 145 | sw38 = self.addSwitch( 'sw38', dpid = '0000000000000a38' ) |
| 146 | sw39 = self.addSwitch( 'sw39', dpid = '0000000000000a39' ) |
| 147 | |
| 148 | |
| 149 | # Add a layer2 switch for control plane connectivity |
| 150 | # This switch isn't part of the SDN topology |
| 151 | # We'll use the ovs-controller to turn this into a learning switch |
| 152 | swCtl100 = self.addSwitch( 'swCtl100', dpid = '0000000000000100' ) |
| 153 | |
| 154 | |
| 155 | # BGP speaker hosts |
| 156 | speaker1 = self.addHost( 'speaker1' ) |
| 157 | speaker2 = self.addHost( 'speaker2' ) |
| 158 | |
| 159 | root = self.addHost( 'root', inNamespace = False , ip = '0' ) |
| 160 | |
| 161 | # hosts behind each AS |
| 162 | host64514 = self.addHost( 'host64514' ) |
| 163 | host64515 = self.addHost( 'host64515' ) |
| 164 | host64516 = self.addHost( 'host64516' ) |
| 165 | |
| 166 | self.addLink( 'speaker1', sw24 ) |
| 167 | self.addLink( 'speaker2', sw24 ) |
| 168 | |
| 169 | # connect all switches |
| 170 | self.addLink( sw1, sw2 ) |
| 171 | self.addLink( sw1, sw6 ) |
| 172 | self.addLink( sw1, sw8 ) |
| 173 | self.addLink( sw2, sw3 ) |
| 174 | self.addLink( sw3, sw4 ) |
| 175 | self.addLink( sw3, sw5 ) |
| 176 | self.addLink( sw4, sw8 ) |
| 177 | self.addLink( sw5, sw7 ) |
| 178 | self.addLink( sw5, sw9 ) |
| 179 | self.addLink( sw6, sw13 ) |
| 180 | self.addLink( sw7, sw8 ) |
| 181 | self.addLink( sw8, sw11 ) |
| 182 | self.addLink( sw9, sw10 ) |
| 183 | self.addLink( sw10, sw12 ) |
| 184 | self.addLink( sw11, sw12 ) |
| 185 | self.addLink( sw11, sw14 ) |
| 186 | self.addLink( sw12, sw17 ) |
| 187 | self.addLink( sw13, sw14 ) |
| 188 | self.addLink( sw13, sw21 ) |
| 189 | self.addLink( sw14, sw15 ) |
| 190 | self.addLink( sw14, sw18 ) |
| 191 | self.addLink( sw14, sw23 ) |
| 192 | self.addLink( sw15, sw16 ) |
| 193 | self.addLink( sw16, sw17 ) |
| 194 | self.addLink( sw17, sw19 ) |
| 195 | self.addLink( sw17, sw20 ) |
| 196 | self.addLink( sw18, sw23 ) |
| 197 | self.addLink( sw19, sw27 ) |
| 198 | self.addLink( sw20, sw28 ) |
| 199 | self.addLink( sw21, sw22 ) |
| 200 | self.addLink( sw21, sw29 ) |
| 201 | self.addLink( sw22, sw23 ) |
| 202 | self.addLink( sw23, sw24 ) |
| 203 | self.addLink( sw23, sw31 ) |
| 204 | self.addLink( sw24, sw25 ) |
| 205 | self.addLink( sw25, sw26 ) |
| 206 | self.addLink( sw26, sw27 ) |
| 207 | self.addLink( sw27, sw28 ) |
| 208 | self.addLink( sw27, sw34 ) |
| 209 | self.addLink( sw29, sw30 ) |
| 210 | self.addLink( sw29, sw35 ) |
| 211 | self.addLink( sw30, sw31 ) |
| 212 | self.addLink( sw31, sw32 ) |
| 213 | self.addLink( sw32, sw33 ) |
| 214 | self.addLink( sw32, sw39 ) |
| 215 | self.addLink( sw33, sw34 ) |
| 216 | self.addLink( sw35, sw36 ) |
| 217 | self.addLink( sw36, sw37 ) |
| 218 | self.addLink( sw37, sw38 ) |
| 219 | self.addLink( sw38, sw39 ) |
| 220 | |
| 221 | # connection between switches and peers |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 222 | self.addLink( pr64514, sw32 ) |
| 223 | self.addLink( pr64515, sw8 ) |
| 224 | self.addLink( pr64516, sw28 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 225 | |
| 226 | # connection between BGP peer and hosts behind the BGP peer |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 227 | self.addLink( pr64514, host64514 ) |
| 228 | self.addLink( pr64515, host64515 ) |
| 229 | self.addLink( pr64516, host64516 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 230 | |
| 231 | # Internal Connection To Hosts |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 232 | self.addLink( swCtl100, pr64514 ) |
| 233 | self.addLink( swCtl100, pr64515 ) |
| 234 | self.addLink( swCtl100, pr64516 ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 235 | self.addLink( swCtl100, speaker1 ) |
| 236 | self.addLink( swCtl100, speaker2 ) |
| 237 | |
| 238 | |
| 239 | |
| 240 | # add host64514 to control plane for ping test |
| 241 | self.addLink( swCtl100, host64514 ) |
| 242 | self.addLink( swCtl100, root ) |
| 243 | |
| 244 | |
| 245 | def startsshd( host ): |
| 246 | "Start sshd on host" |
| 247 | info( '*** Starting sshd\n' ) |
| 248 | name, intf, ip = host.name, host.defaultIntf(), host.IP() |
| 249 | banner = '/tmp/%s.banner' % name |
| 250 | host.cmd( 'echo "Welcome to %s at %s" > %s' % ( name, ip, banner ) ) |
| 251 | host.cmd( '/usr/sbin/sshd -o "Banner %s"' % banner, '-o "UseDNS no"' ) |
| 252 | info( '***', host.name, 'is running sshd on', intf, 'at', ip, '\n' ) |
| 253 | |
| 254 | def startsshds ( hosts ): |
| 255 | for h in hosts: |
| 256 | startsshd( h ) |
| 257 | |
| 258 | def stopsshd(): |
| 259 | "Stop *all* sshd processes with a custom banner" |
| 260 | info( '*** Shutting down stale sshd/Banner processes ', |
| 261 | quietRun( "pkill -9 -f Banner" ), '\n' ) |
| 262 | |
| 263 | def startquagga( host, num, config_file ): |
| 264 | info( '*** Starting Quagga on %s\n' % host ) |
| 265 | host.cmd( "cd %s" % QUAGGA_CONFIG_DIR ) |
| 266 | zebra_cmd = \ |
| 267 | '%s/zebra -d -f ./zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid'\ |
| 268 | % ( QUAGGA_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num ) |
| 269 | quagga_cmd = '%s/bgpd -d -f %s -z %s/zserv%s.api -i %s/bgpd%s.pid' \ |
| 270 | % ( QUAGGA_DIR, config_file, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num ) |
| 271 | |
| 272 | print zebra_cmd |
| 273 | print quagga_cmd |
| 274 | |
| 275 | host.cmd( zebra_cmd ) |
| 276 | host.cmd( quagga_cmd ) |
| 277 | |
| 278 | def startquaggahost5( host, num ): |
| 279 | info( '*** Starting Quagga on %s\n' % host ) |
| 280 | zebra_cmd = \ |
| 281 | '%s/zebra -d -f ./zebra.conf -z %s/zserv%s.api -i %s/zebra%s.pid' \ |
| 282 | % ( QUAGGA_DIR, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num ) |
| 283 | quagga_cmd = \ |
| 284 | '%s/bgpd -d -f ./as4quaggas/quagga%s.conf -z %s/zserv%s.api -i %s/bgpd%s.pid'\ |
| 285 | % ( QUAGGA_DIR, num, QUAGGA_RUN_DIR, num, QUAGGA_RUN_DIR, num ) |
| 286 | |
| 287 | host.cmd( zebra_cmd ) |
| 288 | host.cmd( quagga_cmd ) |
| 289 | |
| 290 | |
| 291 | def stopquagga(): |
| 292 | quietRun( 'sudo pkill -9 -f bgpd' ) |
| 293 | quietRun( 'sudo pkill -9 -f zebra' ) |
| 294 | |
| 295 | def sdn1net(): |
| 296 | topo = SDNTopo() |
| 297 | info( '*** Creating network\n' ) |
| 298 | # time.sleep( 30 ) |
| 299 | net = Mininet( topo = topo, controller = RemoteController ) |
| 300 | |
| 301 | |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 302 | speaker1, speaker2, pr64514, pr64515, pr64516 = \ |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 303 | net.get( 'speaker1', 'speaker2' , |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 304 | 'pr64514', 'pr64515', 'pr64516' ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 305 | |
| 306 | # Adding addresses to host64513_1 interface connected to sw24 |
| 307 | # for BGP peering |
| 308 | speaker1.setMAC( '00:00:00:00:00:01', 'speaker1-eth0' ) |
pingping-lin | 983c7a3 | 2015-12-15 16:20:45 -0800 | [diff] [blame] | 309 | speaker1.cmd( "sudo vconfig add speaker1-eth0 %d" % vlanId ) |
| 310 | speaker1.cmd( 'ip addr add 10.0.4.101/24 dev speaker1-eth0.%d' % vlanId ) |
| 311 | speaker1.cmd( 'ip addr add 10.0.5.101/24 dev speaker1-eth0.%d' % vlanId ) |
| 312 | speaker1.cmd( 'ip addr add 10.0.6.101/24 dev speaker1-eth0.%d' % vlanId ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 313 | |
| 314 | speaker1.defaultIntf().setIP( '10.1.4.101/24' ) |
| 315 | speaker1.defaultIntf().setMAC( '00:00:00:00:00:01' ) |
| 316 | |
| 317 | # Net has to be start after adding the above link |
| 318 | net.start() |
| 319 | |
| 320 | # setup configuration on the interface connected to switch |
pingping-lin | 983c7a3 | 2015-12-15 16:20:45 -0800 | [diff] [blame] | 321 | |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 322 | pr64514.setMAC( '00:00:00:00:00:04', 'pr64514-eth0' ) |
| 323 | pr64514.cmd( "sudo vconfig add pr64514-eth0 %s" % vlanId ) |
| 324 | pr64514.cmd( "ip addr add 10.0.4.1/24 dev pr64514-eth0.%s" % vlanId ) |
pingping-lin | 8aea3d5 | 2015-12-15 17:43:07 -0800 | [diff] [blame] | 325 | pr64514.defaultIntf().setMAC( '00:00:00:00:00:04' ) |
pingping-lin | ed7a26b | 2015-12-15 19:03:57 -0800 | [diff] [blame] | 326 | pr64514.defaultIntf().setIP( '10.0.4.1/24' ) |
pingping-lin | 983c7a3 | 2015-12-15 16:20:45 -0800 | [diff] [blame] | 327 | |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 328 | pr64515.setMAC( '00:00:00:00:00:05', 'pr64515-eth0' ) |
| 329 | pr64515.cmd( "sudo vconfig add pr64515-eth0 %s" % vlanId ) |
pingping-lin | 8aea3d5 | 2015-12-15 17:43:07 -0800 | [diff] [blame] | 330 | pr64515.cmd( "ip addr add 10.0.5.1/24 dev pr64515-eth0.%s" % vlanId ) |
| 331 | pr64515.defaultIntf().setMAC( '00:00:00:00:00:05' ) |
pingping-lin | ed7a26b | 2015-12-15 19:03:57 -0800 | [diff] [blame] | 332 | pr64515.defaultIntf().setIP( '10.0.5.1/24' ) |
pingping-lin | 983c7a3 | 2015-12-15 16:20:45 -0800 | [diff] [blame] | 333 | |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 334 | pr64516.setMAC( '00:00:00:00:00:06', 'pr64516-eth0' ) |
pingping-lin | 8aea3d5 | 2015-12-15 17:43:07 -0800 | [diff] [blame] | 335 | pr64516.cmd( "sudo vconfig add pr64516-eth0 %s" % vlanId ) |
| 336 | pr64516.cmd( "ip addr add 10.0.6.1/24 dev pr64516-eth0.%s" % vlanId ) |
| 337 | pr64516.defaultIntf().setMAC( '00:00:00:00:00:06' ) |
pingping-lin | ed7a26b | 2015-12-15 19:03:57 -0800 | [diff] [blame] | 338 | pr64516.defaultIntf().setIP( '10.0.6.1/24' ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 339 | |
| 340 | # setup configuration on the interface connected to hosts |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 341 | pr64514.setIP( "4.0.0.254", 8, "pr64514-eth1" ) |
| 342 | pr64514.setMAC( '00:00:00:00:00:44', 'pr64514-eth1' ) |
| 343 | pr64515.setIP( "5.0.0.254", 8, "pr64515-eth1" ) |
| 344 | pr64515.setMAC( '00:00:00:00:00:55', 'pr64515-eth1' ) |
| 345 | pr64516.setIP( "6.0.0.254", 8, "pr64516-eth1" ) |
| 346 | pr64516.setMAC( '00:00:00:00:00:66', 'pr64516-eth1' ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 347 | |
| 348 | # enable forwarding on BGP peer hosts |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 349 | pr64514.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' ) |
| 350 | pr64515.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' ) |
| 351 | pr64516.cmd( 'sysctl net.ipv4.conf.all.forwarding=1' ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 352 | |
| 353 | # config interface for control plane connectivity |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 354 | pr64514.setIP( "192.168.0.4", 24, "pr64514-eth2" ) |
| 355 | pr64515.setIP( "192.168.0.5", 24, "pr64515-eth2" ) |
| 356 | pr64516.setIP( "192.168.0.6", 24, "pr64516-eth2" ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 357 | |
| 358 | # Setup hosts in each non-SDN AS |
| 359 | host64514, host64515, host64516 = \ |
| 360 | net.get( 'host64514', 'host64515', 'host64516' ) |
| 361 | host64514.cmd( 'ifconfig host64514-eth0 4.0.0.1 up' ) |
| 362 | host64514.cmd( 'ip route add default via 4.0.0.254' ) |
| 363 | host64514.setIP( '192.168.0.44', 24, 'host64514-eth1' ) # for control plane |
| 364 | host64515.cmd( 'ifconfig host64515-eth0 5.0.0.1 up' ) |
| 365 | host64515.cmd( 'ip route add default via 5.0.0.254' ) |
| 366 | host64516.cmd( 'ifconfig host64516-eth0 6.0.0.1 up' ) |
| 367 | host64516.cmd( 'ip route add default via 6.0.0.254' ) |
| 368 | |
| 369 | |
| 370 | # set up swCtl100 as a learning |
| 371 | swCtl100 = net.get( 'swCtl100' ) |
| 372 | swCtl100.cmd( 'ovs-vsctl set-controller swCtl100 none' ) |
| 373 | swCtl100.cmd( 'ovs-vsctl set-fail-mode swCtl100 standalone' ) |
| 374 | |
| 375 | # connect all switches to controller |
| 376 | ''' |
| 377 | for i in range ( 1, numSw + 1 ): |
| 378 | swX = net.get( 'sw%s' % ( i ) ) |
| 379 | swX.cmd( 'ovs-vsctl set-controller sw%s tcp:%s:6653' % ( i, onos1IP ) ) |
| 380 | ''' |
| 381 | # Start Quagga on border routers |
| 382 | ''' |
| 383 | for i in range ( 64514, 64516 + 1 ): |
| 384 | startquagga( 'peer%s' % ( i ), i, 'quagga%s.conf' % ( i ) ) |
| 385 | ''' |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 386 | startquagga( pr64514, 64514, 'quagga64514.conf' ) |
| 387 | startquagga( pr64515, 64515, 'quagga64515.conf' ) |
| 388 | startquagga( pr64516, 64516, 'quagga64516.conf' ) |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 389 | |
| 390 | # start Quagga in SDN network |
| 391 | startquagga( speaker1, 64513, 'quagga-sdn.conf' ) |
| 392 | |
| 393 | |
| 394 | root = net.get( 'root' ) |
| 395 | root.intf( 'root-eth0' ).setIP( '1.1.1.2/24' ) |
| 396 | root.cmd( 'ip addr add 192.168.0.100/24 dev root-eth0' ) |
| 397 | |
| 398 | speaker1.intf( 'speaker1-eth1' ).setIP( '1.1.1.1/24' ) |
| 399 | |
| 400 | |
| 401 | stopsshd() |
| 402 | |
pingping-lin | e654026 | 2015-12-15 17:15:21 -0800 | [diff] [blame] | 403 | hosts = [ pr64514, pr64515, pr64516, host64514]; |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 404 | startsshds( hosts ) |
| 405 | # |
| 406 | ''' |
| 407 | forwarding1 = '%s:2000:%s:2000' % ( '1.1.1.2', onos1IP ) |
| 408 | root.cmd( 'ssh -nNT -o "PasswordAuthentication no" \ |
| 409 | -o "StrictHostKeyChecking no" -l sdn -L %s %s & ' % ( forwarding1, onos1IP ) ) |
| 410 | |
| 411 | ''' |
pingping-lin | ffca7e2 | 2015-11-13 15:43:08 -0800 | [diff] [blame] | 412 | CLI( net ) |
| 413 | |
| 414 | |
| 415 | stopsshd() |
| 416 | stopquagga() |
| 417 | net.stop() |
| 418 | |
| 419 | if __name__ == '__main__': |
| 420 | setLogLevel( 'debug' ) |
| 421 | sdn1net() |