Hari Krishna | c195f3b | 2015-07-08 20:02:24 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 2 | |
Hari Krishna | c195f3b | 2015-07-08 20:02:24 -0700 | [diff] [blame] | 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/>. |
Hari Krishna | c195f3b | 2015-07-08 20:02:24 -0700 | [diff] [blame] | 22 | """ |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 23 | |
Hari Krishna | c195f3b | 2015-07-08 20:02:24 -0700 | [diff] [blame] | 24 | from mininet.topo import Topo |
| 25 | from mininet.net import Mininet |
| 26 | from mininet.node import RemoteController |
| 27 | from mininet.node import Node |
| 28 | from mininet.node import CPULimitedHost |
| 29 | from mininet.link import TCLink |
| 30 | from mininet.cli import CLI |
| 31 | from mininet.log import setLogLevel |
| 32 | from mininet.util import dumpNodeConnections |
Hari Krishna | af7fcaa | 2015-07-22 16:04:27 -0700 | [diff] [blame] | 33 | from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch ) |
Hari Krishna | c195f3b | 2015-07-08 20:02:24 -0700 | [diff] [blame] | 34 | |
| 35 | class chordalTopo( Topo ): |
| 36 | |
| 37 | def __init__( self, **opts ): |
| 38 | "Create a topology." |
| 39 | |
| 40 | # Initialize Topology |
| 41 | Topo.__init__( self, **opts ) |
| 42 | |
| 43 | # add nodes, switches first... |
| 44 | s1 = self.addSwitch( 's1' ) |
| 45 | s2 = self.addSwitch( 's2' ) |
| 46 | s3 = self.addSwitch( 's3' ) |
| 47 | s4 = self.addSwitch( 's4' ) |
| 48 | s5 = self.addSwitch( 's5' ) |
| 49 | s6 = self.addSwitch( 's6' ) |
| 50 | s7 = self.addSwitch( 's7' ) |
| 51 | s8 = self.addSwitch( 's8' ) |
| 52 | s9 = self.addSwitch( 's9' ) |
| 53 | s10 = self.addSwitch( 's10' ) |
| 54 | s11 = self.addSwitch( 's11' ) |
| 55 | s12 = self.addSwitch( 's12' ) |
| 56 | s13 = self.addSwitch( 's13' ) |
| 57 | s14 = self.addSwitch( 's14' ) |
| 58 | s15 = self.addSwitch( 's15' ) |
| 59 | s16 = self.addSwitch( 's16' ) |
| 60 | s17 = self.addSwitch( 's17' ) |
| 61 | s18 = self.addSwitch( 's18' ) |
| 62 | s19 = self.addSwitch( 's19' ) |
| 63 | s20 = self.addSwitch( 's20' ) |
| 64 | s21 = self.addSwitch( 's21' ) |
| 65 | s22 = self.addSwitch( 's22' ) |
| 66 | s23 = self.addSwitch( 's23' ) |
| 67 | s24 = self.addSwitch( 's24' ) |
| 68 | s25 = self.addSwitch( 's25' ) |
| 69 | |
| 70 | # ... and now hosts |
| 71 | s1_host = self.addHost( 'h1' ) |
| 72 | s2_host = self.addHost( 'h2' ) |
| 73 | s3_host = self.addHost( 'h3' ) |
| 74 | s4_host = self.addHost( 'h4' ) |
| 75 | s5_host = self.addHost( 'h5' ) |
| 76 | s6_host = self.addHost( 'h6' ) |
| 77 | s7_host = self.addHost( 'h7' ) |
| 78 | s8_host = self.addHost( 'h8' ) |
| 79 | s9_host = self.addHost( 'h9' ) |
| 80 | s10_host = self.addHost( 'h10' ) |
| 81 | s11_host = self.addHost( 'h11' ) |
| 82 | s12_host = self.addHost( 'h12' ) |
| 83 | s13_host = self.addHost( 'h13' ) |
| 84 | s14_host = self.addHost( 'h14' ) |
| 85 | s15_host = self.addHost( 'h15' ) |
| 86 | s16_host = self.addHost( 'h16' ) |
| 87 | s17_host = self.addHost( 'h17' ) |
| 88 | s18_host = self.addHost( 'h18' ) |
| 89 | s19_host = self.addHost( 'h19' ) |
| 90 | s20_host = self.addHost( 'h20' ) |
| 91 | s21_host = self.addHost( 'h21' ) |
| 92 | s22_host = self.addHost( 'h22' ) |
| 93 | s23_host = self.addHost( 'h23' ) |
| 94 | s24_host = self.addHost( 'h24' ) |
| 95 | s25_host = self.addHost( 'h25' ) |
| 96 | |
| 97 | # add edges between switch and corresponding host |
| 98 | self.addLink( s1 , s1_host ) |
| 99 | self.addLink( s2 , s2_host ) |
| 100 | self.addLink( s3 , s3_host ) |
| 101 | self.addLink( s4 , s4_host ) |
| 102 | self.addLink( s5 , s5_host ) |
| 103 | self.addLink( s6 , s6_host ) |
| 104 | self.addLink( s7 , s7_host ) |
| 105 | self.addLink( s8 , s8_host ) |
| 106 | self.addLink( s9 , s9_host ) |
| 107 | self.addLink( s10 , s10_host ) |
| 108 | self.addLink( s11 , s11_host ) |
| 109 | self.addLink( s12 , s12_host ) |
| 110 | self.addLink( s13 , s13_host ) |
| 111 | self.addLink( s14 , s14_host ) |
| 112 | self.addLink( s15 , s15_host ) |
| 113 | self.addLink( s16 , s16_host ) |
| 114 | self.addLink( s17 , s17_host ) |
| 115 | self.addLink( s18 , s18_host ) |
| 116 | self.addLink( s19 , s19_host ) |
| 117 | self.addLink( s20 , s20_host ) |
| 118 | self.addLink( s21 , s21_host ) |
| 119 | self.addLink( s22 , s22_host ) |
| 120 | self.addLink( s23 , s23_host ) |
| 121 | self.addLink( s24 , s24_host ) |
| 122 | self.addLink( s25 , s25_host ) |
| 123 | self.addLink(s1, s2) |
| 124 | self.addLink(s1, s3) |
| 125 | self.addLink(s1, s4) |
| 126 | self.addLink(s1, s5) |
| 127 | self.addLink(s1, s6) |
| 128 | self.addLink(s1, s7) |
| 129 | self.addLink(s1, s8) |
| 130 | self.addLink(s1, s9) |
| 131 | self.addLink(s1, s10) |
| 132 | self.addLink(s1, s11) |
| 133 | self.addLink(s1, s12) |
| 134 | self.addLink(s1, s13) |
| 135 | self.addLink(s1, s14) |
| 136 | self.addLink(s1, s15) |
| 137 | self.addLink(s1, s16) |
| 138 | self.addLink(s1, s17) |
| 139 | self.addLink(s1, s18) |
| 140 | self.addLink(s1, s19) |
| 141 | self.addLink(s1, s20) |
| 142 | self.addLink(s1, s21) |
| 143 | self.addLink(s1, s22) |
| 144 | self.addLink(s1, s23) |
| 145 | self.addLink(s1, s24) |
| 146 | self.addLink(s1, s25) |
| 147 | self.addLink(s2, s3) |
| 148 | self.addLink(s2, s4) |
| 149 | self.addLink(s2, s5) |
| 150 | self.addLink(s2, s6) |
| 151 | self.addLink(s2, s7) |
| 152 | self.addLink(s2, s8) |
| 153 | self.addLink(s2, s9) |
| 154 | self.addLink(s2, s10) |
| 155 | self.addLink(s2, s11) |
| 156 | self.addLink(s2, s12) |
| 157 | self.addLink(s2, s13) |
| 158 | self.addLink(s2, s14) |
| 159 | self.addLink(s2, s15) |
| 160 | self.addLink(s2, s16) |
| 161 | self.addLink(s2, s17) |
| 162 | self.addLink(s2, s18) |
| 163 | self.addLink(s2, s19) |
| 164 | self.addLink(s2, s20) |
| 165 | self.addLink(s2, s21) |
| 166 | self.addLink(s2, s22) |
| 167 | self.addLink(s2, s23) |
| 168 | self.addLink(s2, s24) |
| 169 | self.addLink(s2, s25) |
| 170 | self.addLink(s3, s4) |
| 171 | self.addLink(s3, s5) |
| 172 | self.addLink(s3, s6) |
| 173 | self.addLink(s3, s7) |
| 174 | self.addLink(s3, s8) |
| 175 | self.addLink(s3, s9) |
| 176 | self.addLink(s3, s10) |
| 177 | self.addLink(s3, s11) |
| 178 | self.addLink(s3, s12) |
| 179 | self.addLink(s3, s13) |
| 180 | self.addLink(s3, s14) |
| 181 | self.addLink(s3, s15) |
| 182 | self.addLink(s3, s16) |
| 183 | self.addLink(s3, s17) |
| 184 | self.addLink(s3, s18) |
| 185 | self.addLink(s3, s19) |
| 186 | self.addLink(s3, s20) |
| 187 | self.addLink(s3, s21) |
| 188 | self.addLink(s3, s22) |
| 189 | self.addLink(s3, s23) |
| 190 | self.addLink(s3, s24) |
| 191 | self.addLink(s3, s25) |
| 192 | self.addLink(s4, s5) |
| 193 | self.addLink(s4, s6) |
| 194 | self.addLink(s4, s7) |
| 195 | self.addLink(s4, s8) |
| 196 | self.addLink(s4, s9) |
| 197 | self.addLink(s4, s10) |
| 198 | self.addLink(s4, s11) |
| 199 | self.addLink(s4, s12) |
| 200 | self.addLink(s4, s13) |
| 201 | self.addLink(s4, s14) |
| 202 | self.addLink(s4, s15) |
| 203 | self.addLink(s4, s16) |
| 204 | self.addLink(s4, s17) |
| 205 | self.addLink(s4, s18) |
| 206 | self.addLink(s4, s19) |
| 207 | self.addLink(s4, s20) |
| 208 | self.addLink(s4, s21) |
| 209 | self.addLink(s4, s22) |
| 210 | self.addLink(s4, s23) |
| 211 | self.addLink(s4, s24) |
| 212 | self.addLink(s4, s25) |
| 213 | self.addLink(s5, s6) |
| 214 | self.addLink(s5, s7) |
| 215 | self.addLink(s5, s8) |
| 216 | self.addLink(s5, s9) |
| 217 | self.addLink(s5, s10) |
| 218 | self.addLink(s5, s11) |
| 219 | self.addLink(s5, s12) |
| 220 | self.addLink(s5, s13) |
| 221 | self.addLink(s5, s14) |
| 222 | self.addLink(s5, s15) |
| 223 | self.addLink(s5, s16) |
| 224 | self.addLink(s5, s17) |
| 225 | self.addLink(s5, s18) |
| 226 | self.addLink(s5, s19) |
| 227 | self.addLink(s5, s20) |
| 228 | self.addLink(s5, s21) |
| 229 | self.addLink(s5, s22) |
| 230 | self.addLink(s5, s23) |
| 231 | self.addLink(s5, s24) |
| 232 | self.addLink(s5, s25) |
| 233 | self.addLink(s6, s7) |
| 234 | self.addLink(s6, s8) |
| 235 | self.addLink(s6, s9) |
| 236 | self.addLink(s6, s10) |
| 237 | self.addLink(s6, s11) |
| 238 | self.addLink(s6, s12) |
| 239 | self.addLink(s6, s13) |
| 240 | self.addLink(s6, s14) |
| 241 | self.addLink(s6, s15) |
| 242 | self.addLink(s6, s16) |
| 243 | self.addLink(s6, s17) |
| 244 | self.addLink(s6, s18) |
| 245 | self.addLink(s6, s19) |
| 246 | self.addLink(s6, s20) |
| 247 | self.addLink(s6, s21) |
| 248 | self.addLink(s6, s22) |
| 249 | self.addLink(s6, s23) |
| 250 | self.addLink(s6, s24) |
| 251 | self.addLink(s6, s25) |
| 252 | self.addLink(s7, s8) |
| 253 | self.addLink(s7, s9) |
| 254 | self.addLink(s7, s10) |
| 255 | self.addLink(s7, s11) |
| 256 | self.addLink(s7, s12) |
| 257 | self.addLink(s7, s13) |
| 258 | self.addLink(s7, s14) |
| 259 | self.addLink(s7, s15) |
| 260 | self.addLink(s7, s16) |
| 261 | self.addLink(s7, s17) |
| 262 | self.addLink(s7, s18) |
| 263 | self.addLink(s7, s19) |
| 264 | self.addLink(s7, s20) |
| 265 | self.addLink(s7, s21) |
| 266 | self.addLink(s7, s22) |
| 267 | self.addLink(s7, s23) |
| 268 | self.addLink(s7, s24) |
| 269 | self.addLink(s7, s25) |
| 270 | self.addLink(s8, s9) |
| 271 | self.addLink(s8, s10) |
| 272 | self.addLink(s8, s11) |
| 273 | self.addLink(s8, s12) |
| 274 | self.addLink(s8, s13) |
| 275 | self.addLink(s8, s14) |
| 276 | self.addLink(s8, s15) |
| 277 | self.addLink(s8, s16) |
| 278 | self.addLink(s8, s17) |
| 279 | self.addLink(s8, s18) |
| 280 | self.addLink(s8, s19) |
| 281 | self.addLink(s8, s20) |
| 282 | self.addLink(s8, s21) |
| 283 | self.addLink(s8, s22) |
| 284 | self.addLink(s8, s23) |
| 285 | self.addLink(s8, s24) |
| 286 | self.addLink(s8, s25) |
| 287 | self.addLink(s9, s10) |
| 288 | self.addLink(s9, s11) |
| 289 | self.addLink(s9, s12) |
| 290 | self.addLink(s9, s13) |
| 291 | self.addLink(s9, s14) |
| 292 | self.addLink(s9, s15) |
| 293 | self.addLink(s9, s16) |
| 294 | self.addLink(s9, s17) |
| 295 | self.addLink(s9, s18) |
| 296 | self.addLink(s9, s19) |
| 297 | self.addLink(s9, s20) |
| 298 | self.addLink(s9, s21) |
| 299 | self.addLink(s9, s22) |
| 300 | self.addLink(s9, s23) |
| 301 | self.addLink(s9, s24) |
| 302 | self.addLink(s9, s25) |
| 303 | self.addLink(s10, s11) |
| 304 | self.addLink(s10, s12) |
| 305 | self.addLink(s10, s13) |
| 306 | self.addLink(s10, s14) |
| 307 | self.addLink(s10, s15) |
| 308 | self.addLink(s10, s16) |
| 309 | self.addLink(s10, s17) |
| 310 | self.addLink(s10, s18) |
| 311 | self.addLink(s10, s19) |
| 312 | self.addLink(s10, s20) |
| 313 | self.addLink(s10, s21) |
| 314 | self.addLink(s10, s22) |
| 315 | self.addLink(s10, s23) |
| 316 | self.addLink(s10, s24) |
| 317 | self.addLink(s10, s25) |
| 318 | self.addLink(s11, s12) |
| 319 | self.addLink(s11, s13) |
| 320 | self.addLink(s11, s14) |
| 321 | self.addLink(s11, s15) |
| 322 | self.addLink(s11, s16) |
| 323 | self.addLink(s11, s17) |
| 324 | self.addLink(s11, s18) |
| 325 | self.addLink(s11, s19) |
| 326 | self.addLink(s11, s20) |
| 327 | self.addLink(s11, s21) |
| 328 | self.addLink(s11, s22) |
| 329 | self.addLink(s11, s23) |
| 330 | self.addLink(s11, s24) |
| 331 | self.addLink(s11, s25) |
| 332 | self.addLink(s12, s13) |
| 333 | self.addLink(s12, s14) |
| 334 | self.addLink(s12, s15) |
| 335 | self.addLink(s12, s16) |
| 336 | self.addLink(s12, s17) |
| 337 | self.addLink(s12, s18) |
| 338 | self.addLink(s12, s19) |
| 339 | self.addLink(s12, s20) |
| 340 | self.addLink(s12, s21) |
| 341 | self.addLink(s12, s22) |
| 342 | self.addLink(s12, s23) |
| 343 | self.addLink(s12, s24) |
| 344 | self.addLink(s12, s25) |
| 345 | self.addLink(s13, s14) |
| 346 | self.addLink(s13, s15) |
| 347 | self.addLink(s13, s16) |
| 348 | self.addLink(s13, s17) |
| 349 | self.addLink(s13, s18) |
| 350 | self.addLink(s13, s19) |
| 351 | self.addLink(s13, s20) |
| 352 | self.addLink(s13, s21) |
| 353 | self.addLink(s13, s22) |
| 354 | self.addLink(s13, s23) |
| 355 | self.addLink(s13, s24) |
| 356 | self.addLink(s13, s25) |
| 357 | self.addLink(s14, s15) |
| 358 | self.addLink(s14, s16) |
| 359 | self.addLink(s14, s17) |
| 360 | self.addLink(s14, s18) |
| 361 | self.addLink(s14, s19) |
| 362 | self.addLink(s14, s20) |
| 363 | self.addLink(s14, s21) |
| 364 | self.addLink(s14, s22) |
| 365 | self.addLink(s14, s23) |
| 366 | self.addLink(s14, s24) |
| 367 | self.addLink(s14, s25) |
| 368 | self.addLink(s15, s16) |
| 369 | self.addLink(s15, s17) |
| 370 | self.addLink(s15, s18) |
| 371 | self.addLink(s15, s19) |
| 372 | self.addLink(s15, s20) |
| 373 | self.addLink(s15, s21) |
| 374 | self.addLink(s15, s22) |
| 375 | self.addLink(s15, s23) |
| 376 | self.addLink(s15, s24) |
| 377 | self.addLink(s15, s25) |
| 378 | self.addLink(s16, s17) |
| 379 | self.addLink(s16, s18) |
| 380 | self.addLink(s16, s19) |
| 381 | self.addLink(s16, s20) |
| 382 | self.addLink(s16, s21) |
| 383 | self.addLink(s16, s22) |
| 384 | self.addLink(s16, s23) |
| 385 | self.addLink(s16, s24) |
| 386 | self.addLink(s16, s25) |
| 387 | self.addLink(s17, s18) |
| 388 | self.addLink(s17, s19) |
| 389 | self.addLink(s17, s20) |
| 390 | self.addLink(s17, s21) |
| 391 | self.addLink(s17, s22) |
| 392 | self.addLink(s17, s23) |
| 393 | self.addLink(s17, s24) |
| 394 | self.addLink(s17, s25) |
| 395 | self.addLink(s18, s19) |
| 396 | self.addLink(s18, s20) |
| 397 | self.addLink(s18, s21) |
| 398 | self.addLink(s18, s22) |
| 399 | self.addLink(s18, s23) |
| 400 | self.addLink(s18, s24) |
| 401 | self.addLink(s18, s25) |
| 402 | self.addLink(s19, s20) |
| 403 | self.addLink(s19, s21) |
| 404 | self.addLink(s19, s22) |
| 405 | self.addLink(s19, s23) |
| 406 | self.addLink(s19, s24) |
| 407 | self.addLink(s19, s25) |
| 408 | self.addLink(s20, s21) |
| 409 | self.addLink(s20, s22) |
| 410 | self.addLink(s20, s23) |
| 411 | self.addLink(s20, s24) |
| 412 | self.addLink(s20, s25) |
| 413 | self.addLink(s21, s22) |
| 414 | self.addLink(s21, s23) |
| 415 | self.addLink(s21, s24) |
| 416 | self.addLink(s21, s25) |
| 417 | self.addLink(s22, s23) |
| 418 | self.addLink(s22, s24) |
| 419 | self.addLink(s22, s25) |
| 420 | self.addLink(s23, s24) |
| 421 | self.addLink(s23, s25) |
| 422 | self.addLink(s24, s25) |
| 423 | |
| 424 | topos = { 'chordal': ( lambda: chordalTopo() ) } |
| 425 | |
| 426 | # HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS |
| 427 | |
| 428 | def setupNetwork(): |
| 429 | "Create network" |
| 430 | topo = chordalTopo() |
| 431 | #if controller_ip == '': |
| 432 | #controller_ip = '10.0.2.2'; |
| 433 | # controller_ip = '127.0.0.1'; |
| 434 | network = Mininet(topo=topo, switch=OVSSwitch,autoSetMacs=True, controller=None) |
| 435 | network.start() |
| 436 | CLI( network ) |
| 437 | network.stop() |
| 438 | |
| 439 | if __name__ == '__main__': |
| 440 | setLogLevel('info') |
| 441 | #setLogLevel('debug') |
| 442 | setupNetwork() |