DSCP tagging issue using setTrafficClass and WireShark

I am trying to mark DSCP values ​​using setTrafficClass. I have a server and a client configured on two different machines, and I can print the DSCP value, but I do not see it in WireShark. I went through several posts on the Internet, but nothing helped. I am using a professional Windows 7. Any help would be greatly appreciated. Thanks!

I am testing more how this can be done. Here is the client code:

try {

Socket socket = new Socket(addr, 2345); socket.setTrafficClass(10); PrintWriter out = new PrintWriter( socket.getOutputStream(), true); out.println("Current DSCP value: " + socket.getTrafficClass()); out.close(); socket.close(); } catch (Exception e) { e.printStackTrace(); } } 

Server:

  try { ServerSocket serverSocket = new ServerSocket(1234); Socket clientSocket = serverSocket.accept(); BufferedReader in = new BufferedReader(new InputStreamReader( clientSocket.getInputStream())); String fromClient = in.readLine(); System.out.println(fromClient); in.close(); clientSocket.close(); serverSocket.close(); } catch (Exception e) { e.printStackTrace(); } } 

In the server-side console: Current DSCP value: 10

My server code and client are on separate machines.

In wirehark, I see:

Differentiated Services Field: 0x00 (DSCP 0x00: default, ECN: 0x00: non-ECT (ECN not supported))

I expect to see changes in wirehark, and I only see the default value of 0.

+4
java network-programming wireshark
source share
1 answer

The last time I worked with DSCP values ​​in Java, I had to set the java.net.preferIPv4Stack system property to true due to an error in the JVM. Otwerwise DSCP values ​​will not be set on the underlying socket even though they work in the java.net.Socket API.

You may also need to call setTrafficClass before connecting the socket, it may not work after connecting on some platforms.

java -Djava.net.preferIPv4Stack=true ...

+1
source share

All Articles