Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java / TCP Traffic classes

Tags:

java

tcp

sockets

Well I notice in Java and presumably other languages there is a Socket option similar to

setTrafficClass(int tc) 

I know the application I am using has a traffic class of 24, however despite googling I cannot find a list of what these classes correspond to, nor a list of valid ones.

Please enlighten me. md_5

like image 844
md_5 Avatar asked Aug 19 '12 04:08

md_5


People also ask

Do java sockets use TCP?

There are two communication protocols that we can use for socket programming: User Datagram Protocol (UDP) and Transfer Control Protocol (TCP).

What is TCP in java?

The java.net package provides support for the two common network protocols − TCP − TCP stands for Transmission Control Protocol, which allows for reliable communication between two applications. TCP is typically used over the Internet Protocol, which is referred to as TCP/IP.

What is stream socket class in java?

Socket class is implemented in creating a stream socket and which is connected to a specified port number and port address. public Socket(InetAddress address, int port) 2. Socket class is used for the creation of socket and connecting to the specified remote address on the specified remote port in javax.net.


1 Answers

According to the specification for Socket.setTrafficClass, we see:

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

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

The last low order bit is always ignored as this corresponds to the MBZ (must be zero) bit.

24 is 0x18 i.e. 0x10 | 0x08, which corresponds to IPTOS_THROUGHPUT and IPTOS_LOWDELAY being set.

As you can see, the TOS only serves as a hint; it requests high-throughput, low-delay routing... which may or may not be serviced!

You can read more on types of service in RFC 1349 and the relevant Wikipedia article here.

like image 148
obataku Avatar answered Oct 14 '22 04:10

obataku