Adding hardware iperf functionality
diff --git a/scripts/runiperf.sh b/scripts/runiperf.sh
index 3df4fb0..7066bc6 100755
--- a/scripts/runiperf.sh
+++ b/scripts/runiperf.sh
@@ -4,14 +4,15 @@
# Usage: flowid src_dpid dst_dpid params
def usage():
- print "%s flowid src_dpid dst_dpid svr|client <proto>/<duration>/<interval>/<samples>" % sys.argv[0]
+ print "%s flowid src_dpid dst_dpid hw:svr|sw:svr|hw:client|sw:client <proto>/<duration>/<interval>/<samples>" % sys.argv[0]
sys.exit()
def main():
flowid = sys.argv[1]
src_dpid = sys.argv[2]
dst_dpid = sys.argv[3]
- server = sys.argv[4].upper()[0]
+ (testbed,server) = sys.argv[4].upper().split(':')
+ server = server[0]
params = sys.argv[5].split('/')
proto = params[0]
duration = params[1]
@@ -24,23 +25,27 @@
dst_hostid=int(dst_dpid.split(':')[-1], 16)
if (proto == "tcp"):
-# 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)
- 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)
- killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperf_%s.out\"' % (flowid)
- print killcmd
- print cmd
- os.popen(killcmd)
- os.popen(cmd)
+ if (testbed == "SW"):
+ 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)
+ killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperf_%s.out\"' % (flowid)
+ print killcmd
+ print cmd
+ os.popen(killcmd)
+ os.popen(cmd)
else:
if (server == 'S'):
-# 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)
- 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)
+ if (testbed == "SW"):
+ 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)
+ else:
+ 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)
killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfsvr_%s.out\"' % (flowid)
print killcmd
print cmd
else:
- 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)
-# 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)
+ if (testbed == "SW"):
+ 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)
+ else:
+ 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 + 1)
killcmd='sudo pkill -KILL -f \"iperf .* -o .*/iperfclient_%s.out\"' % (flowid)
print killcmd
print cmd
diff --git a/web/topology_rest.py b/web/topology_rest.py
index 7bbf7ce..54e645d 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -864,11 +864,11 @@
cmd = 'up'
result=""
host = controllers[0]
- cmd_string="~/ONOS/scripts/link.sh %s %s %s " % (src_dpid, port1, cmd)
+ cmd_string="~/ONOS/scripts/link-hw.sh %s %s %s " % (src_dpid, port1, cmd)
print cmd_string
res=os.popen(cmd_string).read()
result = result + ' ' + res
- cmd_string="~/ONOS/scripts/link.sh %s %s %s " % (dst_dpid, port2, cmd)
+ cmd_string="~/ONOS/scripts/link-hw.sh %s %s %s " % (dst_dpid, port2, cmd)
print cmd_string
res=os.popen(cmd_string).read()
result = result + ' ' + res
@@ -892,9 +892,9 @@
cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./link.sh %s %s %s'" % (host, src_dpid, src_port, cmd)
else:
if ( src_dpid == "00:00:00:08:a2:08:f9:01" ):
- cmd_string="~/ONOS/scripts/link.sh %s %s %s " % ( dst_dpid, dst_port, cmd)
+ cmd_string="~/ONOS/scripts/link-hw.sh %s %s %s " % ( dst_dpid, dst_port, cmd)
else:
- cmd_string="~/ONOS/scripts/link.sh %s %s %s " % ( src_dpid, src_port, cmd)
+ cmd_string="~/ONOS/scripts/link-hw.sh %s %s %s " % ( src_dpid, src_port, cmd)
print cmd_string
result=os.popen(cmd_string).read()
@@ -957,34 +957,46 @@
src_host = controllers[0]
else:
hostid=int(src_dpid.split(':')[-2])
- src_host = controllers[hostid-1]
+ if TESTBED == "hw":
+ src_host = "mininet%i" % hostid
+ else:
+ src_host = controllers[hostid-1]
if dst_dpid in core_switches:
dst_host = controllers[0]
else:
hostid=int(dst_dpid.split(':')[-2])
- dst_host = controllers[hostid-1]
+ if TESTBED == "hw":
+ dst_host = "mininet%i" % hostid
+ else:
+ dst_host = controllers[hostid-1]
-# /runiperf.sh <flowid> <src_dpid> <dst_dpid> svr|client <proto>/<duration>/<interval>/<samples>
+# /runiperf.sh <flowid> <src_dpid> <dst_dpid> hw:svr|sw:svr|hw:client|sw:client <proto>/<duration>/<interval>/<samples>
protocol="udp"
interval=0.1
- cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./runiperf.sh %d %s %s %s %s/%s/%s/%s'" % (dst_host, flowId, src_dpid, dst_dpid, "svr", protocol, duration, interval, samples)
+ if TESTBED == "hw":
+ cmd_string="dsh -w %s 'cd ONOS/scripts; " % dst_host
+ else:
+ cmd_string="ssh -i ~/.ssh/onlabkey.pem %s '" % dst_host
+ cmd_string += "./runiperf.sh %d %s %s %s:%s %s/%s/%s/%s'" % (flowId, src_dpid, dst_dpid, TESTBED, "svr", protocol, duration, interval, samples)
print cmd_string
os.popen(cmd_string)
- cmd_string="ssh -i ~/.ssh/onlabkey.pem %s 'cd ONOS/scripts; ./runiperf.sh %d %s %s %s %s/%s/%s/%s'" % (src_host, flowId, src_dpid, dst_dpid, "client", protocol, duration, interval, samples)
+ if TESTBED == "hw":
+ cmd_string="dsh -w %s 'cd ONOS/scripts; " % src_host
+ else:
+ cmd_string="ssh -i ~/.ssh/onlabkey.pem %s'" % src_host
+ cmd_string+="./runiperf.sh %d %s %s %s:%s %s/%s/%s/%s'" % (flowId, src_dpid, dst_dpid, TESTBED, "client", protocol, duration, interval, samples)
print cmd_string
os.popen(cmd_string)
return cmd_string
+
#* Get Iperf Throughput
#http://localhost:9000/gui/iperf/rate/<flow_id>
@app.route("/gui/iperf/rate/<flow_id>")
def iperf_rate(flow_id):
- if (TESTBED == "hw"):
- return "{}"
-
try:
command = "curl -s \'http://%s:%s/wm/flow/get/%s/json\'" % (RestIP, RestPort, flow_id)
print command
@@ -1005,9 +1017,12 @@
dst_port = parsedResult['dataPath']['dstPort']['port']['value']
if dst_dpid in core_switches:
- host = controllers[0]
+ host = controllers[0]
else:
- hostid=int(dst_dpid.split(':')[-2])
+ hostid=int(dst_dpid.split(':')[-2])
+ if TESTBED == "hw":
+ host = "mininet%i" % hostid
+ else:
host = controllers[hostid-1]
try:
@@ -1024,7 +1039,6 @@
resp = Response(result, status=200, mimetype='application/json')
return resp
-
if __name__ == "__main__":
random.seed()
read_config()