You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
socket2.diff.txt
Hi,
Currently socket2 has no way to set the DF bit on packets.
The DF bit is needed for Path MTU discovery and also for creating arbitrary ICMP packets with the DF bit set.
Please see the attached patch that will add it.
I have only been able to test it on Linux, not Windows.
This might also be needed to enable Path MTU discovery on TCP sessions when using socket2.
For example, some sample code to send an ICMP packet with the DF bit set:
let domain = Domain::IPV4;
let ty = Type::DGRAM;
let protocol = Some(Protocol::ICMPV4);
let mut sock1 = create_socket(domain, ty, protocol);
let mut sock1r = sock1.unwrap();
let res1 = Socket::set_mtu_discover(&sock1r, true);
let mut sock2 = sock1r;
sock2.set_read_timeout(Some(timeout))?;
let destination = SocketAddr::new(addr.clone(), 0); // destination
let sockaddr1: SockAddr = destination.into();
let result = make_data(&data, size3);
let payload = result.unwrap();
let res2 = sock2.send_to(&payload, &sockaddr1);