不要在 Java 中分割标志 [英] Don't Fragment flag in Java

查看:27
本文介绍了不要在 Java 中分割标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Java 中使用标准 API 发送设置了Don't Fragment"标志的 UDP 数据包?

Is it possible in Java to send a UDP packet with the "Don't Fragment" flag set using the standard API?

我在 上没有看到任何相关选项DatagramSocketDatagramChannel.setOption(或更好:StandardSocketOptions).

I don't see any relevant options on DatagramSocket or DatagramChannel.setOption (or better: StandardSocketOptions).

推荐答案

Don't Fragment"标志是 IP 的一部分,而不是 TCP 或 UDP.IP是TCP和UDP下面的协议1层(TCP和UDP包被IP包裹).

The "Don't Fragment" flag is part of IP, not TCP or UDP. IP is the protocol 1 layer below TCP and UDP (TCP and UDP packets are wrapped in IP).

您需要能够创建原始套接字,这在标准 Java 中是不可用的.似乎有一个名为RockSaw"的库,可能有用.请注意,您的程序需要具有根/管理员权限才能访问原始套接字.

You would need the ability to create a raw socket, which is not available in standard Java. There seems to be a library called "RockSaw" which might be of use. Be aware that your program will need to have root/administrator permissions to access raw sockets.

这篇关于不要在 Java 中分割标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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