Issue with DSCP marking using setTrafficClass and WireShark(使用 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
系统属性设置为 true
由于 JVM 中的错误.尽管似乎在 java.net.Socket API 中工作,但不会在底层套接字上设置 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.
另外你可能需要在连接socket之前调用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 标记的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 setTrafficClass 和 WireShark 进行 DSCP 标记的问题
基础教程推荐
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 降序排序:Java Map 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01