sdamm / asio_dtls

A DTLS implementation using the ASIO library
51 stars 11 forks source link

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

Open VPBalaRama opened 4 years ago

VPBalaRama commented 4 years ago

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

sdamm commented 4 years ago

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.

adminins commented 2 years ago

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:943865390@qq.com,Thanks.