1

I tried a simple code of UDP socket in Java and the analysis showed me that the DF bit was always set in the packet's IP Header, is there a way to clear the flag?

I tried out a code in TCP as well, and both the server and client code was in the same machine. Just wanted to know if there is a default setting for the flags, and if not how to clear it.

Snapshot of the packet capture

Anushreya
  • 11
  • 2
  • DF is set to 1 or 0 (Don't Fragment or Fragment). Why specifically do you want to clear the flag? Are you using a completely closed network where you know that the MTU will be standard? UDP is a message-oriented protocol, meaning that it does not have a built-in reordering or retransmitting mechanism, so you want to avoid fragmentation if at all possible and this is where the DF flag helps. Also with TCP you almost always want the flag enabled so that in instances where fragmentation does happen if DF wasn't set, the sending TCP would never know that it was sending segments that are too large. – sorifiend Feb 04 '19 at 23:39
  • So I am working on a containerized Java based SDN platform. While performing the stress test using Datagram sockets, the packets that have DF flag set to 1(Don't Fragment) is getting dropped hence the need to clear the bit. Also, will using datagram channels help me in any way? Thanks a ton!! – Anushreya Feb 05 '19 at 10:14
  • If the packets are being dropped then it sounds like you have an entirely different but very serious issue that needs fixing first (Many sources use the DF flag), and just removing the DF flag seems like a very bad solution that may cause lost data in the future if packets cannot be reassembled correctly (I recommend you read about what the flag does). To answer your comment on using UDP or TCP: As you know, it depends on what you are trying to send, if you need all the data to get through then don't touch datagram, you need to use TCP or another protocol that makes sure all data is received. – sorifiend Feb 05 '19 at 13:56
  • I understand that, but is there any way I can control this DF flag at all? – Anushreya Feb 07 '19 at 11:32
  • Yes, this link may help: https://stackoverflow.com/q/41032248/1270000 – sorifiend Feb 07 '19 at 11:35

0 Answers0