Log InGet OrdStyle

Real documents, not screenshots

Every piece below is a finished document written as one plain-text file and rendered by the editor with no other software involved. Open a PDF, then look at the plain text it came from. The design lives in the style.

Documents
36
Designs
71
Pages rendered
1,518

Rendered November 5, 2026 from the current build. The same documents ship inside the editor under File ▸ Open Example.

Feature Showcase

Documents that exercise the format itself — the whole feature set in context, and the reference sheets for charts, for drawings made of typed characters, and for tables that calculate.

The Ord Compendium

Every feature, in context

The reference document: columns and balancing, floats and full-bleed figures, footnotes, an index, a table of contents, math, scripture references, charts, circuits, embedded documents and figures drawn by scripts that run at render time. If the engine does it, it is on a page here.

The Ord Compendium, the compendium design: page one
% ============================================================ PART I
# Words & Structure
[Kick] PART ONE OF SIX · THE QUIET FOUNDATIONS
[Lead] An .ord file is plain text with opinions. Everything you will see in these pages — the columns, the charts, the dark dashboards — is carried by ordinary lines you could type in any editor, styled by a single master style sheet at the top of the file.
Six parts build upward from these quiet foundations: prose and outlines first, then figures and computed media, the column engine, the presentation set, the style sheet itself, and at last the framed page. All of it is one plain-text file, written once for $company
## Inline Formatting
The span toolkit works anywhere prose does: **bold**, *italic*, ***bold italic***, __underline__, and their combinations like **__weighted and ruled__**. Superscripts and subscripts nest into equations — E=mc^2, x^{n+1}, H_2O, a_{n-1} — and standalone fractions such as 1/2 and 3/4 typeset themselves. Small caps arrive with {SC:a marker}, an em dash with a double hyphen -- like so -- and a mid-line @@ becomes a bullet.
Named character styles carry semantics: a {=term=design variable} is declared once in the style sheet and referenced by name wherever a color, length, or phrase should stay consistent. The token {=code=$accent} in this very sentence expanded to its value when the page was rendered, and the publisher's name in the opening paragraph is the variable {=code=$company} — change one line and every mention follows.[^vars]
Inline tags gate conditional text; toggling a tag re-publishes a different edition of the same file.[idx:Concepts:Variables][idx:Concepts:Inline tags]
{:1: This paragraph is visible because the Reviewer tag is enabled in the style sheet.}
{:2: This paragraph is excluded from output entirely — the Draft tag is on the excluded list — so it prints only in draft builds.}
Links work three ways: outward to https://example.org, inward to a section like [the column engine](#The Column Engine), and by number with [](#3.1).
## Lists & Outlines
One relative value indents the whole outline: the bullet role carries {=code=+36+} in its margin field — thirty-six points that cascade again at every depth, and the sheet's tab distance is pinned to the same thirty-six so every item's text begins exactly where the next level's bullet will.
- Unordered items take a hyphen
- A second item, long enough to wrap and show the hanging indent that list continuation lines receive automatically
+ A plus sign draws the alternate bullet
1. Ordered lists count themselves
2. In numerals, letters, or Roman numerals
  a. Nested lettering
    i. Nested Roman
- Top level again
  - Indentation nests bullets
    - As deep as the outline goes
## Quotations & Callouts
> A bare quotation takes a quiet left rule and nothing else. It ends when the lines stop leaning on the angle bracket.
> > Quotes nest inside quotes for dialogue or cited citation.
>note> A callout is nothing but a named block style, so each can wear its own shape. The note keeps the classic form — a colored bar at the far left over a quiet field.
>warning>Field advisory> The warning changes voice entirely: a tinted field, a small-caps title, and a sans-serif body face, all assigned by the sheet.
>tip> Rules above and below, a centered italic line — the epigraph shape, one style away.
>card> A card is the neutral container: white fill, hairline border, rounded corners. Anything can live inside one.
[Pull] Presentation is a property of the style sheet, not of the prose — the same file re-skins without touching a word.
## Rules, Ornaments & Space
Three runes draw three different rules, each mapped in the style sheet. A dash rule:
---
An asterisk rule mapped to an SVG ornament:
***
An underscore rule as a short heavy accent:
___
And where a gap should be exact, SPACE|24 reserves precisely twenty-four points — like this:
SPACE|24
— no blank-line guesswork.
## Margins & Asides
[Aside] Margin notes are presentation styles with place=margin — they reserve no height in the flow. | № 1
This page keeps a wide right margin, and the paragraph you are reading has a companion note riding beside it. The section marks along the outer edge of every section heading are style icons — glyphs attached to the heading style itself, not typed into the text.
[Aside] The § wayfinders beside each section heading come from the heading style's icon field. | № 2
Footnotes are the other marginal voice: a marker in the text[^fn] and its definition anywhere in the file meet at the bottom of the page, under a measured rule.
## Scripture & Citation
The verse engine recognizes references in running prose and sets the text itself, styled by its own pair of styles. Consider Psa 19:1 — typed as seven characters, delivered in full.
## Composed Documents
One document can embed another — whole, or a single section — with heading levels adjusted to fit the host outline:
![A note on provenance](showcase-assets/embed-note.ord){sameLevel}
The source of this file also contains comment lines beginning with a percent sign. You cannot see them, which is the point.

[^vars]: Variables cascade across style sections, so alternate looks of one document share a vocabulary.
[^fn]: Mode 3 places footnotes at the bottom of the page; endnote and inline modes are one property away.

% ============================================================ PART II
# Figures & Media
[Kick] PART TWO OF SIX · PICTURES, CODE & COMPUTED FIGURES
[Lead] Anything that is not prose is a figure: images with float and crop behavior, syntax-lit code, ASCII diagrams promoted to vector art, circuits, charts fed by tables, and Python that runs at render time.
Figures are cited, not counted by hand. The mark below is @fig:mark, and the sectioned instrument beside the next paragraphs is @fig:sext — renumber them by reordering, and every reference follows.
## The Image Model
![The meridian mark. Every figure takes a caption, and a label in braces makes it citable. {#mark}](showcase-assets/mark.svg){scale=0.5 align=center}
![Sighting instrument, sectioned. A float reserves a fraction of the column and lets prose wrap past it. {#sext}](showcase-assets/schematic.svg){align=right floatWidth=44}
A floating figure declares its width as a percentage of the column; the text you are reading is wrapping through the remainder, and will widen back to full measure the moment it clears the float's wake. Alignment, margins, and the height of the wrap zone are all attributes on the image line.
![A sidebar float: floatHeight=column holds the gutter open to the bottom of the column. {#side}](showcase-assets/tile-b.svg){align=right floatWidth=26 floatHeight=column}
Floats can also pin a sidebar: with floatHeight=column the gutter persists to the bottom of the column even after the image ends, which is how magazine sidebars hold their shape.
- The image itself paints at natural size
- The wrap zone below it stays reserved
- Every following line keeps the narrow measure
![A raster photograph cover-cropped into a fixed box, with rounded corners, a hairline border, and a drop shadow. {#photo}](showcase-assets/photo.png){align=left wrap=image width=160 height=112 fit=cover radius=8 border=1:$rule shadow=3}
Raster images crop as well as scale. This photograph is forced through a 160 by 112 point box with fit=cover — filled and center-cropped — then rounded, ruled, and shadowed, all from attributes.
![The same photograph through the same box with fit=contain — letterboxed, nothing cropped. {#contain}](showcase-assets/photo.png){width=160 height=112 fit=contain border=1:$rule align=center}
Full bleed is the last word in image placement — edge to edge, margins ignored, flow preserved. The banner below spans the physical page while the text around it keeps the margins:
![](showcase-assets/banner.svg){bleed}
## Code, Lit
```python`Reference implementation
def meridian(readings):
    '''Fold a day of readings into one figure.'''
    total = sum(r.value for r in readings if r.valid)
    return total / max(1, len(readings))
```
```cpp`The same idea, compiled
double meridian(const std::vector<Reading>& rs) {
    double total = 0; int n = 0;
    for (const auto& r : rs)
        if (r.valid) { total += r.value; ++n; }
    return n ? total / n : 0.0;
}
```
Each language keys its own pair of styles — the dark slab, the numbered gutter, and the mono face belong to the sheet, the fences to the text.
## Diagrams & Circuits
ASCII art is promoted to vector art, and the vocabulary runs deep: boxes and pill nodes, diagonal runs, shaded cells, open endpoints, arrows in all four directions, and plain words riding the wires as labels — the whole network, typed.
```diagram The observing network {scale=70}
      o  field telemetry
      |
      v
+-----+-----+      +-----------+
|   Field   |      |  Ingest   |       .---------.
|   array   +----->|   queue   +----->(  uplink   )----.
+-----+-----+      +-----+-----+       '---------'      \
      ^                  |                               v
      |                  v                         +-----------+
      |            +-----------+                   |  Archive  |
      '------------+  Planner  |<------------------+           |
          retask   +-----------+                   +-----------+
```
The notation extends to electronics with a full component library — sources, passives, semiconductors, transducers. The station's alarm loop, typed the same way:
```circuit Station power & alarm loop {scale=85}
+--+batte+--+fuseb+--+spsto+--+--------+--------+
|                             |        |        |
|            FUSE1     SW1    +        + LAMP1  +
|   BATT1                     c        l        s
|                             a C1     a        p
|                             p        m        e   SPK1
|                             a        p        a
|                             c        o        k
|                             +        +        +
|                             |        |        |
+-----------+-----------------+--------+--------+
            |
            +eg
```
Semiconductors route by pin: a transistor's base arrives from the left, collector and emitter leave high and low on the right. A thermistor divider biases the base through a resistor, and the collector drives the warning lamp — the station's thermal switch:
```circuit The thermal switch {scale=85}
Vcc ---+-------------------------+
       |                         |
       +                         +
       t                    LED1 l
       h                         e
       e Therm1                  d
       r                         :
       m                         :
       +                         +
       |                         |
       |                         |
       |                  NPN1   |
       |
       |    R1
       +-----+resis+--------+npn
       |
       +
       r                         |
       e R2                      |
       s                         |
       i                         |
       s                         |
       +                         |
       +----+--------------------+
            |
            +eg
```
And it reaches logic: gates take their inputs a row above and below, so a half adder is nine lines of text:
```circuit Half adder {scale=95}

A o----*--------+
       |        :Xor+-----o Sum
B o--*-)--------+
     | |
     | |
     | |
     | +--------+
     |          And:+-----o Carry
     +----------+
```
## Charts, Fed by Tables
A chart is one directive reading the table above it; markers in the header row assign series types — the family runs bars grouped, stacked, and percent; lines, splines, and areas; scatter, pies, and concentric donuts. One chart-style line in the master sheet sets the palette, the grid, and the typography for every chart in this gallery — and hides each source table, so the numbers live in the file while only the figures reach the page. Braces on a single directive, or an override in a single header cell, retune one chart without touching the rest:
COL|2|50|50|6
| [BarCategories] Quarter | Field [Bar] | Lab [Bar] | Marine [Bar] |
| Q1 | 34 | 21 | 9 |
| Q2 | 41 | 24 | 12 |
| Q3 | 52 | 22 | 17 |
| Q4 | 61 | 27 | 21 |
CHART|Deployments by quarter, grouped|0.6|0.92
| Year [X] | Coverage [Area] | Drift [Spline] <$accent lw=1.6 dash> |
| 2021 | 62 | 14 |
| 2022 | 68 | 12 |
| 2023 | 75 | 9 |
| 2024 | 83 | 7 |
| 2025 | 88 | 6 |
CHART|Coverage rises as drift falls|0.58|0.92|{legend=end}
| Hours [X] | Readings [Scatter] | Fit [Line] <$muted lw=1.4 dash> |
| 1 | 52 | 50 |
| 2 | 61 | 58 |
| 3 | 63 | 66 |
| 4 | 76 | 74 |
| 5 | 80 | 82 |
| 6 | 92 | 90 |
CHART|Observation hours against yield, with fit|0.62|0.92
| [Names] Region | Share [Pie] |
| Highlands | 34 |
| Coast | 27 |
| Basin | 22 |
| Ranges | 17 |
CHART|Network share by region|0.72|0.8
| [HBarCategories] Station | Done [StackedHBar] | Active [StackedHBar] | Queued [StackedHBar] |
| North | 45 | 12 | 8 |
| Coast | 38 | 18 | 14 |
| Basin | 52 | 6 | 4 |
CHART|Task status, stacked by station|0.45|0.92|{labels=1}
| [Names] Class | 2026 [Donut] | 2021 [Donut] |
| Field | 128 | 63 |
| Lab | 74 | 41 |
| Marine | 52 | 18 |
| Airborne | 21 | 6 |
CHART|The instrument fleet — 2026 over the 2021 ring|0.72|0.8|{center=total centersub=instruments}
COL|1

## Computed Figures
A Python figure runs a script at render time, drawing straight into the page with the engine's vector API. The block's body is the script's input — the chart below is a title line and seven data lines, nothing more; the axis scale, the gridlines, and the highlighted maximum are all computed.
![Field readings, parsed and set by a script in the document's own palette.](showcase-assets/season_bars.py){scale=1.0}
title: Field readings · season means
Apr 52
May 61
Jun 78
Jul 95
Aug 88
Sep 64
Oct 41
~~~
A script may instead compute its whole picture and return raw SVG, transparent over the page. Here the document holds nothing but five pendulum constants per line — two frequencies a hair off resonance, two phases, a damping — and the script swings them into eighteen thousand segments:
![A damped harmonograph: two pendulums per trace, detuned a thousandth of a beat, drawn by arithmetic.](showcase-assets/harmonograph.py){scale=1.0}
3.001 2 1.5708 0 0.0065
2 3.0016 0 0.7854 0.008
~~~
The same channel typesets mathematics — a one-line embed hands the expression to the math engine:
![The time-dependent Schrödinger equation, typeset from a one-line embed.](latex_render.py){scale=1.1}
i\hbar \frac{\partial}{\partial t} \Psi(x,t) = \left[ -\frac{\hbar^2}{2m} \frac{\partial^2}{\partial x^2} + V(x,t) \right] \Psi(x,t)
~~~
![Ramanujan's rapidly converging series for 1/π, typeset from a one-line embed.](latex_render.py){scale=1.1}
\frac{1}{\pi} = \frac{2\sqrt{2}}{9801} \sum_{k=0}^{\infty} \frac{(4k)!(1103 + 26390k)}{(k!)^4 396^{4k}}
~~~
![The compressible Navier–Stokes momentum equation, typeset from a one-line embed.](latex_render.py){scale=.9}
\frac{\partial (\rho \mathbf{u})}{\partial t} + \nabla \cdot (\rho \mathbf{u} \cdot \mathbf{u}) = -\nabla p + \mu \nabla^2 \mathbf{u} + \frac{1}{3} \mu \nabla (\nabla \cdot \mathbf{u}) + \rho \mathbf{g}
~~~
% ============================================================ PART III
# The Column Engine
[Kick] PART THREE OF SIX · FLOW, BALANCE & INDEPENDENCE
[Lead] One directive opens a multi-column region; a second closes it. Between them: flowing text, balanced text, or fully independent panels — decorated, tinted, and bled to the page edge.
Three modes cover the ground. Flow fills each column before starting the next; balanced distributes so columns end together; independent gives every column its own content.

## Flow & Breaks
COL|2|50|50|6
Flowing columns read like a newspaper: down the first leg, up to the top of the second. This region was opened with a single COL directive naming two equal columns and a six percent gutter.
Mid-paragraph splitting respects widow and orphan minimums set in the sheet, so a column never strands a single line[^col]. Everything prose can do — spans, links, footnotes — works inside a leg.
COLBRK
A COLBRK forced this sentence to the top of the second leg. Breaks can also ride on styles: any style may carry the column-break effect, so a recurring label starts a fresh leg without a directive in the text.
The engine paginates regions automatically — when both legs of a page are full, the region continues overleaf with the same geometry.
COL|1

## Balance
COL|3|bal|33|34|33|4|minPar=0
Balanced mode measures the whole region and divides it so the columns end within a line of each other, which is what a closing spread wants. This region runs three legs with a narrow gutter. Allowing paragraph splits sharpens the balance further, because the divider can fall mid-paragraph instead of hunting for a boundary. The result reads as one measured band of text, whatever the content happens to be.
COL|1

PAGEBRK
## Pictures in the Legs
COL|2|55|45|6
![Wrapped inside a leg. {#colfloat}](showcase-assets/schematic.svg){align=left floatWidth=55}
Media obeys the leg it lives in. This schematic floats left inside the first column, so its wrap zone is measured against the column's own edge — the same float grammar as Part II, at column scale. Once the prose clears the float's wake it widens back to the leg's full measure; the figure beside this text is @fig:colfloat.
COLBRK
![Scaled to the leg. {#colinline}](showcase-assets/mark.svg){scale=0.42 align=center}
An inline figure in a column adopts the narrower measure — centered at the head of the second leg, caption beneath, numbered in the List of Figures like every other citable image.
COL|1

## Unequal Measures
COL|3|bal|26|37|37|3|gaps=2,9|minPar=0
A narrow opening leg, two wide ones, and unequal gutters: widths are per-column percentages, and the gaps= option sets each gutter separately — two percent after the first leg, then nine of it before the last.
The balancer treats the trio as one region: it measures the whole run of text, then places the dividers so all three legs bottom out together, splitting mid-paragraph where the minimums allow.
Five knobs on one directive — count, mode, widths, gaps, and the splitting minimums — and every combination stays plain text in the file.
COL|1

## Independence
COL|3|indep|33|33|34|4|bg=#FFFFFF,$panel,#FFF4EC|border=0.8:$rule:8|pad=9|boxfill=0
**Panel one.** Independent columns are parallel documents: each leg takes its own content, separated by COLBRK.
COLBRK
**Panel two.** Per-column options decorate each leg separately — this trio carries three different fills under one border style.
COLBRK
**Panel three.** With boxfill off, each box hugs its own content.
COL|1

PAGEBRK
COL|2|30|70|7|bg=grad(linear,180,#17667A,#0E4152),#00000000|fg=#FFFFFF,#232830|pad=12|extent=full|bleed
**The rail.** This teal panel is a column background with extent=full and bleed — it runs the full height of the page and out through the left trim edge, while its text stays inside the margins. A gradient is a legal fill anywhere a color is.
Reversed ink is per-column: this leg's text is flipped to white by an fg option, and the body leg keeps its inherited ink.
COLBRK
## Decoration & Bleed
**The body.** The wide leg carries the running text. Split-panel chapter openers, colored rails, and divider pages are all this one directive wearing different options — no artwork required.
Per-gap widths, inner padding, and per-column borders round out the decoration set; the fills accept the same spec as every background in the system: solid, token, gradient, image, or SVG.
COL|1
PAGEBRK

## Regions Driven by Style
[Duet] This italic line is a trigger: its style carries a column spec, so the paragraphs after it flow into two tinted, balanced legs — until the next heading closes the region.
A style-driven region needs no directives in the body at all. The trigger spans full width above its columns by default, and the region ends according to a heading-break rule the style chooses.
The same spec on a heading style turns every section of that level into columns; on a body style, it turns a paragraph run. Either way the document stays plain.
[NewCol] And a styled label —
— this one carries the column-break effect — starts a fresh leg wherever it lands.

[^col]: Footnotes set inside a column region still gather at the page bottom, full width.

% ============================================================ PART IV
# Data, Presented
[Kick] PART FOUR OF SIX · THE PRESENTATION ENGINE, AFTER DARK
[Lead] A presentation is a styled table: the document holds pipe-separated records, and the style decides whether they render as a statistic band, cards, a ledger, steps, or a live table with meters. Change the style, and the same records change costume.
These pages also switch the page itself: a heading effect advanced the running header set, and this part's set paints a gradient over the full page with reversed ink — the dark room.

## The Statistic Band
[Band]
941 | Instruments afield | across four watersheds
99.2% | Readings accepted | after validation
17 yrs | Continuous record | longest unbroken series

## Indicator Cards
Cards are the packer flowing right with a wrap rule; the ring meters read the leading number of each record.
[Kpi]
87% | Coverage | of stations reporting daily
64% | Adoption | of the revised field protocol
92% | Retention | of season staff, year on year

## Capacity, in Glyphs
The same meter machinery draws a dozen shapes; here, pips.
[Cap]
7/10 | Field kits staged
4/5 | Relays provisioned
6/10 | Baselines rerun
9/10 | Sites winterized

## Photo Cards
The card row again — this time each record opens with a bleed image that rides over the card's padding to its edges.
[Photo]
![](showcase-assets/tile-a.svg){bleed height=56 fit=cover} | Highline | Twenty-two stations above the tree line.
![](showcase-assets/tile-b.svg){bleed height=56 fit=cover} | Coastal | Solar relays out on the headlands.
![](showcase-assets/tile-c.svg){bleed height=56 fit=cover} | Basin | The long-series veterans of the network.

## Ledgers & Leaders
[Led]
North array, full service | 412
Coastal relays, solar | 288
Basin loggers, cabled | 156
High-station heliographs | 85

The fill between the columns is a style choice — dots above, then dashes, then a solid rule:
[LedDsh]
Instruments due for calibration | 37
Firmware revisions pending | 9

[LedLn]
Season budget, committed | 81%
Sites with winter access | 44 of 61

## Sequences
[Step]
Sight | Fix the station against two known marks before first light.
Sample | Take the morning series at the interval the log prescribes.
Seal | Close the record with the operator's cipher and the day's checksum.

## Splits, Three Ways
One group, three record shapes: the style's splits list hands each record its own layout — the records themselves are just fields.
[Vary]
Forty–sixty | The group's default proportions: a label panel beside a wider body panel, divided by a hairline.
Sixty-five–thirty-five | The second entry in the splits list flips the proportions for this record alone.
Stacked | And the third entry drops its fields into a column — same content, a different shape.

## Stacks, Two Ways
A stack leads with its first field and steps the rest down the emphasis ladder; reordering the slots flips the hierarchy without touching the record.
[Big] 1,204,553 | readings this season | validated nightly

[BigL] 41 | winters on the high line

## Layered Text
A stack becomes a lockup when its two fields are pulled deep into each other: an overlap distance, a choice of which field rides in front, and a blend for the crossings. Overprint first — the serif echo sits above the headline and multiplies into it, the inks deepening where they touch:
[LayM] MORNING SERIES | and the evening check

The knockout: the echo again rides in front, but now it carries a thin halo of the card's own color, slicing a clean channel through the headline wherever the two cross:
[LayH] STATION LIGHTS | burn through the fog

And the treatment that refuses to choose: at every crossing the echo threads over or under the headline, letter by letter, to a set balance — no image, just two fields and a style.
[Weave] what the moment forgets | The archive remembers

## The Console
A presentation table: header from a row style, hairline dividers from bars, and three meter columns — a bar, a signed arrow, a traffic dot.
[Console]
Station | Load | Trend | Status
Array North | 92% | +6% | 88%
Coastal Relay | 76% | +2% | 71%
Basin Logger | 58% | -4% | 47%
High Station | 33% | -9% | 22%

## Targets & Ranges
Zebra rows from cycling row chrome; bullet, dumbbell, and range meters against white ticks.
[Targets]
Throughput | 72;90 | 58;83 | 20;80;55
Latency | 64;80 | 71;52 | 10;60;38
Coverage | 88;95 | 80;91 | 40;99;88

## The Dial Drawer
Four more shapes from the same drawer — a half-gauge, a battery, a hundred-cell waffle, and a signed diverging bar — each still just a number in a field.
[Dials]
Depot | Fuel | Cells | Season | Drift
Array North | 72% | 4/5 | 68% | +4%
Coastal Relay | 45% | 3/5 | 54% | -2%
Basin Camp | 88% | 5/5 | 81% | +9%

## Records & Media
An image is a first-class field: these rows crop their thumbnails to the slot.
[Media]
![](showcase-assets/tile-a.svg){height=54 fit=cover} | **Array North.** Twenty-two stations on the high line, resurveyed this season and feeding the morning synthesis.
![](showcase-assets/tile-b.svg){height=54 fit=cover} | **Coastal relays.** Solar, uncrewed, and lately talkative — the new firmware doubled their reporting cadence.
![](showcase-assets/tile-c.svg){height=54 fit=cover} | **Basin loggers.** Cabled veterans of seventeen winters; the longest unbroken series in the network.
[Hero]
![](showcase-assets/photo.png){bleed height=88 fit=cover} | The evening line | A first-slot image with bleed rides over the card's padding to its edges — the photo-header card, composed entirely in the style sheet.

## The Legend
Rows can inject fields from the style itself: each row style contributes a colored dot and a small-caps name, so the document holds three plain sentences and nothing else.
[Legend]
All arrays reporting within tolerance.
Two relays throttled by weather.
One logger awaiting the spring thaw.

PAGEBRK
SPACE|200
[Banner] Nine hundred forty-one | instruments currently in the field

SPACE|36
[Lead] The chrome of that band bleeds to both trim edges while its text keeps the column — the same trick as the rail, worn by a presentation group.

% ============================================================ PART V
# The Style Engine
[Kick] PART FIVE OF SIX · TABLES, SELECTORS & THE SHEET ITSELF
[Lead] This part turns the machinery on itself: data tables with formulas, positional selectors that style by position rather than by name, sub-block styling, boxes, icons, and marks.
Nothing on these pages was styled by hand in the text. Every look you have seen — the page moods, the part palettes, the dark room behind us — cascades from the single style block at the top of the file, and this part shows the sharpest tools in it.

## The Pipe Table
A pipe table takes the document's table style — here a banded header, hairline rows, and heavy top and bottom rules. The caption is citable: this is @tbl:ledger.
TBLCAP| Season ledger, with live formulas {#ledger}
| Line | Unit cost | Count | Extended |
| Field kits | 112.50 | 14 | =B2*C2=1575 |
| Relay masts | 480.00 | 6 | =B3*C3=2880 |
| Logger cable, m | 3.25 | 400 | =B4*C4=1300 |
| Calibration days | 260.00 | 5 | =B5*C5=1300 |
| Total | | | =SUM(D2..D5)=7055 |
| Mean line | | | =AVERAGE(D2..D5)=1763.75 |
| Largest | | | =MAX(D2..D5)=2880 |
| Over plan | | | =IF(D6>7000,D6-7000,0)=55 |
Formulas read like a spreadsheet — cell references, ranges, arithmetic, aggregates, and conditionals — and print their results in place.

### A Scoped Table Style
Tables under this deeper heading resolve a different table style — centered, open sides, heavy caps — without any change to the table text itself:
TBLCAP| Series statistics, per watershed {#series}
| Series | Mean | Deviation |
| North | 62.4 | 4.1 |
| Coast | 58.9 | 6.3 |
| Basin | 61.2 | 3.8 |

## Positional Selectors
The six paragraphs below share one style; everything that differs is selected by position — first, last, and every second — with a small-caps first word thrown in by a sub-block pseudo-element.
[Fea] Selectors address blocks the way CSS addresses elements.
[Fea] Every second paragraph of this role is tinted teal.
[Fea] The base style fills whatever a selector leaves unset.
[Fea] Ranges, steps, and scopes cover the practical patterns.
[Fea] Layering is per-field, most specific selector winning.
[Fea] And the last paragraph signs off in muted italic.

## Sub-block Styling
The drop cap that opened this part — and every part before it — is the most bookish trick in the set, and it is not typed into the text. A sub-block selector in the style sheet, the style named {=code=[#1_Bd.3:letter(3)]}, finds each part's third body block, the paragraph after the kicker and the lead, and sinks its first letter three lines deep. The prose stays clean; the trick lives entirely in the sheet.
[Init] A bare letter pseudo-element raises an initial without sinking it — sized by its own style, inline with the first line.
[Glow] The first typeset line of this paragraph carries small caps and a tint, and the effect ends exactly at the line break, wherever reflow puts it — resize the measure and the styling follows the line.

## Boxes, Icons & Marks
[Panel] A single-block box: this ordinary paragraph names a style whose block chrome draws a panel — fill, border, radius, accent bar — inset to the paragraph, with normal spacing outside.
[RuleRow] A bottom-only border is the list-separator idiom.
[RuleRow] Per-side borders switch each edge independently.
[RuleRow] Top plus bottom caps a category; all four is a box.
[Marked] The glyph in this paragraph's corner is a style icon on the nine-point box grid — content untouched.
[Sealed] And behind this paragraph, the document's mark is stamped as a watermark: centered, faded, and owned entirely by the style.
#### Inside a Section Box
A block style matching a heading style boxes the heading's whole subtree — this heading, this paragraph, and the list below share one panel.
- Boxes nest and layer by heading level
- Fills accept tokens and gradients

% ============================================================ PART VI
# Frames & Regions
[Kick] PART SIX OF SIX · THE PAGE, FRAMED
[Lead] A region is a column with author-declared geometry and its own flow: a sidebar, a band, a glass panel, a rail. This closing part declares fourteen frames across eight sets, routes prose into them, wraps text around them, and layers them — all from the style block.
Regions are the compendium's last instrument, and its quietest power. A named frame is declared beside the headers and footers — page furniture, riding the same counter — and content is routed into it from a style, exactly as every look in this book has been assigned. The geometry is always declared, never measured from the content, which is why a frame can narrow the body, paginate its own interior, and still never corrupt the flow around it.[idx:Concepts:Regions]
Watch the left edge. The dark strip running the full height of this page is the part's first region — forty points wide, rotated to read from the foot of the page, and bled through three trim edges. Each section that follows swaps in a new set of frames the way earlier parts swapped their running headers, and every demonstration narrates itself as it happens.

[SpineT] THE ORD COMPENDIUM · PART VI · A REGION IS A COLUMN WITH DECLARED GEOMETRY

[RSet] FRAME SET № 8 · PLACE=RIGHT · 118 PT · FIT=CONTENT
## Sidebars, Three Ways
The wide right margin of this book has carried sidenotes since Part One; a named region upgrades the same real estate to a true frame — chrome referenced from a block style by name, a content cursor of its own, and pagination that never drops a record. Content arrives three ways. The first is a single tagged line:
[SideNote] ① A tagged line routes one record into the frame.
The second is a bare style tag, which absorbs the lines that follow it as one group:
[SideNote]
② A bare tag opens a group.
Every line until a blank stacks here, in document order.

The third needs no style at all — an inline directive pair fences a span, the way a column region opens and closes:

REGION|side
③ These lines rode an inline fence — no style tag anywhere.
The fence closes; the body resumes.
REGION|1

And a heading style carrying the routing key takes its entire subtree along — the whole section, heading first:
### [SbH] The Field Card
This heading became the card's title, and this paragraph followed it in — a whole section, routed.
### The Measure, Resumed
The section route closed at the heading above, and the body owns the full measure again. When a routed run outgrows its frame it continues in the same frame on the next page — overflow is continue by default, loudly clipped or returned to the body only by request — and a frame placed outer or inner swaps sides with the binding on duplex stock.

[RSet] FRAME SET № 9 · TWO BANDS & A HUNG BADGE · ANCHOR=AFTER
## Bands, Stacked & Hung
[HeroK] MERIDIAN INSTRUMENTS · SEASON DOSSIER
[HeroT] The season, banded
[DeckT] The second band never states a position — its top snaps to the hero's bottom, and the badge hangs from the seam.
[BadgeN] 941
[BadgeL] INSTRUMENTS AFIELD
Three frames compose this page and only the first declares a vertical position. The gradient hero reserves the top of the page and centers its two routed lines in the band; the deck beneath it is anchored after the hero, so its top is the hero's bottom plus a gap; the badge is anchored after the deck and then lifted by a negative offset, which is why it straddles the seam.
The paragraph you are reading entered the page beside that badge and snapped to the wider left side of it — the rectangle reserves, the body wraps, and the text returns to the full measure the moment it clears the card's lower edge.
Reservation is set-wide: both bands push the body down by exactly their stacked heights on every page of this section, which is one page, because the next section declares the next set.

[RSet] FRAME SET № 10 · PLACE=XY · RESERVE=1 · WRAP=SNAP
## The Pull Panel
[PullT] “The rectangle states its geometry; the paragraph finds the wider side and keeps reading.”
[PullA] SIDE-SNAP · THE DEFAULT WRAP
A fixed rectangle is the bluntest of the placements — x, y, width, height, stated outright — and the most composed. The panel on the right of this page is one declaration: a reserved rect flush with the body's right edge, wearing a referenced chrome whose top corner is cut at forty-five degrees and whose left edge carries the part's terracotta bar.
This paragraph began above the panel at the full measure, entered its band, and narrowed to the left strip without a break in the line pitch — the straddling line keeps its natural position, and the wrap simply begins where the rectangle does.
Side-snap is the default answer to a hole in the text: the body takes the single wider side and leaves the narrow gap as whitespace, and any strip thinner than eight percent of the page is not generated at all — below that floor the band reserves the full width and the text resumes underneath.
Below the rectangle's bottom edge the measure widens again, and the page closes the way it opened, at full width, with the panel sitting in the text like a plate set into a wall.

[RSet] FRAME SET № 11 · WRAP=STRIPS · THEN TWO OFFSET RECTS
## The Mini-Span
[TileK] FIELD PLATE № 7
[TileT] The basin at dusk
[PrintQ1] “Last light on the basin.”
[PrintQ2] “Every arc, a season.”
[Flow] The photograph in the middle of this page is a reserved rectangle whose chrome is the image itself, cover-cropped into the frame by the referenced block style, with a routed kicker and title laid over the picture like a caption bar. What matters is the path your eye is on. With the strips wrap, the rectangle's band becomes a small span of columns: this sentence is flowing down the strip on the left of the photograph for the band's full height, and when it reaches the bottom it will rise to the top of the strip on the right and flow down again, exactly as a column region would read.
[Flow] The flow crosses block boundaries inside the band — this second paragraph carried on wherever the first one stood — and a run that ends mid-strip leaves the rest of the band white. A staggered pair under strips would fall back to the snap. The band ends there, and the text resumes underneath.
[Flow] Below, a different arrangement entirely: two prints set side by side and staggered — they share rows but never touch, and each declares the per-line wrap. Where a single print crosses a line, the line simply breaks around it; where the two share a row, the row splits into three — a fragment against each margin and a channel of words running between the prints — and every fragment keeps its justification. Each print also carries a short quote routed over its chrome — white on the terracotta, ink on the gold — the geometry declared underneath.
[Flow] Below the pair the measure knits back — three rectangles, three answers.

[RSet] FRAME SET № 12 · WRAP=BOTH · A CORNER OVERLAP
## Reading Across the Hole
[IsleT] ✦
[Isle2T] TWO RECTS · ONE UNION HOLE
[Flow] The both wrap is the classic picture-in-a-paragraph: every visual line runs across the page and jumps the hole, so the left and right fragments share a baseline and the reading order goes across, then down. The medallion below is a circle only in its chrome — a gold-ruled radial gradient with the oval and square bits set — while the wrap sees its declared rectangle, and each row of this justified paragraph is measured freshly against it.
[Flow] There are two reserved rectangles here, and they overlap at a corner: the pale circle and the small dark card riding its lower shoulder at a higher paint order. Overlapping regions reserve their union regardless of z, so in the shared rows this text jumps one merged hole; above and below the overlap the interval set changes as the rows sweep each frame's edge, and the justification is kept per fragment, on both sides, all the way down.
[Flow] Nothing about the paragraph knows any of this. It is body text with a style; the holes are furniture; and when the band ends the lines quietly reassemble to the full measure, as if the page had never been interrupted.

[RSet] FRAME SET № 13 · Z ORDER · GLASS · AN HONEST CLIP
## Layers & Glass
[GlassK] Z=2 · TINTED GLASS
[GlassT] Glass over the photograph — and the body never moved for either.
[VersoT] VI
[StubT] Clipped stub — five records enter.
[StubT] A fixed frame, parked out in the margin.
[StubT] Each record stacks toward the edge.
[StubT] The frame ends before the records do.
[StubT] What crosses the line is cut, loudly.

Regions may overlap, and an integer decides who paints on top. The photograph band above reserves the body's flow but paints above its plane; the glass card floats over the photograph at a higher z with an alpha fill, so the image reads through it; and the routed caption rides the glass in white.
Behind this paragraph, at z minus one, a region is painting the part's numeral in pale ink — the watermark plane, content the body reads straight over. And parked out in the right margin, a short fixed frame is demonstrating the one clip in the whole feature: its last records fall past the frame and are cut, with a warning in the render log, because a region is never allowed to lose content silently.
Three planes, one page: a watermark beneath the text, a photograph above the flow, glass above the photograph. The order is one integer on each declaration, and ties fall back to document order, so the stack is always deterministic.

[RSet] FRAME SET № 14 · RIBBONS & TIMELINES
## The Dossier Rail
[Rib] CONTACT
[RailB] Meridian Instruments Co.
[RailB] Field Office, Basin Camp
[RailB] dispatch@meridian.co
[Rib] STATIONS
[RailB] 22 on the high line
[RailB] 9 on the headlands
[RailB] 17 in the basin
[Rib] THE YEARS
[RailT] 2019 — the first unbroken season.
[RailT] 2022 — the network doubles.
[RailT] 2024 — one hundred stations.
[RailT] 2026 — the season in this book.
The navy rail on the left is a reserved frame, bled to the trim at its side and its foot, and everything inside it was routed from styles: the terracotta ribbons span the rail and overhang its edge by eighteen points — a per-block chrome extension toward and past the frame — and the year entries fuse their accent bars into one continuous white line with a node per record, the timeline treatment, running inside a frame.
The same treatment works at body scale. These four cards fuse into a teal rail beside the narrowed measure:
[TLine] Declared — the frame's geometry is stated in the sheet, never measured.
[TLine] Routed — content reaches the frame from a style, or an inline fence.
[TLine] Wrapped — the body snaps, strips, or reads across the hole.
[TLine] Layered — planes stack by one integer, and alpha does the rest.
A timeline is not a region and a region is not a timeline; the rail look is block chrome, the frame is furniture, and because the two are orthogonal you may have either, or both, in the same declaration — which is precisely what this page is doing.

[RSet] FRAME SET № 15 · NONE — THE FURNITURE CLEARS
## The Colophon
One last declaration closes the tour: this page's region set is the explicit none. The furniture clears, the frames are gone, and the page is one quiet column again — which is its own demonstration, because absence, too, is declared.
***
[Sign] Meridian
[SignSub] SET IN GARAMOND, MONTSERRAT & SPACE GROTESK · ONE MASTER STYLE
[Led]
Text styles defined | 120
Block styles defined | 56
Named regions declared | 14
Page sets in rotation | 15

The back matter that follows — the lists of figures and tables, and the index — was generated, not written.[idx:Concepts:Back matter]

Compendium

A book-length tour with full front and back matter, running heads, a generated contents list and a real index.

  • 46 pages
  • Portrait · 612 x 792 pt
  • 4.4 MB
Open the PDF

Download the PDF·605 lines of content produced this

Flat Charts Gallery

Every kind of chart, one per panel

Four pages of charts: lines, splines, stacked areas and scatter; grouped, stacked, percent, diverging and horizontal bars with a bar-and-line combination; pies and donuts with leader labels and center totals; and the same charts restyled with palette colors, gradient fills, a dark panel and a sparkline.

Flat Charts Gallery, the gallery design: page one
# Cartesian — lines, splines, areas, scatter
COL|2|50|50|8
| Year [X] | North [Line] | South [Line] | Inland [Line] |
| 2019 | 42 | 30 | 18 |
| 2020 | 48 | 33 | 22 |
| 2021 | 55 | 31 | 29 |
| 2022 | 61 | 38 | 33 |
| 2023 | 74 | 41 | 35 |
| 2024 | 82 | 47 | 44 |
CHART|Line with direct end labels|0.62|1|{legend=end lw=2}
| Month [X] | Throughput [Spline] |
| 1 | 12 |
| 2 | 19 |
| 3 | 15 |
| 4 | 28 |
| 5 | 24 |
| 6 | 36 |
| 7 | 33 |
| 8 | 41 |
CHART|Spline: gradient fill, vertex dots|0.62|1|{fill=gradient points=1 legend=none}
| Year [X] | Hydro [Area] | Wind [Area] | Solar [Area] |
| 2019 | 30 | 12 | 4 |
| 2020 | 31 | 16 | 7 |
| 2021 | 32 | 21 | 12 |
| 2022 | 33 | 27 | 19 |
| 2023 | 34 | 32 | 28 |
| 2024 | 35 | 38 | 39 |
CHART|Stacked areas: generation mix|0.62|1|{}
| Hours [X] | Readings [Scatter] | Fit [Line] <#8A8F98 lw=1.2 dash> |
| 1 | 52 | 50 |
| 2 | 61 | 58 |
| 3 | 70 | 66 |
| 4 | 69 | 74 |
| 5 | 85 | 82 |
| 6 | 88 | 90 |
| 7 | 99 | 98 |
CHART|Scatter with a dashed fit line|0.62|1|{legend=bottom}
COL|1
PAGEBRK
# Bars — grouped, stacked, percent, horizontal
COL|2|50|50|8
| [BarCategories] Quarter | Field [Bar] | Lab [Bar] | Marine [Bar] |
| Q1 | 34 | 21 | 9 |
| Q2 | 41 | 24 | 12 |
| Q3 | 52 | 22 | 17 |
| Q4 | 61 | 27 | 21 |
CHART|Grouped bars, value labels|0.62|1|{labels=1}
| [BarCategories] Quarter | Field [StackedBar] | Lab [StackedBar] | Marine [StackedBar] |
| Q1 | 34 | 21 | 9 |
| Q2 | 41 | 24 | 12 |
| Q3 | 52 | 22 | 17 |
| Q4 | 61 | 27 | 21 |
CHART|Stacked bars, totals labeled|0.62|1|{labels=1}
| [BarCategories] Quarter | Field [PercentBar] | Lab [PercentBar] | Marine [PercentBar] |
| Q1 | 34 | 21 | 9 |
| Q2 | 41 | 24 | 12 |
| Q3 | 52 | 22 | 17 |
| Q4 | 61 | 27 | 21 |
CHART|Percent-normalized stacks|0.62|1|{}
| [HBarCategories] Region | Budget [HBar] |
| Highlands | 128400 |
| Coast | 96100 |
| Basin | 74800 |
| Ranges | 41200 |
| Delta | 22700 |
CHART|Horizontal bars, SI labels|0.62|1|{labels=1 format=si legend=none}
| [BarCategories] Product | Change [Bar] |
| Alpha | 12 |
| Beta | -7 |
| Gamma | 23 |
| Delta | -14 |
| Epsilon | 5 |
CHART|Diverging: negatives below zero|0.62|1|{labels=1 legend=none}
| [BarCategories] Quarter | Revenue [Bar] | Margin [Line] <$accent lw=2> |
| Q1 | 40 | 22 |
| Q2 | 52 | 25 |
| Q3 | 49 | 31 |
| Q4 | 65 | 36 |
CHART|Combo: bars with a line overlay|0.62|1|{}
COL|1
PAGEBRK
# Pies and donuts
COL|2|50|50|8
| [Names] Region | Share [Pie] |
| Highlands | 34 |
| Coast | 27 |
| Basin | 22 |
| Ranges | 17 |
CHART|Pie with leader labels|0.72|1|{}
| [Names] Region | Share [Pie] |
| Highlands | 34 |
| Coast | 27 |
| Basin | 22 |
| Ranges | 17 |
CHART|Pie: labels inside, legend right|0.72|1|{pielabels=in legend=right}
| [Names] Channel | Sales [Donut] |
| Direct | 4200 |
| Partner | 2800 |
| Online | 3600 |
| Retail | 1400 |
CHART|Donut with center total|0.72|1|{center=total centersub=Total_sales format=si}
| [Names] Segment | 2024 [Donut] | 2022 [Donut] |
| Enterprise | 46 | 38 |
| Mid-market | 31 | 33 |
| Consumer | 23 | 29 |
CHART|Multi-ring donut: outer 2024, inner 2022|0.72|1|{legend=right hole=0.45}
COL|1
PAGEBRK
# Styling — tokens, gradients, dark panels, sparklines
COL|2|50|50|8
| [BarCategories] Quarter | Field [Bar] | Lab [Bar] | Marine [Bar] |
| Q1 | 34 | 21 | 9 |
| Q2 | 41 | 24 | 12 |
| Q3 | 52 | 22 | 17 |
| Q4 | 61 | 27 | 21 |
CHART|Token palette: accent, teal, navy|0.62|1|{palette=$accent,$teal,$navy}
| [BarCategories] Quarter | Field [Bar] | Lab [Bar] |
| Q1 | 34 | 21 |
| Q2 | 41 | 24 |
| Q3 | 52 | 22 |
| Q4 | 61 | 27 |
CHART|Gradient bar fills|0.62|1|{fill=gradient barradius=2.5}
| Year [X] | North [Line] | South [Line] |
| 2019 | 42 | 30 |
| 2020 | 48 | 33 |
| 2021 | 55 | 31 |
| 2022 | 61 | 38 |
| 2023 | 74 | 41 |
| 2024 | 82 | 47 |
CHART|Dark panel: gradient bg, explicit ink|0.62|1|{bg=grad(120,#0D141C,#243F59) ink=#E8EAED palette=$gold,#6CC5B0 legend=end lw=2 gridcolor=#2E4256}
| Week [X] | Load [Spline] |
| 1 | 12 |
| 2 | 19 |
| 3 | 15 |
| 4 | 28 |
| 5 | 24 |
| 6 | 36 |
| 7 | 31 |
| 8 | 44 |
CHART|Sparkline with axis=none|0.3|1|{axis=none fill=gradient lw=2 legend=none}
COL|1

Gallery

Each chart captioned with what it demonstrates, grouped by kind, one kind per page.

  • 4 pages
  • Portrait · 612 x 792 pt
  • 54 KB
Open the PDF

Download the PDF·142 lines of content produced this

Foundations of TCP

A technical course module

A teaching document with a title page, running heads, syntax-highlighted code, protocol diagrams and instructor-only passages living in the same file as the student text.

Foundations of TCP, the student edition design: page one
Foundations of TCP, the lecture deck design: page one
Foundations of TCP, the instructor edition design: page one
# Welcome
## [C] Overview
We are excited that you are diving deeply into one of the most consequential pieces of software ever written. Vint Cerf and Bob Kahn’s 1974 paper *A Protocol for Packet Network Intercommunication* sketched the kernel of what would become TCP, and nearly every byte that crosses the modern Internet still passes through a direct descendant of that design. The fact that you are here, learning the protocol from the inside out, is one more sign that the engineering tradition behind it is alive and well.
The purpose of this workshop is to help you build a thorough mental model of TCP — its goals, its mechanisms, and the trade-offs the designers made. We are not trying to sell you on TCP as a silver bullet. Rather, our aim is to explain what the specification actually says, why it says it, and how to reason about TCP behavior when you are debugging a stalled connection at 2 AM.
## Schedule
[Sched]
Monday | Why Reliability Matters
Tuesday | The Connection Story
Wednesday | The Connection State Machine
Thursday | Flow & Congestion Control
Friday | Specification Statement
Saturday | Capstone Lab & Wireshark Walk-Through

:::teach
Facilitator note: Wednesday runs long. Start the state-machine lab immediately after lunch and hold the last twenty minutes for the packet-trace warm-up.
:::
All who complete the modules, work through the lab notebooks, and pass the capstone packet-trace exercise will be presented with a workshop completion certificate on **Demo Day**. After the demo, all attendees and their teams are invited to a networking lunch.
## Expectations for completion
- Mark on the attendance sheet that you intend to complete the certificate so we can pair you with a lab partner.
- If you haven’t set up a Linux VM with `tcpdump` and Wireshark yet, please do so before module 2.
- Participate in all six Foundations of TCP modules.
- Read RFC 9293 (Transmission Control Protocol) — at minimum sections 3.1–3.10.
- Submit a packet-capture exercise summary.
- Write a one-page reflection on a TCP-related production incident you have seen or read about.
- Meet with a workshop mentor before Demo Day.
>note> If you have not been writing networked code for at least six months, you are still welcome to attend, but we kindly ask you to wait to take the certificate exam until the next cohort. We hold a new cohort every four months. We want time to get to know you as engineers before signing off on your work, and we want you to have time to absorb the material without feeling rushed. That said, completion is not a one-way door — engineers who pass the exam frequently return as mentors. We don’t hold tightly to alumni; if your career leads you elsewhere, we trust your judgment. But we believe knowing one another well is key to a healthy engineering community.
## [D] Affirmations for completion
We expect every workshop participant to affirm the following statements, which we hold dear as core engineering convictions that unite us as practitioners.
COL|2|bal|50|50|7
- Do you acknowledge that networks are fundamentally unreliable, that packets are routinely lost, reordered, duplicated, and corrupted, and that no amount of hope substitutes for explicit acknowledgments?
- Do you believe that protocol specifications, being precise and testable, are the ultimate authority on correct behavior — above intuition, above tribal knowledge, and above what a particular implementation happens to do?
- Do you commit to reading RFCs in their original form rather than relying solely on secondary explanations, and to citing section numbers when you make claims about protocol behavior?
- Do you pledge to always grow in your knowledge of the wire-level reality of the systems you build, depending on packet captures and reproducible experiments rather than guesswork?
- Do you pledge to take up the discipline of writing code that is robust to the worst the network can throw at it, treating every recv() as potentially partial and every send() as potentially blocked?
- Do you commit to collaborating openly with other engineers, sharing captures and reproductions, and watching out for one another when systems misbehave under load?
- For the cohort: Do you commit to welcoming new members, encouraging their curiosity, and working together to represent good engineering practice in the broader community?
COL|1
# [B] Why Reliability Matters
Reliable networking demands clarity about the underlying medium and clarity about the contracts a transport protocol offers, because everything that runs on TCP — HTTP, TLS, SSH, SMTP — leans on those contracts.
## **Every** packet on a real network can be **lost, reordered, duplicated, or corrupted**
[A] An unreliable substrate is the key reality that makes a transport protocol necessary in the first place.
In RFC 1122 and again in RFC 9293, the IETF emphasizes a **robust transport layer**: the network underneath TCP is permitted to do almost anything short of inventing data out of thin air. Therefore, it is of utmost importance that we grasp the failure modes with engineering clarity, and that each protocol mechanism we study has been justified against a specific failure it was designed to address.
## A definition of reliability
TCP provides a **reliable, ordered, byte-stream** service over an unreliable packet-switched network. Concretely, this means that bytes written by one endpoint will, barring a connection abort, be delivered to the peer exactly once, in order, with corrupted segments retransmitted, duplicate segments discarded, and reordered segments reassembled — without the application having to manage any of that.
## Reliability begins with the realities of **the IP layer**
There are many ways to break down what a transport must do. The contract does not change, however: the IP layer makes only a best-effort delivery promise, and TCP must compensate.
### IP must be **honestly understood**
#### IP is a *best-effort* protocol; it does not retransmit, reorder, or detect duplicates – RFC 791 §1.4
#### If we do not respect what IP guarantees and what it doesn’t, we will design protocols that work in the lab and fail in the wild – RFC 1122 §1.1.3
### The IP layer must be **thoroughly understood**
#### IP is **packet-switched**, not circuit-switched – RFC 791 §1.1
There is no reserved path between sender and receiver. Each datagram is routed independently and may take a different path than its neighbors.
#### IP datagrams may be **fragmented** in transit – RFC 791 §3.2
A router whose outbound MTU is smaller than the datagram may fragment it. Modern stacks rely on Path MTU Discovery to avoid this where possible.
#### IP routes can **change** mid-connection – RFC 1122 §3.3.4
Routes are not fixed. A long-lived TCP connection may traverse a different path each minute as routing tables update.
#### IP datagrams have a **TTL** that decrements at each hop – RFC 791 §3.2
The TTL prevents stale packets from circulating forever; this is the foundation that justifies TCP’s 2×MSL `TIME-WAIT`.
#### IP delivery is **unordered** – RFC 791 §1.4
Two datagrams sent back-to-back may arrive in either order or not at all.
#### IP delivery is **non-exclusive** – RFC 1122 §3.2.2
The same datagram may be duplicated by a misbehaving link or replicated by routing pathologies; receivers must tolerate seeing the same bytes twice.
#### IP can **silently corrupt** payloads – RFC 1122 §4.1.3.4
Although IP has a header checksum, the payload checksum is the responsibility of the transport. End-to-end checksums are not optional in practice.
#### IP says **nothing** about congestion – RFC 2914 §1
The network can drop packets when overloaded, but offers no mechanism to throttle senders. That responsibility falls on TCP.
#### IP is **stateless** at routers – RFC 791 §1.4
Routers do not remember individual flows. Any per-connection state lives at the endpoints.
#### IP supports **multiple address families** – RFC 8200 §1
IPv4 and IPv6 differ in addressing, fragmentation, and option handling, but TCP runs over both unchanged.
[A] IP is exactly what the specification says it is — no more, no less. Its best-effort nature does not negate its usefulness, nor does its statelessness imply unreliability of the network as a whole — it simply pushes reliability to the endpoints, where TCP picks it up.
[A] Unfortunately, if the underlying medium is not honestly understood, no transport protocol layered above it will behave well under stress.
## TCP defines the nature of **the byte stream abstraction**
[KV]
Common belief | TCP delivers messages, framed by send() and recv() boundaries.
Reality | TCP delivers an undifferentiated byte stream; framing is the application’s problem.
### TCP clearly defines the **service** it provides
#### TCP presents a stream, not a message – RFC 9293 §3.1
A single send() may be split across many segments and a single recv() may return data from several sends. Applications that need message boundaries must add length prefixes or delimiters.
#### TCP is **full-duplex** – RFC 9293 §3.1
Each endpoint can send and receive simultaneously; the two directions are largely independent.
#### TCP is **connection-oriented** – RFC 9293 §3.5
Before any data can flow, a three-way handshake establishes shared state on both endpoints.
#### TCP is **point-to-point** – RFC 9293 §3.1
Each connection has exactly two endpoints; there is no broadcast or multicast variant of TCP.
### TCP rightly defines the **guarantees** of the stream
#### Bytes will arrive **in order** – RFC 9293 §3.4
The sequence-number machinery ensures the receiver presents bytes to the application in the order the sender placed them in the stream.
#### Bytes will arrive **without duplication** – RFC 9293 §3.4
The receiver discards segments whose sequence numbers fall before the next expected byte.
#### Lost bytes will be **retransmitted** – RFC 9293 §3.8.1
Until the sender sees an acknowledgment, it will retransmit data on a timer. Acknowledgments are cumulative.
#### Connections are **closed cleanly** – RFC 9293 §3.6
Both directions are torn down explicitly; an unexpected close indicates a real fault.
[A] A protocol that does not provide all of these guarantees is a different protocol. UDP, QUIC, SCTP, and DCCP each make different trade-offs and are useful in their place — but TCP’s contract is what it is, and applications written against TCP should rely on exactly what TCP promises and no more.
## Reliability culminates in the **end-to-end principle**
### The Internet is built on **endpoint responsibility**
#### Reliability is properly an end-to-end property – Saltzer, Reed & Clark (1984)
#### The network can help with performance, but cannot guarantee correctness on behalf of endpoints – RFC 1958 §2.1
### Reliability is achieved by **acknowledgment and retransmission**
#### Every byte sent is sequenced; every received byte is acknowledged – RFC 9293 §3.4
#### Without an acknowledgment within a calculated timeout, the sender retransmits – RFC 6298 §2
TCP’s retransmission timeout (RTO) is calculated from a smoothed RTT estimate plus a multiple of its variance.
#### Lost retransmissions are themselves retransmitted, with the timer doubled – RFC 6298 §5
[Coda] Reliability demands clarity about what the lower layer guarantees and what it does not, because every higher-level protocol assumes TCP got the basics right.
# The Connection Story
TCP is more than a checksum and a sequence number; it is the story of how two endpoints come to agreement, exchange data, and part ways without losing track of what has and hasn’t been delivered.
## What is a connection again?
[A] We can never remind ourselves of the basic mechanics too often!
A TCP connection is identified by the four-tuple `(source IP, source port, destination IP, destination port)` and is bound to a pair of *sequence-number spaces* — one for each direction. Once established, the connection persists until both directions are closed or until the connection is aborted.
![TCP three-way handshake (Wikimedia Commons)](sample-svg/tcp-handshake.svg){scale=0.7 align=center}
## The connection is meant to **frame** every byte we send
### A handshake establishes shared **initial sequence numbers**
#### The handshake is the SYN, SYN-ACK, ACK exchange – RFC 9293 §3.5
#### Initial sequence numbers should be unpredictable to mitigate spoofing – RFC 6528 §3
#### Three-way is the minimum that defends against delayed duplicates – RFC 9293 §3.4.1
A two-way handshake cannot reject an old SYN that arrives late. The third ACK is what closes that loophole.
### How does the handshake **protect us**?
#### From accepting spurious segments from a previous incarnation of the same four-tuple – RFC 9293 §3.4.1
The 2×MSL `TIME-WAIT` and the unpredictability of ISN together ensure that segments from a previous connection are not mistaken for the new one.
#### From off-path attackers injecting data – RFC 5961 §1
By guessing only one of the two sequence-number spaces, an attacker cannot inject acceptable data; they would have to guess both.
#### From establishing connections to peers that aren’t actually listening – RFC 9293 §3.5.2
A peer that has not opened the port responds with RST, which the initiator treats as an immediate failure.
### As we **send** bytes, the receiver **acknowledges**
#### Cumulative ACKs say "I have received everything up through byte N" – RFC 9293 §3.4
#### Selective ACKs (SACK) communicate that out-of-order ranges have been received – RFC 2018 §3
SACK lets the sender retransmit only the missing range, rather than everything from the loss point onward.
#### The receive window tells the sender how much more it may send without waiting – RFC 9293 §3.4
A zero window halts the sender until the receiver advertises space.
[A] Each segment carries one or more of these signals: SYN, ACK, FIN, RST, PSH, URG. The flags are the protocol’s vocabulary; the sequence and acknowledgment numbers are the grammar.
## Below the abstraction: the **TCP segment header**
### A TCP segment carries a fixed twenty-byte header plus options
```diagram TCP Segment Header (RFC 9293 §3.1)
   0                   1                   2                   3
   0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |          Source Port          |       Destination Port        |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                        Sequence Number                        |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                    Acknowledgment Number                      |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  | Data  |       |C|E|U|A|P|R|S|F|                               |
  | Off   | Rsvd  |W|C|R|C|S|S|Y|I|            Window             |
  |       |       |R|E|G|K|H|T|N|N|                               |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |           Checksum            |         Urgent Pointer        |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                    Options                    |    Padding    |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  |                             Data                              |
  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
```
[A] The header is small because the design intent is to make TCP cheap on the wire and rich in semantics — every field earns its place.
### Famous quotes worth memorizing
>quote>Postel’s Robustness Principle> *Be conservative in what you do, be liberal in what you accept from others.* — RFC 793 §2.10
>quote>RFC 1122 reminds us> *At every layer of the protocols, there is a general rule whose application can lead to enormous benefits in robustness and interoperability: be conservative in what you send, be liberal in what you receive.* — RFC 1122 §1.2.2
>quote>David Clark, MIT> *The Internet is held together by software, not by central coordination, and the only reason it scales is that software is willing to drop, retransmit, and try again.* — paraphrased
## We expect every connection to **transition** through a defined set of states
### Why are state machines so powerful?
#### State machines are precise
A connection is in exactly one state at a time, and each state defines exactly which segments are valid and what the response should be. Ambiguity is the enemy of debugging.
#### State machines are testable
Because the rules are explicit, you can write conformance tests that drive an implementation through every transition and assert the correct output.
#### An example
Two engineers can argue all afternoon about whether a server is "stuck"; but if you can show that the connection is in `CLOSE-WAIT` and the server has not yet called close(2), the argument ends.
### Where the state machine is defined
#### TCP state transitions are normative – RFC 9293 §3.6
The diagram in section 3.6 of RFC 9293 is not illustrative; it is the definition.

#### A reference state diagram in ASCII
```diagram TCP States (simplified)
                             +----------+
                             |  CLOSED  |
                             +----+-----+
                                  |
                      passive open|     |active open
                                  v     v
   +----------+   recv SYN   +----------+   send SYN
   |  LISTEN  +------------->| SYN_RCVD |   +----------+
   +----------+              +----+-----+   | SYN_SENT |
                                  |         +----+-----+
                         recv ACK |              | recv SYN+ACK
                                  v              v
                             +----------+    send ACK
                             |  ESTAB.  |<-------+
                             +----+-----+
                                  |
                         close()  |  recv FIN
                                  v
                             +----------+
                             | FIN_WAIT |
                             +----+-----+
                                  |
                                  v
                             +----------+
                             |TIME_WAIT |
                             +----------+
```
## Endpoints become participants in TCP’s **larger story** through their sockets
### We code against TCP through the **sockets API** – RFC 3493 §3
We are made participants in this protocol when our applications call socket(2), bind(2), listen(2), accept(2), connect(2), send(2), and recv(2). The kernel manages the state machine for us.
### A minimal echo server, in C
```c`Echo Server (BSD sockets)
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <string.h>

int main(void) {
    int s = socket(AF_INET, SOCK_STREAM, 0);
    int yes = 1;
    setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof yes);

    struct sockaddr_in addr = {0};
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = htonl(INADDR_ANY);
    addr.sin_port = htons(7);
    bind(s, (struct sockaddr *)&addr, sizeof addr);
    listen(s, 16);

    for (;;) {
        int c = accept(s, NULL, NULL);
        char buf[1024];
        ssize_t n;
        while ((n = recv(c, buf, sizeof buf, 0)) > 0)
            send(c, buf, n, 0);     // echo back
        close(c);
    }
}
```
### Active and passive opens **share** the same state machine – RFC 9293 §3.10.1
The server reaches `ESTABLISHED` via `LISTEN → SYN_RCVD`; the client via `SYN_SENT`. Both arrive in the same state, ready to exchange data.
### **All implementations** must implement the same state transitions
A conforming TCP, whether on Linux, BSD, Windows, or a microcontroller running lwIP, must obey the same state machine. Compatibility comes from the specification, not from the implementation.
[Coda] We want the connection lifecycle to be front and center, because every production incident in TCP eventually traces to a state the operator did not realize the connection was in.
# The Connection State Machine
The TCP state machine is the ground truth at the center of every connection — RFC 9293 §3.6
## Definition of a connection
### What a connection **is**
[KV]
Definition | A TCP connection is the shared state held by two endpoints, indexed by the four-tuple, sequenced by the initial sequence numbers, and governed by the state machine in RFC 9293 §3.6.
Explanation | The connection is thoroughly bilateral — established by mutual handshake, maintained by mutual acknowledgment, and torn down by mutual close. Neither endpoint owns the connection; both do.
### What a connection **does**
A TCP connection moves bytes reliably and in order. It detects loss, drives retransmission, manages flow and congestion, signals out-of-band conditions via the URG flag, and either closes cleanly or aborts loudly. We will look at flow and congestion control in the next module; in this module we focus on what the connection *is*.
[A] Because a connection is unlike any other object in your program, the specification primarily describes it through four overlapping abstractions: the four-tuple, the sequence-number spaces, the windows, and the state machine.
## A connection is a **four-tuple,** unique on the wire
### Each connection is identified by `(srcIP, srcPort, dstIP, dstPort)` – RFC 9293 §3.4
Two connections with the same four-tuple cannot coexist; this is why `TIME-WAIT` exists, to prevent the next incarnation of a four-tuple from receiving stale segments from the previous one.
### As listening sockets we accept **many** connections sharing one local endpoint – RFC 3493 §6.1
A server listening on `(*, 80)` may have thousands of connections active, each distinguished by its remote endpoint.
### The kernel uses the four-tuple as a **hash key** – Linux TCP source
On Linux and BSD, the established connection table is a hash keyed on the four-tuple. Lookup is O(1) amortized.
### Misuse of the four-tuple **is** a real bug – RFC 6056 §3
Failing to randomize source ports on a NAT or load balancer can cause four-tuple collisions and connection failures.
## A connection is a **pair of sequence-number spaces** governed by the windows – RFC 9293 §3.4
Each direction has an independent 32-bit sequence-number space. Wrapping is real on fast links, which is why timestamps (RFC 7323) extend the effective sequence space.
## A connection is a **bidirectional contract** until both sides FIN – RFC 9293 §3.6
A half-closed connection is legal: one side has sent FIN, the other has not. The receiver application can keep reading until it has consumed the last byte.
## A connection is the **smallest unit** of TCP behavior, holding the contract between endpoints
### The ultimate purpose of a connection is to **deliver bytes reliably** – RFC 9293 §1.5
Everything else — windows, options, congestion control — exists to support that purpose.
### TCP **fills** the connection with state – RFC 9293 §3.4
SND.UNA, SND.NXT, SND.WND, RCV.NXT, RCV.WND, and the rest are all variables maintained per-connection.
### The connection **transitions** through eleven states – RFC 9293 §3.6
[St]
CLOSED
LISTEN
SYN-SENT
SYN-RECEIVED
ESTABLISHED
FIN-WAIT-1
FIN-WAIT-2
CLOSE-WAIT
CLOSING
LAST-ACK
TIME-WAIT
### The **rules** govern transitions
A SYN in the wrong state is rejected with RST; an ACK in `LISTEN` is rejected with RST; a FIN in `ESTABLISHED` moves the receiver to `CLOSE-WAIT`.
### We are **bound** to peers
Each connection ties two endpoints together; an action by either is observable by the other within roughly one RTT.
### We expose the connection **visible** to the application via the socket
The socket file descriptor is the application’s handle on the underlying state. Closing the descriptor triggers the close half of the state machine.
### We represent the connection’s **liveness** through keepalives – RFC 9293 §3.8.4
A connection without traffic is not detectably dead. Keepalive probes, sent at long intervals, surface dead peers.
## The **mission** of a connection is to deliver bytes reliably end-to-end – RFC 9293 §1.5
[A] The ultimate goal is for the receiver application to read exactly what the sender application wrote, in order, without duplication.
### A connection **fragments** the byte stream into segments – RFC 9293 §3.7.1
Segmentation is constrained by the MSS option negotiated at handshake time and by the path MTU.
### A connection **reassembles** segments at the receiver – RFC 9293 §3.4
Out-of-order segments are buffered until the gap fills; then they are passed to the application as a contiguous run of bytes.
But reassembly without flow control is dangerous, since a fast sender can exhaust the receiver’s buffer (see RFC 9293 §3.8.6).
The receive window is the receiver’s mechanism for telling the sender to slow down; the congestion window is the sender’s self-imposed restraint, based on its inference of network conditions.
## Reference reading on connection lifecycle
### RFC 9293 is **canonical** – RFC 9293 §1
RFC 9293 supersedes the venerable RFC 793 and incorporates corrections accumulated over four decades. Keep it within arm’s reach; we will help each other follow it.
### The goal is a **clean** state machine – Stevens, *TCP/IP Illustrated, Vol. 1*
Implementations should not invent states; the specification’s eleven states are sufficient. Any "extra" state in an implementation tends to indicate a misunderstanding.
### We want every transition to be **defensible from the spec** – RFC 9293 §3.6
Each transition should be justifiable from the spec. If you cannot point to the rule, the implementation is probably wrong.
### We need each other because TCP bugs are **subtle** – Cerf & Kahn (1974)
Every implementation has been refined over decades by review and bug fixing. We fight subtle bugs by sharing packet captures and reading the spec together.
### The spec is the only **standard** – RFC 9293 §1.3
Implementations may add extensions, but the wire-level contract is fixed by the spec.
[Coda] The TCP state machine is the centerpiece of every TCP connection — RFC 9293 §3.6
# Flow & Congestion Control in Practice
A well-written network service prioritizes correct backpressure as we partner with the kernel to keep the network healthy.
## How do we treat **the network** in our designs?
### Since the network is shared, we **rate-limit** ourselves – RFC 5681 §2
Senders must reduce their offered load when they detect loss, because loss is the network telling us it is overloaded.
### Since buffers are finite, we **respect** the receive window – RFC 9293 §3.8.6
A sender must never send more than the receiver advertised, no matter how fast its own NIC is.
### Since congestion is real, we **probe gently** – RFC 5681 §3.1
Slow Start grows the congestion window exponentially until loss is observed; this is intentionally cautious.
### Since fairness matters, we **back off multiplicatively** – RFC 5681 §3.1
On loss, the congestion window is halved (or set to 1 in some recovery paths). The combination of additive increase and multiplicative decrease (AIMD) yields fairness across competing flows.
| RTT round [X] | Congestion window [Line] |
| 0 | 1 |
| 1 | 2 |
| 2 | 4 |
| 3 | 8 |
| 4 | 16 |
| 5 | 32 |
| 6 | 16 |
| 7 | 17 |
| 8 | 18 |
| 9 | 19 |
| 10 | 20 |
| 11 | 21 |
| 12 | 22 |
| 13 | 23 |
| 14 | 24 |
| 15 | 12 |
| 16 | 13 |
| 17 | 14 |
| 18 | 15 |
| 19 | 16 |
| 20 | 17 |
| 21 | 18 |
| 22 | 9 |
| 23 | 10 |
| 24 | 11 |
CHART|The AIMD sawtooth — slow start, then additive increase, multiplicative decrease (idealized)|0.3|1.0|{palette=$rust legend=none table=hide ymin=0 vline=6:loss;15:loss;22:loss}
## What are the **rhythms** of a healthy connection?
A rhythm is a behavior the implementation performs continuously. These behaviors aren’t optional in production code.
### We **ack** what we receive – RFC 9293 §3.8.6
Acknowledgments are how the sender learns its data arrived. Delayed ACKs (up to 500ms) reduce ACK traffic but must not be applied to every segment.
### We listen for **window updates** – RFC 9293 §3.8.6
A receiver that has freed buffer space sends a window update so the sender can resume.
### We **retransmit** when ACKs go missing – RFC 6298 §5
The retransmission timeout is exponentially backed off on repeated loss.
### We **partner** with the OS – Linux `tcp(7)`
Tunables like `tcp_rmem`, `tcp_wmem`, `tcp_congestion_control`, and `tcp_no_metrics_save` let operators adjust behavior to their environment.
### We **stay in step** with the receiver – RFC 9293 §3.4
The sender’s decisions are informed by what the receiver tells it. There is no point in pushing data faster than the peer can absorb.
### We **estimate** the round-trip time – RFC 6298 §2
SRTT and RTTVAR are continuously updated based on observed ACK timings; RTO is computed from them.
### We **react** to congestion signals – RFC 3168 §5
ECN marks (when negotiated) let the network signal congestion without dropping packets.
### We do **not** congestion-collapse – RFC 896 §1
Pre-TCP networks suffered congestion collapse because senders kept retransmitting into already-overloaded networks. AIMD prevents this.
### We **make room** for others – RFC 5681 §3.1
A polite sender backs off generously on loss; this is what allows competing flows to coexist.
### We **pay** for correctness – RFC 9293 §3.5.2
A clean close costs an RTT and 2×MSL of `TIME-WAIT`. Aborting with RST is faster but loses data; we do the right thing even when it’s expensive.
[Coda] Healthy networking prioritizes correct backpressure as we partner with the kernel and the network to keep traffic flowing for everyone.
# Reliability Made Visible in Hardware
Hardware-level diagrams help us understand things that are otherwise invisible at the software level.
COL|2|bal|50|50|8
## A pragmatic example - **the line driver**
Even at the lowest level, reliable communication is enabled by analog circuitry that conditions the signal. Below is a basic AC-coupling and termination network used at the entrance of an Ethernet line interface.
```circuit Ethernet AC-Coupled Line Termination {scale=115}
       +--+resis+--+--+capac+--+
       a                       |
       c                       +eg
       v
       s
       r
       +
```
The capacitor blocks DC bias; the resistor terminates the line at its characteristic impedance. Without these, the receiver sees reflections and the link silently corrupts data.
## A second example - **the supply rail decoupling**
Every digital pin transition draws current. Without local decoupling, supply rail noise corrupts logic levels and packet checksums fail intermittently.
```circuit Power Supply Decoupling {scale=115}
       |
    +--+--+
    |     |
    +resis+
    |     |
    +-----+
    |     |
    +capac+
    |     |
    +-----+
    |     
    +eg  
```
[A] The voltage divider sets a stable bias; the bypass capacitor sinks transient currents. Reliable bytes on the wire start with a clean power rail at the chip.
COL|1
[Coda] Software reliability rests on hardware reliability. The transport layer cannot recover from corruption it cannot detect, and corruption is much easier to detect than to debug.
# [B] Specification Statement
## The Purpose of a specification statement
The primary purpose of our specification statement is to foster shared understanding so that, as practitioners, we all agree on the behavior our implementations must exhibit. Since every workshop participant affirms this statement, we can be confident that we are unified in our reading of the specification.[^1] The statement also serves as a guard against quiet drift, protecting our implementations from subtle deviations that creep in over time.[^2]
The specification statement should not be so narrow that it excludes implementations we want to interoperate with. But it should also not be so wide that it permits behavior that breaks the contract. Thus this statement centers on the wire-level guarantees that every TCP must provide. Good engineering — and therefore a good specification statement — always holds the various trade-offs in tension and is careful to qualify in what sense each guarantee holds. For example, "TCP delivers data reliably" is one of the most foundational claims in networking, yet *reliable* doesn’t mean *guaranteed*: a network partition can still cause an abort. To not hold reliability in proper relationship with timeouts and aborts is to misunderstand the true nature of TCP’s guarantee.
## The Service
TCP is a **reliable, in-order, byte-stream, connection-oriented, full-duplex transport** layered on a best-effort packet network.[^3] It establishes connections via a three-way handshake,[^4] delivers bytes via cumulative and selective acknowledgment,[^5] terminates connections via a four-way close,[^6] and provides flow control and congestion control mechanisms that allow many concurrent flows to share a network without collapse.[^7]
## The Specification
The Transmission Control Protocol is normatively defined by **RFC 9293**, which obsoletes RFC 793, RFC 879, RFC 2873, RFC 6093, RFC 6429, RFC 6528, and RFC 6691.[^8] We rely on RFC 9293 as our primary reference and treat it, together with its cited dependencies, as the authoritative description of TCP behavior.[^9] Without this document, interoperability would be a coincidence rather than an engineering property.[^10]
We believe that an implementation conforms to TCP only when it implements every MUST-level requirement in RFC 9293 §3 and §4 and does not violate any MUST-NOT.[^11] SHOULD-level requirements may be relaxed only with documented justification, and in interoperability testing the resulting implementation must still cooperate correctly with conforming peers.[^12]
We believe that the IETF process — open mailing lists, public drafts, working group review, and rough consensus — is what produces specifications worth implementing.[^13] An RFC that has not been through that process should be treated as a single party’s proposal, not a community standard.[^14]
We believe that since the specification is a contract among independent implementers, behavior outside the spec is undefined and must not be relied upon.[^15] Code that depends on the quirks of one particular stack will eventually meet a different stack.
We believe that errata, when published, are part of the specification, and that implementers are responsible for tracking them.[^16]
## The doctrine of segments
We believe that a TCP segment is the unit of communication on the wire,[^17] consisting of the TCP header followed by zero or more payload bytes.[^18] The header has a fixed twenty-byte portion plus optional extensions[^19] and is checksummed over a pseudo-header that includes the IP source and destination addresses.[^20] The checksum is mandatory and must be validated by the receiver.[^21]
## Sequence numbers
We believe that every byte transmitted on a TCP connection is assigned a 32-bit sequence number that increases monotonically (modulo 2³²) as data flows.[^22] The connection’s initial sequence number is chosen unpredictably[^23] and the SYN and FIN flags each consume one sequence-number slot.[^24] PAWS (Protection Against Wrapped Sequences) using TCP timestamps protects long-lived high-bandwidth connections against wrap-around ambiguity.[^25]
## Acknowledgments
We believe that the receiver acknowledges contiguous bytes cumulatively via the ACK field of the header,[^26] and may additionally report non-contiguous out-of-order ranges via the SACK option.[^27] An acknowledgment is a positive statement: it asserts that the named bytes have been received and stored.[^28] An unacknowledged byte must be assumed lost only after the retransmission timer expires or after sufficient duplicate ACKs trigger fast retransmit.[^29]
## Flow control
We believe that the receiver advertises its remaining buffer space in the Window field of every segment it sends,[^30] scaled by the WSCALE option negotiated at handshake time.[^31] The sender must not transmit more unacknowledged bytes than the advertised window permits.[^32] When the window reaches zero, the sender enters persist mode and probes periodically until the receiver opens the window again.[^33]
## Congestion control
We believe that on top of flow control, the sender maintains a congestion window driven by an algorithm such as Reno, CUBIC, or BBR.[^34] The effective send window is the minimum of the receive window and the congestion window.[^35] Loss, detected via timeout or duplicate ACKs, is treated as a signal of congestion and triggers reduction of the congestion window.[^36] ECN, when negotiated, lets routers signal congestion explicitly without dropping packets.[^37]
## Reset and abort
We believe that RST aborts a connection unilaterally and immediately,[^38] is appropriate when no graceful close is possible,[^39] and must be validated against the current sequence-number window before being accepted.[^40] Off-path RST injection is a known attack and is mitigated by RFC 5961 challenge ACKs.[^41]
## Things to come
We believe that QUIC and other UDP-based transports complement rather than replace TCP.[^42] The principles in this specification — reliable delivery, ordered streams, flow control, congestion avoidance — recur in all serious transport designs and will outlive any particular wire format.[^43]
# Compatibility with Real Networks
## The goal
The goal of this document is to walk through how the specification interacts with the real-world conditions our deployments will face — NAT, middleboxes, asymmetric paths, lossy wireless — so that we may build software that works in production and not only on the loopback interface.
We will address the topic under three categories: 1) middleboxes and NAT, 2) wireless and lossy links, 3) operational visibility.
## Middleboxes and NAT
Middleboxes — NATs, firewalls, load balancers, deep-packet-inspection appliances — see TCP segments and often modify them. NATs rewrite source IP and source port; some load balancers terminate and re-establish connections; some firewalls strip TCP options they don’t recognize. RFC 8546 articulates the principle that the wire image of a protocol must be treated as the protocol; whatever the middlebox sees becomes part of what implementations must tolerate.
We acknowledge that some otherwise-compliant TCP implementations behave poorly in the presence of options the spec adds later (TFO, MPTCP). This is one of the practical reasons new transport features have moved to QUIC, where ossification is harder.
## Wireless and lossy links
On wired Ethernet, packet loss is overwhelmingly the result of buffer overflow at routers; AIMD interprets it correctly as a congestion signal. On wireless links, loss is often the result of interference, and interpreting it as congestion is wrong — but the kernel has no general way to tell the two apart. ECN, where deployed, helps. So does running a congestion control algorithm such as BBR that infers bandwidth and RTT directly rather than treating loss as the sole signal.
## Operational visibility
Most production TCP problems are diagnosed with `ss`, `tcpdump`, Wireshark, eBPF, and `netstat`. Without those tools, the connection state machine is invisible. Operators should be able to read packet captures fluently and correlate them to the state machine in RFC 9293 §3.6.
We believe an engineer who cannot read a SYN, SYN-ACK, ACK in a `tcpdump` output is not yet ready to debug TCP issues in production. This is not snobbery — it is the same standard we apply to ourselves.
# Sample Capture & Code Repository
## Explanation
As practitioners, we believe that the best way to internalize the specification is to read packet captures alongside the RFC. We provide a sample capture (`tcp-handshake.pcap`) that walks through SYN, SYN-ACK, ACK, three data segments with cumulative ACKs, and a graceful close. The corresponding annotation document maps each segment to a section of RFC 9293.
However, even sample captures cannot replace running your own. We strongly encourage every workshop participant to capture their own production traffic on a non-sensitive endpoint (e.g., a localhost echo server) and step through it byte-by-byte.
:::teach
Facilitator note: open tcp-handshake.pcap in Wireshark before the session starts — the SYN, SYN-ACK, ACK walkthrough lands better live than in screenshots.
:::
At Foundations of TCP, we eagerly welcome questions, captures, and reproductions from any engineer. We welcome all who are willing to read the spec carefully. Yet we also recognize that some kinds of broken behavior require careful attention. Therefore, we have established a triage policy for issues raised against our reference implementation.
## Practices
- An issue against the reference implementation must include a packet capture or a minimal repro program.
- An issue claiming a specification violation must cite the specific RFC and section.
- All proposed fixes must be accompanied by a regression test that fails before the fix and passes after.
- The maintainers and reviewers will be made aware of all open issues affecting protocol correctness.
- The community needs to be informed when correctness issues are found in widely deployed code; however, named affected vendors are disclosed only when the working group chairs believe it to be necessary.
The goal of this policy is not to embarrass any particular implementation, but to ensure that the specification remains the shared ground we all stand on. Good engineering takes shared mistakes seriously, and so we celebrate good repros.
[Coda] If you have any questions about this policy, please contact the workshop organizers.
# Footnotes
[^1]: RFC 1958 §1; RFC 9293 §1
[^2]: RFC 7414 §1
[^3]: RFC 9293 §1.5; Cerf & Kahn (1974)
[^4]: RFC 9293 §3.5
[^5]: RFC 9293 §3.4; RFC 2018 §3
[^6]: RFC 9293 §3.6
[^7]: RFC 5681; RFC 9293 §3.8
[^8]: RFC 9293 §1
[^9]: RFC 9293 §1.3
[^10]: RFC 1958 §3
[^11]: RFC 2119 (key word definitions); RFC 9293 §3
[^12]: RFC 8174 (BCP 14 update)
[^13]: RFC 2026 §1
[^14]: RFC 2026 §3
[^15]: RFC 1958 §2.4
[^16]: RFC 2026 §6.1
[^17]: RFC 9293 §3.1
[^18]: RFC 9293 §3.1
[^19]: RFC 9293 §3.1; RFC 7323 §2
[^20]: RFC 9293 §3.1; RFC 1071
[^21]: RFC 9293 §3.1; RFC 1122 §4.2.2.7
[^22]: RFC 9293 §3.4
[^23]: RFC 6528 §3
[^24]: RFC 9293 §3.4 — note that SYN and FIN consume sequence space even though they carry no data.
[^25]: RFC 7323 §5
[^26]: RFC 9293 §3.4
[^27]: RFC 2018 §3; RFC 2883
[^28]: RFC 9293 §3.4
[^29]: RFC 5681 §3.2; RFC 6298 §5
[^30]: RFC 9293 §3.4
[^31]: RFC 7323 §2
[^32]: RFC 9293 §3.8.6
[^33]: RFC 9293 §3.8.6.1
[^34]: RFC 5681 (Reno); RFC 9438 (CUBIC); Cardwell et al. 2017 (BBR)
[^35]: RFC 5681 §2
[^36]: RFC 5681 §3.1; RFC 6298 §5
[^37]: RFC 3168
[^38]: RFC 9293 §3.5.3
[^39]: RFC 9293 §3.10.4
[^40]: RFC 5961 §3
[^41]: RFC 5961 §4
[^42]: RFC 9000 §1
[^43]: RFC 1958 §2.1

The course book as the class receives it: title page, section numbering, figures with captions, and the instructor material held back.

  • 25 pages
  • Portrait · 612 x 792 pt
  • 399 KB
Open the PDF

Download the PDF·500 lines of content produced all 3 of these

The same module projected at 16:9: each heading stays up while its points arrive one at a time.

  • 372 pages
  • Landscape · 1549 x 871 pt
  • 1.9 MB
Open the PDF

Download the PDF·500 lines of content produced all 3 of these

The identical file with the teaching notes turned on: the passages hidden from the student edition print here, stamped INSTRUCTOR EDITION.

  • 25 pages
  • Portrait · 612 x 792 pt
  • 399 KB
Open the PDF

Download the PDF·500 lines of content produced all 3 of these

Wire, Line & Code

A bench manual of figures made from typed characters

Engineering drawings that arrive as text and nothing else: block diagrams typed as rows of characters, twenty-two circuits spelled out along their own wires from a library of a hundred and eleven component symbols, and eight figures — frequency responses, a phase portrait, truth tables and typeset equations — that the document computes for itself while the page is being made. Not one image file on disk.

Wire, Line & Code, the bench manual design: page one
# Lines That Become Pictures
[Kick] PART ONE OF THREE · ASCII PROMOTED TO VECTOR ART
[Lead] A diagram in this format is not a picture the document carries. It is a rectangle of typed characters — hyphens, pipes, plus signs, a few arrowheads — that the engine reads as geometry and redraws as vector art at the resolution of the page.
Nothing here is a file. Open the source of this document in any editor and every figure in the next twenty pages is sitting there as text you can retype, diff, and merge. That is the whole argument for the format: a drawing that survives version control because it *is* version control's native material.
## The Character Vocabulary
Six classes of character carry the whole notation. Straight runs are hyphens and pipes; corners are plus signs, or a period and an apostrophe when the corner should be round. Everything else is decoration riding on top of a run.
```diagram Runs, corners and the rounded pair {scale=72}
+---------+       .---------.       +---------+---------+
|  square |      (  rounded  )      |  cell   |  cell   |
+---------+       '---------'       +---------+---------+
```
Arrowheads point four ways and attach wherever a run ends. Points come in two weights: a hollow terminal and a solid junction.
```diagram Arrowheads, terminals and junctions {scale=72}
             ^                    o-----*-----o 
             |                    |           |
        <----+---->               *           o
             |                    |           |
             v                    o-----*-----o
```
A run that must cross another without touching it takes a parenthesis — the notation's wire jump. The left crossing below hops; the right one connects.
```diagram A jump beside a junction {scale=72}
        |            |
        |            |
   -----)------------+-----
        |            |
        |            |
```
Diagonals run at the grid's own aspect, so slashes and backslashes close into figures without any hinting.
```diagram Diagonals close a figure {scale=72}
     .---.                +
    /     \              / \
   /       \            /   \
  +---------+          +-----+
                        \   /
                         \ /
                          +
```
The last class is fill. Four block characters give four gray levels, and four quarter-triangles chamfer a solid block — enough to key a drawing without leaving the keyboard.
```diagram Gray levels and corner wedges {scale=72}
  ░░░░░   ▒▒▒▒▒   ▓▓▓▓▓   █████    ◢███◣
  ░░░░░   ▒▒▒▒▒   ▓▓▓▓▓   █████    █████
  ░░░░░   ▒▒▒▒▒   ▓▓▓▓▓   █████    ◥███◤
```

## Worked Sheets
Given that vocabulary, ordinary engineering drawings fall out of it. A block diagram is boxes and arrows; the only discipline is keeping the columns lined up.
```diagram The observing network {scale=70}
      o  field telemetry
      |
      v
+-----+-----+      +-----------+
|   Field   |      |  Ingest   |       .---------.
|   array   +----->|   queue   +----->(  uplink   )----.
+-----+-----+      +-----+-----+       '---------'      \
      ^                  |                               v
      |                  v                         +-----------+
      |            +-----------+                   |  Archive  |
      '------------+  Planner  |<------------------+           |
          retask   +-----------+                   +-----------+
```
Where a drawing is really a table of extents, the gray levels do the work that hatching does on a real sheet.
```diagram Instrument memory map {scale=68}
 0xFFFF  +--------------------------------+
         |████  interrupt vectors    2 kB |
 0xF800  +--------------------------------+
         |▓▓▓▓  program image      224 kB |
 0x8000  +--------------------------------+
         |▒▒▒▒  calibration table   16 kB |
 0x4000  +--------------------------------+
         |░░░░  sample ring         16 kB |
 0x0000  +--------------------------------+
```
## A Diagram in the Margin of the Text
A diagram takes the same float grammar as any other figure. Give it an alignment and a wrap extent and the prose reads past it.
```diagram The fold {scale=60, align=right, width=30%, wrap=image}
 +-----------+
 |  header   |
 +-----+-----+
       |
       v
 +-----------+
 |   body    |
 +-----+-----+
       |
       v
 +-----------+
 |  footer   |
 +-----------+
```
The figure beside this paragraph declared `align=right`, `width=30%` and `wrap=image`, so it reserves three tenths of the measure and lets the following lines run past its left edge before the column widens back out. Nothing about the drawing itself changed — the same characters, sized by the scale attribute and floated by the wrap attribute. That separation is the point of the whole system: the picture is content, its placement is style, and neither has to know about the other.
Every diagram in this part is also numbered and collected: the list of diagrams in the back matter was generated from these blocks, not typed.

% ============================================================ PART II
# Circuits, Typed
[Kick] PART TWO OF THREE · A COMPONENT LIBRARY ON A CHARACTER GRID
[Lead] A circuit block is the same character grid with one addition: certain letter runs are component names. Spell a name along a wire and the engine swaps in the symbol, keeps the wire's connection points, and paints the rest of the sheet exactly as it would a diagram.
The notation is markdeep's, and its component table ships with the application, so a circuit costs the document nothing but the characters you type.

## How the Notation Works
There are three ways a component joins the grid, and the whole of Part II is built from them.
[Step]
Inline | Spell the name into a horizontal run, plus signs at both ends: a resistor is `+resis+`, a capacitor `+capac+`. The two plus signs are its terminals.
Upright | Spell the same name down a column, one letter per line, plus signs above and below. The symbol turns with it.
Pinned | Some parts have terminals off the run — a transistor's collector and emitter, a gate's two inputs. Those land at fixed offsets from the name's own cell, so the wire meeting them just has to be in the right row.

The simplest complete circuit is one component and a ground. Here it is inline, upright, and grounded, all at once.
```circuit Divider, inline and upright {scale=85}
Vin o---+resis+---+---o Vout
                  |
         R1       +
                  r
                  e
                  s   R2
                  i
                  s
                  +
                  |
                  +eg
```
Four ground symbols are available and each is spelled the same way — the wire arrives from above and the name closes it: `+eg` earth, `+cg` chassis, `+sg` signal, `+ag` arbitrary.
```circuit The four grounds {scale=75}
  |          |          |          |
  +eg        +cg        +sg        +ag
```

## The Component Index
The whole library, drawn from the table the application ships. Most parts are a name typed between two plus signs on a wire; a ground closes a wire from above, a gate needs no lead at all, and a transistor hangs its other two terminals off the grid to the right.
```circuit Passives and sources {scale=64}
  --+resis+--      --+vresi+--      --+poten+--      --+therm+--      --+photo+--









  --+capac+--      --+pcapa+--      --+vcapa+--      --+induc+--      --+vindu+--









  --+diode+--      --+zener+--      --+schot+--      --+led::+--      --+pdiod+--









  --+batte+--      --+c+--          --+dcvsr+--      --+acvsr+--      --+cursr+--









  --+fuseb+--      --+break+--      --+spsto+--      --+spstc+--      --+pbnop+--









  --+lampf+--      --+lampo+--      --+speak+--      --+motor+--      --+cryst+--
```
The reactive parts run deeper than one row, and the rectifier family past the plain diode covers the thyristors:
```circuit Taps, transformers and thyristors {scale=64}
  --+feedc+--      --+tindu+--      --+tind          --+longind+--    --+transfo+--









  --+tdiod+--      --+varic+--      --+pindi+--      --+diac:+--      --+scr::+--









  --+triac+--
```
Four grounds, two dependent sources, and the switches the alarm loop did not need:
```circuit Grounds, dependent sources and the rest of the switches {scale=64}
  |                |                |                |
  +eg              +cg              +sg              +ag









  --+dvsrc+--      --+dcsrc+--









  --+pbncl+--      --+spdt:+--      --+spdt2         --+3wasw+--      --+5wasw+--









  --+s+w+--
```
Ten transistors, in the three families the table carries — bipolar, MOSFET and JFET. Each hangs its other two terminals five cells to the right, three rows up and three down:
```circuit Transistors {scale=64}
  --+npn           --+pnp           --+npnd          --+pnpd









  --+nmos          --+pmos          --+nmod          --+pmod









  --+nfet          --+pfet
```
An amplifier takes its inputs two rows out; a gate takes them one row out, or two for a three-input part. Drawn on their own like this they need no leads at all:
```circuit Amplifiers and logic {scale=64}
  opamp:plus+--          opamp:nega+--          amplifier:+--









  And:+--        :Or:+--        :Xor+--        :Nand+--       ::Nor+--       :Xnor+--









  +:And3+--      +:Or3:+--      +:Xor3+--      +:Nand3+--     +:Nor3:+--     +:Xnor3+--









  --+buf+--        --+Not:+--       --+n+--          --+O+--
```
The coil, the relay it drives, the lamps and the tube; then what a signal arrives on and leaves through:
```circuit Electromechanical, transducers and connectors {scale=64}
  --+col+--        --+relay+--      --+incan+--      --+neon1+--





  !+vacu+--














  --+headp+--      --+phono+--      --+ant           --+termi+--









  jack2pin+--      jack3pin+--      jack3nc:+--      jack5nc:+--
```
Last, eight numbered terminals, each in a left-hand and a right-hand form:
```circuit Numbered terminals {scale=64}
  --+t1     --+t2     --+t3     --+t4     --+t5     --+t6     --+t7     --+t8




 t1+--     t2+--     t3+--     t4+--     t5+--     t6+--     t7+--     t8+--
```
That is every drawable name in the table. The one it declares and cannot draw is `+rela2+`, whose symbol is missing from the shipped artwork.
## Passive Networks
The first-order low-pass is the whole notation in eleven lines: a resistor in the series arm, a capacitor to ground, and two open terminals.
```circuit First-order low-pass {scale=85}
In o---+resis+---+---o Out
                 |
        R1       +
                 c
                 a
                 p   C1
                 a
                 c
                 +
                 |
                 +eg
```
Swap the two parts and the same drawing becomes a high-pass. Nothing else on the sheet moves.
```circuit First-order high-pass {scale=85}
In o---+capac+---+---o Out
                 |
        C1       +
                 r
                 e
                 s   R1
                 i
                 s
                 +
                 |
                 +eg
```
Put an inductor in the series arm beside the resistor and the network is second order — the circuit Part III will compute a resonance for.
```circuit Series RLC, output across the capacitor {scale=85}
In o--+resis+--+induc+--+---o Out
                        |
       R1        L1     +
                        c
                        a
                        p   C1
                        a
                        c
                        +
                        |
                        +eg
```

## Power and Protection
The station's alarm loop: a battery, a fuse, a switch, and three parallel legs — a timing capacitor, a lamp, and a speaker — closing on earth.
```circuit Station power and alarm loop {scale=85}
+--+batte+--+fuseb+--+spsto+--+--------+--------+
|                             |        |        |
|            FUSE1     SW1    +        + LAMP1  +
|   BATT1                     c        l        s
|                             a C1     a        p
|                             p        m        e   SPK1
|                             a        p        a
|                             c        o        k
|                             +        +        +
|                             |        |        |
+-----------+-----------------+--------+--------+
            |
            +eg
```
Rectification and smoothing, drawn the same way: an AC source, a series diode, a reservoir capacitor and a load.
```circuit Half-wave supply {scale=85}
                 D1
  +---+diode+----+--------+---o V+
  |              |        |
  +              +        +
  a              c        r
  c              a        e
  v   AC1        p   C1   s   RL
  s              a        i
  r              c        s
  +              +        +
  |              |        |
  +--------------+--------+---o GND
```
An indicator leg is a switch, a current-limiting resistor and an LED — the smallest circuit that does something visible.
```circuit Indicator leg {scale=85}
+--+batte+--+--+spsto+--+resis+--+led::+--+
|                                         |
|                                         |
|    BATT1     SW1        R1       D1     |
|                                         |
+-----------------------------------------+
```

## Semiconductors
A transistor's base arrives on the run; its collector and emitter leave five cells to the right, three rows above and three below. Once that offset is understood the part places itself. A thermistor divider biasing the base, and the collector driving a lamp, is the station's thermal switch:
```circuit The thermal switch {scale=85}
Vcc ---+-------------------------+
       |                         |
       +                         +
       t                    LED1 l
       h                         e
       e Therm1                  d
       r                         :
       m                         :
       +                         +
       |                         |
       |                         |
       |                  NPN1   |
       |
       |    R1
       +-----+resis+--------+npn
       |
       +                         |
       r                         |
       e R2                      |
       s                         |
       i                         |
       s                         |
       +                         |
       +----+--------------------+
            |
            +eg
```
The same offsets drive an inductive load. Here the relay coil and its flyback diode sit side by side between the collector and the supply, so the diode conducts the coil's kick back into Vcc when the base turns off:
```circuit Relay driver with flyback diode {scale=80}
                        +---+diode+---+
                        |             |
                        |             |
                        |      D1     |
                        |             |
                        |             |
                        |             |
                        |             |
                        |             |
                        |             |
                        |             |
                        |             |
                        +---+col+-----+---o Vcc
                        |
                        |     K1
                        |
In o--+resis+------+npn
         R1
                              Q1
                        |
                        |
                        |
                        |
                        +eg
```

## Logic
Gates take their two inputs one row above and one row below the name's first cell, and hand the result out the trailing plus. A half adder is nine lines of text.
```circuit Half adder {scale=95}

A o----*--------+
       |        :Xor+-----o Sum
B o--*-)--------+
     | |
     | |
     | |
     | +--------+
     |          And:+-----o Carry
     +----------+
```
Four gates and one inverter make a two-to-one multiplexer. The select line branches once and feeds both AND gates, one of them through the inverter.
```circuit Two-to-one multiplexer {scale=80}
A o-------------------+
                      And:+----+
Sel o--*--------------+        | 
       |                       | 
       |                       +--+
       |                          :Or:+---o Out
       |                       +--+
B o----)--------------+        |
       |              And:+----+
       +--+Not:+------+
```
The rest of the family is spelled the same way — the name changes, the geometry does not.
```circuit The two-input family {scale=70}
--+          --+          --+          --+          --+          --+
  :Xor+--      And:+--      ::Nor+--     :Nand+--     :Or:+--      :Xnor+--
--+          --+          --+          --+          --+          --+
```
Buffers and inverters are inline parts, because they have one input.
```circuit Buffer and inverter {scale=75}
  --+buf+--            --+Not:+--
```

## Amplifiers
The operational amplifier is a pinned part with its inputs two rows out from the name's first cell. Two spellings put the inverting input on either side: `opamp:plus+` carries the non-inverting input on top, `opamp:nega+` the inverting one. The second is what the classic inverting configuration wants — signal through Rin into the summing node, Rf closing the loop from the output, and the other input tied to ground:
```circuit Inverting amplifier {scale=80}
              +----+resis+----------+
              |                     |
              |     Rf              |
              |                     |
              |                     |
              |                     |
In o--+resis+-+-------+             |
                                    |
         Rin          opamp:nega+---+---o Out

                      |
                      |
                      +eg
```

% ============================================================ PART III
# Python at Render Time
[Kick] PART THREE OF THREE · FIGURES THE DOCUMENT COMPUTES FOR ITSELF
[Lead] The third family is not drawn at all. A Python block names a script and hands it a few lines of input; the script runs while the page is being made and returns a figure. What reaches the paper is whatever the arithmetic decided.
A Python figure is written like an image whose file happens to end in `.py`. The lines under it, down to a `~~~` fence, are the script's input.
```python`The shape of a Python figure
![Caption](script.py){scale=1.15}
R 10k
C 100n
~~~
```
The script exposes one function. It returns either a height — having painted through the vector API — or a height and a string of raw SVG. Both channels are used in this part.
```python`The two return channels
import qtdraw

def render(content):
    qtdraw.setPen("#17667A", 1.8)
    qtdraw.drawPolyline(points_from(content))
    return 220                    # painted through the API

def render(content):                       # or, instead:
    return (300, "<svg ...>...</svg>")     # returned as raw SVG
```

## The Filter, Answered
Part II drew a first-order low-pass and never said what it does. Here is the same network handed to a script as two component values. The corner frequency, the decade span, the decibel scale, the asymptote and the marker are all computed — the document holds two lines of input.
![The first-order low-pass of Part II, solved from values](schem_bode.py){scale=1.15}
title: First-order low-pass · computed response
R 10k
C 100n
~~~
The transfer function the script is evaluating, typeset by a second script on the same channel:
![The first-order transfer function.](latex_render.py){scale=1.0}
H(j\omega) = \frac{1}{1 + j\omega R C}, \qquad f_c = \frac{1}{2\pi R C}
~~~
Add the inductor from the series RLC and the same script finds a second-order response instead — a resonant peak, a phase that swings the full half turn, and a roll-off that has doubled. Nothing about the block changed except one line of input.
![The series RLC, with the peak and the doubled roll off](schem_bode.py){scale=1.15}
title: Series RLC · computed response
R 2.2
L 10m
C 100u
~~~
![The second-order transfer function, in the damping-ratio form](latex_render.py){scale=1.0}
H(s) = \frac{\omega_0^2}{s^2 + 2\zeta\omega_0 s + \omega_0^2}, \qquad \zeta = \frac{R}{2}\sqrt{\frac{C}{L}}
~~~

## The State Plane
The same three components, integrated instead of solved. This figure comes back as raw SVG: the script steps the circuit's two state variables through a fourth-order Runge–Kutta from seven starting conditions, and returns several thousand path segments that fade as the energy leaves the loop.
![Seven trajectories of the series RLC in the plane of capacitor voltage against inductor current, with the tangent field behind them.](schem_phase.py){scale=1.2}
title: RLC state plane
R 2.2
L 10m
C 100u
seeds 7
~~~
>note> Both axes are volts: the current is scaled by the network's characteristic impedance, so a lossless circuit would trace circles and the damping shows as the inward pitch of the spiral.

## The Logic, Enumerated
The half adder of Part II is two Boolean expressions. Written out as expressions, the script enumerates every input combination itself and draws both the table and the waveforms — no truth table is typed anywhere in this document.
![The half adder's table and timing, enumerated from its two expressions.](schem_truth.py){scale=1.15}
title: Half adder
in A B
out Sum = A ^ B
out Carry = A & B
~~~
Three inputs and two longer expressions give the full adder, at the same cost in typing.
![The full adder, from three inputs and two expressions.](schem_truth.py){scale=1.15}
title: Full adder
in A B Cin
out Sum = A ^ B ^ Cin
out Carry = (A & B) | (Cin & (A ^ B))
~~~
![The carry expression the script evaluated.](latex_render.py){scale=1.0}
S = A \oplus B \oplus C_{in}, \qquad C_{out} = AB + C_{in}(A \oplus B)
~~~

## The Script, Shown
There is no privileged machinery here. The response plot above is ninety lines of ordinary Python; this is the part of it that chooses the decibel scale and clips the asymptote to the frame.
```python`From schem_bode.py
# The span is chosen from the roll-off, not fixed: the asymptote should fall
# about 60 dB inside the frame whether it leaves at 20 or 40 dB per decade.
slope = -40.0 if L else -20.0
x_lo = math.log10(f0) - 2.0
x_hi = math.log10(f0) + 60.0 / abs(slope)

db_peak = max(s[1] for s in samples)
db_hi = 10.0 if db_peak <= 3.0 else 20.0 * math.ceil((db_peak + 3) / 20.0)
db_lo = 20.0 * math.floor((min(s[1] for s in samples) - 4) / 20.0)
```
[Pull] Three families, one file: a diagram is characters, a circuit is characters with names in it, and a Python figure is characters that run.
## What the Document Costs
Everything in these pages is plain text in one file. The three scripts it calls sit beside it; the component symbols come from the application. There is no image on disk anywhere in this manual.
[Led]
Diagrams drawn | 11
Circuits drawn | 22
Component symbols shown | 111
Python figures computed | 8
Image files used | 0
___
[Kick] MERIDIAN INSTRUMENTS CO. · BENCH MANUAL № 2

Bench manual

Cream paper and a book serif: a quiet title page, a generated contents list on dot leaders, three numbered parts, and every figure captioned beneath it in the measure of the text.

  • 21 pages
  • Portrait · 612 x 792 pt
  • 1.3 MB
Open the PDF

Download the PDF·642 lines of content produced this

Table Formula Demo

Tables that calculate

A sales report with subtotal, tax and total; sums, averages, medians and standard deviation; rounding, powers and square roots; grades from if-then rules; quarterly figures that refer to other rows; and currency and percent columns.

Table Formula Demo, the plain design: page one
# Table Formula Demo
## Sales Report
| Product  | Price | Qty | Total                    |
| Apples   | 1.50  | 10  | =B2*C2=15                |
| Oranges  | 2.25  | 8   | =B3*C3=18                |
| Bananas  | 0.75  | 20  | =B4*C4=15                |
| Grapes   | 3.00  | 5   | =B5*C5=15                |
| Pears    | 1.80  | 12  | =B6*C6=21.6              |
| Subtotal |       |     | =SUM(D2..D6)=84.6        |
| Tax 8%   |       |     | =D7*0.08=6.768           |
| Total    |       |     | =SUM(D2..D6)*1.08=91.368 |
## Aggregate Functions
| Value     |                              |
| 12        |                              |
| 7         |                              |
| 19        |                              |
| 3         |                              |
| 15        |                              |
| 7         |                              |
| 22        |                              |
| Sum       | =SUM(A2..A8)=85              |
| Average   | =AVERAGE(A2..A8)=12.14285714 |
| Min       | =MIN(A2..A8)=3               |
| Max       | =MAX(A2..A8)=22              |
| Count     | =COUNT(A2..A8)=7             |
| Median    | =MEDIAN(A2..A8)=12           |
| Mode      | =MODE(A2..A8)=7              |
| Stdev     | =ROUND(STDEV(A2..A8),2)=6.94 |
| Product   | =PRODUCT(A2..A8)=11060280    |
| 2nd Large | =LARGE(A2..A8,2)=19          |
| 3rd Small | =SMALL(A2..A8,3)=7           |
## Math Functions
| Input | Result             | Description      |
| -8.7  | =ABS(A2)=8.7       | Absolute value   |
| 3.756 | =ROUND(A3,1)=3.8   | Round to 1 digit |
| 7.9   | =FLOOR(A4)=7       | Floor            |
| 2.1   | =CEIL(A5)=3        | Ceiling          |
| -4.8  | =INT(A6)=-4        | Truncate         |
| 17    | =MOD(A7,5)=2       | Modulo           |
| 2     | =POWER(A8,10)=1024 | Power            |
| 144   | =SQRT(A9)=12       | Square root      |
| 1000  | =LOG(A10,10)=3     | Log base 10      |
|       | =PI()=3.141592654  | Pi constant      |
| -42   | =SIGN(A12)=-1      | Sign             |
## Logic & Conditionals
| Score | Grade                          | Pass              |
| 92    | =IF(A2>=90,4,IF(A2>=80,3,2))=4 | =IF(A2>=60,1,0)=1 |
| 85    | =IF(A3>=90,4,IF(A3>=80,3,2))=3 | =IF(A3>=60,1,0)=1 |
| 55    | =IF(A4>=90,4,IF(A4>=80,3,2))=2 | =IF(A4>=60,1,0)=0 |
| 78    | =IF(A5>=90,4,IF(A5>=80,3,2))=2 | =IF(A5>=60,1,0)=1 |
| Avg   | =AVERAGE(B2..B5)=2.75          | =SUM(C2..C5)=3    |
| All?  | =AND(C2>0,C3>0,C4>0,C5>0)=0    | =OR(C2>0,C3>0)=1  |
## Cross-referencing Formulas
| Q1                | Q2                | Q3                | Q4                | Annual             | Avg/Q                        |
| 1200              | 1450              | 1100              | 1600              | =SUM(A2..D2)=5350  | =AVERAGE(A2..D2)=1337.5      |
| 800               | 950               | 1050              | 900               | =SUM(A3..D3)=3700  | =AVERAGE(A3..D3)=925         |
| 2100              | 2300              | 1800              | 2400              | =SUM(A4..D4)=8600  | =AVERAGE(A4..D4)=2150        |
| Total             | =SUM(B2..B4)=4700 | =SUM(C2..C4)=3950 | =SUM(D2..D4)=4900 | =SUM(E2..E4)=17650 | =AVERAGE(E2..E4)=5883.333333 |
| =SUM(A2..A4)=4100 |                   |                   |                   |                    |                              |
## Currency & Percent
| Item     | Price   | Discount | Final                        |
| Widget   | $125.00 | 10%      | =B2*(1-C2)=112.5             |
| Gadget   | $89.50  | 15%      | =B3*(1-C3)=76.075            |
| Doohicky | $210.00 | 5%       | =B4*(1-C4)=199.5             |
| Total    |         |          | =SUM(D2..D4)=388.075         |
| Rounded  |         |          | =ROUND(SUM(D2..D4),2)=388.08 |

Plain

The default page: lettered sections and ruled tables, with nothing restyled.

  • 3 pages
  • Portrait · 612 x 792 pt
  • 26 KB
Open the PDF

Download the PDF·66 lines of content produced this

Every one of these documents opens in the editor

They are bundled with it. Install, choose File ▸ Open Example, and the document opens unsaved — yours to pull apart, restyle, and keep wherever you like.