⌘K
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) { ... }betweenhostandcompile. - Use only the formal placeholder names (
c,s) inside theflowbody. - Stamp
tls_check(...)insidecompilefor 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.Scroll to
compile { ... }at the bottom of the sandbox. - 2.Add
tls_check(wifi_user, sso_gw)right aftertls_check(floor2_pc, sso_gw). - 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
flowbraces, only reference the parameters (c,s), never globalhostnames. - No
loopkeyword exists: want 3 bursts? Call theflowon 3 lines insidecompileso packet count stays 100% obvious.
Word-by-Word Syntax BreakdownDefine the exchange once, then stamp it out for any host pair:
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 sc -> s tcp syn ...Stencil BodyUses c and s so any IPv4 pair or IPv6 pair can plug right intls_check(floor1_pc, sso_gw)Flow CallExpands all 4 frames inside compile for floor1_pc <-> sso_gwQuick Formatting Reference (2 rules)
| Item | Valid .frasm | Avoid |
|---|---|---|
| Flow parameters | flow tls_check(c, s) { c -> s tcp syn dstport 443 } | flow tls_check { floor1_pc -> sso_gw tcp syn } |
| Repeating sequences | compile { 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 == 10 B · 0.000 ms
Compiling capture in WebAssembly…