def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:

    h1 -- s1 -------- s3 -- h2
          |            |
          ---- s4 ------
    """

    switch_type.create('s1')
    switch_type.create('s3')
    switch_type.create('s4')

    host_type.create('h1')
    host_type.create('h2')
    

    
    topo.link(s1, s3, 10)
    topo.link(s1, s4, 1)
    topo.link(s4, s3, 5)

    # topo.link(s1, s3)
    # topo.link(s1, s4)
    # topo.link(s4, s3)

    topo.link(h1, s1)
    topo.link(s3, h2)
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
     h1--x ----- y
         |       |
         |       a
         |       |
         v ----- z--h2
    with link weight x<->y = 5
                     y<->a = 3
                     a<->z = 4
                     z<->v = 1
                     v<->x = 2
    run start()
        h1.ping(h2)
    expected path: x -> v -> z
    """

    switch_type.create('x')
    switch_type.create('y')
    switch_type.create('z')
    host_type.create('h1')
    host_type.create('h2')


    topo.link(x, y, 2)
    topo.link(y, z, 1)
    topo.link(x, z, 7)
    topo.link(h1, x, 1)
    topo.link(h2, z, 1)
def create (switch_type = FakeEntity, host_type = FakeEntity, n = 2):
    RIPRouter.create('student')
    BasicHost.create('dest')
    FakeEntity.create('announcer', None, [dest, 7])
    FakeEntity.create('listener', [dest, 8], None)

    topo.link(student, announcer)
    topo.link(student, listener)
示例#4
0
def create(switch_type=FakeEntity, host_type=FakeEntity, n=2):
    DVRouter.create('student')
    BasicHost.create('dest')
    FakeEntity.create('announcer', None, [dest, 7])
    FakeEntity.create('listener', [dest, 8], None)

    topo.link(student, announcer)
    topo.link(student, listener)
def create(switch_type):
    switch_type.create("student")
    BasicHost.create("dest")
    BasicHost.create("src")
    ReceiveEntity.create("announcer1", src)
    ReceiveEntity.create("announcer2", dest)
    ReceiveEntity.create("announcer3", None)

    topo.link(student, announcer1)
    topo.link(student, announcer2)
    topo.link(student, announcer3)
    topo.link(src, announcer1)
    topo.link(dest, announcer2)
def create (switch_type):
    switch_type.create('student')
    BasicHost.create('dest')
    BasicHost.create('src')
    ReceiveEntity.create('announcer1', src)
    ReceiveEntity.create('announcer2', dest)
    ReceiveEntity.create('announcer3', None)

    topo.link(student, announcer1)
    topo.link(student, announcer2)
    topo.link(student, announcer3)
    topo.link(src, announcer1)
    topo.link(dest, announcer2)
def create(switch_type):
    switch_type.create('student')
    BasicHost.create('dest')
    BasicHost.create('src')
    ReceiveEntity.create('announcer1', src)
    ReceiveEntity.create('announcer2', dest)
    ReceiveEntity.create('announcer3', None)

    topo.link(student, announcer1)
    topo.link(student, announcer2)
    topo.link(student, announcer3)
    topo.link(src, announcer1)
    topo.link(dest, announcer2)
示例#8
0
文件: candy.py 项目: pyc3/project1
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5    h2a
       \  /      \  /
        s1        s2
       /  \      /  \ 
    h1b    --s3--    h2b
    """

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    #switch_type.create('s5')

    # host_type.create('h1a')
    # host_type.create('h1b')
    # host_type.create('h2a')
    # host_type.create('h2b')

    topo.link(s1, s2)
    topo.link(s2, s3)
    topo.link(s3, s1)
    topo.link(s2, s4)
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:

        s1 ------ s2
       /  \      /  \ 
     h1    --s3--    h2
    """

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')

    host_type.create('h1')
    host_type.create('h2')

    topo.link(s1, h1)
    topo.link(s2, h2)

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

    topo.link(s1, s2)
示例#10
0
def create(switch_type=DVRouter, host_type=BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5           h2a
       \  /      \          /
        s1        s2--s6--s7
       /  \      /     \    \    
    h1b    --s3--       s8--s9--h2b
    """
    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')

    host_type.create('h1')
    host_type.create('h2')
    host_type.create('h3')

    topo.link(s1, h1)
    topo.link(s2, h2)
    topo.link(s3, h3)

    topo.link(s1, s2)
    topo.link(s2, s3)
示例#11
0
def create (switch_type = DVRouter, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5           h2a
       \  /      \          /
        s1        s2--s6--s7
       /  \      /     \    \    
    h1b    --s3--       s8--s9--h2b
    """
    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')

    host_type.create('h1')
    host_type.create('h2')
    host_type.create('h3')

    topo.link(s1, h1)
    topo.link(s2, h2)
    topo.link(s3, h3)

    topo.link(s1, s2)
    topo.link(s2, s3)
示例#12
0
def create(switch_type=Hub, host_type=BasicHost, n=2):
    """
    Creates a really simple topology like:
    s1 -- s2 -- .. -- sn
     |     |           |
    h1    h2          hn
    n defaults to 2.
    """

    switches = []
    for i in range(1, n + 1):
        s = switch_type.create('s' + str(i))
        switches.append(s)
        h = host_type.create('h' + str(i))
        topo.link(s, h, 2)
        # s.linkTo(h)

    # Connect the switches
    prev = switches[0]
    for s in switches[1:]:
        # prev.linkTo(s)
        # link is the same as linkto
        topo.link(prev, s, 1)  # 这里设置每根线缆的latery为2
        prev = s
示例#13
0
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:

    h1 -- s1 ----s2---- s3 --- s4--- h2

    """

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    

    host_type.create('h1')
    host_type.create('h2')
    

    topo.link(h1, s1)
    topo.link(s1, s2, 2)
    topo.link(s2, s3, 2)
    topo.link(s3, s4, 2)

    topo.link(s4, h2)
示例#14
0
def create (switch_type = FakeEntity, host_type = FakeEntity, n = 2):
    RIPRouter.create('A')
    RIPRouter.create('B')
    #RIPRouter.create('C')
    #RIPRouter.create('D')
    RIPRouter.create('E')
    FakeEntity.create('Z', {A: 1}, {})
    topo.link(A, B)
    #topo.link(B, C)
    #topo.link(C, D)
    #topo.link(D, E)
    topo.link(B, E)
    topo.link(B, Z)
示例#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)
示例#16
0
def create(switch_type=RIPRouter, host_type=BasicHost):
    """
              A---h1a
              |
              |
              B
             / \
            /   \
           C-----D--h1b
    """
    switch_type.create("A")
    switch_type.create("B")
    switch_type.create("C")
    switch_type.create("D")
    host_type.create("h1a")
    host_type.create("h1b")
    topo.link(A, B)
    topo.link(B, C)
    topo.link(C, D)
    topo.link(B, D)
    topo.link(h1a, A)
    topo.link(h1b, D)
    C.OracleTable = {h1b: [[2, 1, D], [3, 0, B]], B: [[1, 0, B], [2, 1, D]], D: [[1, 1, D], [2, 0, B]]}
示例#17
0
def create(switch_type=Hub, host_type=BasicHost):
    """
    Creates the topology required by the simulation:
    hA--sA -- sB--hB
         |  /  |
    hC--sC -- sD--hD
    """
    switch_type.create('sA')
    switch_type.create('sB')
    switch_type.create('sC')
    switch_type.create('sD')

    host_type.create('hA')
    host_type.create('hB')
    host_type.create('hC')
    host_type.create('hD')

    topo.link(sA, hA, latency=0)
    topo.link(sB, hB, latency=0)
    topo.link(sC, hC, latency=0)
    topo.link(sD, hD, latency=0)

    topo.link(sA, sB, latency=2)
    topo.link(sA, sC, latency=7)

    topo.link(sB, sC, latency=1)
    topo.link(sB, sD, latency=3)
    topo.link(sC, sD, latency=1)
示例#18
0
def create(switch_type = RIPBenchmark, host_type = BasicHost):

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')

    host_type.create('h1a')
    host_type.create('h1b')
    host_type.create('h2a')
    host_type.create('h2b')

    topo.link(s1, h1a)
    topo.link(s4, h1b)
    topo.link(s2, h2a)
    topo.link(s5, h2b)

    topo.link(s1, s2)
    topo.link(s2, s5)
    topo.link(s5, s4)
    topo.link(s4, s1)

    topo.link(s3, s1)
    topo.link(s3, s2)
    topo.link(s3, s4)
    topo.link(s3, s5)
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
            h2
            |
            s2
           /  \  
        s1 ---- s3
         |       |
        h1      h3
    
    """

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')

    host_type.create('h1')
    host_type.create('h2')
    host_type.create('h3')

    topo.link(s1, s3, 10)
    topo.link(s3, s2, 1)
    topo.link(s1, s2, 4)
    topo.link(h2, s2, 1)
    topo.link(h1, s1, 1)
    topo.link(h3, s3, 1)
示例#20
0
def create(switch_type=Hub, host_type=BasicHost):
    """
    Creates a topology with loops that looks like:
             h2
             |
             B
          /  |  \
    h1 - A   |   D - h4
          \  |  /
             C
             |
             h3
    """

    a = switch_type.create('a')
    b = switch_type.create('b')
    c = switch_type.create('c')
    d = switch_type.create('d')

    h1 = host_type.create('h1')
    h2 = host_type.create('h2')
    h3 = host_type.create('h3')
    h4 = host_type.create('h4')

    topo.link(h1, a, 1)
    topo.link(h2, b, 1)
    topo.link(h3, c, 1)
    topo.link(h4, d, 1)

    topo.link(a, b, 2)
    topo.link(a, c, 7)
    topo.link(b, c, 1)
    topo.link(b, d, 3)
    topo.link(c, d, 1)
示例#21
0
def create(switch_type = Hub, host_type = BasicHost):
  switch_type.create('s1')
  switch_type.create('s2')
  switch_type.create('s3')
  switch_type.create('s4')
  switch_type.create('s5')
  switch_type.create('s6')
  switch_type.create('s7')

  host_type.create('h1a')
  host_type.create('h2a')

  topo.link(s1, h1a)
  topo.link(s7, h2a)

  topo.link(s1, s2)
  topo.link(s1, s3)
  topo.link(s1, s4)
  topo.link(s1, s5)
  topo.link(s1, s6)

  topo.link(s7, s2)
  topo.link(s7, s3)
  topo.link(s7, s4)
  topo.link(s7, s5)
  topo.link(s7, s6)
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
     h1--A ----- D--h4
         |\     /|
         | --C-- |
         |       |
     h2--B ----- E--h3
    with link weight A<->B = 2
                     A<->D = 7
                     A<->C = 1
                     B<->E = 5
                     C<->D = 2
                     D<->E = 3
                     h1<->A = 1
                     h2<->B = 1
                     h3<->E = 1
                     h4<->D = 1
    run h1.ping(h4)
    expected path: A -> C -> D

    run h1.ping(h3)
    expected path: A -> C -> D -> E

    run h2.ping(h4)
    expected path: B -> A -> C -> D
    """

    switch_type.create('A')
    switch_type.create('B')
    switch_type.create('C')
    switch_type.create('D')
    switch_type.create('E')
    host_type.create('h1')
    host_type.create('h2')
    host_type.create('h3')
    host_type.create('h4')


    topo.link(A, B, 2)
    topo.link(A, D, 7)
    topo.link(A, C, 1)
    topo.link(B, E, 5)
    topo.link(C, D, 2)
    topo.link(D, E, 3)
    topo.link(A, h1, 1)
    topo.link(B, h2, 1)
    topo.link(E, h3, 1)
    topo.link(D, h4, 1)
示例#23
0
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5    h2a
       \  /      \  /
        s1        s2
       /  \      /  \ 
    h1b    --s3--    h2b
    """

    switch_type.create('A')
    switch_type.create('B')
    switch_type.create('C')
    switch_type.create('D')

    host_type.create('ha')
    host_type.create('hb')
    host_type.create('hc')
    host_type.create('hd')

    topo.link(A, ha)
    topo.link(B, hb)
    topo.link(C, hc)
    topo.link(D, hd)

    topo.link(A, B, 1)
    topo.link(A, C, 1)
    topo.link(B, D, 1)
    topo.link(C, D, 10)
示例#24
0
def create(switch_type=RIPRouter, host_type=BasicHost):
    '''
              A---h1a
              |
              |
              B
             / \
            /   \
           C-----D--h1b
    '''
    switch_type.create('A')
    switch_type.create('B')
    switch_type.create('C')
    switch_type.create('D')
    host_type.create('h1a')
    host_type.create('h1b')
    topo.link(A, B)
    topo.link(B, C)
    topo.link(C, D)
    topo.link(B, D)
    topo.link(h1a, A)
    topo.link(h1b, D)
    C.OracleTable = {
        h1b: [[2, 1, D], [3, 0, B]],
        B: [[1, 0, B], [2, 1, D]],
        D: [[1, 1, D], [2, 0, B]]
    }
示例#25
0
def create (switch_type = DVRouter, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a     s3-s4        h2a
       \  /       \      /
        s1         -s5-s6
         \       /         
          --s2--       
    """
    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')
    switch_type.create('s6')

    host_type.create('h1a')
    host_type.create('h2a')

    ReceiveEntity.create('sneakylistener', [s6, s5, s4, s3, s1] , [h1a, 1], 5)

    topo.link(sneakylistener, h1a)
    topo.link(sneakylistener, s1)
    topo.link(s1, s2)
    topo.link(s2, s5)
    topo.link(s5, s6)
    topo.link(s6, h2a)
    topo.link(s1, s3)
    topo.link(s3, s4)
    topo.link(s4, s5)
def create (switch_type = LearningSwitch, host_type = BasicHost):
    

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    

    host_type.create('h1')
    host_type.create('h2')
    host_type.create('h3')
    host_type.create('h4')
    host_type.create('h5')
    host_type.create('h6')

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

    topo.link(s2, h3)
    topo.link(s2, h4)

    topo.link(s3, h5)
    topo.link(s3, h6)

    print "testing: type(h1)==HostEntity? should be True. The answer is %s" % isinstance(h1, HostEntity)
    print "testing: type(s1)==HostEntity? should be False. The answer is %s" % isinstance(s1, HostEntity)
    print "testing: type(s1)==Entity? should be True. The answer is %s" % isinstance(s1, Entity)
    print "testing: type(h1)==Entity? Should be True. the answer is %s" % isinstance(h1, Entity)
示例#27
0
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
        h1    h2
        |     |
        s1 - s2 
         |   /
         |  / 
   h3 -- s3 -
         |
        s4
         |
         h4

    No router should handle packages to h4 is s3 and s4 is unlinked
    """

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')

    host_type.create('h1')
    host_type.create('h2')
    host_type.create('h3')
    host_type.create('h4')

    topo.link(s1, h1)
    topo.link(s2, h2)
    topo.link(s3, h3)
    topo.link(s4, h4)

    topo.link(s1, s2)
    topo.link(s1, s3)
    topo.link(s2, s3)
    topo.link(s3, s4)
示例#28
0
def create (switch_type = FakeEntity, host_type = FakeEntity, n = 2):
    RIPRouter.create('A')
    BasicHost.create('C')
    FakeEntity.create('B', {C: 100}, {C: 1}) 
    topo.link(A, B)
示例#29
0
def create(switch_type=Hub, host_type=BasicHost):
    """
    B-------sbd1-------sbd2-------sbd3------sbd4----------------D
    |\                                                          |
    | \                                                         |
    |  \                                                        |
    sab1\                                                       sdc1
    |    \                                                      |
    |     \                                                     |
    |      \                                                    |
    sab2    sbc1-------------------------------------sbc2       |
    |                                                    \      sdc2
    |                                                     \     |
    |                                                      \    |
    sab3                                                    \   |
    |                                                        \  |
    |                                                         \ |
    |                                                          \|
    A---sac1---sac2---sac3---sac4---sac5---sac6---sac7---sac8---C
    """

    switch_type.create('sbd1')
    switch_type.create('sbd2')
    switch_type.create('sbd3')
    switch_type.create('sbd4')
    switch_type.create('sab1')
    switch_type.create('sab2')
    switch_type.create('sab3')
    switch_type.create('sbc1')
    switch_type.create('sbc2')
    switch_type.create('sdc1')
    switch_type.create('sdc2')
    switch_type.create('sac1')
    switch_type.create('sac2')
    switch_type.create('sac3')
    switch_type.create('sac4')
    switch_type.create('sac5')
    switch_type.create('sac6')
    switch_type.create('sac7')
    switch_type.create('sac8')
    host_type.create('ha')
    host_type.create('hb')
    host_type.create('hc')
    host_type.create('hd')

    topo.link(ha, sac1)
    topo.link(sac1, sac2)
    topo.link(sac2, sac3)
    topo.link(sac3, sac4)
    topo.link(sac4, sac5)
    topo.link(sac5, sac6)
    topo.link(sac6, sac7)
    topo.link(sac7, sac8)
    topo.link(sac8, hc)

    topo.link(hb, sbd1)
    topo.link(sbd1, sbd2)
    topo.link(sbd2, sbd3)
    topo.link(sbd3, sbd4)
    topo.link(sbd4, hd)

    topo.link(hd, sdc1)
    topo.link(sdc1, sdc2)
    topo.link(sdc2, hc)

    topo.link(ha, sab1)
    topo.link(sab1, sab2)
    topo.link(sab2, sab3)
    topo.link(sab3, hb)

    topo.link(hb, sbc1)
    topo.link(sbc1, sbc2)
    topo.link(sbc2, hc)
示例#30
0
def create (switch_type = DVRouter, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5    h2a
       \  /      \  /
        s1        s2
       /  \      /  \ 
    h1b    --s3--    h2b
    """
    
    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')

    host_type.create('h1a')
    host_type.create('h1b')
    host_type.create('h2a')
    host_type.create('h2b')

    topo.link(s1, h1a)
    topo.link(s1, h1b)
    topo.link(s2, h2a)
    topo.link(s2, h2b)

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

    topo.link(s1, s4)
    topo.link(s4, s5)
    topo.link(s5, s2)
示例#31
0
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4-1-s5    h2a
       \2  /4     2\ /3
        s1        s2
       /3  \5    3/  \1
    h1b    --s3--    h2b
    """

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')

    host_type.create('h1a')
    host_type.create('h1b')
    host_type.create('h2a')
    host_type.create('h2b')

    topo.link(s1, h1a, 2)
    topo.link(s1, h1b, 3)
    topo.link(s2, h2a, 3)
    topo.link(s2, h2b, 1)

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

    topo.link(s1, s4, 4)
    topo.link(s4, s5, 1)
    topo.link(s5, s2, 2)
示例#32
0
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()
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)
示例#34
0
def create(switch_type=Hub, host_type=BasicHost):
    host_type.create('s')
    host_type.create('t')

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')

    topo.link(s, s1)

    topo.link(t, s2)
    topo.link(t, s4)

    topo.link(s1, s2)
    topo.link(s1, s3)
    topo.link(s3, s4)
示例#35
0
def create(switch_type=RIPBenchmark, host_type=BasicHost):

    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')

    host_type.create('h1a')
    host_type.create('h1b')
    host_type.create('h2a')
    host_type.create('h2b')

    topo.link(s1, h1a)
    topo.link(s4, h1b)
    topo.link(s2, h2a)
    topo.link(s5, h2b)

    topo.link(s1, s2)
    topo.link(s2, s5)
    topo.link(s5, s4)
    topo.link(s4, s1)

    topo.link(s3, s1)
    topo.link(s3, s2)
    topo.link(s3, s4)
    topo.link(s3, s5)
def create (switch_type = RIPRouter, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5           h2a
       \  /      \          /
        s1        s2--s6--s7
       /  \      /     \    \    
    h1b    --s3--       s8--s9--h2b
    """
    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')

    switch_type.create('s6')
    switch_type.create('s7')
    switch_type.create('s8')
    switch_type.create('s9')


    host_type.create('h1a')
    host_type.create('h1b')
    host_type.create('h2a')
    host_type.create('h2b')


    ReceiveEntity.create('sneakylistener', [s7, s9, s8, s6, s2, s5, s4, s1] , [h1a, 1], 5)

    topo.link(sneakylistener, h1a)
    topo.link(sneakylistener, s1)
    topo.link(s1, h1b)
    topo.link(s2, s6)
    topo.link(s6, s8)
    topo.link(s8, s9)
    topo.link(s9, h2b)
    topo.link(s6, s7)
    topo.link(s7, s9)
    topo.link(s7, h2a)
    

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

    topo.link(s1, s4)
    topo.link(s4, s5)
    topo.link(s5, s2)
示例#37
0
def create(switch_type=switch, host_type=BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5           h2a
       \  /      \          /
        s1        s2--s6--s7
       /  \      /     \    \
    h1b    --s3--       s8--s9--h2b
    """
    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')

    switch_type.create('s6')
    switch_type.create('s7')
    switch_type.create('s8')
    switch_type.create('s9')

    host_type.create('h1a')
    host_type.create('h1b')
    host_type.create('h2a')
    host_type.create('h2b')

    ReceiveEntity.create('sneakylistener', [s7, s9, s8, s6, s2, s5, s4, s1],
                         [h1a, 1], 5)

    topo.link(sneakylistener, h1a)
    topo.link(sneakylistener, s1)
    topo.link(s1, h1b)
    topo.link(s2, s6)
    topo.link(s6, s8)
    topo.link(s8, s9)
    topo.link(s9, h2b)
    topo.link(s6, s7)
    topo.link(s7, s9)
    topo.link(s7, h2a)

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

    topo.link(s1, s4)
    topo.link(s4, s5)
    topo.link(s5, s2)
def create (switch_type = Hub, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a -- s1-----s2 -- h2a
            | \  / |
            |  s3  |
            | /  \ |
    h1b -- s4-----s5 -- h2b
    """
    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')

    host_type.create('h1a')
    host_type.create('h1b')
    host_type.create('h2a')
    host_type.create('h2b')

    topo.link(s1, h1a)
    topo.link(s4, h1b)
    topo.link(s2, h2a)
    topo.link(s5, h2b)

    topo.link(s1, s2)
    topo.link(s2, s5)
    topo.link(s5, s4)
    topo.link(s4, s1)

    topo.link(s3, s1)
    topo.link(s3, s2)
    topo.link(s3, s4)
    topo.link(s3, s5)
示例#39
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()
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)
def create (switch_type = DVRouter, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5           h2a
       \  /      \          /
        s1        s2--s6--s7
       /  \      /     \    \    
    h1b    --s3--       s8--s9--h2b
    """

    switch_type.create('x')
    switch_type.create('y')
    switch_type.create('z')
    host_type.create('h1')
    host_type.create('h2')

    ReceiveEntity.create('sneakylistener', [x, z] , [h2, 1], 5)

    topo.link(x, y, 2)
    topo.link(y, z, 1)
    topo.link(x, z, 7)
    topo.link(h1, x, 1)
    topo.link(h2, sneakylistener, 1)
    topo.link(z, sneakylistener, 1)
示例#42
0
def create(switch_type=Hub, host_type=BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a    s4--s5    h2a
       \  /      \  /
        s1        s2
       /  \      /  \ 
    h1b    --s3--    h2b
    """

    s1 = switch_type.create('s1')
    s2 = switch_type.create('s2')
    s3 = switch_type.create('s3')
    s4 = switch_type.create('s4')
    s5 = switch_type.create('s5')

    h1a = host_type.create('h1a')
    h1b = host_type.create('h1b')
    h2a = host_type.create('h2a')
    h2b = host_type.create('h2b')

    topo.link(s1, h1a)
    topo.link(s1, h1b)
    topo.link(s2, h2a)
    topo.link(s2, h2b)

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

    topo.link(s1, s4)
    topo.link(s4, s5)
    topo.link(s5, s2)
示例#43
0
def create(switch_type=Hub, host_type=BasicHost):
    """
    h1-----            ---------h2
           \          /
            \        /
             \      /
              \    /
    h3--------- s1 -------------h4
               /  \
              /    \
             /      \
    h5-------        ----------h6
    """

    switch_type.create('s1')

    host_type.create('h1')
    host_type.create('h2')
    host_type.create('h3')
    host_type.create('h4')
    host_type.create('h5')
    host_type.create('h6')

    topo.link(s1, h1)
    topo.link(s1, h2)
    topo.link(s1, h3)
    topo.link(s1, h4)
    topo.link(s1, h5)
    topo.link(s1, h6)
def create(switch_type=FakeEntity, host_type=FakeEntity, n=2):
    RIPRouter.create("A")
    BasicHost.create("C")
    FakeEntity.create("B", {C: 100}, {C: 1})
    topo.link(A, B)
示例#45
0
def create (switch_type = DVRouter, host_type = BasicHost):
    """
    Creates a topology with loops that looks like:
    h1a                                              h2a
       \                                           /
        s1 - s2 - s3 - s4 - s5 - s6 - s7 - s8 - s9       
    """
    switch_type.create('s1')
    switch_type.create('s2')
    switch_type.create('s3')
    switch_type.create('s4')
    switch_type.create('s5')
    switch_type.create('s6')
    switch_type.create('s7')
    switch_type.create('s8')
    switch_type.create('s9')


    host_type.create('h1a')
    host_type.create('h2a')

    ReceiveEntity.create('sneakylistener', [s9, s8, s7, s6, s5, s4, s3, s2, s1] , [h1a, 1], 5)

    topo.link(sneakylistener, h1a)
    topo.link(sneakylistener, s1)
    topo.link(s1, s2)
    topo.link(s2, s3)
    topo.link(s3, s4)
    topo.link(s4, s5)
    topo.link(s5, s6)
    topo.link(s6, s7)
    topo.link(s7, s8)
    topo.link(s8, s9)
    topo.link(s9, h2a)
def create(switch_type=FakeEntity, host_type=FakeEntity, n=2):
    DVRouter.create('A')
    BasicHost.create('C')
    FakeEntity.create('B', {C: 100}, {C: 1})
    topo.link(A, B)