UDP socket set DontFragment (DF) field in outgoing packets - will it catch the ICMP "packet too large" respnses?

80 Views Asked by At

I'm using UDP socket to send data to a remote connection and i'd like to implement PMTUD (path mtu discovery) on top of it.

So I set the DF bit on the socket which trigger the appropriate bit in every outgoing packet.

When packet size is bigger than the path mtu, it suppose to receive ICMP response with the appropriate type (DF bit is set and packet is too big).

Since the socket is defined as UDP (here's how its defined using boost asio wrapper), I don't think it's suitable to catch ICMP responses since it's a different protocol.

  socket_ = std::make_shared<boost::asio::ip::udp::socket>(ioc);

Should I create an additional RAW/ICMP socket (dedicated for ICMP packets) in order to catch the ICMP responses ? for instance :

fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_ICMP);

In this case, how can I know that the ICMP response relates to my specific UDP socket, and not to another connection ?

Thanks !

0

There are 0 best solutions below