Repository navigation
testing/nettest: Add a TCP case with a lossy peer on a TUN device. - #4101
Merged
Merged
Conversation
xiaoxiang781216
previously approved these changes
Nov 21, 2026
Contributor
|
Thanks, nice regression test. It hits the bug well: the 10 rounds of mss/8 all stay inside one write buffer (4 × mss), and each retransmission is fully ACKed, so Blocking
Should fix
Nits
|
cmocka_net_tun plays a TCP peer on a TUN device. The link loses the first transmission of each segment: the peer opens a window of mss / 8 bytes, ignores a segment the first time and acknowledges it when it comes again. So each timeout of the server retransmits one segment, the peer acknowledges it, and the connection makes progress at each timeout. After TCP_MAXRTX + 2 such rounds the window opens. The server writes 8192 bytes in one send(): the case checks that each byte comes at its own sequence number, that the whole stream and the FIN come, and that the server does not reset the connection. The time limits come from CONFIG_NET_TCP_RTO. With TCP write buffers, NuttX freed a write buffer at its eighth retransmission, also when the peer had acknowledged a part of it at each timeout, and reset the connection at the next timeout. Data sent in between went out at the sequence numbers of the freed data. The case takes about 16 seconds. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
tcp-wrb-expiry-test-up
branch
from
November 22, 2026 18:51
cdca206 to
952d3a5
Compare
Contributor
Author
|
Done. |
casaroli
marked this pull request as ready for review
November 22, 2026 18:52
xiaoxiang781216
approved these changes
Nov 23, 2026
acassis
approved these changes
Nov 24, 2026
jerpelea
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
cmocka_net_tun: a TCP case against a peer that the program plays on a TUN device (/dev/tun), so the case controls every segment that the peer sends.test_tun_tcp_lossy: the link loses the first transmission of each segment. The peer opens a window of mss / 8 bytes, ignores a segment the first time and acknowledges it when it comes again. So each timeout of the server retransmits one segment, the peer acknowledges it, and the connection makes progress at each timeout. AfterCONFIG_NET_TCP_MAXRTX+ 2 rounds the window opens and the peer acknowledges everything. The server writes 8192 bytes in onesend(). The case checks that each byte comes at its own sequence number, that the whole stream and the FIN come, and that the server does not reset the connection. The time limits come fromCONFIG_NET_TCP_RTO. The case takes about 16 s.With TCP write buffers, NuttX freed a write buffer at its eighth retransmission, also when the peer had acknowledged a part of it at each timeout. The next data then went out at the sequence numbers of the freed data, and the next timeout reset the connection. apache/nuttx#22132 fixed that.
Impact
New program,
CONFIG_TESTING_NET_TUN(default y whenNET_TUN,NET_TCP,NET_IPv4,NET_TCPBACKLOGandNET_SOCKOPTSare set and pthreads are enabled). No other test changes. Uses the addresses 10.78.0.1/24 (the TUN interface) and 10.78.0.2 (the peer). No CI configuration enables bothNET_TUNandTESTING_NET_TESTyet, so CI does not build or run the case.Testing
qemu-armv8a:knsh (kernel build) and qemu-armv8a:nsh (flat build) under HVF (Apple M-series), 96 IOBs of 196 bytes,
IOB_THROTTLE8, TCP write buffers,NET_TUN_PKTSIZE1500; 3 runs ofcmocka_net_tunin one boot.CONFIG_SMP), flat nshBuilds in the NuttX CI image (
EXTRAFLAGS="-Wno-cpp -Werror"), all OK, 0 compiler warnings,cmocka_net_tunbuilt: qemu-armv8a:netnsh + TCP write buffers +NET_TUN(Make, CMake, without write buffers, withNET_IPv6, with the defaultNET_TUN_PKTSIZE), sim:tcpblaster (NET_TUNis on there).tools/checkpatch.sh -c -u -m -gpasses.