Java / TCP Traffic Classes

Well, I notice that in Java and possibly other languages ​​there is a Socket option similar to

setTrafficClass(int tc) 

I know that the application I use has a traffic class of 24, however, despite googling, I can not find a list of what correspond to these classes, and a list of valid ones.

Please enlighten me. md_5

+4
source share
3 answers

Javadocs has some details. Essentially, you are setting the TOS header (service type) of your package. The routing network may prefer to use this as a suggestion on how to process the packet (or it may completely ignore it). Many networks do not actually do anything significant in this field, so I will not rely on its behavior.

+2
source

According to the specification for Socket.setTrafficClass we see:

For the Internet Protocol v4, the value consists of an integer , the least significant 8 bits of which represent the value of the TOS octet in the IP packets sent by the socket. RFC 1349 defines TOS values ​​as follows:

  • IPTOS_LOWCOST ( 0x02 )
  • IPTOS_RELIABILITY ( 0x04 )
  • IPTOS_THROUGHPUT ( 0x08 )
  • IPTOS_LOWDELAY ( 0x10 )

The last bit of the least significant bit is always ignored, since this corresponds to the MBZ bit (must be equal to zero).

24 is 0x18 ie 0x10 | 0x08 0x10 | 0x08 , which corresponds to IPTOS_THROUGHPUT and IPTOS_LOWDELAY .

As you can see, TOS is just a hint; it requests high-performance, low-latency routing ... that may or may not be served!

You can learn more about the types of services in RFC 1349 and the related Wikipedia article here .

+2
source

The class of traffic is ultimately up to you and your nearest router. The field was through several mutations. It also varies between IPv4 and IPv6. The first definition for IPv4 was given in RFC 791-5; it was revised in RFC 1349 and completely redefined in RFC 2474 as "Differentiated Services". The whole business may have been revised again since I researched it for my book in 2003 or so. For IPv6, see RFC 2460. The Javadoc material on IPTOS_* values ​​refers to RFC 1349 and has been outdated for several years when it was recorded.

0
source

All Articles