blob: ec903e321e6c7948785f76bd44934ed789daa2b6 [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"):
27 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 killcmd='pkill -KILL -f \"iperf .* -o .*/iperf_%s.out\"' % (flowid)
29 print killcmd
30 print cmd
31 os.popen(killcmd)
32 os.popen(cmd)
33 else:
34 if (server == 'S'):
35 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)
36 killcmd='pkill -KILL -f \"iperf .* -o .*/iperfsvr_%s.out\"' % (flowid)
37 print killcmd
38 print cmd
39 else:
40 cmd="ssh -o StrictHostKeyChecking=no 1.1.%d.1 '/home/ubuntu/ONOS/scripts/iperf -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)
41 killcmd='pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid)
42 print killcmd
43 print cmd
44 os.popen(killcmd)
45 os.popen(cmd)
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000046
47if __name__ == "__main__":
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070048 if len(sys.argv) != 6:
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000049 print len(sys.argv)
50 usage()
51
52 main()