IP Don't fragment bit on Mac OS

匿名 (未验证) 提交于 2019-12-03 01:27:01

问题:

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 val = 1; setsockopt(sd, IPPROTO_IP, IP_DONTFRAG, &val, sizeof(val)); 

However IP_DONTFRAG does not seem available on Mac OS. Am I missing something? or did I forget to include it correctly?

Thanks in advance if anyone knows

--Sam

回答1:

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



回答2:

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.



回答3:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!