casaroli opened a new pull request, #22355:
URL: https://github.com/apache/nuttx/pull/22355

   ## Summary
   
   With `CONFIG_NET_TCP_WRITE_BUFFERS`, `tcp_input()` set the retry count of 
the connection (`conn->nrtx`) to zero only when an ACK covered the last segment 
sent. After a timeout the write buffers send all the data again, so a peer that 
acknowledges only a part of it at each timeout never gets there. The count 
grows at each timeout although the connection makes progress: the timeout 
doubles at each round, and `tcp_timer()` resets the connection after 
`TCP_MAXRTX` timeouts.
   
   This PR does the four points of the review of apache/nuttx#22132 by @cederom:
   
   - Commit 1 sets the count to zero at each ACK of new data. RFC 1122, section 
4.2.3.5, counts the retransmissions of the same segment.
   - Commit 1 does the reset after the RTT estimate, as `tcp_appsend()` does 
without write buffers. So the ACK of a retransmission gives no RTT sample 
(Karn's algorithm). Before, the reset came just before the RTT estimate.
   - Commit 2 moves the rewind of a write buffer, which both retransmission 
paths of `psock_send_eventhandler()` had, into `rewind_segment()`, and fixes 
the comment "the number of bytes sent sent". No change of behaviour.
   - Commit 3 adds one item to the retransmission timer section of 
`Documentation/os/networking/tcp_state_machine.rst`.
   
   ## Impact
   
   TCP with `CONFIG_NET_TCP_WRITE_BUFFERS` only. No API, ABI or Kconfig change. 
Without write buffers nothing changes: there `tcp_appsend()` already sets the 
count to zero after the RTT estimate.
   
   - A connection that makes progress at each timeout is no longer reset. A 
connection whose peer acknowledges nothing ends after `TCP_MAXRTX` timeouts, as 
before.
   - The ACK of a retransmission gives no RTT sample. The timeout stays at its 
backed-off value until the next sample.
   
   Common network code: the same in flat, protected and kernel builds and on 
all architectures.
   
   ## Testing
   
   `cmocka_net_tun` of nuttx-apps (apache/nuttx-apps#NNNN) plays a TCP peer on 
a TUN device. Its new case `test_tun_tcp_partack` acknowledges one segment at 
each timeout, but not all the data sent. Options: TCP write buffers, 96 IOBs of 
196 bytes, `NET_TUN_PKTSIZE` 1500, `NET_PREALLOC_DEVIF_CALLBACKS` 64. Master is 
4f8706c4b35.
   
   | Test | master | this PR |
   |---|---|---|
   | qemu-armv8a:knsh (kernel build), QEMU TCG, 1 CPU, 3 runs in one boot | 
`test_tun_tcp_partack` FAIL 3 of 3: 5 of 10 rounds in the time limit, because 
the timeout doubles at each round | PASS 3 of 3 |
   | qemu-intel64:knsh_romfs (kernel build, CMake), QEMU KVM, 1 run | FAIL (5 
of 10 rounds) | PASS |
   | `test_tun_tcp_lossy` (the peer acknowledges all the data at each timeout), 
the same runs | PASS | PASS |
   
   The arm64 kernel build also has the 4 commits of apache/nuttx#22329, so that 
the init program loads. They are not part of this PR.
   
   Builds in the NuttX CI image with `EXTRAFLAGS="-Wno-cpp -Werror"`: all OK, 
no new warning. Text size in bytes:
   
   | Configuration | Build mode | Write buffers | master | this PR |
   |---|---|---|---|---|
   | qemu-armv8a:nsh + TCP | flat | y | 579924 | 579928 (+4) |
   | the same + `NET_SENDFILE`, `NET_TCP_FIXED_RTO` | flat | y | 581964 | 
581972 (+8) |
   | qemu-armv8a:nsh + TCP | flat | n | | builds |
   | qemu-armv8a:knsh + TCP | kernel | y | 306216 | 306216 (+0) |
   | qemu-armv8a:knsh + TCP | kernel | n | | builds |
   | rv-virt:netnsh (32-bit) | flat | y | 525881 | 525883 (+2) |
   | rv-virt:netnsh (32-bit) | flat | n | | builds |
   | rv-virt:knsh (32-bit) + TCP | kernel | y | | builds |
   | qemu-intel64:knsh_romfs + TCP, CMake | kernel | y | 8983337 | 8983289 
(-48) |
   
   Protected builds: not built; the change is common network code with no 
build-mode test.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to