Repository navigation
Spike for #807: NET_CMD_WRITE_SOCKET_CHUNK ($16), a payload larger than one command as one datagram - #835
Spike for #807: NET_CMD_WRITE_SOCKET_CHUNK ($16), a payload larger than one command as one datagram#835JC-000 wants to merge 8 commits into
Conversation
8290268 to
1653b0a
Compare
|
Rebased onto
Separately, the Neither result alone separates a firmware fault from a WireGuard one; together they say the rebase changed nothing on either side. Both are claims of parity with the previous image, not a general clearance of |
WRITE_SOCKET sends whatever one command carries, and a command carries at most 895 bytes because command_protocol.vhd stops command_pointer on the last byte of the buffer. A UDP payload above 892 therefore leaves as several datagrams, which a peer expecting one rejects. Six scenarios for a WRITE_SOCKET_CHUNK that announces a total, carries an explicit offset per chunk, and sends once when the payload is whole: one datagram rather than several, the 1472 ceiling accepted and 1473 refused, chunks refused for a wrong offset, total or handle, commands too short to hold a header, and a payload in progress discarded by an abort and by a C64 reset. The oracles were checked against a simulator of the contract with the defence under test removed, one variant at a time, so each fails for its own defect rather than passing because the firmware cannot do the wrong thing. Peer.collect_udp watches the wire for a whole settle window: the reply to a write is a byte count, and 1000 is 1000 whether it left as one datagram or as two. Red on test-merge d2acbd4: 12 of 12 scenario/route combinations fail with 21,UNKNOWN COMMAND, and the 20 pre-existing combinations pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
NET_CMD_WRITE_SOCKET_CHUNK ($16) takes a payload across several commands
and hands it to lwip once, so a datagram up to 1472 bytes leaves whole
where WRITE_SOCKET could carry only 892.
$03 $16 <HANDLE> <OFFSET_LSB> <OFFSET_MSB> <TOTAL_LSB> <TOTAL_MSB> <DATA>
The offset is on the wire rather than accumulated silently. A chunk that
names a position nothing is holding is refused, which is what a client
sees when its payload was discarded by a reset or by any other command
between chunks, and what a duplicated chunk becomes. An implicit counter
would instead have opened a fresh payload and spliced the two together in
the next datagram, reporting 00,OK throughout.
$16 rather than the next free $12: xlar54/ultimateii-dos-lib defines TCP
listener commands at $12 to $15 and ships a sample that sends $03 $12, so
those numbers are spoken for whether or not this firmware implements them.
WRITE_SOCKET and the completing chunk now share send_to_socket(), so both
report a send identically and neither can bypass the ownership gate that
GideonZ#814 added. No new status codes: a total above 1472 is 82, a chunk that
does not fit the payload in progress is 81, and a send error is 12.
Green on a U64 Elite, core 1.4E: 32 of 32 scenario/route combinations
pass, 177 checks, against the same tests that fail 12 of 12 on d2acbd4.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The proposal NET_CMD_WRITE_SOCKET_CHUNK implements, written as the "Ultimate Command Interface - Network Target" documents are: sections 1 and 2 state constants and required behaviour, and every "because" lives in an appendix with the file and line it rests on. The appendices record what was measured and what was not, including the properties the bench cannot show and the one scenario that cannot fail on this tree for the reason it exists. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1653b0a to
9cd2a98
Compare
# Conflicts: # tests/e2e/io/command_interface/net_target_test.py
Be careful with sharing this type of information. It could be considered PII when it can be linked to you as a person. |
|
Hi @JC-000 , just an FYI - the target branch for all future PRs should be I have already amended this PR here. Thanks |
|
Rgr, I saw the change but wasn't sure what your flow was so I didn't know if you were graduating the PR or I had missed the original target. |
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nZ#835) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> # Conflicts: # software/io/network/network_target.cc # software/io/network/network_target.h
…tomically IDENTIFY, GET_INTERFACE_COUNT, GET_IPADDR and GET_NETADDR are answered on the UCI Server task and never reach execute(), so they no longer ended a payload in progress: chunk, IDENTIFY, completing chunk was accepted and sent. They now set write_chunk_stale before they answer. execute() read and then cleared write_chunk_stale in two steps; the UCI Server task, which runs at a higher priority, could set it in between and the word was lost. The swap is now inside a critical section. New host tests: a payload ended by IDENTIFY (failed before this change), by an abort and by a C64 reset is never completed by the next chunk. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The line numbers now match the worker-task network target, the reset is said to close the sockets on the worker, and a TCP send that fails after a partial send is noted to report -1, so restarting the payload at offset zero sends those bytes again. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Merged the current master into this branch. Master now runs socket commands on a worker task and answers socket-free commands on the UCI task, so the chunk handling moved onto the worker. An abort or a C64 reset now marks a partly built payload stale; the next command drops it and never completes it. Quick commands such as IDENTIFY mark it stale too, so any other command still ends a chunked write. Two commits on top of the merge do this, each with a host test that failed first: the quick-command rule, and an atomic read-and-clear of the flag. The doc's line references are updated. It also notes that a TCP send that fails after a partial send reports -1, so restarting the payload at offset 0 would resend bytes. Written with Claude Sonnet 5.5 and Claude Opus 5.5 in Claude Code. |
What this is
A spike for #807:
NET_CMD_WRITE_SOCKET_CHUNK($16), which assembles a payloadfrom several UCI commands and sends it to a socket as one datagram. Today
NET_CMD_WRITE_SOCKETcan carry at most 892 bytes, so a larger datagram cannotbe sent at all — splitting it across two commands sends two datagrams, which a
peer expecting one rejects. Receiving already reaches 1472; this makes sending
match.
It is offered as a spike, not for merge as it stands, per @chrisgleissner's note
on #807. The specification it implements is included as
doc/uci_network_chunked_write.mdso the design can be reviewed on its own.Three commits
30a88b4d8c92263382902682doc/uci_network_chunked_write.mdEvidence
Bench: Ultimate 64 Elite, firmware 3.15, FPGA 124, core 1.4F,
as
/v1/inforeports it. Both routes, REST and native (6502 agent). The suiteregisters 20 scenarios run on both routes — 40 combinations, 20 of them of this
command.
ed8bc28d, unpatched21,UNKNOWN COMMAND; the 20 pre-existing combinations passd33b7802+ this branchThe two rows come from different bases. The branch was rebased from
ed8bc28donto
d33b7802after the baseline run; the baseline row is a claim about theabsence of this command, and nothing in those seven commits adds it. The spike
row was measured on the base this branch now sits on.
Baseline run 937 s; patched run 1323 s.
The two properties the command exists for, measured on the wire:
datagrams [1472]— onedatagram — the completing chunk replying
c0 05, being 1472 little-endian;NET_CMD_WRITE_SOCKETcan carry,arrived as
datagrams [893], with nothing on the wire after the first chunk.Verified by an independent client, and adopted
c64-wireguardimplemented this command in its own adapter — a second client onunrelated code — and ran it on the same bench.
one wire datagram of the right length; 1473 refused before reaching the device.
the response count at zero and the buffer untouched, answering
00,OK; onlythe completing part writes the 2-byte total.
per-peer configuration: 60/60 checks, twice. Outbound 888-1472 bytes each
one datagram; inbound 892, 893, 1452, 1472 bytes received whole.
and 48.4 s, ICMP answered through the tunnel, and a 1278-byte DNS response
received whole over the internet. Sizes above 1280 are capped by WARP's own
MTU, not by this command.
That work is merged (
c64-wireguardPR #112), so the first consumer hasshipped support rather than holding a branch.
Byte weight
Measured baseline vs patched at
ed8bc28dwithmake u2_rv_swonly:ed8bc28d+504 bytes on the U2 application image, of a 792 KiB partition. The U64 image
grows by 524 bytes and its size gate stays PASS at 20.5 % free.
The one design decision worth arguing about
Each chunk carries an explicit offset rather than being positioned by an
accumulator the target keeps. It costs two bytes per chunk, taking the largest
chunk from 890 to 888. It buys the failure of two silent-corruption paths that
the implicit design has:
a payload left in progress is silently continued by the next program's chunks,
and the handle does not save you — lwip's
alloc_socketis a first-fit fromzero, so the low descriptors are reissued and a stale handle names a live
socket.
NET_CMD_READ_SOCKETbetween two chunks discards the accumulation, and everycommand still answers
00,OK, so a client cannot see that it happened.Appendix B of the specification sets both out with the code they rest on.
Command number
0x12is not free.xlar54/ultimateii-dos-libdefines the TCP listener commandsat
0x12-0x15and itsu-echoserver.csample sends$03 $12. This uses0x16. See Appendix C.Not in this PR
While splitting
write_socketI found thatNET_CMD_WRITE_SOCKEThas nominimum-length guard: a two-byte command
$03 $11giveslength = -1, whichreaches
lwip_send'ssize_tas0xFFFFFFFF. It predates this work and isreachable without ever sending
$16, so it is filed separately rather thanbundled here.
🤖 Generated with Claude Code