Search code examples
node.jstcpip

Can I set IP header from node.js


There is a need to set DSCP values in packet headers in messages sent from node.js WebSocket. From the Wikipedia page, I understood I have to modify DS field in the IP header to set custom DSCP value. Is it possible to set it from node application and for some specific messages?


Solution

  • Unfortunately, Node.js does not expose any IP level API (current version: v11.10.1). So you cannot set custom IP header only with JavaScript code.

    However, in the Node.js application, you can write C/C++ addon to send the custom IP packet and integrate that addon in Node.js code.

    Take module raw-socket for example, it writes raw network logic in C++ and expose that in JavaScript interface.