IP Don't fragment bit on Mac OS

前端 未结 4 1359
猫巷女王i
猫巷女王i 2020-12-21 03:52

I am writing a file transferring program over TCP.

I want to set the don\'t fragment flag on IP

On a socket this is what I want to do:

int va         


        
相关标签:
4条回答
  • 2020-12-21 04:10

    The Don't Fragment bit is typically set on all TCP packets anyway. You don't have to do any special to achieve this.

    0 讨论(0)
  • 2020-12-21 04:23

    The DF bit is typically used for path MTU (PMTU) discovery automatically by the operating system with TCP connections. If anything, you may have a socket option for disabling PMTU discovery which will have the effect of never setting DF (it's the IP_MTU_DISCOVER socket option on linux). If you leave PMTU discovery on, it will have the effect of always setting DF.

    It wouldn't make sense to set/unset it on a packet-by-packet basis because you're using TCP and TCP operates on segments, not packets. If you want to set packet-level stuff, you need to use a lower-layer protocol.

    0 讨论(0)
  • 2020-12-21 04:25

    google brought up this: http://lists.apple.com/archives/macnetworkprog/2006/Jul/msg00014.html

    0 讨论(0)
  • 2020-12-21 04:35

    Looking at /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers it seems to be called IP_DF here:

    netinet/ip.h
    99:#define IP_DF 0x4000                    /* dont fragment flag */
    netinet6/in6.h
    547:#define IPV6_DONTFRAG           62 /* bool; disable IPv6 fragmentation */
    
    0 讨论(0)
提交回复
热议问题