blob: 7066bc66b2cae4d8d5cbf03d15dd71bfe4b40934 [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():
Tim Lindbergb03673d2013-04-10 13:47:31 -07007 print "%s flowid src_dpid dst_dpid hw:svr|sw:svr|hw:client|sw: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]
Tim Lindbergb03673d2013-04-10 13:47:31 -070014 (testbed,server) = sys.argv[4].upper().split(':')
15 server = server[0]
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070016 params = sys.argv[5].split('/')
17 proto = params[0]
18 duration = params[1]
19 interval = params[2]
20 samples = params[3]
21
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000022 src_nwid=int(src_dpid.split(':')[-2], 16)
23 dst_nwid=int(dst_dpid.split(':')[-2], 16)
24 src_hostid=int(src_dpid.split(':')[-1], 16)
25 dst_hostid=int(dst_dpid.split(':')[-1], 16)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070026
27 if (proto == "tcp"):
Tim Lindbergb03673d2013-04-10 13:47:31 -070028 if (testbed == "SW"):
29 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)
30 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperf_%s.out\"' % (flowid)
31 print killcmd
32 print cmd
33 os.popen(killcmd)
34 os.popen(cmd)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070035 else:
36 if (server == 'S'):
Tim Lindbergb03673d2013-04-10 13:47:31 -070037 if (testbed == "SW"):
38 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)
39 else:
40 cmd="~/mininet/util/m g%sh%02d '/home/ubuntu/ONOS/scripts/iperf -us -i%s -k%s -yJ -o /home/ubuntu/ONOS/web/log/iperfsvr_%s.out 2>&1 &' &" % (dst_nwid, dst_hostid, interval, samples, flowid)
Pavlin Radoslavovd639f1e2013-04-10 08:06:43 +000041 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfsvr_%s.out\"' % (flowid)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070042 print killcmd
43 print cmd
44 else:
Tim Lindbergb03673d2013-04-10 13:47:31 -070045 if (testbed == "SW"):
46 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)
47 else:
48 cmd="~/mininet/util/m g%sh%02d '/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_nwid, src_hostid, duration, interval, samples, flowid, dst_nwid, dst_hostid + 1)
Pavlin Radoslavovd639f1e2013-04-10 08:06:43 +000049 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070050 print killcmd
51 print cmd
52 os.popen(killcmd)
53 os.popen(cmd)
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000054
55if __name__ == "__main__":
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070056 if len(sys.argv) != 6:
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000057 print len(sys.argv)
58 usage()
59
60 main()