def main(argv): try: own_ip = argv[1] forwarder_addr = argv[2] num_keys = int(argv[3]) data_file = open(argv[4], "w") if len(argv) > 4 else sys.stdout except: print_usage() keys = range(num_keys) ports = map(lambda x: x + OWN_PORT_START, keys) r = receiver.Receiver(ports) r.start() c = controller.Controller((forwarder_addr, FORWARDER_CONTROL_PORT)) c.open() c.release_servers() for k in keys: c.add_server(own_ip, OWN_PORT_START + k, k) c.close() for p in PAYLOADS: print "Running", p s = sender.Sender((forwarder_addr, FORWARDER_PORT), keys, p, ITERS, 10) s.start() s.join() print "Finished", p time.sleep(5) c = controller.Controller((forwarder_addr, FORWARDER_CONTROL_PORT)) c.open() c.release_servers() c.close() trials = r.get_trials() if len(trials) != len(PAYLOADS): print "WEIRDNESS! len(trials) =", len(trials), "len(PAYLOADS) = ", print len(PAYLOADS) for i, t in enumerate(trials): bps = receiver.process_trial(t) data_file.write("%d\t%.2f\t%.3f\n" % (PAYLOADS[i], bps, bps / (1000 * 1000))) if data_file != sys.stdout: data_file.close() r.stop() print "Goodbye" sys.exit(0)
#!/usr/bin/env python import sender import receiver import time if __name__ == '__main__': r = receiver.Receiver([10000]) r.start() s = sender.Sender(('127.0.0.1', 10000), [1], 10000, 10000, 20) s.start() s.join() time.sleep(2) r.stop() r.join() trials = r.get_trials() print trials print receiver.process_trial(trials[0]), 'bps'