예제 #1
0
def get(alias, nodeID) :
    connection.network.send(verifyNodeGlobal.makeframe(alias, nodeID))
    while (True) :
        reply = connection.network.receive()
        if (reply == None ) : return None,None
        if (reply.startswith(":X180B7")) :
            return int(reply[7:10],16),canolcbutils.bodyArray(reply)
예제 #2
0
def get(alias, nodeID, verbose) :
    connection.network.send(verifyNodeGlobal.makeframe(alias, nodeID))
    while (True) :
        reply = connection.network.receive()
        if (reply == None ) : return None,None
        if (reply.startswith(":X19170")) :
            alias,nodeID = int(reply[7:10],16),canolcbutils.bodyArray(reply)
            if verbose : print "Found alias "+str(alias)+" ("+hex(alias)+") for node ID ",nodeID
            return alias,nodeID
예제 #3
0
def get(alias, nodeID, verbose):
    connection.network.send(verifyNodeGlobal.makeframe(alias, nodeID))
    while (True):
        reply = connection.network.receive()
        if (reply == None): return None, None
        if (reply.startswith(":X19170")):
            alias, nodeID = int(reply[7:10], 16), canolcbutils.bodyArray(reply)
            if verbose:
                print "Found alias " + str(alias) + " (" + hex(
                    alias) + ") for node ID ", nodeID
            return alias, nodeID
예제 #4
0
def once(alias, n, connection, verbose, parallel) :
    for j in range(parallel) :
        connection.network.send(verifyNodeGlobal.makeframe(alias, None))
    for j in range(parallel) :
        reply = connection.network.receive()
        while reply != None and reply.startswith("!") :
            # skip
            reply = connection.network.receive()
        if reply == None : 
            print "No reply received"
            return 1
        if not reply.startswith(":X180B7") :
            print "Incorrect reply received"
            return 2
    return 0
def once(dest, connection, identifynode, verbose, marks):
    alias = (dest - 10) | 1

    # Note: This test assumes that the response will be
    # to reacquire another alias after the conflicted one is
    # dropped.  This isn't required behavior by standard, but
    # is a necessary condition for the test to continue and
    # check another conflict condition.
    #
    # Sending a global message (that normally doesn't get a response)
    # by sending verifyNodeGlobal with a nodeID that doesn't match any valid
    connection.network.send(
        verifyNodeGlobal.makeframe(dest, [0, 0, 0, 0, 0, 1]))
    reply = connection.network.receive()
    if reply == None:
        print "no response received to conflict frame"
        return -21
    if not reply.startswith(":X10703"):
        print "Expected first AMR"
        return -22
    reply = connection.network.receive()
    if reply == None:
        print "no response received to conflict frame"
        return -21
    if not reply.startswith(":X17"):
        print "Expected first CID"
        return -22
    if int(reply[7:10], 16) == 0:
        print "received alias == 0"
        return -24
    if int(reply[7:10], 16) == dest:
        print "received alias == previous alias"
        # this is just noted, it doesnt end test
    dest = int(reply[7:10], 16)
    marks.add(dest)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    time.sleep(0.65)
    reply = connection.network.receive()  # RID
    reply = connection.network.receive()  # AMD
    reply = connection.network.receive()  # VerifiedNID

    return dest
def once(dest, connection, identifynode, verbose, marks) :
    alias = (dest-10)|1

    # Note: This test assumes that the response will be
    # to reacquire another alias after the conflicted one is
    # dropped.  This isn't required behavior by standard, but
    # is a necessary condition for the test to continue and 
    # check another conflict condition.
    #
    # Sending a global message (that normally doesn't get a response)
    # by sending verifyNodeGlobal with a nodeID that doesn't match any valid
    connection.network.send(verifyNodeGlobal.makeframe(dest, [0,0,0,0,0,1]))
    reply = connection.network.receive()
    if reply == None :
        print "no response received to conflict frame"
        return -21
    if not reply.startswith(":X10703") :
        print "Expected first AMR"
        return -22
    reply = connection.network.receive()
    if reply == None :
        print "no response received to conflict frame"
        return -21
    if not reply.startswith(":X17") :
        print "Expected first CID"
        return -22
    if int(reply[7:10],16) == 0 :
        print "received alias == 0"
        return -24
    if int(reply[7:10],16) == dest :
        print "received alias == previous alias"
        # this is just noted, it doesnt end test
    dest = int(reply[7:10],16)
    marks.add(dest)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    time.sleep(0.65)
    reply = connection.network.receive()  # RID
    reply = connection.network.receive()  # AMD
    reply = connection.network.receive()  # VerifiedNID

    return dest
예제 #7
0
def test(alias, dest, connection, verbose) :
    # Note: This test assumes that the response will be
    # to reacquire another alias after the conflicted one is
    # dropped.  This isn't required behavior by standard, but
    # is a necessary condition for the test to continue and 
    # check another conflict condition.
    #
    # Sending a global message (that normally doesn't get a response)
    # by sending verifyNodeGlobal with a nodeID that doesn't match any valid
    if verbose : print "  check no-response global message with alias conflict"
    connection.network.send(verifyNodeGlobal.makeframe(dest, [0,0,0,0,0,1]))
    reply = connection.network.receive()
    if reply == None :
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X10703") :
        print "Expected first AMR"
        return 22
    if int(reply[7:10],16) != dest :
        print "incorrect alias in AMR"
        return 23
    reply = connection.network.receive()
    if reply == None :
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X17") :
        print "Expected first CID"
        return 22
    if int(reply[7:10],16) == 0 :
        print "received alias == 0"
        return 23
    dest = int(reply[7:10],16)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    timeout = connection.network.timeout
    connection.network.timeout = 1.0
    reply = connection.network.receive()  # RID
    connection.network.timeout = timeout
    # dump everything until nothing heard
    while (reply != None) :
        reply = connection.network.receive()
    
    # Sending a global message (that normally does get a response)
    if verbose : print "  check response-inducing global message with alias conflict"
    connection.network.send(verifyNodeGlobal.makeframe(dest, None))
    reply = connection.network.receive()
    if reply == None :
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X10703") :
        print "Expected second AMR"
        return 22
    if int(reply[7:10],16) != dest :
        print "incorrect alias in AMR"
        return 23
    reply = connection.network.receive()
    if reply == None :
        print "no response received to conflict frame"
        return 31
    if not reply.startswith(":X17") :
        print "Expected second CID"
        return 32
    if int(reply[7:10],16) == 0 :
        print "received alias == 0"
        return 33
    dest = int(reply[7:10],16)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    timeout = connection.network.timeout
    connection.network.timeout = 1.0
    reply = connection.network.receive()  # RID
    connection.network.timeout = timeout
    # dump everything until nothing heard
    while (reply != None) :
        reply = connection.network.receive()
    
    # Sending an addressed message to some other alias (note arguments backwards, on purpose)
    if verbose : print "  check addressed message with alias conflict"
    connection.network.send(verifyNodeAddressed.makeframe(dest, alias, None))
    reply = connection.network.receive()
    if reply == None :
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X10703") :
        print "Expected third AMR"
        return 22
    if int(reply[7:10],16) != dest :
        print "incorrect alias in AMR"
        return 23
    reply = connection.network.receive()
    if reply == None :
        if verbose : print "no response received to conflict frame"
        return 41
    if not reply.startswith(":X17") :
        if verbose : print "Expected third CID"
        return 42
    if int(reply[7:10],16) == 0 :
        print "received alias == 0"
        return 43
    dest = int(reply[7:10],16)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    timeout = connection.network.timeout
    connection.network.timeout = 1.0
    reply = connection.network.receive()  # RID
    connection.network.timeout = timeout
    # dump everything until nothing heard
    while (reply != None) :
        reply = connection.network.receive()

    # send a CheckID   
    if verbose : print "  check CheckID with alias conflict"
    connection.network.send(canolcbutils.makeframestring(0x17020000+dest, None))
    reply = connection.network.receive()
    if reply == None :
        if verbose : print "no response received to CID"
        return 51
    if int(reply[7:10],16) != dest :
        if verbose : print "mismatched reply alias"
        return 52
    if not reply.startswith(":X10700") :
        if verbose : print "CID reply not correct, RID expected"
        return 53

    # send a ReserveID   
    connection.network.send(canolcbutils.makeframestring(0x10700000+dest, None))
    if verbose : print "  check ReserveID with alias conflict"
    reply = connection.network.receive()
    if reply == None :
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X10703") :
        print "Expected fourth AMR"
        return 22
    if int(reply[7:10],16) != dest :
        print "incorrect alias in AMR"
        return 23
    reply = connection.network.receive()
    if reply == None :
        if verbose : print "no response received to conflict frame"
        return 61
    if not reply.startswith(":X17") :
        if verbose : print "Expected fourth CID"
        return 62
    if int(reply[7:10],16) == 0 :
        print "received alias == 0"
        return 63
    dest = int(reply[7:10],16)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    timeout = connection.network.timeout
    connection.network.timeout = 1.0
    reply = connection.network.receive()  # RID
    connection.network.timeout = timeout
    # dump everything until nothing heard
    while (reply != None) :
        reply = connection.network.receive()

    return 0
예제 #8
0
def test(alias, dest, connection, verbose):
    # Note: This test assumes that the response will be
    # to reacquire another alias after the conflicted one is
    # dropped.  This isn't required behavior by standard, but
    # is a necessary condition for the test to continue and
    # check another conflict condition.
    #
    # Sending a global message (that normally doesn't get a response)
    # by sending verifyNodeGlobal with a nodeID that doesn't match any valid
    if verbose: print "  check no-response global message with alias conflict"
    connection.network.send(
        verifyNodeGlobal.makeframe(dest, [0, 0, 0, 0, 0, 1]))
    reply = connection.network.receive()
    if reply == None:
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X10703"):
        print "Expected first AMR"
        return 22
    if int(reply[7:10], 16) != dest:
        print "incorrect alias in AMR"
        return 23
    reply = connection.network.receive()
    if reply == None:
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X17"):
        print "Expected first CID"
        return 22
    if int(reply[7:10], 16) == 0:
        print "received alias == 0"
        return 23
    dest = int(reply[7:10], 16)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    timeout = connection.network.timeout
    connection.network.timeout = 1.0
    reply = connection.network.receive()  # RID
    connection.network.timeout = timeout
    # dump everything until nothing heard
    while (reply != None):
        reply = connection.network.receive()

    # Sending a global message (that normally does get a response)
    if verbose:
        print "  check response-inducing global message with alias conflict"
    connection.network.send(verifyNodeGlobal.makeframe(dest, None))
    reply = connection.network.receive()
    if reply == None:
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X10703"):
        print "Expected second AMR"
        return 22
    if int(reply[7:10], 16) != dest:
        print "incorrect alias in AMR"
        return 23
    reply = connection.network.receive()
    if reply == None:
        print "no response received to conflict frame"
        return 31
    if not reply.startswith(":X17"):
        print "Expected second CID"
        return 32
    if int(reply[7:10], 16) == 0:
        print "received alias == 0"
        return 33
    dest = int(reply[7:10], 16)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    timeout = connection.network.timeout
    connection.network.timeout = 1.0
    reply = connection.network.receive()  # RID
    connection.network.timeout = timeout
    # dump everything until nothing heard
    while (reply != None):
        reply = connection.network.receive()

    # Sending an addressed message to some other alias (note arguments backwards, on purpose)
    if verbose: print "  check addressed message with alias conflict"
    connection.network.send(verifyNodeAddressed.makeframe(dest, alias, None))
    reply = connection.network.receive()
    if reply == None:
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X10703"):
        print "Expected third AMR"
        return 22
    if int(reply[7:10], 16) != dest:
        print "incorrect alias in AMR"
        return 23
    reply = connection.network.receive()
    if reply == None:
        if verbose: print "no response received to conflict frame"
        return 41
    if not reply.startswith(":X17"):
        if verbose: print "Expected third CID"
        return 42
    if int(reply[7:10], 16) == 0:
        print "received alias == 0"
        return 43
    dest = int(reply[7:10], 16)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    timeout = connection.network.timeout
    connection.network.timeout = 1.0
    reply = connection.network.receive()  # RID
    connection.network.timeout = timeout
    # dump everything until nothing heard
    while (reply != None):
        reply = connection.network.receive()

    # send a CheckID
    if verbose: print "  check CheckID with alias conflict"
    connection.network.send(
        canolcbutils.makeframestring(0x17020000 + dest, None))
    reply = connection.network.receive()
    if reply == None:
        if verbose: print "no response received to CID"
        return 51
    if int(reply[7:10], 16) != dest:
        if verbose: print "mismatched reply alias"
        return 52
    if not reply.startswith(":X10700"):
        if verbose: print "CID reply not correct, RID expected"
        return 53

    # send a ReserveID
    connection.network.send(
        canolcbutils.makeframestring(0x10700000 + dest, None))
    if verbose: print "  check ReserveID with alias conflict"
    reply = connection.network.receive()
    if reply == None:
        print "no response received to conflict frame"
        return 21
    if not reply.startswith(":X10703"):
        print "Expected fourth AMR"
        return 22
    if int(reply[7:10], 16) != dest:
        print "incorrect alias in AMR"
        return 23
    reply = connection.network.receive()
    if reply == None:
        if verbose: print "no response received to conflict frame"
        return 61
    if not reply.startswith(":X17"):
        if verbose: print "Expected fourth CID"
        return 62
    if int(reply[7:10], 16) == 0:
        print "received alias == 0"
        return 63
    dest = int(reply[7:10], 16)
    # pull & drop rest of sequence
    reply = connection.network.receive()  # CID 2
    reply = connection.network.receive()  # CID 3
    reply = connection.network.receive()  # CID 4
    timeout = connection.network.timeout
    connection.network.timeout = 1.0
    reply = connection.network.receive()  # RID
    connection.network.timeout = timeout
    # dump everything until nothing heard
    while (reply != None):
        reply = connection.network.receive()

    return 0