automesh-network / netstack-smoltcp

A netstack based on smoltcp-rs.
Apache License 2.0
14 stars 5 forks source link

Do we need to consider the issue of IP packet reassembly #9

Open lbl8603 opened 4 weeks ago

lbl8603 commented 4 weeks ago

let packet = match UdpPacket::new_checked(packet.payload()) {

cavivie commented 4 weeks ago

I don't know what you mean. Does it mean to use udp to process data with smoltcp?

lbl8603 commented 4 weeks ago

The code for processing UDP packets in netstack-smoltcp directly converts IP payloads into UDP packets without considering the problem of IP packet segmentation.I'm not sure if this is correct, I hope you can answer it, thank you

cavivie commented 4 weeks ago

IP datagram > 1500 bytes (i.e. > MTU): At this time, the sender's IP layer needs to be fragmented, dividing the datagram into several pieces, so that each piece is less than MTU, while the recipient's IP layer needs to reorganize the datagram, which will do a lot more. What's more serious is due to the characteristics of UDP. When a piece of data transmission is lost, it is convenient to reorganize the datagram, which will lead to the disposal of the entire UDP datagram.

Since this crate was originally designed to integrate with the tun device, the mtu setting of the tun device should be less than or equal to 1500 as much as possible. If it is used for other purposes, we may also need to consider the problems you mentioned. The best way is to use smoltcp to process udp packets instead of directly processing udp packets like tcp. I hope this can help you.