setting up iperf session
diff --git a/web/ons-demo/js/app.js b/web/ons-demo/js/app.js
index 695e4bb..c150b9f 100644
--- a/web/ons-demo/js/app.js
+++ b/web/ons-demo/js/app.js
@@ -232,6 +232,23 @@
flows.exit().remove();
}
+// TODO: cancel the interval when the flow is desel
+function startIPerfForFlow(flow) {
+ var duration = 10; // seconds
+ var interval = 100; // ms. this is defined by the server
+ var updateRate = 1000; // ms
+
+ if (flow.flowId) {
+ console.log('starting iperf for: ' + flow.flowId.value);
+ startIPerf(flow, duration, updateRate/interval);
+ flow.iperfInterval = setInterval(function () {
+ getIPerfData(flow, function (data) {
+ console.log(data);
+ });
+ });
+ }
+}
+
function updateSelectedFlows() {
// make sure that all of the selected flows are either
// 1) valid (meaning they are in the latest list of flows)
@@ -249,6 +266,7 @@
if (liveFlow) {
newSelectedFlows.push(liveFlow);
liveFlow.deletePending = flow.deletePending;
+ liveFlow.iperfInterval = flow.iperfInterval;
} else if (flow.createPending) {
newSelectedFlows.push(flow);
}
@@ -256,6 +274,11 @@
});
selectedFlows = newSelectedFlows;
}
+ selectedFlows.forEach(function (flow) {
+ if (!flow.iperfInterval) {
+ startIPerfForFlow(flow);
+ }
+ });
while (selectedFlows.length < 3) {
selectedFlows.push(null);
}
@@ -288,6 +311,11 @@
flowKey !== makeFlowKey(flow) ||
flowKey === makeFlowKey(flow) && ifCreatePending && !flow.createPending ) {
newSelectedFlows.push(flow);
+ } else {
+ if (flow && flow.iperfInterval) {
+ console.log('clearing iperf interval for: ' + flow.flowId.value);
+ clearInterval(flow.iperfInterval);
+ }
}
});
selectedFlows = newSelectedFlows;
diff --git a/web/ons-demo/js/controller.js b/web/ons-demo/js/controller.js
index fd3f6ae..929e21b 100644
--- a/web/ons-demo/js/controller.js
+++ b/web/ons-demo/js/controller.js
@@ -1,10 +1,13 @@
/*global d3*/
-function callURL(url) {
+function callURL(url, cb) {
d3.text(url, function (error, result) {
if (error) {
alert(url + ' : ' + error.status);
} else {
+ if (cb) {
+ cb(result);
+ }
console.log(result);
}
});
@@ -37,6 +40,16 @@
delFlowCmd: function (flow) {
var url = '/proxy/gui/delflow/' + flow.flowId.value;
callURL(url);
+ },
+ startIPerfCmd: function (flow, duration, numSamples) {
+ var flowId = parseInt(flow.flowId.value, 16);
+ var url = '/proxy/guid/iperf/start/' + [flowId, duration, numSamples].join('/');
+ callURL(url)
+ },
+ getIPerfDataCmd: function (flow, cb) {
+ var flowId = parseInt(flow.flowId.value, 16);
+ var url = '/proxy/gui/iperf/rate/' + flowId;
+ callURL(url, cb);
}
};
@@ -70,4 +83,12 @@
function deleteFlow(flow) {
controllerFunctions.delFlowCmd(flow);
+}
+
+function startIPerf(flow, duration, numSamples) {
+ controllerFunctions.startIPerfCmd(flow, duration, numSamples);
+}
+
+function getIPerfData(flow, cb) {
+ controllerFunctions.getIPerfDataCmd(flow, cb);
}
\ No newline at end of file
diff --git a/web/topology_rest.py b/web/topology_rest.py
index e7e1d83..4ed3ae5 100755
--- a/web/topology_rest.py
+++ b/web/topology_rest.py
@@ -153,6 +153,34 @@
resp = Response(result, status=200, mimetype='application/json')
return resp
+
+@app.route("/proxy/gui/iperf/start/<flow_id>/<duration>/<samples>")
+def proxy_iperf_start(flow_id,duration,samples):
+ try:
+ command = "curl -s %s/gui/iperf/start/%s/%s/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id, duration, samples)
+ print command
+ result = os.popen(command).read()
+ except:
+ print "REST IF has issue"
+ exit
+
+ resp = Response(result, status=200, mimetype='application/json')
+ return resp
+
+@app.route("/proxy/gui/iperf/rate/<flow_id>")
+def proxy_iperf_rate(flow_id):
+ try:
+ command = "curl -s %s/gui/iperf/rate/%s" % (ONOS_GUI3_CONTROL_HOST, flow_id)
+ print command
+ result = os.popen(command).read()
+ except:
+ print "REST IF has issue"
+ exit
+
+ resp = Response(result, status=200, mimetype='application/json')
+ return resp
+
+
@app.route("/wm/core/topology/switches/all/json")
def switches():
if request.args.get('proxy') == None:
@@ -204,7 +232,7 @@
print "REST IF has issue"
exit
-
+
resp = Response(result, status=200, mimetype='application/json')
return resp
@@ -858,7 +886,7 @@
print cmd_string
os.popen(cmd_string)
- return
+ return
#* Get Iperf Throughput
#http://localhost:9000/gui/iperf/rate/<flow_id>