Giter Club home page Giter Club logo

Comments (5)

stephenwvickers avatar stephenwvickers commented on July 28, 2024

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?

from node-net-ping.

MauJFernandezUVR avatar MauJFernandezUVR commented on July 28, 2024

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.

from node-net-ping.

stephenwvickers avatar stephenwvickers commented on July 28, 2024

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

from node-net-ping.

stephenwvickers avatar stephenwvickers commented on July 28, 2024

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.

from node-net-ping.

MauJFernandezUVR avatar MauJFernandezUVR commented on July 28, 2024

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!

from node-net-ping.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.