cederom commented on PR #22355:
URL: https://github.com/apache/nuttx/pull/22355#issuecomment-7247657190
Post-merge review (read the three commits as merged; `range-diff` vs. the PR
head is identical).
### 37d7a84d net/tcp: Reset the retry count at each ACK of new data
The fix looks correct to me.
- With write buffers, `conn->sndseq` is `TCP_WBSEQNO(wrb) + TCP_WBSENT(wrb)`
of the last segment sent. After the go-back-N rewind, the old `sndseq <=
ackseq` reset fired only when an ACK covered the whole current retransmission
pass. A peer that ACKs one segment per RTO never got there, as the commit
message says.
- `tx_unacked < lasttxunacked` is the right guard. By this point the
duplicate-ACK case has already jumped to `skip_rtt`, so this is effectively "an
ACK of new data". It also stays false in the `ackseq > unackseq` branch that
leaves `tx_unacked` alone.
- The reset now comes after the RTT block, which fixes Karn's algorithm for
the write-buffer path: before, the ACK that ended a retransmission gave an RTT
sample. `tcp_timer()` overwrites `conn->rto` with `TCP_RTO << nrtx`, and only
an RTT sample recomputes it. So clearing `nrtx` on a partial ACK does not
collapse the RTO right away, which matches RFC 6298 section 5.
Minor points, none blocking:
1. `nrtx` serves as both the RFC 1122 retry counter and the Karn "don't
sample" flag. After a partial ACK resets it, the *next* ACK yields an RTT
sample even though, with go-back-N, that ACK most likely covers retransmitted
data. So Karn applies only to the first ACK after a timeout. The new doc
sentence says exactly that ("The first ACK after a retransmission gives no RTT
sample"), so the docs are accurate. A separate flag, like Linux's split between
the retransmit count and the backoff, would be the complete fix if anyone wants
it later.
2. The new block is under `CONFIG_NET_TCP_WRITE_BUFFERS` but outside the
`!conn->sendfile` guard, where the removed line was. For sendfile connections
it duplicates the reset that `tcp_appsend()` already does. It's harmless; I'm
only noting that the scope changed.
### 09e7ee8b net/tcp: Share the rewind of a write buffer in the
retransmission paths
I checked it line by line against the two removed copies: the same `wb_nrtx`
saturation, the same `conn->sent` underflow clamp, the same `ninfo`. No
behaviour change. The doc blocks follow the nxstyle header format.
### a8bb89bf Documentation: Say when an ACK resets the TCP retransmission
count
Correct for the write-buffer path. But see below: in the path without write
buffers (and for sendfile), the code doesn't do what this section says.
### Pre-existing issue (not introduced here), suggest a follow-up
Without `CONFIG_NET_TCP_WRITE_BUFFERS`, and for sendfile connections,
`tcp_appsend()` sets `conn->nrtx = 0` in its default branch on *every* call.
`tcp_input()` calls it in ESTABLISHED whenever `flags & (TCP_NEWDATA |
TCP_ACKDATA)`, and the duplicate-ACK path also sets `TCP_ACKDATA` before `goto
skip_rtt`. As far as I can see, that means:
- a duplicate ACK resets the retry count, which contradicts the existing
bullet "...does not reset the count of retransmissions";
- a peer that keeps sending data but never ACKs ours keeps resetting `nrtx`,
so the connection never reaches `TCP_MAXRTX` and the backoff restarts each time.
The commit message's "as without write buffers (tcp_appsend() sets it to
zero there)" is true about *where* it happens, but that path resets on more
than an ACK of new data. Moving the reset in `tcp_appsend()` behind the same
"new data ACKed" condition, or doing it once in `tcp_input()` for both modes,
would make both configurations match the docs. A variant of
`test_tun_tcp_partack` / `test_tun_tcp_lossy` built without write buffers, with
a peer that sends data and holds its ACK, should show it.
--
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]