1

Apparently Socket implementations were re-written as part of https://openjdk.java.net/jeps/353 and now it uses java.base/sun.nio.ch.NioSocketImpl

Been trying to set the traficClass or in other words the IP_TOS field of the ip header without success.

Have tried with socket.setTrafficClass and socket.setSocketOption(StandardSocketOption.IPTOS) and neither i see the values in wireshark nor subsequent calls to getTrafficClass or getSocketOption returning anything other than 0

Problem happening in Windows 10 but i at least on centos7 getTrafficClass does return the value previously set

pranahata
  • 530
  • 4
  • 18
  • 1
    AFAIU the behaviour of IP_TOS is highly system dependent: https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/net/StandardSocketOptions.html#IP_TOS I wonder if you might see any difference when running with `-Djava.net.preferIPv4Stack` – daniel Jan 15 '20 at 14:09
  • 2
    It would be useful to expand the question to say more about what you are doing. Are you using java.net.Socket or java.net.DatagramSocket. Also useful to know if you've run with strace -f java Test and look at the setsockopt usages. If IPv6 is enabled then I would expect to see the JDK set the IPV6_TCLASS socket option. If IPv4 only then I would expect to see the IP_TOS socket option set. – Alan Bateman Jan 15 '20 at 14:20
  • Thanks Alan, Testing it with java.net.Socket. Seems to be working on centos 7 (or at least getTrafficClass() is returning the value previously set), but not on windows 10. – pranahata Jan 16 '20 at 07:43
  • 1
    Windows went a different route for QoS and hasn't supported setting IP_TOS for many years. At one point it was possible to tweak a registry setting to allow it but that was a long time ago. So I don't think this is a JDK issue. – Alan Bateman Jan 16 '20 at 08:14
  • Thanks @AlanBateman , is there anything in windows that you can set on a tcp socket to reduce latency? seems like TCP_QUICKACK is not supported either? what way did windows go? As to whether it is a JDK issue or not, i don't understand with socket.supportedOptions returns IP_TOS if windows doesn't do anything about it, because either windows shouldn't report it as an option or the JDK shouldn't infere this is a supported option – pranahata Jan 17 '20 at 03:48
  • StandardSocketOptions.IP_TOS specifies that the value is a hint so that it's dependent on the underlying implementation/platform. TCP_QUICKACK is not a standard socket option and I don't know of an equivalent on Windows. There are registry settings that control this (like TcpAckFrequency or TcpDelAckTicks/TcpAckFrequency on specific interfaces) but this is advanced tuning so lots of reading and analysis needed before touching these. – Alan Bateman Jan 18 '20 at 08:33

0 Answers0