Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with DSCP marking using setTrafficClass and WireShark

I am trying to mark DSCP values using setTrafficClass. I have server and client set up on two different machines and I am able to print value of DSCP but I can not see it in WireShark. I have gone through some posts online but nothing helped. I am using Windows 7 professional. Any help would be appreciated. Thank you!

I am more testing to see 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 console on server side: Current DSCP value: 10

My server code and client are on separate machines.

In wireshark I see:

Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00: Not-ECT (Not ECN-Capable Transport))

I expect to see changes in wireshark and I only see default value zero.

like image 805
ron_g_1 Avatar asked Nov 10 '22 00:11

ron_g_1


1 Answers

Last time I worked with DSCP values in Java one had to set the java.net.preferIPv4Stack system property to true due to a bug in the JVM. Othwerwise DSCP values would not be set on the underlying socket despite appearing to work in the java.net.Socket API.

Also you may have to call setTrafficClass before connecting the socket, it may not work after connection on some platforms.

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

like image 139
Dev Avatar answered Nov 15 '22 00:11

Dev