Masayoshi Kobayashi | 4cfa127 | 2013-04-03 00:45:46 +0000 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | import sys |
| 3 | import os |
| 4 | |
| 5 | def usage(): |
| 6 | print "%s flowid src_dpid src_port dst_dpid dst_port duration samples" % sys.argv[0] |
| 7 | sys.exit() |
| 8 | |
| 9 | def main(): |
| 10 | flowid = sys.argv[1] |
| 11 | src_dpid = sys.argv[2] |
| 12 | dst_dpid = sys.argv[4] |
| 13 | duration=int(sys.argv[6]) |
| 14 | samples=int(sys.argv[7]) |
| 15 | src_nwid=int(src_dpid.split(':')[-2], 16) |
| 16 | dst_nwid=int(dst_dpid.split(':')[-2], 16) |
| 17 | src_hostid=int(src_dpid.split(':')[-1], 16) |
| 18 | dst_hostid=int(dst_dpid.split(':')[-1], 16) |
| 19 | # /home/ubuntu/ONOS/web/scripts/iperf -t%s -i0.1 -yJ -o /tmp/iperf_%s.out -c 127.0.0.1 & |
| 20 | cmd="ssh -o StrictHostKeyChecking=no 1.1.%d.1 '/home/ubuntu/ONOS/scripts/iperf -t %s -i0.1 -k %d -yJ -o /home/ubuntu/ONOS/web/log/iperf_%s.out -c 192.168.%d.%d 2>&1 &' &" % (src_hostid, duration, samples, flowid, dst_nwid, dst_hostid) |
| 21 | killcmd='pkill -KILL -f \"iperf .* -o .*/iperf_%s.out\"' % (flowid) |
| 22 | print killcmd |
| 23 | print cmd |
| 24 | os.popen(killcmd) |
| 25 | os.popen(cmd) |
| 26 | |
| 27 | if __name__ == "__main__": |
| 28 | if len(sys.argv) != 8: |
| 29 | print len(sys.argv) |
| 30 | usage() |
| 31 | |
| 32 | main() |