Skip to content

Test: integrate PSH and ARP optimization configuration coverage - #1385

Draft
StitchLilo626 wants to merge 11 commits into
FreeRTOS:mainfrom
StitchLilo626:review/tcp-1381-1382-integration
Draft

StitchLilo626 wants to merge 11 commits into
FreeRTOS:mainfrom
StitchLilo626:review/tcp-1381-1382-integration

Conversation

@StitchLilo626

Copy link
Copy Markdown

Description

Both #1381 and #1382 add test/unit-test/FreeRTOS_TCP_Transmission_DiffConfig/, with different configuration headers and test sources. Merging them produces add/add conflicts in FreeRTOSIPConfig.h and FreeRTOS_TCP_Transmission_DiffConfig_utest.c. This draft integrates that shared suite and verifies the two options together and independently.

Dependency and attribution: this branch includes comotion's original commits from #1381 (e5d21da3) and #1382 (c6e6ff09), preserving their authorship. Both PRs are still open. The production changes are exactly those from the two original PRs. The integration resolves the two test conflicts, and the follow-up commit 5f9beab5 changes only tests and test build configuration. That follow-up is available for reuse after the feature changes are integrated.

  • Retain the four existing PSH/ARP test cases and share the configuration, fixtures and mock sources.
  • Compile five separate variants: both enabled, PSH only, ARP only, both explicitly disabled, and both unspecified to exercise the production defaults.
  • Apply matching definitions to each variant's production, mock and test targets. Use the real defaults header for conditional assertions because the generated Annexed_TCP copy removes those definitions.
  • Add combined checks that pass the same prepared segment through prvTCPReturnPacket(), checking PSH, ACK, packet length, destination MAC and output count.
  • Add no-payload PSH clearing, socketless ARP lookup, expired cache-miss fallback and host tick-wrap checks.
  • Keep one CMake suite registration and register all five targets as coverage build dependencies.

Test Steps

Tested on WSL Ubuntu 24.04 x86_64 with GCC 13.3.0, CMake 3.28.3, Ninja, Ruby 3.2.3 and unifdef 2.12, using the repository-pinned Kernel/CMock/Unity dependencies.

cmake -G Ninja -S test/unit-test -B work/build \
  -DBUILD_CLONE_SUBMODULES=OFF -DSANITIZE=
cmake --build work/build -j 8 --target \
  FreeRTOS_TCP_Transmission_DiffConfig_utest \
  FreeRTOS_TCP_Transmission_DiffConfig_PSHOnly_utest \
  FreeRTOS_TCP_Transmission_DiffConfig_ARPOnly_utest \
  FreeRTOS_TCP_Transmission_DiffConfig_Disabled_utest \
  FreeRTOS_TCP_Transmission_DiffConfig_Defaults_utest \
  FreeRTOS_TCP_Transmission_utest \
  FreeRTOS_TCP_Transmission_IPv6_utest
ctest --test-dir work/build \
  -R '^FreeRTOS_TCP_Transmission.*_utest$' --verbose --output-on-failure
Suite/configuration Unity cases
Both enabled 10 passed
PSH only 10 passed
ARP only 10 passed
Both disabled 10 passed
Production defaults 10 passed
Existing Transmission 82 passed
Existing Transmission_IPv6 22 passed

Result: 7/7 CTest targets, 154/154 Unity cases passed, zero failures or ignored cases. Hang protection was enabled for these runs. The original four cases also passed in the minimal merged version before the matrix was added.

The initial matrix run exposed two fixture problems (stripped default definitions and a helper-local pointer retained by CMock); both were fixed before the successful final run, without changing production code.

Separate configuration failure reproduced in #1382: with ipconfigTCP_HANG_PROTECTION=0, compiling FreeRTOS_TCP_Transmission_IPv4.c succeeds when ipconfigTCP_SKIP_ARP_LOOKUP_MS=0, but fails when it is 1000: IPTCPSocket_t has no member named xLastActTime. Both the member declaration and its update in prvTCPTouchSocket() are conditional on hang protection. This draft leaves that production issue visible for resolution in the feature change. The timestamp is also refreshed on TCP state changes, so it is not exclusively the last peer-receive time.

Not run locally: the full repository test suite, sanitizers, coverage thresholds, board throughput measurements, or an IPv6-specific matrix with the PSH option enabled. The existing IPv6 suite uses defaults. Host tick wrap was checked with the POSIX port's 64-bit TickType_t; this does not establish 16/32-bit target behavior.

Checklist:

  • I have tested my changes. No regression in the existing test suites listed above.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

#1380
Depends on #1381 and #1382.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

comotion and others added 11 commits November 3, 2026 13:35
A Linux peer ACKs every segment that carries PSH at once, so setting
PSH on every data segment makes a sender with several segments queued
get one ACK per segment.

- ipconfigTCP_PSH_ON_LAST_SEGMENT_ONLY sets PSH only on the segment
  that carries the last queued byte, as other stacks do.
- It is off by default, and nothing changes while it is off.
A connected TCP socket can now send each segment to the peer MAC in its
header template, and search the ARP cache only after the peer has been
quiet for a while, as RFC 1122 2.3.2.1 allows.

- ipconfigTCP_SKIP_ARP_LOOKUP_MS sets how long the peer may be quiet
  before the stack searches the cache again, and a hit then replaces
  the MAC in the template.
- The search runs for every sent segment and limits send throughput on
  a slow CPU.
- The default is 0, which searches the cache for every segment as
  before.
The proof runs once with the default configuration and once with the skip enabled, so CI checks the code that the option compiles in.
The skip reads the time of the socket's last activity, which only hang protection keeps, so a build without it failed with a missing member. It now stops with an error that names the option it needs. That time also moves on every state change, so the description no longer says it is only the time the peer was heard from.
A sender that keeps its queue full never empties it, so PSH would never be
set. A receiver that waits for PSH before it hands data to the application
then holds the data until its buffer fills. Linux sets PSH in the same case.
The proof now also runs with PSH set only on the last segment, so CI checks the code that the option compiles in.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants