Don't Fragment flag in Java

2019-09-12 05:45发布

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

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

标签: java udp
1条回答
对你真心纯属浪费
2楼-- · 2019-09-12 06:24

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

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.

查看更多
登录 后发表回答