Exemplo n.º 1
0
def form_clique(size):  # generate the stats

    N = size
    instances = list()

    t0 = time()

    # create a leader instance
    leaderInst = NonameInstance()
    instances.append(leaderInst)
    print("%d: Leader instance created with name %s" % (time() - t0, leaderInst.userID))
    # create a new group
    leaderInst.create(groupName)
    print("%d: Leader instance created a group named %s" % (time() - t0, groupName))

    # create N-1 more instances of NoNaMe
    for i in range(N - 1):
        # create a new instance
        newInst = NonameInstance()
        instances.append(newInst)

        print("%d: Created a new instance with name %s" % (time() - t0, newInst.userID))

        print("%d: Wait a bit to make sure everyone gets refreshed AddressBook" % (time() - t0))
        sleep(6)  # wait for some time, so that everyone got the new AddressBook

        # leader adds new guy to group
        print("%d: Leader instance has added the new guy to group" % (time() - t0))
        leaderInst.add(newInst.userID, groupName)

        print("%d: Wait a bit to finalise DH" % (time() - t0))
        sleep(2)  # make sure all DH noise is gone
        print("%d: Done %d out of %d" % (time() - t0, i + 1, N - 1))

    return instances
Exemplo n.º 2
0
    # leader creates a group
    leaderInst.create(groupName)
    print("Leader instance has successfully created a group with name %s" % groupName)

    for i in range(1, Nmax):
        print("N = %d" % (i + 1))

        newInst = NonameInstance(patch_period=PERIOD)
        instances.append(newInst)

        print("\tCreated a new instance with name %s" % newInst.userID)

        sleep(5)  # make sure everyone gets the new guy in their address books

        # leader adds the new guy
        leaderInst.add(newInst.userID, groupName)
        sleep(5)  # make sure all DH noise is gone
        print("\tLeader instance has successfully added the newcomer to the group")

        results = list()
        M = 5*(i + 1)
        print("\tNewcomer sends %d messages, to estimate how long they propagate." % M)
        for j in range(M):
            author = newInst

            txt = str("Hello, %s is here! (%d,%d)" % (author.userID, i, j))
            author.sendMessage(groupName, txt)
            t0 = millis()

            haventReceived = set([x.userID for x in instances])
            while (haventReceived):