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