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(): |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 7 | print "%s flowid src_dpid dst_dpid svr|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] |
| 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 Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 21 | 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 Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 25 | |
| 26 | if (proto == "tcp"): |
Pavlin Radoslavov | d639f1e | 2013-04-10 08:06:43 +0000 | [diff] [blame] | 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 | cmd="${HOME}/ONOS/test-network/mininet/mrun host%d \'/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) |
| 29 | killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperf_%s.out\"' % (flowid) |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 30 | print killcmd |
| 31 | print cmd |
| 32 | os.popen(killcmd) |
| 33 | os.popen(cmd) |
| 34 | else: |
| 35 | if (server == 'S'): |
Pavlin Radoslavov | d639f1e | 2013-04-10 08:06:43 +0000 | [diff] [blame] | 36 | # 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) |
| 37 | cmd="${HOME}/ONOS/test-network/mininet/mrun host%d \'/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) |
| 38 | killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfsvr_%s.out\"' % (flowid) |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 39 | print killcmd |
| 40 | print cmd |
| 41 | else: |
Pavlin Radoslavov | d639f1e | 2013-04-10 08:06:43 +0000 | [diff] [blame] | 42 | cmd="${HOME}/ONOS/test-network/mininet/mrun host%d \'/home/ubuntu/ONOS/scripts/iperf -l 1000 -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) |
| 43 | # cmd="ssh -o StrictHostKeyChecking=no 1.1.%d.1 '/home/ubuntu/ONOS/scripts/iperf -l 1000 -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) |
| 44 | killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid) |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 45 | print killcmd |
| 46 | print cmd |
| 47 | os.popen(killcmd) |
| 48 | os.popen(cmd) |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 49 | |
| 50 | if __name__ == "__main__": |
Umesh Krishnaswamy | 5c3eddf | 2013-04-06 00:24:01 -0700 | [diff] [blame] | 51 | if len(sys.argv) != 6: |
Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 52 | print len(sys.argv) |
| 53 | usage() |
| 54 | |
| 55 | main() |