IP Do not fragment bits on Mac OS

I am writing a file transfer program over TCP.

I want to set the do not fragment flag to IP

In a socket, this is what I want to do:

int val = 1; setsockopt(sd, IPPROTO_IP, IP_DONTFRAG, &val, sizeof(val)); 

However, IP_DONTFRAG not displayed on Mac OS. Am I missing something? or did I forget to turn it on correctly?

Thanks in advance if anyone knows

- Sam

+4
source share
3 answers

The DF bit is typically used to detect MTU paths (PMTUs) automatically by an operating system with TCP connections. Anyway, you may have a socket option to disable PMTU detection, which will have the effect of never setting DF (this is the socket option IP_MTU_DISCOVER on Linux). If you leave PMTU detection enabled, this will have the effect of always setting DF.

It would be pointless to set it on / off on an “individually” basis, because you are using TCP and TCP for segments, not packets. If you want to set the packet level, you need to use the lower layer protocol.

+1
source

The Don't Fragment bit is usually set in all TCP packets. You do not need to do any special actions to achieve this.

0
source

All Articles