blob: 62339861f458dca75ae65963bd241a69c834fbe0 [file] [log] [blame]
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +00001#! /usr/bin/env python
2import sys
3import os
4
Masayoshi Kobayashia55f8a32013-06-20 18:09:25 -07005ONOSDIR=os.getenv("HOME") + "/ONOS"
6IPERF=ONOSDIR + "/scripts/iperf"
7IPERFLOGDIR=ONOSDIR + "/web/log"
8
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -07009# Usage: flowid src_dpid dst_dpid params
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000010def usage():
Tim Lindbergb03673d2013-04-10 13:47:31 -070011 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 +000012 sys.exit()
13
Masayoshi Kobayashia55f8a32013-06-20 18:09:25 -070014
15
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000016def main():
17 flowid = sys.argv[1]
18 src_dpid = sys.argv[2]
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070019 dst_dpid = sys.argv[3]
Tim Lindbergb03673d2013-04-10 13:47:31 -070020 (testbed,server) = sys.argv[4].upper().split(':')
21 server = server[0]
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070022 params = sys.argv[5].split('/')
23 proto = params[0]
24 duration = params[1]
25 interval = params[2]
26 samples = params[3]
27
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000028 src_nwid=int(src_dpid.split(':')[-2], 16)
29 dst_nwid=int(dst_dpid.split(':')[-2], 16)
30 src_hostid=int(src_dpid.split(':')[-1], 16)
31 dst_hostid=int(dst_dpid.split(':')[-1], 16)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070032
Masayoshi Kobayashia55f8a32013-06-20 18:09:25 -070033 if (testbed == "SW"):
34 MRUN=ONOSDIR + "/test-network/mininet/mrun"
35 HOST_FMT="host%d.%d"
36 else:
37 MRUN=ONOSDIR + "$HOME/mininet/util/m"
38 HOST_FMT="g%sh%02d"
39
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070040 if (proto == "tcp"):
Masayoshi Kobayashia55f8a32013-06-20 18:09:25 -070041 mininet_host = HOST_FMT % (dst_nwid, dst_hostid)
42 cmd="%s %s \'%s -t%s -i%s -k%s -yJ -o %s/iperf_%s.out -c 192.168.%d.%d 2>&1 &\' &" % (MRUN, mininet_host, IPERF, src_hostid, duration, interval, samples, IPERFLOGDIR, flowid, dst_nwid, dst_hostid)
Tim Lindbergb03673d2013-04-10 13:47:31 -070043 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperf_%s.out\"' % (flowid)
44 print killcmd
45 print cmd
46 os.popen(killcmd)
47 os.popen(cmd)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070048 else:
49 if (server == 'S'):
Masayoshi Kobayashia55f8a32013-06-20 18:09:25 -070050 mininet_host = HOST_FMT % (dst_nwid, dst_hostid)
51 cmd="%s %s \'%s -us -i%s -k%s -yJ -o %s/iperfsvr_%s.out 2>&1 &\' &" % (MRUN, mininet_host, IPERF, interval, samples, IPERFLOGDIR, flowid)
Pavlin Radoslavovd639f1e2013-04-10 08:06:43 +000052 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfsvr_%s.out\"' % (flowid)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070053 print killcmd
54 print cmd
55 else:
Masayoshi Kobayashia55f8a32013-06-20 18:09:25 -070056 mininet_host = HOST_FMT % (src_nwid, src_hostid)
57 cmd="%s %s \'%s -u -t%s -i%s -k%s -yJ -o %s/iperfclient_%s.out -c 192.168.%d.%d 2>&1 &\' &" % (MRUN, mininet_host, IPERF, duration, interval, samples, IPERFLOGDIR, flowid, dst_nwid, dst_hostid)
Pavlin Radoslavovd639f1e2013-04-10 08:06:43 +000058 killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid)
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070059 print killcmd
60 print cmd
Masayoshi Kobayashia55f8a32013-06-20 18:09:25 -070061
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070062 os.popen(killcmd)
63 os.popen(cmd)
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000064
65if __name__ == "__main__":
Umesh Krishnaswamy5c3eddf2013-04-06 00:24:01 -070066 if len(sys.argv) != 6:
Masayoshi Kobayashi4cfa1272013-04-03 00:45:46 +000067 print len(sys.argv)
68 usage()
69
70 main()