Advanced Reading #abnf #handshake #state-machine #protocols

📜 Reading Protocol Specs

5 exercises — interpret real protocol specifications: ABNF grammar notation, the WebSocket opening handshake, the TCP state machine, IPv4 header field definitions and URI syntax.

Protocol spec notation
  • ABNF/ = alternatives, [x] = optional, *x = zero+, n*m x = between n and m
  • State machine → read each edge as state → (event; action) → next-state
  • Handshake → ordered steps; the exact primitive (SHA-1 vs SHA-256) matters
  • Field definition → note width, unit and constraints (e.g. length in 32-bit words)
0 / 5 completed
1 / 5
📜 RFC 5234 — ABNF Grammar
RFC 5234 — Augmented BNF for Syntax Specifications: ABNF
Example grammar for a US postal address

   postal-address   = name-part street zip-part

   name-part        = *(personal-part SP) last-name [SP suffix] CRLF
   personal-part    = first-name / (initial ".")
   street           = [apt SP] house-num SP street-name CRLF
   zip-part         = town-name "," SP state 1*2SP zip-code CRLF

   Notation reminders:
     /        alternatives (one of)
     [foo]    optional element
     *foo     zero or more repetitions
     1*2foo   between one and two repetitions
     n*m      between n and m repetitions
In the rule zip-part = town-name "," SP state 1*2SP zip-code CRLF, what does 1*2SP specify?