sockets - How to set "don't fragment" flag bit for TCP packet in Go? -


i intend set "don't fragment" flag bit in go, same thing this post while in c. checked constant list didn't find option. corresponding option in go?

thanks in advance!

how set "don't fragment" flag bit tcp packet in go?

first should know tcp doesn't ip fragments. if not major implementations avoid fragmentation tcp segments using path mtu discovery.

the tl;dr typical ip packet containing tcp segment has df bit set. can (and should) try out. here sniffing few seconds of traffic between machine , stackoverflow.com:

% tshark -w /tmp/tcp.pcap tcp , host stackoverflow.com <wait few seconds> % tshark -r /tmp/tcp.pcap -t fields -e ip.flags | sort | uniq -c     186 0x00000002 

0x02 means df bit set. confess in other captures have seen occasional tcp segment in ip packet without df bit; suspect rfc1191 has explanation this.


now question, think there's no portable way set df bit , more widespread question (there isn't posix-portable way). there (likely) escape hatch in relevant package implementation under golang.org/x/sys.

for example, on unix supports ip_dontfrag such freebsd 1 use unix.setsockoptint , dig relevant constant value.

on linux there not ip_dontfrag, discovered the question linked. workaround seems to use ip_mtu_discover happens available a constant in unix package. can use same unix.setsockoptint set it.


Comments

Popular posts from this blog

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

wordpress - (T_ENDFOREACH) php error -

Using django-mptt to get only the categories that have items -