def create (switch_type = FakeEntity, host_type = FakeEntity, n = 2): global expectedUpdate1 global expectedSender1 global waittime print "Creating routers..." RIPRouter.create('A') RIPRouter.create('B') RIPRouter.create('C') RIPRouter.create('D') RIPRouter.create('E') RIPRouter.create('F') RIPRouter.create('G') RIPRouter.create('H') RIPRouter.create('I') RIPRouter.create('J') createExpectedDict() FakeEntity.create('Z', expectedUpdate1, expectedSender1, {}) print "Case 1: A-B-Z" topo.link(A, B) #A - B - Z topo.link(B, Z) time.sleep(waittime) if(failed): return print "Case 2: A B-Z" topo.unlink(A, B) #A B - Z time.sleep(waittime) if(failed): return print "Case 3: A-B Z" topo.unlink(B, Z) time.sleep(waittime/2) topo.link(A, B) #A - B Z time.sleep(waittime) if(failed): return print "Case 4: A-B-C-D-E-Z" topo.link(E, Z) #A - B - C - D - E - Z topo.link(B, C) topo.link(C, D) time.sleep(waittime) topo.link(D, E) time.sleep(waittime) if(failed): return print "Case 5: Circle(A,E)-Z" topo.link(E, A) #A - B - C - D - E - Z time.sleep(waittime) # \_____________/ if(failed): return print "Case 6: Clique(A,E)-Z" #topo.link(A, B) topo.link(A, C) topo.link(A, D) #topo.link(A, E) #topo.link(B, C) topo.link(B, D) # ---A--- topo.link(B, E) # / / \ \ time.sleep(waittime) # B--|---|-E -- Z #topo.link(C, D) # \ |/ \| / topo.link(C, E) # C-----D #topo.link(D, E) # Clique time.sleep(waittime) if(failed): return print "Case 7: Centralize(A,{B,C,D,E,Z}" #topo.unlink(A, B) #topo.unlink(A, C) #topo.unlink(A, D) #topo.unlink(A, E) topo.unlink(E, Z) topo.unlink(B, C) topo.unlink(B, D) # Z topo.unlink(B, E) # | topo.unlink(C, D) # B -- A -- E topo.unlink(C, E) # / \ topo.unlink(D, E) # C D time.sleep(waittime) topo.link(A, Z) time.sleep(waittime) if(failed): return print "Case 8: Centralize(A,Circle(B-E,Z))" topo.link(B, C) topo.link(C, D) topo.link(D, E) time.sleep(waittime) # ---Z--- topo.link(E, Z) # / | \ time.sleep(waittime/2) # B -- A -- E topo.link(Z, B) # \ / \ / time.sleep(waittime) # C-----D if(failed): return print "Case 9: A-B-Branch(Z, C-D-E, F-G)" topo.unlink(A, Z) topo.unlink(E, Z) topo.unlink(B, Z) #topo.unlink(A, B) topo.unlink(A, C) topo.unlink(A, D) topo.unlink(A, E) topo.unlink(B, C) topo.link(F, G) #print "REM" #topo.unlink(C, D) #topo.unlink(D, E) time.sleep(waittime) topo.link(B, Z) time.sleep(waittime/2) Z.send_specific_announce({F: 1, G: 2, C: 1, D: 2, E: 3}) time.sleep(waittime/2) topo.unlink(B, Z) topo.link(Z, C) time.sleep(waittime/2) Z.send_specific_announce({F: 1, G: 2, B: 1, A: 2}) time.sleep(waittime/2) # topo.unlink(C, Z) # F - G topo.link(Z, F) # | time.sleep(waittime/2) # A - B - Z - C - D - E Z.send_specific_announce({B: 1, A: 2, C: 1, D: 2, E: 3}) time.sleep(waittime/2) topo.unlink(F, G) Z.send_specific_announce({B: 1, A: 2, C: 1, D: 2, E: 3, G: 100}) #print "NIM" time.sleep(waittime/2) topo.link(F, G) time.sleep(waittime) if(failed): return print "Case 10: EShaped(ABC,EHD,FGZ)" #topo.unlink(B, Z) #topo.unlink(Z, C) topo.unlink(Z, F) #topo.unlink(A, B) topo.unlink(C, D) topo.unlink(D, E) #topo.unlink(F, G) topo.link(B, C) topo.link(A, E) # A ------B------C topo.link(E, H) # | topo.link(H, D) # E ------H------D topo.link(A, F) # | time.sleep(waittime) # F-------G------Z topo.link(G, Z) time.sleep(waittime/2) topo.disconnect(H) time.sleep(waittime) if(failed): return A.remove() B.remove() C.remove() D.remove() E.remove() F.remove() G.remove() H.remove() I.remove() J.remove() Z.remove()
def create(switch_type=FakeEntity, host_type=FakeEntity, n=2): global expectedUpdate1 global expectedSender1 global waittime global testCaseNum print "Creating routers..." DVRouter.create('A') DVRouter.create('B') DVRouter.create('C') DVRouter.create('D') DVRouter.create('E') DVRouter.create('F') DVRouter.create('G') DVRouter.create('H') DVRouter.create('I') DVRouter.create('J') createExpectedDict() FakeEntity.create('Z', expectedUpdate1, expectedSender1, {}) print "Case 1: A-B-Z" testCaseNum += 1 topo.link(A, B) #A - B - Z topo.link(B, Z) time.sleep(waittime) if (failed): return print "Case 2: A B-Z" testCaseNum += 1 topo.unlink(A, B) #A B - Z time.sleep(waittime) if (failed): return print "Case 3: A-B Z" testCaseNum += 1 topo.unlink(B, Z) time.sleep(waittime / 2) topo.link(A, B) #A - B Z time.sleep(waittime) if (failed): return print "Case 4: A-B-C-D-E-Z" testCaseNum += 1 topo.link(E, Z) #A - B - C - D - E - Z topo.link(B, C) topo.link(C, D) time.sleep(waittime) topo.link(D, E) time.sleep(waittime) if (failed): return print "Case 5: Circle(A,E)-Z" testCaseNum += 1 topo.link(E, A) #A - B - C - D - E - Z time.sleep(waittime) # \_____________/ if (failed): return print "Case 6: Clique(A,E)-Z" testCaseNum += 1 #topo.link(A, B) topo.link(A, C) topo.link(A, D) #topo.link(A, E) #topo.link(B, C) topo.link(B, D) # ---A--- topo.link(B, E) # / / \ \ time.sleep(waittime) # B--|---|-E -- Z #topo.link(C, D) # \ |/ \| / topo.link(C, E) # C-----D #topo.link(D, E) # Clique time.sleep(waittime) if (failed): return print "Case 7: Centralize(A,{B,C,D,E,Z}" testCaseNum += 1 #topo.unlink(A, B) #topo.unlink(A, C) #topo.unlink(A, D) #topo.unlink(A, E) topo.unlink(E, Z) topo.unlink(B, C) topo.unlink(B, D) # Z topo.unlink(B, E) # | topo.unlink(C, D) # B -- A -- E topo.unlink(C, E) # / \ topo.unlink(D, E) # C D time.sleep(waittime) topo.link(A, Z) time.sleep(waittime) if (failed): return print "Case 8: Centralize(A,Circle(B-E,Z))" testCaseNum += 1 topo.link(B, C) topo.link(C, D) topo.link(D, E) time.sleep(waittime) # ---Z--- topo.link(E, Z) # / | \ time.sleep(waittime / 2) # B -- A -- E topo.link(Z, B) # \ / \ / time.sleep(waittime) # C-----D if (failed): return print "Case 9: A-B-Branch(Z, C-D-E, F-G)" testCaseNum += 1 topo.unlink(A, Z) topo.unlink(E, Z) topo.unlink(B, Z) #topo.unlink(A, B) topo.unlink(A, C) topo.unlink(A, D) topo.unlink(A, E) topo.unlink(B, C) topo.link(F, G) #print "REM" #topo.unlink(C, D) #topo.unlink(D, E) time.sleep(waittime) topo.link(B, Z) time.sleep(waittime / 2) Z.send_specific_announce({F: 1, G: 2, C: 1, D: 2, E: 3}) time.sleep(waittime / 2) topo.unlink(B, Z) topo.link(Z, C) time.sleep(waittime / 2) Z.send_specific_announce({F: 1, G: 2, B: 1, A: 2}) time.sleep(waittime / 2) # topo.unlink(C, Z) # F - G topo.link(Z, F) # | time.sleep(waittime / 2) # A - B - Z - C - D - E Z.send_specific_announce({B: 1, A: 2, C: 1, D: 2, E: 3}) time.sleep(waittime / 2) topo.unlink(F, G) Z.send_specific_announce({B: 1, A: 2, C: 1, D: 2, E: 3, G: 100}) #print "NIM" time.sleep(waittime / 2) topo.link(F, G) time.sleep(waittime) if (failed): return print "Case 10: EShaped(ABC,EHD,FGZ)" testCaseNum += 1 #topo.unlink(B, Z) #topo.unlink(Z, C) topo.unlink(Z, F) #topo.unlink(A, B) topo.unlink(C, D) topo.unlink(D, E) #topo.unlink(F, G) topo.link(B, C) topo.link(A, E) # A ------B------C topo.link(E, H) # | topo.link(H, D) # E ------H------D topo.link(A, F) # | time.sleep(waittime) # F-------G------Z topo.link(G, Z) time.sleep(waittime / 2) topo.disconnect(H) time.sleep(waittime) if (failed): return A.remove() B.remove() C.remove() D.remove() E.remove() F.remove() G.remove() H.remove() I.remove() J.remove() Z.remove()