Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | import sys |
| 3 | import os |
| 4 | |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 5 | # Usage: flowid src_dpid dst_dpid params |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 6 | def usage(): |
Tim Lindberg | b03673d | 2013-04-10 13:47:31 -0700 | [diff] [blame] | 7 | 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] | 8 | sys.exit() |
| 9 | |
| 10 | def main(): |
| 11 | flowid = sys.argv[1] |
| 12 | src_dpid = sys.argv[2] |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 13 | dst_dpid = sys.argv[3] |
Tim Lindberg | b03673d | 2013-04-10 13:47:31 -0700 | [diff] [blame] | 14 | (testbed,server) = sys.argv[4].upper().split(':') |
| 15 | server = server[0] |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 16 | params = sys.argv[5].split('/') |
| 17 | proto = params[0] |
| 18 | duration = params[1] |
| 19 | interval = params[2] |
| 20 | samples = params[3] |
| 21 | |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 22 | 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 Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 26 | |
| 27 | if (proto == "tcp"): |
Tim Lindberg | b03673d | 2013-04-10 13:47:31 -0700 | [diff] [blame] | 28 | 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 Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 35 | else: |
| 36 | if (server == 'S'): |
Tim Lindberg | b03673d | 2013-04-10 13:47:31 -0700 | [diff] [blame] | 37 | 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 Radoslavov | d639f1e | 2013-04-10 08:06:43 +0000 | [diff] [blame] | 41 | killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfsvr_%s.out\"' % (flowid) |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 42 | print killcmd |
| 43 | print cmd |
| 44 | else: |
Tim Lindberg | b03673d | 2013-04-10 13:47:31 -0700 | [diff] [blame] | 45 | 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: |
miniuser | 3e5ea2b | 2013-05-13 22:33:58 -0700 | [diff] [blame] | 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 ) |
Pavlin Radoslavov | d639f1e | 2013-04-10 08:06:43 +0000 | [diff] [blame] | 49 | killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid) |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 50 | print killcmd |
| 51 | print cmd |
| 52 | os.popen(killcmd) |
| 53 | os.popen(cmd) |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 54 | |
| 55 | if __name__ == "__main__": |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 56 | if len(sys.argv) != 6: |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 57 | print len(sys.argv) |
| 58 | usage() |
| 59 | |
| 60 | main() |