You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
regarding the IPv4/IPv6 uniformity, since RFC 2474 standardized the DS Field to work similarly for both IPv4 (TOS byte) and IPv6 (Traffic Class byte), could the API simply accept the 8-bit integer and handle the implementation details internally? ideally, socket.setTOS(val) would just map to setsockopt(..., IP_TOS, ...) for AF_INET and setsockopt(..., IPV6_TCLASS, ...) for AF_INET6, this keeps the user-facing API uniform since the DSCP constants (like CS1, AF11) represent the same priority intent regardless of the protocol version.
I plan to implement the C++ bindings in TCPWrap (handling IP_TOS/IPV6_TCLASS) and expose it via lib/net.js. I'll open a Draft PR once I have the basic implementation working.
Activity
ronag commentedon Jan 23, 2026
Note that there is a difference between ipv4 and ipv6. Not sure how/if this can exposed in a uniform way.
ronag commentedon Jan 23, 2026
In our ipv4 case we would like to use the following TOS values:
CS1 (TOS BYTE 0x20) = LOW PRIO
Best Effort (TOS BYTE 0x00) = NORMAL PRIO
AF11 (TOS BYTES 0x28) = HIGH PRIO
amyssnippet commentedon Jan 23, 2026
regarding the IPv4/IPv6 uniformity, since RFC 2474 standardized the DS Field to work similarly for both IPv4 (TOS byte) and IPv6 (Traffic Class byte), could the API simply accept the 8-bit integer and handle the implementation details internally? ideally,
socket.setTOS(val)would just map tosetsockopt(..., IP_TOS, ...)forAF_INETandsetsockopt(..., IPV6_TCLASS, ...)forAF_INET6, this keeps the user-facing API uniform since the DSCP constants (likeCS1,AF11) represent the same priority intent regardless of the protocol version.amyssnippet commentedon Jan 23, 2026
should i work on this, or is this you already been working on?
ronag commentedon Jan 23, 2026
Please do work on it.
amyssnippet commentedon Jan 23, 2026
Awesome, I'm on it!
I plan to implement the C++ bindings in TCPWrap (handling IP_TOS/IPV6_TCLASS) and expose it via lib/net.js. I'll open a Draft PR once I have the basic implementation working.
amyssnippet commentedon Jan 24, 2026
@ronag i did it, please have a look at the pr #61503
net: add `setTOS` and `getTOS` to `Socket`
net: add `setTOS` and `getTOS` to `Socket`
net: add `setTOS` and `getTOS` to `Socket`
net: add `setTOS` and `getTOS` to `Socket`
net: add `setTOS` and `getTOS` to `Socket`