Chapter 5: Copy-Paste Detox with Parameterized flow(c, s)

Write a multi-packet sequence once with placeholder names, then stamp it across Floor 1, Floor 2, Wi-Fi, or dual-stack IPv4 + IPv6.

Labs completed0/7
The Situation · 5 min

Three campus subnets (floor1_pc, floor2_pc, wifi_user) all need to pass the same 4-packet TCP + TLS handshake to sso_gw without copy-pasting 12 lines.

What You'll Pull Off Here

  • Declare flow name(c, s) { ... } between host and compile.
  • Use only the formal placeholder names (c, s) inside the flow body.
  • Stamp tls_check(...) inside compile for as many host pairs (even mixed v4 pairs + v6 pairs) as you want.
Interactive Lab Check

Lab 5: Stamp Out tls_check for wifi_user

Add tls_check(wifi_user, sso_gw) inside compile { ... } so all 3 subnets run the 4-packet handshake (12 frames total).

  1. 1.Scroll to compile { ... } at the bottom of the sandbox.
  2. 2.Add tls_check(wifi_user, sso_gw) right after tls_check(floor2_pc, sso_gw).
  3. 3.Click Check Exercise to verify 12 frames compile cleanly.

1. flow(c, s) — A Packet Stencil Without Loops

Copy-pasting the same 4-packet TCP + TLS sequence across five subnets is a great way to forget updating line 14.

A flow block sits between host and compile. Give it placeholder endpoints in parentheses (flow tls_check(c, s) { ... }), and then call tls_check(floor1_pc, sso_gw) inside compile whenever you want those 4 packets stamped out.

  • Parentheses with >= 1 parameter are mandatory: flow tls_check(c, s) { ... }.
  • Inside the flow braces, only reference the parameters (c, s), never global host names.
  • No loop keyword exists: want 3 bursts? Call the flow on 3 lines inside compile so packet count stays 100% obvious.
Word-by-Word Syntax Breakdown
Define the exchange once, then stamp it out for any host pair:
flow tls_check(c, s) { ... }   ->   compile { tls_check(floor1_pc, sso_gw) }
flow tls_check(c, s)Stencil HeaderReusable template taking two placeholder endpoints c and s
c -> s tcp syn ...Stencil BodyUses c and s so any IPv4 pair or IPv6 pair can plug right in
tls_check(floor1_pc, sso_gw)Flow CallExpands all 4 frames inside compile for floor1_pc <-> sso_gw
Quick Formatting Reference (2 rules)
ItemValid .frasmAvoid
Flow parametersflow tls_check(c, s) { c -> s tcp syn dstport 443 }flow tls_check { floor1_pc -> sso_gw tcp syn }
Repeating sequencescompile { tls_check(a, s) tls_check(b, s) }loop 2 { ... } // does not exist in v3.1
campus_sso_matrix.frasmLoading WASM…
Wireshark filter: tls.handshake.type == 1
Open in Playground
0 B · 0.000 ms
Compiling capture in WebAssembly…
Learn .frasm — Labs, Guides & 81 Protocols | FrameAssembly