blob: 3df4fb01b348afd0b6266e242f4ad42a9edd874c [file] [log] [blame]
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +00001#! /usr/bin/env python
2import sys
3import os
4
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -07005# Usage: flowid src_dpid dst_dpid params
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +00006def usage():
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -07007 print "%s flowid src_dpid dst_dpid svr|client <proto>/<duration>/<interval>/<samples>" % sys.argv[0]
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +00008 sys.exit()
9
10def main():
11 flowid = sys.argv[1]
12 src_dpid = sys.argv[2]
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070013 dst_dpid = sys.argv[3]
14 server = sys.argv[4].upper()[0]
15 params = sys.argv[5].split('/')
16 proto = params[0]
17 duration = params[1]
18 interval = params[2]
19 samples = params[3]
20
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000021 src_nwid=int(src_dpid.split(':')[-2], 16)
22 dst_nwid=int(dst_dpid.split(':')[-2], 16)
23 src_hostid=int(src_dpid.split(':')[-1], 16)
24 dst_hostid=int(dst_dpid.split(':')[-1], 16)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070025
26 if (proto == "tcp"):
Pavlin Radoslavovd639f1e2013-04-10 08:06:43 +000027# cmd="ssh -o StrictHostKeyChecking=no 1.1.%d.1 '/home/ubuntu/ONOS/scripts/iperf -t%s -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperf_%s.out -c 192.168.%d.%d 2>&1 &' &" % (src_hostid, duration, interval, samples, flowid, dst_nwid, dst_hostid)
28 cmd="${HOME}/ONOS/test-network/mininet/mrun host%d \'/home/ubuntu/ONOS/scripts/iperf -t%s -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperf_%s.out -c 192.168.%d.%d 2>&1 &\' &" % (src_hostid, duration, interval, samples, flowid, dst_nwid, dst_hostid)
29 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperf_%s.out\"' % (flowid)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070030 print killcmd
31 print cmd
32 os.popen(killcmd)
33 os.popen(cmd)
34 else:
35 if (server == 'S'):
Pavlin Radoslavovd639f1e2013-04-10 08:06:43 +000036# cmd="ssh -o StrictHostKeyChecking=no 1.1.%d.1 '/home/ubuntu/ONOS/scripts/iperf -us -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperfsvr_%s.out 2>&1 &' &" % (dst_hostid, interval, samples, flowid)
37 cmd="${HOME}/ONOS/test-network/mininet/mrun host%d \'/home/ubuntu/ONOS/scripts/iperf -us -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperfsvr_%s.out 2>&1 &\' &" % (dst_hostid, interval, samples, flowid)
38 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfsvr_%s.out\"' % (flowid)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070039 print killcmd
40 print cmd
41 else:
Pavlin Radoslavovd639f1e2013-04-10 08:06:43 +000042 cmd="${HOME}/ONOS/test-network/mininet/mrun host%d \'/home/ubuntu/ONOS/scripts/iperf -l 1000 -u -t%s -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperfclient_%s.out -c 192.168.%d.%d 2>&1 &\' &" % (src_hostid, duration, interval, samples, flowid, dst_nwid, dst_hostid)
43# cmd="ssh -o StrictHostKeyChecking=no 1.1.%d.1 '/home/ubuntu/ONOS/scripts/iperf -l 1000 -u -t%s -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperfclient_%s.out -c 192.168.%d.%d 2>&1 &' &" % (src_hostid, duration, interval, samples, flowid, dst_nwid, dst_hostid)
44 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070045 print killcmd
46 print cmd
47 os.popen(killcmd)
48 os.popen(cmd)
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000049
50if __name__ == "__main__":
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070051 if len(sys.argv) != 6:
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000052 print len(sys.argv)
53 usage()
54
55 main()