sendfile() problems - Destination unreachable

2023-05-27 Thread Fotis Panagiotopoulos
Hello,

I encounter some problems using sendfile().

I am using sendfile to... send a file to a remote server, with my own
implementation of an FTP client.
sendfile() indeed starts to transmit chunks of the file, but as I see in
Wireshark, I get an ICMP response "Destination unreachable (Fragmentation
needed)".
I have verified that the Ethrenet MTU is correctly set to 1500.

I tried lowering the MTU a lot (1000 bytes), and the problem is solved.
Communication succeeds.

This raises some questions, and indicates some potential bugs:

1. Why is there a problem with MTU in the first place? Shouldn't MTU be
negotiated? (Is this functionality available in NuttX?)
2. Why is the ICMP response not handled? It seems that sendfile() just
ignores it and continues to send chunks, nevertheless.
3. Why sendfile() sends TCP segments without receiving any ACKs back?
AFAIK, depending on the configuration, TCP allows at most two pending
segments on the wire. But I see dozens of them, till sendfile finally fails.

This last point is also verified in my MQTT client.
I have seen NuttX TCP allowing sending lots of TCP segments without ACKing
the previous data.

So, is there any insight on the above?
Is my configuration wrong, or is there anything wrong with TCP?

Thank you.


Re: sendfile() problems - Destination unreachable

2023-05-27 Thread Xiang Xiao
On Sat, May 27, 2023 at 8:19 PM Fotis Panagiotopoulos 
wrote:

> Hello,
>
> I encounter some problems using sendfile().
>
> I am using sendfile to... send a file to a remote server, with my own
> implementation of an FTP client.
> sendfile() indeed starts to transmit chunks of the file, but as I see in
> Wireshark, I get an ICMP response "Destination unreachable (Fragmentation
> needed)".
> I have verified that the Ethrenet MTU is correctly set to 1500.
>
> I tried lowering the MTU a lot (1000 bytes), and the problem is solved.
> Communication succeeds.
>
> This raises some questions, and indicates some potential bugs:
>
> 1. Why is there a problem with MTU in the first place? Shouldn't MTU be
> negotiated? (Is this functionality available in NuttX?)
>

MTU isn't negotiated but a physical attribute of your transport(netdev). On
the other hand, PMTU could be discovered from ICMP.


> 2. Why is the ICMP response not handled? It seems that sendfile() just
> ignores it and continues to send chunks, nevertheless.
>

It is handled by the recent addition here:
https://github.com/apache/nuttx/pull/9254
but this feature is disabled by default, you have to enable it manually..


> 3. Why sendfile() sends TCP segments without receiving any ACKs back?
> AFAIK, depending on the configuration, TCP allows at most two pending
> segments on the wire. But I see dozens of them, till sendfile finally
> fails.
>
>
Why only two segments? TCP can send packages until the slide window is full.


> This last point is also verified in my MQTT client.
> I have seen NuttX TCP allowing sending lots of TCP segments without ACKing
> the previous data.
>
> So, is there any insight on the above?
> Is my configuration wrong, or is there anything wrong with TCP?
>
> Thank you.
>