Skip to content

Instantly share code, notes, and snippets.

@xdenser
Last active August 29, 2015 14:01
Show Gist options
  • Save xdenser/73f33f6728e6de6fd10d to your computer and use it in GitHub Desktop.
Save xdenser/73f33f6728e6de6fd10d to your computer and use it in GitHub Desktop.
var dgram = require('dgram'),
vsocket = dgram.createSocket('udp4'),
dataRcv=0, prevDataRcv=0;
setInterval(function(){
console.log('Rcv rate',dataRcv-prevDataRcv);
prevDataRcv = dataRcv;
},1000)
vsocket.bind(35668,'127.0.0.1',function(){
vsocket.addMembership('224.0.0.101','127.0.0.1');
vsocket.on('message',function(data){
dataRcv+=data.length;
});
});
var dgram = require('dgram'),
socket = dgram.createSocket('udp4'),
dataSent=0, prevdataSent= 0,
buf = new Buffer(65507);
setInterval(function(){
console.log('Send rate',dataSent-prevdataSent);
prevdataSent = dataSent;
},1000)
socket.bind('127.0.0.1',function(){
socket.addMembership('224.0.0.101','127.0.0.1');
socket.setMulticastLoopback(false);
function send(){
dataSent+=buf.length;
socket.send(buf,0,buf.length,35668,'224.0.0.101',send);
}
send();
});
@xdenser
Copy link
Author

xdenser commented May 19, 2014

Test of max UDP multicats rate on loopback interface.

@No9
Copy link

No9 commented May 20, 2014

Hey
I can't reproduce this
Suggest you look at https://github.com/hij1nx/net-log
for an initial direction on how you might want to go about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment