예제 #1
0
def publisher(server_port, peers):
    n = Node(server_port, peers)
    #print "Started published at ", server_port


    for i in range(num_msgs):
        msg = n.generate_random_message()
        n.broadcast(msg)
        #time.sleep(1)
    #print "Broadcasted"
    while sum(n.msgs_acks.values()) < num_msgs*len(peers):
        time.sleep(1)
    k = 0
    mean = 0
    for i in n.msgs_stats:
        k += 1
        mean += n.msgs_stats[i]
    print num_subs, mean/num_msgs
예제 #2
0
import sys
from gossip import Node
import time

if __name__ == '__main__':

    server_port = sys.argv[1]

    peers = sys.argv[2:]

    n = Node(server_port, peers)

    for i in range(10):
        msg = n.generate_random_message()
        n.broadcast(msg)
    time.sleep(2)

    for i in n.msgs_stats:
        print i, n.msgs_stats[i]
    

    while True:
        pass