Skip to content

Prefer Ethernet over WiFi on a shared subnet, and answer on the interface that owns the address (#862) - #1018

Merged
chrisgleissner merged 15 commits into
GideonZ:masterfrom
JC-000:fix/862-route-r2
Oct 23, 2026
Merged

chrisgleissner merged 15 commits into
GideonZ:masterfrom
JC-000:fix/862-route-r2

Conversation

@JC-000

@JC-000 JC-000 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #862.

Problem

With Ethernet and WiFi up on the same subnet, ip4_route() returns the first netif in netif_list whose subnet holds the destination. netif_add() prepends and the WiFi netif is added after the wired one, so WiFi wins every lookup. Measured on hardware (see the issue thread):

  • connections and datagrams the device starts (UCI network target, syslog) leave from the WiFi address;
  • replies on a connection accepted on the Ethernet address leave through WiFi, with the Ethernet address as source and the WiFi MAC (124 of 124 frames on a U64 Elite; 40,383 of 40,392 on the official C64 Ultimate 1.1.0 release). On the U64 Elite that costs wired clients about 8 ms per round trip (REST p50 16.9 ms, against 9.3 ms with WiFi disabled).

Change

LWIP_HOOK_IP4_ROUTE_SRC (the only stock lwIP routing hook that sees the source address), implemented by route_select() in software/io/network/route_select.h. Every rule considers only netifs that are up, have link and have an address. In order:

  1. a destination that is the address of one of these netifs, when there is no source or the source is that same address: that netif, so lwIP loops it back. A different explicit source goes on to rule 2: a UDP socket bound to one address and sent to the other needs a netif that owns its local address, or udp_sendto_if() returns ERR_RTE;
  2. a source address that belongs to one of these netifs: that netif, if the destination is on its subnet or the netif has a gateway. TCP routes every segment with the connection's local address as source, so a reply leaves from the interface that owns the address the request was sent to, normally the one it arrived on;
  3. a source of 0.0.0.0, which every unbound socket passes: among the netifs whose subnet holds the destination, a wired one before a wireless one. A NULL source is not affected: ip4_route_src(NULL, ...) and a plain ip4_route() run lwIP's on-link lookup before the hook, and in lwIP only etharp_add_static_entry() routes that way;
  4. anything else: NULL, and lwIP's own lookup runs as before. Off-link destinations with no source still go to netif_default; sockets bound with SO_BINDTODEVICE never reach the hook.

This is the policy from the issue thread: a reply goes out the interface its request arrived on; anything the device starts, or anything ambiguous, prefers Ethernet. Moving the WiFi netif to the tail of netif_list would fix what the device starts, but would send replies for the WiFi address out of Ethernet. Binding individual sockets, as #993 does for the streamers, leaves every other socket on WiFi.

The hook is configured in software/network/config/lwipopts.h, with its prototype in lwip_hooks.h (shared by all targets). The only other firmware change is a two-function adapter in network_interface.cc that tells the hook which netifs are wireless.

Known limits

  • A UDP socket bound to INADDR_ANY has no source address when it answers, so its replies take rule 3. In the firmware that is the Ident service (UDP port 64, socket_dma.cc): a unicast Ident request to either address is now answered from the Ethernet address (before, both were answered from the WiFi address). Fixing that needs the receiving address in identThread, which is a separate change.
  • The reply follows the address the request was sent to, not the physical port. A request for the WiFi address that arrives over Ethernet (ip4_input tries every netif) is answered from the WiFi address, through WiFi. Two kinds of reply follow the arrival port instead and never reach the hook:
    • ICMP echo replies (icmp.c);
    • the RSTs lwIP sends for a segment that matches no connection (tcp_rst_netif() in tcp_in.c). On a C64 Ultimate, two such RSTs from the WiFi address left by Ethernet.
  • An off-link destination from a netif with no gateway keeps lwIP's old choice, the default netif. While the owning netif is down, its connections' segments leave by the other netif, as before. That includes the RSTs lwIP sends when a DHCP lease is released on link_down and the connections on that address are aborted.
  • A TCP connection between the device's two own addresses now leaves by the netif that owns its source and goes on the wire, in both directions and both netif_list orders. Before, it was looped back when the destination's netif headed netif_list (.81 to .83 with WiFi first, .83 to .81 with Ethernet first). Nothing in the firmware does this.
  • UDP between the two addresses now returns ERR_OK in all four cases and leaves by the source's netif. Master returned ERR_RTE in the two cases where the source's netif was not at the head of netif_list. Like TCP, these datagrams go on the wire rather than being looped back; a routing hook cannot change that.

Tests

Host (make -C software/io/network/tests, run by build.yml; passes with clang on macOS and gcc 11 on Ubuntu 22.04):

  • route-select: 19 cases. They run against lwIP's own ip4.c, netif.c and udp.c, built with the hook lines of the firmware's lwipopts.h (the build stops if the hook is removed).

    • Each case asserts the netif lwIP's ip4_route_src() returns. The UDP cases go through the real udp_sendto() for both bind directions and also assert its result and the netif the datagram is handed to, or that it was looped back.
    • netif_list is hand-built, in both orders where the order matters. A down netif is modelled as the firmware leaves it: UP cleared, the link flag and a static address kept.
    • A NULL source and a pointer to 0.0.0.0 are separate cases.
  • route-select-red: the same cases with lwIP built without the hook. The target fails if they all pass; 9 of 19 fail.

  • Not covered:

    • the adapter in network_interface.cc;
    • lwIP's multicast branches (LWIP_IGMP is 0 in the host build);
    • TCP, which is not compiled in;
    • the device's netif flags: the test netifs lack NETIF_FLAG_BROADCAST, so ip4_route()'s point-to-point gateway match is live on the host but not on the device.

    The hook lines are taken from lwipopts.h by grep, whatever #if they sit in.

E2E (./run-tests --suite uci-net-route <device>, deep profile):

  • Through the C64's command interface, the device opens three TCP connections and one UDP socket to ports the test host binds, and the test reads the address they come from. With WiFi joined on the same subnet, it requires the Ethernet address. The wired interface is the one whose MAC equals ethernet_mac from GET /v1/info.
  • The suite ends as skipped, with the reason printed, when:
    • there is no command interface (the registers read $FF);
    • there is no second interface with an address on the host's subnet;
    • there is no ethernet_mac (firmware before v3.15a), or no interface on the subnet has that MAC;
    • the interface rows of the root menu cannot be read (GET /v1/machine:menu_screen; the menu has to be at its root);
    • either link is down. A static address stays configured when its link goes down, so link state comes from those rows, not from the address.
  • If the menu is closed, the suite opens it and closes it again. In Freeze mode this stops the C64 while the menu is open.
  • Link state is read once, before the traffic, so a link lost during the checks shows as a routing failure.
  • The suite enables the Command Interface setting and restores it on exit, also after a failure or Ctrl-C.
  • uci-net-route-precondition runs the skip and cleanup paths device-free.
  • The reply path needs the device's source MACs, so it was checked with a capture on the host's wired port.

Rig evidence (U64 Elite, Ethernet 10.43.23.81, WiFi joined on the same /24 as 10.43.23.83, capture on the test host's wired port)

At 5399781, uci-net-route of that revision:

Firmware uci-net-route Frames from .81 on the host's wired port
bench build without this change: an older master plus unmerged work (#835, WiFi-module firmware changes, bench-only TCP buffer and WiFi transmit switches). None of it touches route selection or how netifs are added, and lwIP is at the same pin FAIL: "a TCP connection came from 10.43.23.83 (the WiFi address)" 4077 with the WiFi MAC, 6 with the Ethernet MAC (ICMP echo replies, sent on the arrival port)
master + this PR + #835 (unmerged; it changes the UCI socket write, not routing) PASS, 7 checks 4781 of 4781 with the Ethernet MAC

At 409142b, with the suite as in this PR. The Command Interface was Disabled before each run, and the suite put it back to Disabled.

  • Bench image with this PR's first three firmware commits (before the rule-1 change), on the bench build from the FAIL row plus link-loss counters: PASS, 7 checks. The menu showed Link Up for both interfaces, and all 4900 captured frames from the Ethernet address carry the Ethernet MAC.
  • Bench image with this PR's four firmware commits on an older master plus unmerged work (Spike for #807: NET_CMD_WRITE_SOCKET_CHUNK ($16), a payload larger than one command as one datagram #835 and WiFi-module firmware changes); route_select.h, the hook lines and the adapter are as at this head:
    • uci-net-route: PASS, 7 checks. The menu showed Link Up for both interfaces, and all 3950 captured frames from the Ethernet address carry the Ethernet MAC.
    • REST GET /v1/version, 100 requests per address: 100 of 100 answered on each, each with the MAC of the interface that owns the address.
  • The address precondition, on the same image: after the updater's configuration reset, WiFi came up associated but without a DHCP lease (address 0.0.0.0). The suite skipped ("needs two interfaces with an address on the subnet of this host ...") instead of passing. The link-down skip has run only device-free.

None of these hardware checks sends between the device's own two addresses, so the rule-1 change is covered by the host tests only.

Reply path at 5399781, 100 REST requests per address:

  • Ethernet address: 100 of 100 answered, 593 of 593 reply frames with the Ethernet MAC (p50 9.4 ms).
  • WiFi address: 100 of 100 answered, before and after, every reply frame with the WiFi MAC.

C64 Ultimate, REST check only:

Builds: u64 and u64ii build (rc=0, including their updater images) from a tree whose firmware sources equal this head's. The last commit that changes firmware is e900999. The U2-family targets were not built here; CI builds them.

Written with Claude Sonnet 5.5 in Claude Code; reviewed adversarially by separate Claude Opus 5.5 sessions before posting.

🤖 Generated with Claude Code

JC-000 and others added 8 commits October 22, 2026 21:08
lwIP returns the first netif in netif_list whose subnet holds the
destination. netif_add() prepends, and the WiFi netif is added after the
wired one, so with both up on one subnet every reply and every unbound
connect left by WiFi, including replies to the Ethernet address.

Use LWIP_HOOK_IP4_ROUTE_SRC: a destination that is an own address, or a
source address that belongs to an up netif, selects that netif; with no
source, a wired netif is preferred over a wireless one among those whose
subnet holds the destination. Everything else falls through to lwIP
unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…t fail

route-select runs the selection against real lwIP netif and ip4_addr
headers and a hand-built netif_list. route-select-red runs the same cases
against a model of lwIP's lookup (the first on-link netif in the list) and
has to fail, as eth-tx-frame-red does.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The C64 opens TCP connections and a UDP socket through the UCI network
target to ports this host binds; the suite reads the address they come
from. With Ethernet and WiFi on one subnet it must be the Ethernet one
(GideonZ#862). It skips unless the device has two interfaces with an address on a
subnet that also holds this host, so a device with WiFi off cannot pass it
vacuously.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A device without a second interface on the host's subnet, or without a
command interface, made the suite report OK. It now ends with suite_skip,
after the setting is restored.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The tests now assert the interface a packet finally leaves by: lwIP's
ip4_route_src() composed from the hook, lwIP's on-link lookup and
netif_default. The hook comes from software/network/config/lwipopts.h
(its LWIP_HOOK lines are extracted by the Makefile) and the prototype from
lwip_hooks.h, so removing or misspelling the hook in the firmware stops the
tests from building. network_interface.cc now includes lwip_hooks.h so its
definition is checked against that prototype. Correct the comment on why the
WiFi netif wins.

route-select-red now fails 4 of 10 cases; the two that only differed in
what the hook alone returns are gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…eway

Rule 2 sent a reply from a netif's address out of that netif even to a
destination off its subnet. With no gateway configured there the packet is
dropped, where lwIP's own lookup used the default netif's gateway and
worked. Apply the rule only when the destination is on that netif's subnet
or the netif has a gateway; otherwise fall through as before the change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Match each interface's MAC from the network target against the
ethernet_mac GET /v1/info reports, instead of assuming interface 0 is the
wired one. The suite skips with the reason when none matches.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…without ethernet_mac

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@chrisgleissner chrisgleissner left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The production diff is small, and using the shared lwIP source-routing hook is an architecturally defensible place to implement this policy. I found one reproducible UDP regression and three test/precondition defects that should be corrected before merging; the inline comments give the triggering conditions and concrete changes.

Validation: the existing network host targets pass (13 routing cases, with the expected five failures in the legacy variant). I additionally compiled the pinned lwIP ip4.c/udp.c and supporting core code with the PR hook to check actual UDP send behavior and NULL-source dispatch, and reproduced the absent-command-interface cleanup failure with the real Uci transport over a machine double. This review did not rebuild/deploy firmware or repeat the hardware captures.

Comment thread software/io/network/route_select.h Resolved
@chrisgleissner

Copy link
Copy Markdown
Collaborator

Hi @JC-000 , many thanks for having raised this very useful PR! I reviewed it and left some comments. Many thanks for addressing them.

@chrisgleissner chrisgleissner added enhancement New functionality or an improvement to existing behavior, including formats and developer tooling. network Networking and remote services: REST, Socket DMA, FTP, Telnet, and online access. 3.15 Targeted for release 3.15. and removed 3.15 Targeted for release 3.15. labels Oct 23, 2026
JC-000 and others added 5 commits October 23, 2026 12:45
The test model called the hook for every source, but ip4_route_src() only
calls it when the source is a pointer; a NULL source takes the on-link
lookup first (with the hook configured, lwIP's only NULL caller of
ip4_route() is etharp_add_static_entry()). Compile the pinned ip4.c,
netif.c, udp.c and what they need instead of re-stating the composition,
with the hook lines of the firmware's lwipopts.h, and add cases that tell
a NULL source from a pointer to 0.0.0.0.

Model a down netif as the firmware leaves it (NETIF_FLAG_UP cleared,
LINK_UP kept, address kept). The multicast branches of ip4.c and udp.c stay
compiled out (LWIP_IGMP is 0 in the host configuration).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…dress

The local-destination shortcut in route_select() overrode the source: a UDP
socket bound to the WiFi address and sent to the Ethernet address got the
Ethernet netif, and udp_sendto_if() rejects a netif that does not own the
socket's local address with ERR_RTE. Apply the shortcut only with no source
or when the source is the destination; a different explicit source goes on
to the source-owner rule. Regressions through lwIP's own udp_sendto() for
both bind directions and both netif_list orders, and cases for the
netif_is_up and netif_is_link_up guards.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…sent

An address stays configured when its link goes down, so two addresses on
the subnet do not mean two working routes: with WiFi down every connection
leaves from Ethernet on unpatched firmware too, and with Ethernet down it
cannot be the winner. Read link state from the interface rows of the root
menu (GET /v1/machine:menu_screen, opening the menu and closing it again if
it was closed) and skip when the rows cannot be read or either link is down.

The command interface setting reads Enabled on a C64 Ultimate whose
$DF1B-$DF1F all read $FF. The suite skipped there, but its cleanup then tried
to bring the absent interface to Idle, which release() cannot see ($FF is
Data More), so the skip became a failure after a wait. Track whether the
registers answer separately from whether the setting was changed, release
only a present interface, and hand the setting back in a finally that runs
first.

Device-free cases drive the real main(), Uci and the menu_screen decode
against a DeviceDouble: a retained WiFi address with WiFi down, a retained
Ethernet address with Ethernet down, unreadable rows, a menu that will not
open, and an absent interface.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…menu path

hand_back() restored the setting first, which on a U64 whose Command Interface
was Disabled lets go of the registers ($DF1C then reads $FF; c64.cc:331-334),
so release() could never see Idle and every run after the presence check
failed. Release first, then restore, as net_target_test.py does. The menu the
suite opened to read the link rows is closed again whatever happens while it is
open, and the read waits for the interface rows rather than the first frame.

DeviceDouble can now (opt-in) honour menu_button and report ethernet_mac, so
open, read, close and the whole skip path run device-free, including a U64
whose $DF1C reads $FF while the setting is off. The host test for an Ethernet
netif without an address now gives it mask 0 as DHCP does, and the
explicit-source route is checked in both list orders.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
failure = failure or hand_back(...) short-circuited, so a run that failed (the
RED run on unpatched firmware included) never released the interface or restored
the setting. Run the cleanup first and keep its result for later. The steps are
nested so an interrupt in one still reaches the rest. The peer bind gets its own
check, so a failure there has a verdict.

Device-free cases: a failed run reports the routing failure, releases the
present interface just before the setting goes home, and restores the setting;
a release that never reaches Idle fails a skip, and does not replace the run's
own failure; the read waits for the interface rows when the first frame has none.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@JC-000

JC-000 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, all four were right. I've pushed follow-up commits to the branch and updated the PR description.

  1. ERR_RTE on a UDP socket bound to the other address. Reproduced through the real udp_sendto() and applied your condition: the local-destination shortcut now needs no source, or src == dest.

    • Regression tests go through udp_sendto() for both bind directions and both netif_list orders. All four return ERR_OK and leave by the source's netif. (Master returned ERR_RTE in the two cases where the source's netif was not the list head.)
    • As you said, those datagrams go on the wire rather than being looped back. The hook cannot change that.
    • The same holds for a TCP connection between the device's two addresses: it now leaves by the netif that owns its source and goes on the wire, in both directions and both list orders. Master looped it back when the destination's netif headed netif_list (.81 -> .83 with WiFi first, .83 -> .81 with Ethernet first). Loopback needs the chosen netif to own the destination, and the route now picks the netif that owns the source.
    • Nothing in the firmware binds a socket to one of its addresses and sends to the other.
  2. The NULL-source model. Agreed. The host tests now compile the pinned ip4.c/netif.c/udp.c with the firmware's hook lines, with loopback compiled in.

    • A NULL source and a pointer to 0.0.0.0 are separate cases. The preference applies to the 0.0.0.0 pointer, which every unbound socket passes.
    • The test netifs go down the way the firmware's do (UP cleared, LINK_UP kept).
    • Multicast stays compiled out of the host build (LWIP_IGMP 0), and the firmware adapter is still a copy. Both are noted in the PR.
  3. Cleanup with an absent command interface. Fixed. Presence is tracked separately from the setting.

    • Only a present interface is released, so an absent one costs no release timeout.
    • The interface is released before the setting is restored, because a U64 with the setting off lets go of the registers.
    • All of this runs in a finally that also runs after a failed run.
    • A device-free all-$FF case asserts skip, exit 0 and the setting restored.
  4. Link state. Agreed. GET_IPADDR returns stored values, so the suite now reads link state from the root menu rows (GET /v1/machine:menu_screen, "Link Up"/"Link Down" per interface), with no firmware change.

    • It skips when either link is down or the rows cannot be read.
    • Device-free cases cover a retained WiFi address with WiFi down, a retained Ethernet address with Ethernet down, and the suite's main() against a double.
    • On a U64 Elite (a bench image: an older master plus unmerged work plus this PR's firmware, as described in the PR), the menu showed Link Up for both interfaces. The suite passed, with all 3950 captured frames from the Ethernet address carrying the Ethernet MAC.
    • The link-down skip itself has only run device-free so far.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

@JC-000 Many thanks for the fast fixes!

@chrisgleissner

chrisgleissner commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Review summary

I found no defect in the change. It does what #862 and the policy in the issue thread ask for, on all three hardware classes I could test, and it builds on every target I tried. Latency to the Ethernet address drops by 15 to 22% on every route measured. Latency to the WiFi address rises by 5 to 14% on most routes when requests to both addresses are interleaved, and is unchanged within noise when only the WiFi address is used. Details are under "Latency" below. The smaller test and maintainability observations in the first version of this comment are addressed by commits 9e5a4a1 and f22da00, described in a separate comment.

The acceptance criteria are taken from #862 and the maintainer's comment there (reply on the interface the request arrived on, otherwise prefer Ethernet), since the PR does not reference any other ticket.

What was run

Firmware under test: this PR at 409142b, built from a clean checkout. The base for comparison is its merge base, 1947533, built the same way.

Host tests (make -C software/io/network/tests):

  • route-select: 19 passed.
  • route-select-red: 9 of 19 fail without the hook, as the target requires.

uci-net-route on hardware, with Ethernet and WiFi both up on 192.168.1.0/24 and this host as the peer:

Device Firmware Result
Ultimate 64 Elite base 1947533 FAIL: "a TCP connection came from 192.168.1.70 (the WiFi address), expected the Ethernet address 192.168.1.13"
Ultimate 64 Elite this PR, JTAG load PASS, 7 checks; 3 of 3 TCP connections and the UDP datagram came from 192.168.1.13
Ultimate II+L in a C64 Ultimate base FAIL: TCP came from 192.168.1.97 (WiFi), expected 192.168.1.74
Ultimate II+L in a C64 Ultimate this PR, flashed (cached bitstream) PASS, 7 checks; 3 of 3 TCP and the UDP datagram from 192.168.1.74

Other checks:

  • uci-net-target on the Ultimate 64 Elite with this PR: 143 checks OK.
  • uci-net-route-precondition: OK.
  • Builds: u64, u64ii, u2pl and u2plus_swonly succeed. u2 compiles ultimate.bin; the only error is the known missing rv700dd.chk updater artifact of a software-only build.
  • tests/lib/registry_test.py: the only failure is directory_rename_test.py not being registered, which is not part of this PR.

Latency

The change decides which interface carries a reply, so the cost of each REST call on each address is a direct measurement of it. Each request opens a new TCP connection. The routes were /v1/version, /v1/info, /v1/configs, one config category, /v1/drives, machine:readmem of 64 B, 16 KB and 60 KB, a machine:writemem of 8 bytes, and a file lookup. The measuring tool is tests/perf/rest_path_latency_perf_test.py (added in f22da00). --compare gives the change of each median with a 95% bootstrap interval, and marks a route only when the interval excludes zero and the change is at least 5%.

Ultimate 64 Elite. Three alternating rounds of base, then PR, each flashed by JTAG, 100 rounds per route per round, so 300 samples per route and firmware. Ethernet is 192.168.1.13, WiFi is 192.168.1.70, requests to both addresses interleaved:

Route Ethernet, base to PR (median, ms) Change WiFi, base to PR (median, ms) Change
version 11.0 to 8.5 -22% 14.7 to 16.7 +14%
info 14.0 to 11.2 -20% 16.1 to 17.6 +10%
configs (all) 15.3 to 12.5 -18% 17.5 to 19.5 +11%
drives 18.6 to 15.7 -16% 19.8 to 22.4 +13%
readmem 64 B 12.2 to 10.2 -17% 14.9 to 16.3 +10%
readmem 16 KB 63.4 to 49.8 -22% 72.9 to 72.9 0%
readmem 60 KB 193.7 to 158.0 -19% 209.8 to 220.7 +5%
writemem 8 B 12.3 to 10.5 -15% 14.3 to 16.2 +13%
file info 11.9 to 10.0 -16% 14.8 to 15.7 +6% (interval includes 0)

All ten Ethernet routes are faster, with 95% intervals of about 2 points or less. Eight of ten WiFi routes are slower with an interval that excludes zero; the 16 KB read is unchanged and the file lookup is within noise.

WiFi address measured alone (same three rounds, no requests to the Ethernet address): the median changes are -0.3% to +8.7%, mostly +1% to +4%. Two routes (version +8.7%, readmem 64 B +7.2%) have intervals that only just exclude zero, and the third PR round is slower than the other two on the same firmware, so part of the remaining difference is drift between rounds.

Ultimate II+L in the C64 Ultimate, one base run and one PR run of 100 rounds each, interleaved: Ethernet (192.168.1.74) is 5% to 15% faster on every route, WiFi (192.168.1.97) is 3% to 22% slower, with the same pattern as on the Ultimate 64 Elite. A WiFi-only pair on this device was not conclusive: medians within -4% to +26% with the larger transfers showing a higher 95th percentile. This device was measured with fewer repetitions than the Ultimate 64 Elite.

Reading the WiFi result. Before the change, replies to requests for the Ethernet address also left through the WiFi module. When Ethernet and WiFi requests alternate, the WiFi radio was therefore busy a few milliseconds before each WiFi request. After the change, only WiFi requests use it. Two checks on the PR firmware are consistent with that, and neither proves it:

  • A 5 packets per second ping to the WiFi address while measuring the WiFi address changed nothing (all routes within noise). That traffic is too sparse to keep the radio awake.
  • Sending a small UDP datagram to the WiFi address 5 ms before each request, alternating request by request, lowered the median by 1.8 to 2.8 ms on three of four routes and raised it by 2.4 ms on the fourth.

The difference is about 2 ms. If it is a radio wake-up cost, the stock firmware only avoided it for WiFi requests that closely followed Ethernet requests, and the WiFi path in steady use is unchanged. A client that uses only the WiFi address sees the same latency as before within the noise of these measurements. Which of these explanations is right is not established. To reproduce:

tests/perf/rest_path_latency_perf_test.py -H 192.168.1.13 --address 192.168.1.70 \
    --label base --json base.json          # flash the base build, then the PR build
tests/perf/rest_path_latency_perf_test.py -H 192.168.1.13 --address 192.168.1.70 \
    --label pr --json pr.json
tests/perf/rest_path_latency_perf_test.py --compare base.json pr.json

Repeat each firmware at least three times and add -H <wifi address> on its own to measure the WiFi address without the Ethernet traffic. A follow-up could look at the ESP32 power-save and DTIM settings, and at the radio's idle wake-up latency, independent of this change.

Not verified

  • The C64 Ultimate was not run with this firmware. It was only the host for the Ultimate II+L.
  • The wire capture of reply source MACs was not repeated. The reply path is covered by the latency results above, the host tests and the capture in the PR description.
  • The base for the red runs is 1947533, not the current head of master. Neither contains route-selection changes.
  • Rules 1 and 2 were not reverted one at a time on hardware, and the E2E suite does not send between the device's own two addresses.
  • The cause of the WiFi result above is not established.

State of the devices

The Ultimate 64 Elite runs the PR firmware built at 9e5a4a1 (the firmware is identical at f22da00) volatile (JTAG) and returns to its flashed firmware on a power cycle. The Ultimate II+L has that same firmware flashed. The C64 Ultimate was power-cycled through its own menu as the last step of each U2+L flash. Command Interface and the C64 Ultimate settings changed by the suite were restored by the runner.

@chrisgleissner

Copy link
Copy Markdown
Collaborator

Follow-up commits pushed to this branch

Two commits are added on top of 409142b: 9e5a4a1 and f22da00. Both are in the test, documentation and header-readability scope. Neither changes route selection.

9e5a4a1

  1. uci-net-route runs the UDP check after a TCP failure. net_route_test.py ran the TCP check and the UDP check inside one sequence, so a failing TCP check ended the suite before the UDP check executed. On firmware without this change the suite therefore reported only the TCP failure, and the UDP check had no failing result on hardware. The two checks now run independently and the suite fails with the first failure after both have run.
  2. route_usable() in route_select.h. The condition "up, link up, has an address" was written out in both loops of route_select(). It is now one small function used by both. The behaviour is the same.
  3. README. tests/README.md describes what uci-net-route needs: two device interfaces on this host's subnet, link up on both, the menu at its root, and that it opens and closes the menu.

f22da00

tests/perf/rest_path_latency_perf_test.py, registered as rest-path-latency in the perf category (run-tests, tests/README.md, tests/perf/README.md). It measures ten REST routes on each address given, keeps every sample, and --compare BASE NEW reports the change of each median with a 95% bootstrap interval. It was used for the latency measurements in the assessment comment above. The comparison was checked device-free on synthetic samples: a distribution shifted by 20% is marked SLOWER, and two samples from the same distribution (+3.0%, interval -0.5 to +7.4) are not marked. This is a measurement tool, so it has no pass/fail verdict and no red/green run.

Verification on hardware

Item 1, the only one with a behaviour that can fail on a device:

Device Firmware Test Result
Ultimate 64 Elite base 1947533 previous uci-net-route FAIL at the TCP check; the UDP check does not run
Ultimate 64 Elite base 1947533 uci-net-route at 9e5a4a1 FAIL at TCP ("came from 192.168.1.70 (the WiFi address)") and FAIL at UDP ("came from 192.168.1.70 (the WiFi address)")
Ultimate 64 Elite PR firmware uci-net-route at 9e5a4a1 PASS, 7 checks
Ultimate II+L in the C64 Ultimate base 1947533 uci-net-route at 9e5a4a1 FAIL at TCP and FAIL at UDP, both from 192.168.1.97
Ultimate II+L in the C64 Ultimate PR firmware uci-net-route at 9e5a4a1 PASS, 7 checks

The previous test's result on the base firmware is the one recorded in the assessment comment; it was run on both devices before the change. The UDP failure on base firmware is shown on hardware for the first time by the new test.

Item 2 changes no behaviour, so there is no failing hardware run for it and none is claimed. It was checked by the host tests (route-select: 19 pass, route-select-red: 9 of 19 fail as before) and by the hardware runs above, which were made with a firmware built from 9e5a4a1 on both devices.

Item 3 and the perf test were checked as described above. tests/lib/registry_test.py reports only the existing directory_rename_test.py failure, and ./run-tests --list shows rest-path-latency. The perf test ran through ./run-tests --suite rest-path-latency u64.

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

Labels

enhancement New functionality or an improvement to existing behavior, including formats and developer tooling. network Networking and remote services: REST, Socket DMA, FTP, Telnet, and online access.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syslog is sent from the WiFi interface while wired Ethernet is connected

2 participants