Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Quality of Service #42

Closed
MauJFernandezUVR opened this issue Jul 18, 2017 · 5 comments
Closed

Support for Quality of Service #42

MauJFernandezUVR opened this issue Jul 18, 2017 · 5 comments

Comments

@MauJFernandezUVR
Copy link

Hi, I was looking for a package like this one, but what I was searching specifically was QoS support, do you have any plans to add it?

Thanks.

@stephenwvickers
Copy link
Collaborator

This is quite tricky, and would be something the raw-socket module (also my module) would have to support.

Are you enquiring specifically about QoS support for ICMP ping messages, or QoS for packets in general?

@MauJFernandezUVR
Copy link
Author

Right now specifically for ICMP ping messages, but a general QoS support for the raw-socket module might open some possibilities for me to develop tools at my work.

@stephenwvickers
Copy link
Collaborator

stephenwvickers commented Jul 19, 2017

For Windows it's not simple, and would require using the QoS API specifically exposed to work with QoS, something that would not be done anytime soon I'm afraid because of work commitments.

If you are working with Linux however, you could try the IP_TOS socket option. First identify the value for your local system (using IPTOS_THROUGHPUT here as an example):

$ grep -R IP_TOS /usr/include/*
/usr/include/bits/in.h:#define        IP_TOS          1       /* int; IP type of service and precedence.  */
/usr/include/linux/in.h:#define IP_TOS          1
...
$ grep -R IPTOS_THROUGHPUT /usr/include/*
/usr/include/linux/ip.h:#define IPTOS_THROUGHPUT        0x08
/usr/include/netinet/ip.h:#define       IPTOS_THROUGHPUT        0x08
...

Then use this to set the socket option before you use the net-ping session (assumes latest version of net-ping):

var ping = require("net-ping")
var raw = require("raw-socket")

var session = ping.createSession(...)

var level = raw.SocketLevel.IPPROTO_IP
var option = 1 // IP_TOS
var value = new Buffer([0x08]) // IPTOS_THROUGHPUT

session.getSocket().setOption(level, option, value, value.length)

// Then go on to session.pingHost() etc.

See the raw-socket docs for more information on the setSocket() method.

Steve

@stephenwvickers
Copy link
Collaborator

Just realised, we already expose the IP_TOS option, so this would actually be:

var ping = require("net-ping")
var raw = require("raw-socket")

var session = ping.createSession(...)

var level = raw.SocketLevel.IPPROTO_IP
var option = raw.SocketOption.IP_TOS
var value = new Buffer([0x08]) // IPTOS_THROUGHPUT

session.getSocket().setOption(level, option, value, value.length)

// Then go on to session.pingHost() etc.

@MauJFernandezUVR
Copy link
Author

Sorry for the delay, I've been dragged with another things at work, I'll try it when I find time to code it, it looks really promising.

Thanks for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants