Esempio 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
Esempio n. 2
0
groupName = "grp"

PERIOD = 3000


def millis():
    return int(round(time() * 1000))


if __name__ == "__main__":

    instances = list()

    f = open("results/error_bars/prop_delay_vs_N(%d,noseal).txt" % PERIOD, "w")

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

    print("Created leader instance with name %s" % leaderInst.userID)

    # 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)