Last active
August 29, 2015 14:27
-
-
Save John-Lin/ac08cfefcab03d9d116b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var request = require('request'); | |
| var config = require('./config'); | |
| module.exports = { | |
| startPkt: function() { | |
| dpid = config.dpid; | |
| urlApi = 'http://127.0.0.1:8080/packetgen/start/' + dpid; | |
| request(urlApi, function(error, response, body) { | |
| if (!error && response.statusCode == 200) { | |
| console.log(200); | |
| } | |
| }); | |
| }, | |
| stopPkt: function() { | |
| dpid = config.dpid; | |
| urlApi = 'http://127.0.0.1:8080/packetgen/stop/' + dpid; | |
| request(urlApi, function(error, response, body) { | |
| if (!error && response.statusCode == 200) { | |
| console.log(200); | |
| } | |
| }); | |
| }, | |
| setOutputPort: function(outputPort) { | |
| request({ | |
| url: 'http://127.0.0.1:8080/packetgen/setoutput', | |
| method: 'PUT', | |
| json:{output: outputPort}, | |
| function(error, response, body) { | |
| if (!error && response.statusCode == 200) { | |
| console.log('Set output port' + outputPort); | |
| } | |
| } | |
| }); | |
| }, | |
| setPayloadSize: function(size) { | |
| request({ | |
| url: 'http://127.0.0.1:8080/packetgen/setpktsize', | |
| method: 'PUT', | |
| json:{payloadSize: outputPort}, | |
| function(error, response, body) { | |
| if (!error && response.statusCode == 200) { | |
| console.log('Set packet size' + size); | |
| } | |
| } | |
| }); | |
| }, | |
| startPktWithTuple: function(src, dst, src_ip, dst_ip, src_port, dst_port) { | |
| dpid = config.dpid; | |
| urlApi = 'http://127.0.0.1:8080/packetgen/start/' + dpid; | |
| request({ | |
| url: urlApi, | |
| method: 'PUT', | |
| json:{src:src, dst:dst, src_ip:src_ip, dst_ip:dst_ip, src_port:src_ip, dst_port:dst_port}, | |
| function(error, response, body) { | |
| if (!error && response.statusCode == 200) { | |
| console.log('Set 5 tuple' + json); | |
| } | |
| } | |
| }); | |
| }, | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function(){ | |
| var app = require('./app.js') | |
| $('.menu .item').tab(); | |
| $('.ui.checkbox').checkbox(); | |
| $('.ui.toggle.button').state({ | |
| text: { | |
| inactive : 'Send', | |
| active : 'Sending' | |
| } | |
| }); | |
| $('.message .close') | |
| .on('click', function() { | |
| $(this) | |
| .closest('.message') | |
| .transition('fade') | |
| ; | |
| }); | |
| $("#applyBtn").click(function() { | |
| var pktGenStatus = $('#pktGenStatus').checkbox('is checked'); | |
| var outputPortNum = $("#outputPort").val(); | |
| var pktSize = $("#pktSize").val(); | |
| if (!outputPortNum) { | |
| $("#dutInPortField").removeClass('inline field').addClass('inline field error'); | |
| return | |
| } else if (!pktSize) { | |
| $("#pktSizeField").removeClass('inline field').addClass('inline field error'); | |
| return | |
| } else { | |
| $("#dutInPortField").removeClass('inline field error').addClass('inline field'); | |
| $("#pktSizeField").removeClass('inline field error').addClass('inline field'); | |
| } | |
| if(pktGenStatus) { | |
| app.setOutputPort(outputPortNum); | |
| app.setPayloadSize(pktSize); | |
| app.startPkt(); | |
| } else { | |
| app.stopPkt(); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment