asio_dtls icon indicating copy to clipboard operation
asio_dtls copied to clipboard

Accumulating multiple packets into a single datagram before writing into network.

Open VPBalaRama opened this issue 4 years ago • 2 comments

Hi I have attached the screenshot of the DTLS Handshake pcap. Here my client certificate of length 3100+ bytes is fragmented to smaller chunks of 1500 bytes(MTU size) and written into the socket. While writing into the network, all packets(fragmented chunks) are accumulated into a single datagram.

And Handshake is failing with error new fragment overlaps the older data.

Please let me know to how to disable the accumulation of multiple packets in to single datagram. i couldn't find the UDP_CORK option here. Capture

Capture

VPBalaRama avatar Jun 16 '20 23:06 VPBalaRama

When using the stateless cookie exchange method, it is required that openssl sends the client Hello as one single Packet (it will be split by the IP-Layer if needed, that is expected). To accomplish that you can use the set_mtu method of the dtls socket (client side) to set the MTU to a size bigger than the expected Handshake Packet. The MTU set here actually does not matter after the handshake as every send / async_send corresponds to one UDP Packet, so the application has to match the MTU when sending anyway.

I guess a

socket.set_mtu(60000); // Check that this is big enough

on the client side before the handshake should fix your problem.

sdamm avatar Jun 17 '20 07:06 sdamm

Hi I have attached the screenshot of the DTLS Handshake pcap. Here my client certificate of length 3100+ bytes is fragmented to smaller chunks of 1500 bytes(MTU size) and written into the socket. While writing into the network, all packets(fragmented chunks) are accumulated into a single datagram.

And Handshake is failing with error new fragment overlaps the older data.

Please let me know to how to disable the accumulation of multiple packets in to single datagram. i couldn't find the UDP_CORK option here. Capture

Capture

hello,can you give me a DTLS demo use ASIO library and send code to my e-mail:[email protected],Thanks.

adminins avatar Jul 21 '22 03:07 adminins