Don't Fragment flag in Java

后端 未结 1 1531
囚心锁ツ
囚心锁ツ 2021-01-28 04:02

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 Datagram

相关标签:
1条回答
  • 2021-01-28 04:40

    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.

    0 讨论(0)
提交回复
热议问题