コード例 #1
0
def drop():
    print '----------------------------------------'
    print '|Link-down convergence Benchmark for LS|'
    print '----------------------------------------'
    print '######remove link between s1 and s2#####'  
    s1.convergencedTable = {s4: 2, h1b: 2, s3: 3, h2b: 2, h1a: 0, s5: 2, s2: 3, h2a: 3}
    s2.convergencedTable = {h2a: 0, s1: 3, s3: 3, s5: 2, h1b: 2, h1a: 3, h2b: 2, s4: 2}
    s3.convergencedTable = {h2a: 1, s4: 2, s1: 0, h1b: 2, h2b: 3, h1a: 0, s5: 3, s2: 1}
    s4.convergencedTable = {h2a: 1, s1: 2, s3: 3, h1b: 0, s5: 1, h1a: 2, h2b: 1, s2: 1}
    s5.convergencedTable = {h1a: 2, s4: 2, s1: 2, h1b: 2, s3: 3, s2: 1, h2b: 0, h2a: 1}
    topo.unlink(s1, s2)
    start_time = time.time()
    timer_s1 = create_timer(0.0001, s1.checklDownConvergened, kw = {"start":start_time})
    timer_s2 = create_timer(0.0001, s2.checklDownConvergened, kw = {"start":start_time})
    timer_s3 = create_timer(0.0001, s3.checklDownConvergened, kw = {"start":start_time})
    timer_s4 = create_timer(0.0001, s4.checklDownConvergened, kw = {"start":start_time})
    timer_s5 = create_timer(0.0001, s5.checklDownConvergened, kw = {"start":start_time})
コード例 #2
0
def drop():
    print '-----------------------------------------'
    print '|Link-down convergence Benchmark for RIP|'
    print '-----------------------------------------'
    print '######remove link between s1 and s2######'
    s1.convergencedTable = {h1a: {h1a: (1, 0)}, s4: {s5: (2, 2), h2b: (3, 2), h2a: (4, 2), s2: (3, 2), h1b: (2, 2), s4: (1, 2), h1a: (101, 2), s3: (2, 2)}, s3: {s5: (2, 3), h2b: (3, 3), h2a: (3, 3), s4: (2, 3), h1b: (3, 3), s2: (2, 3), h1a: (101, 3), s3: (1, 3)}}
    s2.convergencedTable = {h2a: {h2a: (1, 0)}, s3: {s5: (2, 3), h2b: (3, 3), h2a: (101, 3), s1: (2, 3), h1b: (3, 3), s4: (2, 3), h1a: (3, 3), s3: (1, 3)}, s5: {s5: (1, 2), h2b: (2, 2), h2a: (101, 2), s1: (3, 2), h1b: (3, 2), s4: (2, 2), h1a: (4, 2), s3: (2, 2)}}
    s3.convergencedTable = {s5: {s5: (1, 3), h2b: (2, 3), s4: (2, 3), s2: (2, 3), s1: (3, 3), h1b: (3, 3), h2a: (3, 3), h1a: (4, 3)}, s2: {s5: (2, 1), h2b: (3, 1), h2a: (2, 1), s1: (101, 1), h1b: (4, 1), s2: (1, 1), s4: (3, 1), h1a: (101, 1)}, s1: {s5: (3, 0), h2b: (4, 0), s4: (2, 0), s1: (1, 0), h1b: (3, 0), s2: (101, 0), h2a: (101, 0), h1a: (2, 0)}, s4: {s5: (2, 2), h2b: (3, 2), h2a: (4, 2), s2: (3, 2), s1: (2, 2), h1b: (2, 2), s4: (1, 2), h1a: (3, 2)}}
    s4.convergencedTable = {h1b: {h1b: (1, 0)}, s1: {s5: (101, 2), h2b: (101, 2), h2a: (4, 2), s1: (1, 2), h1b: (101, 2), s2: (3, 2), h1a: (2, 2), s3: (2, 2)}, s3: {s5: (2, 3), h2b: (3, 3), h2a: (3, 3), s1: (2, 3), h1b: (101, 3), s2: (2, 3), h1a: (3, 3), s3: (1, 3)}, s5: {s5: (1, 1), h2b: (2, 1), h2a: (3, 1), s1: (101, 1), h1b: (101, 1), s2: (2, 1), h1a: (101, 1), s3: (2, 1)}}
    s5.convergencedTable = {h2b: {h2b: (1, 0)}, s4: {h2b: (101, 2), s3: (2, 2), h2a: (101, 2), s1: (2, 2), h1b: (2, 2), s2: (101, 2), s4: (1, 2), h1a: (3, 2)}, s3: {h2b: (101, 3), h1b: (3, 3), h2a: (3, 3), s1: (2, 3), s4: (2, 3), s3: (1, 3), h1a: (3, 3), s2: (2, 3)}, s2: {h2b: (101, 1), s3: (2, 1), h2a: (2, 1), s1: (3, 1), h1a: (4, 1), h1b: (101, 1), s4: (101, 1), s2: (1, 1)}}
    topo.unlink(s1, s2)
    start_time = time.time()
    timer_s1 = create_timer(0.0001, s1.checklDownConvergened, kw = {"start":start_time})
    timer_s2 = create_timer(0.0001, s2.checklDownConvergened, kw = {"start":start_time})
    timer_s3 = create_timer(0.0001, s3.checklDownConvergened, kw = {"start":start_time})
    timer_s4 = create_timer(0.0001, s4.checklDownConvergened, kw = {"start":start_time})
    timer_s5 = create_timer(0.0001, s5.checklDownConvergened, kw = {"start":start_time})
コード例 #3
0
ファイル: loop2.py プロジェクト: ziranshang/cs168_proj1
    topo.link(s3, s4)
    topo.link(s4, s5)

import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = False

create(switch)
start = sim.core.simulate
start()
time.sleep(30)
topo.unlink(s2, s5)
time.sleep(30)
h2a.ping(h1a)
print("first ping sent")
time.sleep(30)
h2a.ping(h1a)
print("second ping sent")
time.sleep(30)
h2a.ping(h1a)
print("third ping sent")
time.sleep(30)
print("TIMEOUT")
os._exit(50)
コード例 #4
0
    topo.link(s1, s2)
    topo.link(s2, s3)


import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(5)

print "unlink"
topo.unlink(s1, s2)
time.sleep(5)

h3.ping(h1)
print("ping sent")
time.sleep(10)

print("OVER")
os._exit(50)
コード例 #5
0
    topo.link(s1, s2)
    topo.link(s2, s3)

import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(5)

print "unlink"
topo.unlink(s1, s2)
time.sleep(5)

h3.ping(h1)
print("ping sent")
time.sleep(10)


print("OVER")
os._exit(50)
コード例 #6
0
def create(switch_type=FakeEntity, host_type=FakeEntity, n=2):
    RIPRouter.create('A')
    RIPRouter.create('B')
    FakeEntity.create('C', {A: 1}, {})
    topo.link(A, B)
    topo.link(B, C)


import sim.core
from hub import Hub as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(10)
topo.unlink(A, B)
time.sleep(10)
if (failed):
    print("You have failed since I got unexpected updates!")
    os._exit(0)
else:
    print("Test is successful!")
    os._exit(2)
コード例 #7
0
import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(20)
topo.unlink(y, z)
topo.link(y, z, 2)
topo.unlink(x, z)
topo.link(x, z, 2)
topo.unlink(x, y)
topo.link(x, y, 1)
time.sleep(20)
h1.ping(h2)
print("first ping sent")
time.sleep(30)
h1.ping(h2)
print("second ping sent")
time.sleep(30)
h1.ping(h2)
print("third ping sent")
time.sleep(30)
コード例 #8
0
    topo.link(s1, ho)

    topo.link(s1, s2)
    topo.link(s2, s3)
    topo.link(s1, s3)


import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()

time.sleep(20)

topo.unlink(s1, ho)

time.sleep(100)

print("OVER")
os._exit(50)
コード例 #9
0
import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(30)
print("STARTING TO UNLINK")
topo.unlink(s1, h1b)
topo.unlink(s7, s6)
topo.unlink(s3, s2)
time.sleep(30)
h2a.ping(h1a)
print("first ping sent")
time.sleep(30)
# h2a.ping(h1a)
# print("second ping sent")
# time.sleep(30)
# h2a.ping(h1a)
# print("third ping sent")
# time.sleep(30)
print("TIMEOUT")
os._exit(50)
import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(30)

topo.unlink(s1, h1b)
topo.unlink(s7, s6)
topo.unlink(s3, s2)
time.sleep(30)

h2a.ping(h1a)
print("first ping sent")
time.sleep(30)
h2a.ping(h1a)
print("second ping sent")
time.sleep(30)
h2a.ping(h1a)
print("third ping sent")
time.sleep(30)
print("TIMEOUT")
os._exit(50)
コード例 #11
0
ファイル: big2.py プロジェクト: ziranshang/cs168_proj1
    topo.link(s5, s2)

import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(30)
topo.unlink(s7, s6)
topo.unlink(s3, s2)
time.sleep(30)
h2a.ping(h1a)
print("first ping sent")
time.sleep(30)
h2a.ping(h1a)
print("second ping sent")
time.sleep(30)
h2a.ping(h1a)
print("third ping sent")
time.sleep(30)
print("TIMEOUT")
os._exit(50)
コード例 #12
0
ファイル: link_break1.py プロジェクト: dradding/DVR
import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(10)
topo.unlink(s1, s3)
time.sleep(10)
h2a.ping(h1a)
print("first ping sent")
time.sleep(10)
h2a.ping(h1a)
print("second ping sent")
time.sleep(10)
h2a.ping(h1a)
print("third ping sent")
time.sleep(10)
h1a.ping(h2a)
print("first ping sent")
time.sleep(10)
h1a.ping(h2a)
print("second ping sent")
コード例 #13
0
ファイル: infinity.py プロジェクト: qkw24/CS168-Project-1
    topo.link(s1, ho)

    topo.link(s1, s2)
    topo.link(s2, s3)
    topo.link(s1, s3)

import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()

time.sleep(20)

topo.unlink(s1, ho)

time.sleep(100)


print("OVER")
os._exit(50)
コード例 #14
0
def drop():
    print '----------------------------------------'
    print '|Link-down convergence Benchmark for LS|'
    print '----------------------------------------'
    print '######remove link between s1 and s2#####'
    s1.convergencedTable = {
        s4: 2,
        h1b: 2,
        s3: 3,
        h2b: 2,
        h1a: 0,
        s5: 2,
        s2: 3,
        h2a: 3
    }
    s2.convergencedTable = {
        h2a: 0,
        s1: 3,
        s3: 3,
        s5: 2,
        h1b: 2,
        h1a: 3,
        h2b: 2,
        s4: 2
    }
    s3.convergencedTable = {
        h2a: 1,
        s4: 2,
        s1: 0,
        h1b: 2,
        h2b: 3,
        h1a: 0,
        s5: 3,
        s2: 1
    }
    s4.convergencedTable = {
        h2a: 1,
        s1: 2,
        s3: 3,
        h1b: 0,
        s5: 1,
        h1a: 2,
        h2b: 1,
        s2: 1
    }
    s5.convergencedTable = {
        h1a: 2,
        s4: 2,
        s1: 2,
        h1b: 2,
        s3: 3,
        s2: 1,
        h2b: 0,
        h2a: 1
    }
    topo.unlink(s1, s2)
    start_time = time.time()
    timer_s1 = create_timer(0.0001,
                            s1.checklDownConvergened,
                            kw={"start": start_time})
    timer_s2 = create_timer(0.0001,
                            s2.checklDownConvergened,
                            kw={"start": start_time})
    timer_s3 = create_timer(0.0001,
                            s3.checklDownConvergened,
                            kw={"start": start_time})
    timer_s4 = create_timer(0.0001,
                            s4.checklDownConvergened,
                            kw={"start": start_time})
    timer_s5 = create_timer(0.0001,
                            s5.checklDownConvergened,
                            kw={"start": start_time})
コード例 #15
0
def create (switch_type = FakeEntity, host_type = FakeEntity, n = 2):
    RIPRouter.create('A')
    RIPRouter.create('B')
    FakeEntity.create('C', {A: 1}, {})
    topo.link(A, B)
    topo.link(B, C)
    
import sim.core
from hub import Hub as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(10)
topo.unlink(A, B)
time.sleep(10)
if(failed):
  print("You have failed since I got unexpected updates!")
  os._exit(0)
else:
  print("Test is successful!")
  os._exit(2)
コード例 #16
0
def drop():
    print '-----------------------------------------'
    print '|Link-down convergence Benchmark for RIP|'
    print '-----------------------------------------'
    print '######remove link between s1 and s2######'
    s1.convergencedTable = {
        h1a: {
            h1a: (1, 0)
        },
        s4: {
            s5: (2, 2),
            h2b: (3, 2),
            h2a: (4, 2),
            s2: (3, 2),
            h1b: (2, 2),
            s4: (1, 2),
            h1a: (101, 2),
            s3: (2, 2)
        },
        s3: {
            s5: (2, 3),
            h2b: (3, 3),
            h2a: (3, 3),
            s4: (2, 3),
            h1b: (3, 3),
            s2: (2, 3),
            h1a: (101, 3),
            s3: (1, 3)
        }
    }
    s2.convergencedTable = {
        h2a: {
            h2a: (1, 0)
        },
        s3: {
            s5: (2, 3),
            h2b: (3, 3),
            h2a: (101, 3),
            s1: (2, 3),
            h1b: (3, 3),
            s4: (2, 3),
            h1a: (3, 3),
            s3: (1, 3)
        },
        s5: {
            s5: (1, 2),
            h2b: (2, 2),
            h2a: (101, 2),
            s1: (3, 2),
            h1b: (3, 2),
            s4: (2, 2),
            h1a: (4, 2),
            s3: (2, 2)
        }
    }
    s3.convergencedTable = {
        s5: {
            s5: (1, 3),
            h2b: (2, 3),
            s4: (2, 3),
            s2: (2, 3),
            s1: (3, 3),
            h1b: (3, 3),
            h2a: (3, 3),
            h1a: (4, 3)
        },
        s2: {
            s5: (2, 1),
            h2b: (3, 1),
            h2a: (2, 1),
            s1: (101, 1),
            h1b: (4, 1),
            s2: (1, 1),
            s4: (3, 1),
            h1a: (101, 1)
        },
        s1: {
            s5: (3, 0),
            h2b: (4, 0),
            s4: (2, 0),
            s1: (1, 0),
            h1b: (3, 0),
            s2: (101, 0),
            h2a: (101, 0),
            h1a: (2, 0)
        },
        s4: {
            s5: (2, 2),
            h2b: (3, 2),
            h2a: (4, 2),
            s2: (3, 2),
            s1: (2, 2),
            h1b: (2, 2),
            s4: (1, 2),
            h1a: (3, 2)
        }
    }
    s4.convergencedTable = {
        h1b: {
            h1b: (1, 0)
        },
        s1: {
            s5: (101, 2),
            h2b: (101, 2),
            h2a: (4, 2),
            s1: (1, 2),
            h1b: (101, 2),
            s2: (3, 2),
            h1a: (2, 2),
            s3: (2, 2)
        },
        s3: {
            s5: (2, 3),
            h2b: (3, 3),
            h2a: (3, 3),
            s1: (2, 3),
            h1b: (101, 3),
            s2: (2, 3),
            h1a: (3, 3),
            s3: (1, 3)
        },
        s5: {
            s5: (1, 1),
            h2b: (2, 1),
            h2a: (3, 1),
            s1: (101, 1),
            h1b: (101, 1),
            s2: (2, 1),
            h1a: (101, 1),
            s3: (2, 1)
        }
    }
    s5.convergencedTable = {
        h2b: {
            h2b: (1, 0)
        },
        s4: {
            h2b: (101, 2),
            s3: (2, 2),
            h2a: (101, 2),
            s1: (2, 2),
            h1b: (2, 2),
            s2: (101, 2),
            s4: (1, 2),
            h1a: (3, 2)
        },
        s3: {
            h2b: (101, 3),
            h1b: (3, 3),
            h2a: (3, 3),
            s1: (2, 3),
            s4: (2, 3),
            s3: (1, 3),
            h1a: (3, 3),
            s2: (2, 3)
        },
        s2: {
            h2b: (101, 1),
            s3: (2, 1),
            h2a: (2, 1),
            s1: (3, 1),
            h1a: (4, 1),
            h1b: (101, 1),
            s4: (101, 1),
            s2: (1, 1)
        }
    }
    topo.unlink(s1, s2)
    start_time = time.time()
    timer_s1 = create_timer(0.0001,
                            s1.checklDownConvergened,
                            kw={"start": start_time})
    timer_s2 = create_timer(0.0001,
                            s2.checklDownConvergened,
                            kw={"start": start_time})
    timer_s3 = create_timer(0.0001,
                            s3.checklDownConvergened,
                            kw={"start": start_time})
    timer_s4 = create_timer(0.0001,
                            s4.checklDownConvergened,
                            kw={"start": start_time})
    timer_s5 = create_timer(0.0001,
                            s5.checklDownConvergened,
                            kw={"start": start_time})
コード例 #17
0
    #topo.link(B, C)
    #topo.link(C, D)
    #topo.link(D, E)
    topo.link(B, E)
    topo.link(B, Z)
    #topo.link(C, Z)
    
import sim.core
from hub import Hub as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(5)
topo.unlink(B, E)
time.sleep(5)
if(failed):
  print("You have failed since I got unexpected updates!")
  print(msg)
  os._exit(0)
else:
  print("Test is successful!")
  os._exit(2)
コード例 #18
0
ファイル: tsao.py プロジェクト: alexgtom/ee122
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()
コード例 #19
0
def kill():
    topo.unlink(s2,s3)
コード例 #20
0
ファイル: jami.py プロジェクト: qkw24/CS168-Project-1
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()
コード例 #21
0

import sim.core
from dv_router import DVRouter as switch

import sim.api as api
import logging
api.simlog.setLevel(logging.DEBUG)
api.userlog.setLevel(logging.DEBUG)

_DISABLE_CONSOLE_LOG = True

create(switch)
start = sim.core.simulate
start()
time.sleep(30)
topo.unlink(s4, s5)
topo.unlink(s1, s3)
time.sleep(30)
h2a.ping(h1a)
print("first ping sent")
time.sleep(30)
h2a.ping(h1a)
print("second ping sent")
time.sleep(30)
h2a.ping(h1a)
print("third ping sent")
time.sleep(30)
print("TIMEOUT")
os._exit(50)