You Wang | db927a5 | 2016-02-26 11:03:28 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | from mininet.topo import Topo |
| 4 | from mininet.net import Mininet |
| 5 | from mininet.node import Controller, RemoteController, OVSController |
| 6 | from mininet.node import CPULimitedHost, Host, Node |
| 7 | from mininet.cli import CLI |
| 8 | from mininet.log import setLogLevel, info |
| 9 | from mininet.link import TCLink, Intf |
| 10 | from subprocess import call |
| 11 | from mininet.util import dumpNodeConnections |
| 12 | from mininet.node import ( UserSwitch, OVSSwitch, IVSSwitch ) |
| 13 | |
| 14 | class spineTopo( Topo ): |
| 15 | |
| 16 | def __init__( self, **opts ): |
| 17 | "Create a topology." |
| 18 | |
| 19 | # Initialize Topology |
| 20 | Topo.__init__( self, **opts ) |
| 21 | |
| 22 | # add nodes, Leaf switches |
| 23 | s1 = self.addSwitch( 's1' ) |
| 24 | s2 = self.addSwitch( 's2' ) |
| 25 | s3 = self.addSwitch( 's3' ) |
| 26 | s4 = self.addSwitch( 's4' ) |
| 27 | s5 = self.addSwitch( 's5' ) |
| 28 | s6 = self.addSwitch( 's6' ) |
| 29 | s7 = self.addSwitch( 's7' ) |
| 30 | s8 = self.addSwitch( 's8' ) |
| 31 | s9 = self.addSwitch( 's9' ) |
| 32 | s10 = self.addSwitch( 's10' ) |
| 33 | s11 = self.addSwitch( 's11' ) |
| 34 | s12 = self.addSwitch( 's12' ) |
| 35 | s13 = self.addSwitch( 's13' ) |
| 36 | s14 = self.addSwitch( 's14' ) |
| 37 | |
| 38 | # add nodes, Spine switches first... |
| 39 | s15 = self.addSwitch( 's15' ) |
| 40 | s16 = self.addSwitch( 's16' ) |
| 41 | s17 = self.addSwitch( 's17' ) |
| 42 | s18 = self.addSwitch( 's18' ) |
| 43 | s19 = self.addSwitch( 's19' ) |
| 44 | s20 = self.addSwitch( 's20' ) |
| 45 | s21 = self.addSwitch( 's21' ) |
| 46 | s22 = self.addSwitch( 's22' ) |
| 47 | s23 = self.addSwitch( 's23' ) |
| 48 | s24 = self.addSwitch( 's24' ) |
| 49 | s25 = self.addSwitch( 's25' ) |
| 50 | s26 = self.addSwitch( 's26' ) |
| 51 | s27 = self.addSwitch( 's27' ) |
| 52 | s28 = self.addSwitch( 's28' ) |
| 53 | s29 = self.addSwitch( 's29' ) |
| 54 | s30 = self.addSwitch( 's30' ) |
| 55 | s31 = self.addSwitch( 's31' ) |
| 56 | s32 = self.addSwitch( 's32' ) |
| 57 | s33 = self.addSwitch( 's33' ) |
| 58 | s34 = self.addSwitch( 's34' ) |
| 59 | s35 = self.addSwitch( 's35' ) |
| 60 | s36 = self.addSwitch( 's36' ) |
| 61 | s37 = self.addSwitch( 's37' ) |
| 62 | s38 = self.addSwitch( 's38' ) |
| 63 | s39 = self.addSwitch( 's39' ) |
| 64 | s40 = self.addSwitch( 's40' ) |
| 65 | s41 = self.addSwitch( 's41' ) |
| 66 | s42 = self.addSwitch( 's42' ) |
| 67 | s43 = self.addSwitch( 's43' ) |
| 68 | s44 = self.addSwitch( 's44' ) |
| 69 | s45 = self.addSwitch( 's45' ) |
| 70 | s46 = self.addSwitch( 's46' ) |
| 71 | s47 = self.addSwitch( 's47' ) |
| 72 | s48 = self.addSwitch( 's48' ) |
| 73 | s49 = self.addSwitch( 's49' ) |
| 74 | s50 = self.addSwitch( 's50' ) |
| 75 | s51 = self.addSwitch( 's51' ) |
| 76 | s52 = self.addSwitch( 's52' ) |
| 77 | s53 = self.addSwitch( 's53' ) |
| 78 | s54 = self.addSwitch( 's54' ) |
| 79 | s55 = self.addSwitch( 's55' ) |
| 80 | s56 = self.addSwitch( 's56' ) |
| 81 | s57 = self.addSwitch( 's57' ) |
| 82 | s58 = self.addSwitch( 's58' ) |
| 83 | s59 = self.addSwitch( 's59' ) |
| 84 | s60 = self.addSwitch( 's60' ) |
| 85 | s61 = self.addSwitch( 's61' ) |
| 86 | s62 = self.addSwitch( 's62' ) |
| 87 | s63 = self.addSwitch( 's63' ) |
| 88 | s64 = self.addSwitch( 's64' ) |
| 89 | s65 = self.addSwitch( 's65' ) |
| 90 | s66 = self.addSwitch( 's66' ) |
| 91 | s67 = self.addSwitch( 's67' ) |
| 92 | s68 = self.addSwitch( 's68' ) |
| 93 | s69 = self.addSwitch( 's69' ) |
| 94 | s70 = self.addSwitch( 's70' ) |
| 95 | s71 = self.addSwitch( 's71' ) |
| 96 | s72 = self.addSwitch( 's72' ) |
| 97 | s73 = self.addSwitch( 's73' ) |
| 98 | s74 = self.addSwitch( 's74' ) |
| 99 | s75 = self.addSwitch( 's75' ) |
| 100 | s76 = self.addSwitch( 's76' ) |
| 101 | s77 = self.addSwitch( 's77' ) |
| 102 | s78 = self.addSwitch( 's78' ) |
| 103 | |
| 104 | # ... and now hosts |
| 105 | #s1_host = self.addHost( 'h1' ) |
| 106 | #s2_host = self.addHost( 'h2' ) |
| 107 | #s3_host = self.addHost( 'h3' ) |
| 108 | #s4_host = self.addHost( 'h4' ) |
| 109 | #s5_host = self.addHost( 'h5' ) |
| 110 | #s6_host = self.addHost( 'h6' ) |
| 111 | #s7_host = self.addHost( 'h7' ) |
| 112 | #s8_host = self.addHost( 'h8' ) |
| 113 | #s9_host = self.addHost( 'h9' ) |
| 114 | #s10_host = self.addHost( 'h10' ) |
| 115 | s11_host = self.addHost( 'h11' ) |
| 116 | s12_host = self.addHost( 'h12' ) |
| 117 | s13_host = self.addHost( 'h13' ) |
| 118 | s14_host = self.addHost( 'h14' ) |
| 119 | s15_host = self.addHost( 'h15' ) |
| 120 | s16_host = self.addHost( 'h16' ) |
| 121 | s17_host = self.addHost( 'h17' ) |
| 122 | s18_host = self.addHost( 'h18' ) |
| 123 | s19_host = self.addHost( 'h19' ) |
| 124 | s20_host = self.addHost( 'h20' ) |
| 125 | s21_host = self.addHost( 'h21' ) |
| 126 | s22_host = self.addHost( 'h22' ) |
| 127 | s23_host = self.addHost( 'h23' ) |
| 128 | s24_host = self.addHost( 'h24' ) |
| 129 | s25_host = self.addHost( 'h25' ) |
| 130 | s26_host = self.addHost( 'h26' ) |
| 131 | s27_host = self.addHost( 'h27' ) |
| 132 | s28_host = self.addHost( 'h28' ) |
| 133 | s29_host = self.addHost( 'h29' ) |
| 134 | s30_host = self.addHost( 'h30' ) |
| 135 | s31_host = self.addHost( 'h31' ) |
| 136 | s32_host = self.addHost( 'h32' ) |
| 137 | s33_host = self.addHost( 'h33' ) |
| 138 | s34_host = self.addHost( 'h34' ) |
| 139 | s35_host = self.addHost( 'h35' ) |
| 140 | s36_host = self.addHost( 'h36' ) |
| 141 | s37_host = self.addHost( 'h37' ) |
| 142 | s38_host = self.addHost( 'h38' ) |
| 143 | s39_host = self.addHost( 'h39' ) |
| 144 | s40_host = self.addHost( 'h40' ) |
| 145 | s41_host = self.addHost( 'h41' ) |
| 146 | s42_host = self.addHost( 'h42' ) |
| 147 | s43_host = self.addHost( 'h43' ) |
| 148 | s44_host = self.addHost( 'h44' ) |
| 149 | s45_host = self.addHost( 'h45' ) |
| 150 | s46_host = self.addHost( 'h46' ) |
| 151 | s47_host = self.addHost( 'h47' ) |
| 152 | s48_host = self.addHost( 'h48' ) |
| 153 | s49_host = self.addHost( 'h49' ) |
| 154 | s50_host = self.addHost( 'h50' ) |
| 155 | s51_host = self.addHost( 'h51' ) |
| 156 | s52_host = self.addHost( 'h52' ) |
| 157 | s53_host = self.addHost( 'h53' ) |
| 158 | s54_host = self.addHost( 'h54' ) |
| 159 | s55_host = self.addHost( 'h55' ) |
| 160 | s56_host = self.addHost( 'h56' ) |
| 161 | s57_host = self.addHost( 'h57' ) |
| 162 | s58_host = self.addHost( 'h58' ) |
| 163 | s59_host = self.addHost( 'h59' ) |
| 164 | s60_host = self.addHost( 'h60' ) |
| 165 | s61_host = self.addHost( 'h61' ) |
| 166 | s62_host = self.addHost( 'h62' ) |
| 167 | s63_host = self.addHost( 'h63' ) |
| 168 | s64_host = self.addHost( 'h64' ) |
| 169 | s65_host = self.addHost( 'h65' ) |
| 170 | s66_host = self.addHost( 'h66' ) |
| 171 | s67_host = self.addHost( 'h67' ) |
| 172 | s68_host = self.addHost( 'h68' ) |
| 173 | s69_host = self.addHost( 'h69' ) |
| 174 | s70_host = self.addHost( 'h70' ) |
| 175 | s71_host = self.addHost( 'h71' ) |
| 176 | s72_host = self.addHost( 'h72' ) |
| 177 | s73_host = self.addHost( 'h73' ) |
| 178 | s74_host = self.addHost( 'h74' ) |
| 179 | s75_host = self.addHost( 'h75' ) |
| 180 | s76_host = self.addHost( 'h76' ) |
| 181 | s77_host = self.addHost( 'h77' ) |
| 182 | s78_host = self.addHost( 'h78' ) |
| 183 | |
| 184 | # add edges between switch and corresponding host |
| 185 | #self.addLink( s1 , s1_host ) |
| 186 | #self.addLink( s2 , s2_host ) |
| 187 | #self.addLink( s3 , s3_host ) |
| 188 | #self.addLink( s4 , s4_host ) |
| 189 | #self.addLink( s5 , s5_host ) |
| 190 | #self.addLink( s6 , s6_host ) |
| 191 | #self.addLink( s7 , s7_host ) |
| 192 | #self.addLink( s8 , s8_host ) |
| 193 | #self.addLink( s9 , s9_host ) |
| 194 | #self.addLink( s10 , s10_host ) |
| 195 | self.addLink( s11 , s11_host ) |
| 196 | self.addLink( s12 , s12_host ) |
| 197 | self.addLink( s13 , s13_host ) |
| 198 | self.addLink( s14 , s14_host ) |
| 199 | self.addLink( s15 , s15_host ) |
| 200 | self.addLink( s16 , s16_host ) |
| 201 | self.addLink( s17 , s17_host ) |
| 202 | self.addLink( s18 , s18_host ) |
| 203 | self.addLink( s19 , s19_host ) |
| 204 | self.addLink( s20 , s20_host ) |
| 205 | self.addLink( s21 , s21_host ) |
| 206 | self.addLink( s22 , s22_host ) |
| 207 | self.addLink( s23 , s23_host ) |
| 208 | self.addLink( s24 , s24_host ) |
| 209 | self.addLink( s25 , s25_host ) |
| 210 | self.addLink( s26 , s26_host ) |
| 211 | self.addLink( s27 , s27_host ) |
| 212 | self.addLink( s28 , s28_host ) |
| 213 | self.addLink( s29 , s29_host ) |
| 214 | self.addLink( s30 , s30_host ) |
| 215 | self.addLink( s31 , s31_host ) |
| 216 | self.addLink( s32 , s32_host ) |
| 217 | self.addLink( s33 , s33_host ) |
| 218 | self.addLink( s34 , s34_host ) |
| 219 | self.addLink( s35 , s35_host ) |
| 220 | self.addLink( s36 , s36_host ) |
| 221 | self.addLink( s37 , s37_host ) |
| 222 | self.addLink( s38 , s38_host ) |
| 223 | self.addLink( s39 , s39_host ) |
| 224 | self.addLink( s40 , s40_host ) |
| 225 | self.addLink( s41 , s41_host ) |
| 226 | self.addLink( s42 , s42_host ) |
| 227 | self.addLink( s43 , s43_host ) |
| 228 | self.addLink( s44 , s44_host ) |
| 229 | self.addLink( s45 , s45_host ) |
| 230 | self.addLink( s46 , s46_host ) |
| 231 | self.addLink( s47 , s47_host ) |
| 232 | self.addLink( s48 , s48_host ) |
| 233 | self.addLink( s49 , s49_host ) |
| 234 | self.addLink( s50 , s50_host ) |
| 235 | self.addLink( s51 , s51_host ) |
| 236 | self.addLink( s52 , s52_host ) |
| 237 | self.addLink( s53 , s53_host ) |
| 238 | self.addLink( s54 , s54_host ) |
| 239 | self.addLink( s55 , s55_host ) |
| 240 | self.addLink( s56 , s56_host ) |
| 241 | self.addLink( s57 , s57_host ) |
| 242 | self.addLink( s58 , s58_host ) |
| 243 | self.addLink( s59 , s59_host ) |
| 244 | self.addLink( s60 , s60_host ) |
| 245 | self.addLink( s61 , s61_host ) |
| 246 | self.addLink( s62 , s62_host ) |
| 247 | self.addLink( s63 , s63_host ) |
| 248 | self.addLink( s64 , s64_host ) |
| 249 | self.addLink( s65 , s65_host ) |
| 250 | self.addLink( s66 , s66_host ) |
| 251 | self.addLink( s67 , s67_host ) |
| 252 | self.addLink( s68 , s68_host ) |
| 253 | self.addLink( s69 , s69_host ) |
| 254 | self.addLink( s70 , s70_host ) |
| 255 | self.addLink( s71 , s71_host ) |
| 256 | self.addLink( s72 , s72_host ) |
| 257 | self.addLink( s73 , s73_host ) |
| 258 | self.addLink( s74 , s74_host ) |
| 259 | self.addLink( s75 , s75_host ) |
| 260 | self.addLink( s76 , s76_host ) |
| 261 | self.addLink( s77 , s77_host ) |
| 262 | self.addLink( s78 , s78_host ) |
| 263 | |
| 264 | #info( '*** Add Leaf links\n') |
| 265 | self.addLink(s1, s9) |
| 266 | self.addLink(s2, s10) |
| 267 | self.addLink(s3, s9) |
| 268 | self.addLink(s4, s10) |
| 269 | self.addLink(s5, s9) |
| 270 | self.addLink(s6, s10) |
| 271 | self.addLink(s7, s9) |
| 272 | self.addLink(s8, s10) |
| 273 | self.addLink(s9, s11) |
| 274 | self.addLink(s9, s12) |
| 275 | self.addLink(s10, s13) |
| 276 | self.addLink(s10, s14) |
| 277 | self.addLink(s11, s12) |
| 278 | self.addLink(s13, s14) |
| 279 | |
| 280 | #info( '*** Add Spine-1 links\n') |
| 281 | self.addLink(s15, s1) |
| 282 | self.addLink(s15, s2) |
| 283 | self.addLink(s16, s1) |
| 284 | self.addLink(s16, s2) |
| 285 | self.addLink(s17, s1) |
| 286 | self.addLink(s17, s2) |
| 287 | self.addLink(s18, s1) |
| 288 | self.addLink(s18, s2) |
| 289 | self.addLink(s19, s1) |
| 290 | self.addLink(s19, s2) |
| 291 | self.addLink(s20, s1) |
| 292 | self.addLink(s20, s2) |
| 293 | self.addLink(s21, s1) |
| 294 | self.addLink(s21, s2) |
| 295 | self.addLink(s22, s1) |
| 296 | self.addLink(s22, s2) |
| 297 | self.addLink(s23, s1) |
| 298 | self.addLink(s23, s2) |
| 299 | self.addLink(s24, s1) |
| 300 | self.addLink(s24, s2) |
| 301 | self.addLink(s25, s1) |
| 302 | self.addLink(s25, s2) |
| 303 | self.addLink(s26, s1) |
| 304 | self.addLink(s26, s2) |
| 305 | self.addLink(s27, s1) |
| 306 | self.addLink(s27, s2) |
| 307 | self.addLink(s28, s1) |
| 308 | self.addLink(s28, s2) |
| 309 | self.addLink(s29, s1) |
| 310 | self.addLink(s29, s2) |
| 311 | self.addLink(s30, s1) |
| 312 | self.addLink(s30, s2) |
| 313 | |
| 314 | #info( '*** Add Spine-2 links\n') |
| 315 | self.addLink(s31, s3) |
| 316 | self.addLink(s31, s4) |
| 317 | self.addLink(s32, s3) |
| 318 | self.addLink(s32, s4) |
| 319 | self.addLink(s33, s3) |
| 320 | self.addLink(s33, s4) |
| 321 | self.addLink(s34, s3) |
| 322 | self.addLink(s34, s4) |
| 323 | self.addLink(s35, s3) |
| 324 | self.addLink(s35, s4) |
| 325 | self.addLink(s36, s3) |
| 326 | self.addLink(s36, s4) |
| 327 | self.addLink(s37, s3) |
| 328 | self.addLink(s37, s4) |
| 329 | self.addLink(s38, s3) |
| 330 | self.addLink(s38, s4) |
| 331 | self.addLink(s39, s3) |
| 332 | self.addLink(s39, s4) |
| 333 | self.addLink(s40, s3) |
| 334 | self.addLink(s40, s4) |
| 335 | self.addLink(s41, s3) |
| 336 | self.addLink(s41, s4) |
| 337 | self.addLink(s42, s3) |
| 338 | self.addLink(s42, s4) |
| 339 | self.addLink(s43, s3) |
| 340 | self.addLink(s43, s4) |
| 341 | self.addLink(s44, s3) |
| 342 | self.addLink(s44, s4) |
| 343 | self.addLink(s45, s3) |
| 344 | self.addLink(s45, s4) |
| 345 | self.addLink(s46, s3) |
| 346 | self.addLink(s46, s4) |
| 347 | |
| 348 | #info( '*** Add Spine-3 links\n') |
| 349 | self.addLink(s47, s5) |
| 350 | self.addLink(s47, s6) |
| 351 | self.addLink(s48, s5) |
| 352 | self.addLink(s48, s6) |
| 353 | self.addLink(s49, s5) |
| 354 | self.addLink(s49, s6) |
| 355 | self.addLink(s50, s5) |
| 356 | self.addLink(s50, s6) |
| 357 | self.addLink(s51, s5) |
| 358 | self.addLink(s51, s6) |
| 359 | self.addLink(s52, s5) |
| 360 | self.addLink(s52, s6) |
| 361 | self.addLink(s53, s5) |
| 362 | self.addLink(s53, s6) |
| 363 | self.addLink(s54, s5) |
| 364 | self.addLink(s54, s6) |
| 365 | self.addLink(s55, s5) |
| 366 | self.addLink(s55, s6) |
| 367 | self.addLink(s56, s5) |
| 368 | self.addLink(s56, s6) |
| 369 | self.addLink(s57, s5) |
| 370 | self.addLink(s57, s6) |
| 371 | self.addLink(s58, s5) |
| 372 | self.addLink(s58, s6) |
| 373 | self.addLink(s59, s5) |
| 374 | self.addLink(s59, s6) |
| 375 | self.addLink(s60, s5) |
| 376 | self.addLink(s60, s6) |
| 377 | self.addLink(s61, s5) |
| 378 | self.addLink(s61, s6) |
| 379 | self.addLink(s62, s5) |
| 380 | self.addLink(s62, s6) |
| 381 | |
| 382 | #info( '*** Add Spine-4 links\n') |
| 383 | self.addLink(s63, s7) |
| 384 | self.addLink(s63, s8) |
| 385 | self.addLink(s64, s7) |
| 386 | self.addLink(s64, s8) |
| 387 | self.addLink(s65, s7) |
| 388 | self.addLink(s65, s8) |
| 389 | self.addLink(s66, s7) |
| 390 | self.addLink(s66, s8) |
| 391 | self.addLink(s67, s7) |
| 392 | self.addLink(s67, s8) |
| 393 | self.addLink(s68, s7) |
| 394 | self.addLink(s68, s8) |
| 395 | self.addLink(s69, s7) |
| 396 | self.addLink(s69, s8) |
| 397 | self.addLink(s70, s7) |
| 398 | self.addLink(s70, s8) |
| 399 | self.addLink(s71, s7) |
| 400 | self.addLink(s71, s8) |
| 401 | self.addLink(s72, s7) |
| 402 | self.addLink(s72, s8) |
| 403 | self.addLink(s73, s7) |
| 404 | self.addLink(s73, s8) |
| 405 | self.addLink(s74, s7) |
| 406 | self.addLink(s74, s8) |
| 407 | self.addLink(s75, s7) |
| 408 | self.addLink(s75, s8) |
| 409 | self.addLink(s76, s7) |
| 410 | self.addLink(s76, s8) |
| 411 | self.addLink(s77, s7) |
| 412 | self.addLink(s77, s8) |
| 413 | self.addLink(s78, s7) |
| 414 | self.addLink(s78, s8) |
| 415 | |
| 416 | topos = { 'spine': ( lambda: spineTopo() ) } |
| 417 | |
| 418 | # HERE THE CODE DEFINITION OF THE TOPOLOGY ENDS |
| 419 | |
| 420 | def setupNetwork(): |
| 421 | "Create network" |
| 422 | topo = spineTopo() |
| 423 | #if controller_ip == '': |
| 424 | #controller_ip = '10.0.2.2'; |
| 425 | # controller_ip = '127.0.0.1'; |
| 426 | network = Mininet(topo=topo, switch=OVSSwitch, link=TCLink, autoSetMacs = True, controller=None) |
| 427 | network.start() |
| 428 | CLI( network ) |
| 429 | network.stop() |
| 430 | |
| 431 | if __name__ == '__main__': |
| 432 | setLogLevel('info') |
| 433 | #setLogLevel('debug') |
| 434 | setupNetwork() |