LedgerMath

View as Markdown

net_rtt

Written entirely by AI

The round-trip time between this box and a peer box over TCP: one small frame echoed per sample on a kept-open connection, or one TCP handshake per sample, with every round trip recorded on its own.

What a figure means

Each sample is one round trip and nothing else (repetitions is 1). With tcp_echo, the binary writes one frame of size_bytes (plus a 4-byte length) on a TCP_NODELAY connection opened before the first sample, and the sample ends when the whole echo has been read back. With tcp_connect, the sample is one connect(): SYN out, SYN-ACK back.

Method runs v1 reads the samples as any benchmark's: the time of one repetition (time_per_repetition_ns) is the median round trip of the Run's counted samples. The stream also holds an op_histogram (metric rtt) of every counted round trip, in methods/requests v1's bins (each within 1/128 of the time), for a Method that reads tails.

What a figure does not show

  • Throughput: a frame is small and the connection idles between samples (see net_throughput).
  • The peer's own time: the echo server answers as soon as it has read a frame, but its thread waking up is inside the round trip.
  • Anything about other placements: scope names where the peer was put (same AZ, another AZ, loopback); AWS does not promise one path between two instances.

Parameters

The benchmark's Series and their figures are listed at https://api.ledgermath.com/v1/benchmarks/net_rtt.json.

Variable--quick defaultMeaning
LM_PARAM_SCOPEloopbackWhere the peer is (same_az, cross_az, ...); part of the Series
LM_PARAM_PROTOCOLtcp_echotcp_echo or tcp_connect
LM_PARAM_SIZE_BYTES64Payload bytes per frame, 1 to 65536
LM_PARAM_TIMEOUT_MS5000Socket timeout of every send, read and connect
LM_PARAM_GAP_MS5Pause between samples, outside them

Service inputs: LM_SERVICE_PEER_HOST (an IP literal, or a name resolved through LM_PARAM_RESOLV_CONF, default /etc/resolv.conf) and LM_SERVICE_PEER_PORT. The peer runs the same binary as net_rtt --serve <port> [<bind address>]. Under --quick with no peer, the binary serves itself on 127.0.0.1.

Observed values

KeyWhat it is
protocol, size_bytesWhat each sample did (size_bytes is 0 for tcp_connect)
peer_address, peer_port, local_addressThe addresses connected
nodelayWhether TCP_NODELAY was in force
bytes_per_repetitionBytes one echo sends and reads back, frame headers included
warmup_samplesSamples before the counted ones (5 for tcp_echo, 2 for tcp_connect)

A tcp_info event after the samples holds the kernel's view of the connection (smoothed RTT, minimum RTT, path MTU, retransmissions).

Findings

No finding of its own so far.

How it works

Each frame is the Fixture pattern at an offset of its sample's own, so an echo of an older frame or of other bytes is caught. After each sample, outside it, every echoed byte is compared with what was sent (a difference exits 1) and FNV-1a'd into verified. Before the first sample one echo is checked, so a peer that is not a net_rtt server is refused before the stream has samples. A timeout exits 1.

Building and testing

make BUILD=static
./build/static/net_rtt --quick | python3 ../../scripts/check-events.py --quick
bun test tests/net-and-ec2-benchmarks.test.ts