Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | import sys |
| 3 | import os |
| 4 | |
Masayoshi Kobayashi | a55f8a3 | 2013-06-20 18:09:25 -0700 | [diff] [blame] | 5 | ONOSDIR=os.getenv("HOME") + "/ONOS" |
| 6 | IPERF=ONOSDIR + "/scripts/iperf" |
| 7 | IPERFLOGDIR=ONOSDIR + "/web/log" |
| 8 | |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 9 | # Usage: flowid src_dpid dst_dpid params |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 10 | def usage(): |
Tim Lindberg | b03673d | 2013-04-10 13:47:31 -0700 | [diff] [blame] | 11 | print "%s flowid src_dpid dst_dpid hw:svr|sw:svr|hw:client|sw:client <proto>/<duration>/<interval>/<samples>" % sys.argv[0] |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 12 | sys.exit() |
| 13 | |
Masayoshi Kobayashi | a55f8a3 | 2013-06-20 18:09:25 -0700 | [diff] [blame] | 14 | |
| 15 | |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 16 | def main(): |
| 17 | flowid = sys.argv[1] |
| 18 | src_dpid = sys.argv[2] |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 19 | dst_dpid = sys.argv[3] |
Tim Lindberg | b03673d | 2013-04-10 13:47:31 -0700 | [diff] [blame] | 20 | (testbed,server) = sys.argv[4].upper().split(':') |
| 21 | server = server[0] |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 22 | params = sys.argv[5].split('/') |
| 23 | proto = params[0] |
| 24 | duration = params[1] |
| 25 | interval = params[2] |
| 26 | samples = params[3] |
| 27 | |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 28 | 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 Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 32 | |
Masayoshi Kobayashi | a55f8a3 | 2013-06-20 18:09:25 -0700 | [diff] [blame] | 33 | 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 Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 40 | if (proto == "tcp"): |
Masayoshi Kobayashi | a55f8a3 | 2013-06-20 18:09:25 -0700 | [diff] [blame] | 41 | 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 Lindberg | b03673d | 2013-04-10 13:47:31 -0700 | [diff] [blame] | 43 | 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 Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 48 | else: |
| 49 | if (server == 'S'): |
Masayoshi Kobayashi | a55f8a3 | 2013-06-20 18:09:25 -0700 | [diff] [blame] | 50 | 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 Radoslavov | d639f1e | 2013-04-10 08:06:43 +0000 | [diff] [blame] | 52 | killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfsvr_%s.out\"' % (flowid) |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 53 | print killcmd |
| 54 | print cmd |
| 55 | else: |
Masayoshi Kobayashi | a55f8a3 | 2013-06-20 18:09:25 -0700 | [diff] [blame] | 56 | 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 Radoslavov | d639f1e | 2013-04-10 08:06:43 +0000 | [diff] [blame] | 58 | killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid) |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 59 | print killcmd |
| 60 | print cmd |
Masayoshi Kobayashi | a55f8a3 | 2013-06-20 18:09:25 -0700 | [diff] [blame] | 61 | |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 62 | os.popen(killcmd) |
| 63 | os.popen(cmd) |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 64 | |
| 65 | if __name__ == "__main__": |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 66 | if len(sys.argv) != 6: |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 67 | print len(sys.argv) |
| 68 | usage() |
| 69 | |
| 70 | main() |