使用setTrafficClass和WireShark发出DSCP标记问题 [英] Issue with DSCP marking using setTrafficClass and WireShark

查看:943
本文介绍了使用setTrafficClass和WireShark发出DSCP标记问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用setTrafficClass标记DSCP值。我在两台不同的机器上设置了服务器和客户端,我能够打印DSCP的值,但我无法在WireShark中看到它。
我在线浏览了一些帖子,但没有任何帮助。我使用的是Windows 7专业版。
任何帮助将不胜感激。谢谢!

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:

尝试{

        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();
    }

}

服务器:

    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();
    }

}

在服务器端的控制台:
当前DSCP值:10

In console on server side: Current DSCP value: 10

我的服务器代码和客户端位于不同的计算机上。

My server code and client are on separate machines.

在wireshark中,我看到:

In wireshark I see:

区分服务字段:0x00(DSCP 0x00:默认值; ECN:0x00:非ECT(不支持ECN))

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

我希望看到wireshark的变化,我只看到默认值为零。

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

推荐答案

上次我使用Java中的DSCP值时,必须设置 java.net.preferIPv4Stack 系统属性由于JVM中的错误,导致 true 。尽管看起来在java.net.Socket API中工作,但不会在底层套接字上设置Othwerwise DSCP值。

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.

此外,您可能必须在连接套接字之前调用 setTrafficClass ,在某些平台上连接后它可能无法正常工作。

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 ...

这篇关于使用setTrafficClass和WireShark发出DSCP标记问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆