Skip to content

net: TCP timestamps (RFC 7323); media, files: TIFF pictures - #118

Merged
v3nn7 merged 3 commits into
mainfrom
v3nn7/practical-euler-ot7vt8
Nov 12, 2026
Merged

v3nn7 merged 3 commits into
mainfrom
v3nn7/practical-euler-ot7vt8

Conversation

@v3nn7

@v3nn7 v3nn7 commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

What does this change?

Two unrelated changes, one commit each.

TCP timestamps (RFC 7323)

The TCP stack sent no timestamps option: the round-trip time came from one timed segment per window (none while retransmitting, by Karn's rule), and nothing protected a long connection against old duplicates.

  • The SYN offers the timestamps option. It is used when the peer's SYN carries it too, and then goes on every segment: 12 bytes with its two NOPs, taken off the data a segment carries (Tcb::mss).
  • TS.Recent follows the segment that covers the last ACK sent, so an ACK echoes the oldest segment it acknowledges.
  • The round-trip time is taken from the echo, once per round trip, for retransmitted data as well. Without the option the single timed segment and Karn's rule remain.
  • PAWS: a segment with a timestamp older than the last one accepted is acknowledged and dropped, whatever its sequence number says. A reset is exempt.
  • The codec parses and writes the option next to MSS, window scale, SACK-permitted and SACK blocks (timestamps and three blocks fill the 40 option bytes exactly). Segments without it are encoded as before.

TIFF pictures in Files

Files could not show .tif files. osyx-media now decodes the first page of a TIFF 6.0 file (userspace/media/src/image/tiff.rs), and the built-in viewer and "Open with" take tif and tiff.

  • Both byte orders, strips and tiles, chunky and planar samples.
  • Uncompressed, PackBits, LZW, Deflate, CCITT Group 3 and Group 4. The LZW, inflate and fax decoders are the ones the PDF reader already has.
  • Bilevel and grey of 1, 2, 4, 8 or 16 bits in either polarity, palettes of 1 to 8 bits, RGB and CMYK of 8 or 16 bits, with an alpha sample (associated alpha is un-premultiplied).
  • The horizontal differencing predictor, the fill order and the eight orientations.
  • BigTIFF, JPEG-compressed strips, YCbCr and L*a*b* pixels and floating-point samples are refused with a message that names them. Sizes from the file are bounded before anything is allocated.

How was it tested?

TCP:

  • cargo test --locked -p osyx-net: 74 passed. Five new tests in network/net/tests/timestamps.rs: the option through the codec with every other option and with a wrong length, negotiation with and without a willing peer, the echo, segment sizes, a round-trip sample taken from a retransmission, and a stale segment inside the window.
  • One existing test sent 10 * 1460 bytes as ten segments; with the option a segment carries 1448, so it now sends 10 * 1448. The SACK tests strip the option from their SYN because they count whole segments.
  • Against the Linux TCP stack (guest on a TAP device behind a relay, scripts/net-bench-host.py, 4 MiB each way). tcpdump shows TS val/ecr on both SYNs and on data segments of 1448 bytes.
Loss Upload Download
none (2 runs) 57 to 60 MiB/s 54 to 57 MiB/s
2 % of data segments each way (4 runs) 4.2 to 9.1 MiB/s 3.5 to 28 MiB/s
  • The functional network checks under the same 2 % loss pass (UDP echo, 1 MiB TCP echo, four concurrent connections, refused connect, loopback, non-blocking read, socket release).
  • Full test boot in QEMU (4 CPUs): 35 kernel self-tests passed, 94 of 95 user checks passed.

TIFF:

  • cargo test --locked -p osyx-media: all suites pass; --test image has three new tests.
  • 23 files are compared with reference decodings: exact for 22, within 1 for CMYK (Pillow rounds the inks its own way). The references are Pillow's decodings where it reads the file the same way, and are computed from the written pixels for 16-bit samples, associated alpha and orientation. tests/make_tiff_fixtures.py writes the files with Pillow and tifffile and asserts that Pillow agrees wherever both exist.
  • Six of the files are fed through the decoder truncated at every seventh length and with every byte changed three ways; no panic, and whatever decodes has w * h pixels.
  • The format line (TIFF, 8-bit RGB, LZW, ..., page 1 of 2) and the messages for JPEG-compressed and BigTIFF files are checked.
  • osyx-desktop builds for x86_64-unknown-none; cargo test -p osyx-filekit passes (20).

Limitations or screenshots

  • TCP under 2 % loss: the numbers before this change were 3.9 to 13 MiB/s up and 22 to 31 MiB/s down (4 runs). The spread of so few runs is wide; two of the four download runs here were slower (3.5 and 12 MiB/s), and the captures show a single long stall on the Linux sender in each. I could not tell from four runs whether timestamps make this more likely.
  • TCP: a segment without the option on a connection that negotiated it is accepted (RFC 7323 says it should be dropped). No 24-day idle rule for TS.Recent.
  • TIFF: the viewer was not opened on a .tif file in QEMU; only the decoder and the build are tested. No screenshot. Only the first page is shown. No thumbnails.
  • CI does not run the osyx-media or osyx-filekit tests, so the TIFF tests only ran here.
  • The one failing user check fails on main too: ipc: ordinary users cannot register services, take the display or read input.
  • Not run: the PowerShell test scripts (Windows host), real hardware, a real network with delay.

Labels

Labels: enhancement, network, desktop

🤖 Generated with Claude Code

https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK

- The SYN offers the timestamps option; it is used when the peer's SYN
  carries it too, and then goes on every segment (12 bytes with its two
  NOPs, taken off the data a segment carries).
- TS.Recent follows the segment that covers the last ACK sent, so an ACK
  echoes the oldest segment it acknowledges.
- The round-trip time is taken from the echo, once per round trip, for
  retransmitted data as well; without the option the single timed
  segment and Karn's rule remain.
- PAWS: a segment with a timestamp older than the last one accepted is
  acknowledged and dropped, whatever its sequence number says.

Tests (network/net/tests/timestamps.rs): the option through the codec
next to every other option and with a wrong length, negotiation with and
without a willing peer, the echo, segment sizes, a round-trip sample
from a retransmission, and a stale segment inside the window.

Against the Linux TCP stack over a TAP device: both SYNs carry the
option, 57 to 60 MiB/s up and 54 to 57 MiB/s down without loss; with 2 %
of the data segments dropped each way, 4.2 to 9.1 MiB/s up and 3.5 to 28
MiB/s down in four runs (before: 3.9 to 13 up, 22 to 31 down; the spread
of these few runs is wide).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
@v3nn7 v3nn7 added enhancement New feature or request network Area: networking labels Nov 12, 2026 — with Claude
@coderabbitai

coderabbitai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@codspeed

codspeed Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 36 untouched benchmarks


Comparing v3nn7/practical-euler-ot7vt8 (472f6f0) with main (2953c07)

Open in CodSpeed

Files could not show .tif files. The image decoder now reads the first
page of a TIFF 6.0 file:

- both byte orders, strips and tiles, chunky and planar samples;
- uncompressed, PackBits, LZW, Deflate, CCITT Group 3 and Group 4 (the
  LZW, inflate and fax decoders are the ones the PDF reader already has);
- bilevel and grey of 1, 2, 4, 8 or 16 bits in either polarity, palettes
  of 1 to 8 bits, RGB and CMYK of 8 or 16 bits, with an alpha sample
  (associated alpha is un-premultiplied);
- the horizontal differencing predictor, the fill order and the eight
  orientations.

BigTIFF, JPEG-compressed strips, YCbCr and L*a*b* pixels and
floating-point samples are refused with a message that names them. Sizes
from the file are bounded before anything is allocated.

Tests compare 23 files with reference decodings (Pillow's where it reads
the file the same way; computed from the written pixels for 16 bits,
associated alpha and orientation) and feed truncated and bit-flipped
files through the decoder. tests/make_tiff_fixtures.py writes them with
Pillow and tifffile.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
@v3nn7 v3nn7 changed the title net: TCP timestamps (RFC 7323) net: TCP timestamps (RFC 7323); media, files: TIFF pictures Nov 12, 2026
@v3nn7 v3nn7 added the desktop Area: desktop label Nov 12, 2026 — with Claude
CodSpeed reported tcp_parse_segment_1460 12.8 % slower with the
timestamps option. Callgrind shows why: with two more callers, be32 was
no longer inlined, and each call cost about 25 instructions for a
four-byte load. A parse took 863 instructions against 779 on main; with
be16, be32, put16 and put32 marked #[inline] it takes 788.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Wky8K1hAgSGYFWjvQ1gDqK
@v3nn7
v3nn7 marked this pull request as ready for review November 12, 2026 10:25
@v3nn7
v3nn7 merged commit ad33a45 into main Nov 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Area: desktop enhancement New feature or request network Area: networking

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants