def run_broadcast(t): print('--- running broadcast ---') msg = 'test' net = Network(Broadcast, t) net.nodes[0].data['shout'] = msg # this one will initiate the shout net.run() # check that it worked for n in net.nodes: if n.data['msg'] != msg: n.log('did not receive message!')
def run_convergecast(t): print('--- running convergecast ---') net = Network(Convergecast, t) msgs = list(range(100)); shuffle(msgs) for n, m in zip(net.nodes, msgs): n.data['msg'] = m net.run() # check that it worked m = max([ n.data['msg'] for n in net.nodes ]) k = net.nodes[0].data['max'] if k != m: print('Found {}, but max is {}!', k, m)
def run(n): msg = 'test' t = topo.random(n, n//2) net = Network(ShoutAndEcho, t) net.nodes[0].data['shout'] = msg net.run() # check that it worked for n in net.nodes: if n.data['msg'] != msg: n.log("did not get the message!")
def run(n): net = Network(MyNode, topo.C(n)) net.run()