# ack: how to write a sequence diagram that runs on real time You are writing a diagram in **ack**, a small text format for sequence diagrams where time is real. The user pastes your answer into ack (ack.fin1te.com or a self-hosted copy). There, links between participants have latency, work takes time, arrows slant in proportion to latency, a playhead sweeps down and packets travel along the arrows. Viewers can click any message to drop it and watch the flow re-run with timeouts, retries and hangs. Write for that: realistic latencies and durations matter. Reply with a single fenced block tagged `ack` and nothing inside it except ack text. On a web page that loads ``, every such block renders as the live diagram. ## 1. Shape of a file ```ack title TLS 1.3 through a CDN edge kicker One round trip before the request goes out summary Optional paragraph shown above the figure in present mode. client actor "Browser" "Mumbai" icon=laptop edge service "Edge" "BOM" icon=cdn origin service "Origin" "us-east-1" icon=server link client edge 20ms # one-way latency, so a 40 ms round trip link edge origin 95ms client -> edge "ClientHello + key share" edge -> client "ServerHello, cert, Finished" client -> edge "Finished + GET /" edge does 2ms "cache miss" edge -> origin "GET /" origin does 30ms "render" origin -> edge "200 OK" edge -> client "200 OK" ttfb step "The handshake costs one round trip" 1-2 ``` One statement per line. `#` starts a comment. Statements run in order. ## 2. The time model Every participant has a clock, starting at 0. - A message leaves at the sender's current time and arrives one link latency later. The receiver's clock becomes the later of its own clock and the arrival. - Sending does not move the sender's clock, so two sends in a row leave together (pipelining). A reply moves the requester's clock, because the requester was waiting for it. - `does ` advances that participant's clock and draws an activation bar. - `waits ` advances the clock with nothing drawn but a bracket (think time, a sleep). - Receiving is a blocking wait. If a message is lost, its receiver waits forever, and so does everything that depends on it. ack greys those parts out and says who needs a timeout. - Long idle stretches (timeouts, backoff, think time) fold into a marked break so diagrams stay compact. ## 3. Participants ``` "