Every built-in keyword, operator, wait time unit, cross-layer header modifier, protocol subkeyword, alias, compiler rule, CLI subcommand, and reverse decompiler stage in FrameAssembly v3.2.2.
Two-Block Minimal Program (host + compile) & Parameterized flow Templates
Every .frasm specification needs only 1+host declarations and 1compile block, with optional parameterized flow(p1, p2) templates for replaying exchanges across IPv4 and IPv6.
flow <name>(<p1>[, <p2>, ...]) { ... } requires >= 1 parameter in parentheses; frame endpoints inside a flow must reference formal parameters rather than global host names.
There is no loop keyword (removed in v2.0.0); invoke flow(...) or repeat frame lines explicitly inside compile.
compile freely mixes inline a -> b ... / a <- b ... frame lines and flow(...) calls.
frameassembly
host app_v4 { ip 10.10.1.10 }
host db_v4 { ip 10.10.1.20 }
host app_v6 { ip 2001:db8:10::10 }
host db_v6 { ip 2001:db8:10::20 }
flow pg_ping(c, s) {
c -> s tcp syn srcport 52100 dstport 5432 win 65535 mss 1460 wait 1ms
c <- s tcp syn ack win 65535 mss 1460 wait 1ms
c -> s tcp ack wait 1ms
c -> s postgres query sql "SELECT 1;"
}
compile {
pg_ping(app_v4, db_v4)
pg_ping(app_v6, db_v6)
}
Strict-Lowercase Built-In Keywords ([a-z0-9]+) vs. Flexible User Identifiers
All 646 built-in keywords and time units use lowercase letters and digits with zero underscores or hyphens, while user-defined host and flow names allow capitals, _, and internal -.
Built-in keywords match ^[a-z0-9]+$ (echorequest, innervlan, sackperm, hosthdr, transporthdr, readholdingregisters); uppercase or _ typos trigger self-healing suggestions.
User identifiers match [a-zA-Z_][a-zA-Z0-9_]*(-[a-zA-Z0-9_]+)* (e.g. fw-dmz-01, Core_SW_1), stopping cleanly before ->.
Line comments begin with // (# and ; are rejected with an explicit diagnostic).
Strings are double-quoted UTF-8 supporting \r, \n, \t, \\, \", \', \xHH, and \uXXXX (single-quoted strings are rejected).
Integers accept decimal (443) or hex (0x0800); signed integers (int varbinds, ntp precision, kerberos etype, ldap msgid) also accept negative decimal (-20).
Hex byte strings (hexpayload, iv, icv, engineid) accept optional spaces or colons ("deadbeef", "de:ad:be:ef", "de ad be ef").
ASN.1 OIDs (oid, enterprise, varbind, oidval) accept unquoted dotted trees with >= 2 numeric arcs (1.3.6.1.2.1.1.1.0 or .1.3.6.1...) or quoted strings.
FrameAssembly synthesizes deterministic Ethernet framing automatically whenever mac, srcmac, or dstmac is omitted.
Unicast host blocks without mac receive sequential deterministic MACs in 1-based declaration order: 00:00:00:00:00:01, 00:00:00:00:00:02, 00:00:00:00:00:03, and so on.
Explicit mac, srcmac, and dstmac values accept colon (00:1a:2b:3c:4d:5e), hyphen (00-1A-2B-3C-4D-5E), or Cisco dot-quad (001a.2b3c.4d5e) notation.
Shared 4-Tuple TCP seq / acknum State Machine & <- Port Memory
Raw tcp frames and all TCP-based Layer 7 protocols share one canonical 4-tuple state tracker and bidirectional port memory.
Setting srcport 51234 dstport 443 on a -> b (or relying on ephemeral 49152 -> default_port) automatically swaps ports to 443 -> 51234 on a <- b replies and reuses 51234 -> 443 on later a -> b frames.
Initial TCP seq defaults to 1000 per direction; syn and fin each advance that direction’s next seq by +1.
Every TCP payload or TCP Layer 7 frame defaults to psh ack, sets acknum to the peer’s latest expected seq, and advances its own next seq by +payload_len.
Explicit seq <u32> or acknum <u32> overrides emit that exact header value and re-anchor downstream connection state for testing retransmissions, gaps, or blind RSTs.
Dynamic Layer 7 Port Pairing & Automatic Multicast Overrides
Protocols with asymmetric request/reply or event/general port pairs select RFC-accurate ports automatically.
dhcp: IPv4 discover/request/release use UDP 68 -> 67 and offer/ack use 67 -> 68; over IPv6 hosts, solicit/request use UDP 546 -> 547 and advertise/reply use 547 -> 546.
mdns: Defaults to UDP 5353 -> 5353 and overrides destination IP to 224.0.0.251 (IPv4) or ff02::fb (IPv6) with matching RFC multicast MACs.
ptp: Event messages (sync, delayreq) use UDP 319; general messages (followup, delayresp, announce) use UDP 320.
Any L2/L3/L4/L7 protocol statement can be wrapped in single/double VLAN tags, an MPLS shim, DiffServ markings, IPv4 fragments, or TCP options on a single line.
mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>] inserts one 32-bit MPLS shim (0x8847) between L2/VLAN and L3 (repeating mpls twice on one line is rejected).
ttl <0..255>, dscp <0..63>, and ecn <0..3> work uniformly across IPv4 and IPv6; ipid, df, mf, and fragoffset apply to IPv4 while flowlabel applies to IPv6.
Dual-stack morphing: icmp automatically emits ICMPv4 (proto 1) over IPv4 and ICMPv6 (Next Header 58 with IPv6 pseudo-header checksum) over IPv6; ospf morphs between OSPFv2 and OSPFv3; rip morphs between RIPv2 and RIPng.
Live Wire Checksums, SNMPv3 USM Crypto (Ku -> Kul), BGP 4-Byte ASN & OT CRCs
FrameAssembly computes real cryptographic digests and wire-exact CRCs offline so Wireshark, Suricata, and NMS receivers validate every byte.
snmp3: Performs full RFC 3414 / RFC 7860 1 MiB password-to-key (Ku) and engineid-localized (Kul) derivation, live HMAC (md5, sha, sha256, sha384, sha512), and ScopedPDU encryption via AES-128-CFB (priv aes, RFC 3826) or CBC-DES (priv des).
bgp: Supports full 32-bit asn <u32>; when asn > 65535 on bgp open, writes AS_TRANS (23456) in the 16-bit header slot and appends Capability 65 (RFC 6793 4-octet ASN).
sctp: Computes hardware-matching Castagnoli CRC-32c checksums and 4-byte chunk padding across init, initack, cookieecho, cookieack, data, sack, heartbeat, abort, and shutdown.
dnp3: Splits link-layer frames into 16-byte data blocks and appends reflected DNP3 CRC-16 (0x3d65) per block.
IPv4 header, ICMPv4/v6, IGMP, MLD, TCP, UDP, GRE, OSPF, VRRP, and PIM checksums are computed over exact pseudo-headers on every build.
Compile-Time validate_semantics Bounds & 9-Protocol transport Whitelist
Invalid IP family pairings, out-of-range bit-widths, and illegal L4 overrides fail cleanly at compile time before writing a .pcap.
Endpoint family match: both hosts on a frame must be IPv4, both IPv6, or (on the 8 L2 protocols only) MAC-only. igmp requires IPv4 hosts; ndp and mld require IPv6 hosts.
transport <tcp|udp> is permitted exclusively on the 9 dual-transport protocols: dns, sip, syslog, kerberos, memcached, dnp3, modbus, nfs, and ethernetip.
TCP flags (syn, ack, fin, rst, psh, urg, ece, cwr), seq/acknum/win/window/urgent, and TCP options (mss, wscale, sackperm, tsval, tsecr) are rejected on UDP/L2/L3 non-TCP protocols, and duplicate TCP flags on one line are rejected.
payload and hexpayload are mutually exclusive on the same frame; dns/mdnsqname validates RFC 1035 label length <= 63 and total domain <= 253; snmp3engineid requires non-empty even-length hex; hsrphellotime validates 0..=255.
Rootless CLI Commands, .pcap vs .pcapng, Drag-and-Drop & Overwrite Guards
Single static binary with default root compilation plus 5 subcommands (show, reverse, update, version, help) and zero root socket privileges.
frameassembly <in.frasm> [out.pcap | out.pcapng] compiles .frasm to classic libpcap .pcap (0xa1b2c3d4, microsecond resolution) by default, or nanosecond .pcapng (IfTsResol = 9, snaplen 65535) when the output ends in .pcapng.
frameassembly show <in.frasm> validates syntax/semantics and prints the relative-timestamp packet ladder (Time, Source, Destination, Proto, Len, summary) to stdout without writing disk files.
frameassembly reverse <in.pcap|.pcapng> [out.frasm] decompiles captures back into canonical .frasm code (defaulting output to <stem>.frasm, or <stem>.reversed.frasm if input somehow shares extension).
frameassembly update runs a zero-flag self-updater: prefers cargo install frameassembly --locked --force when cargo + rustc >= 1.89 + a working C linker exist, otherwise verifies SHA-256 checksums on GitHub Release binaries.
Safety & UX guards: refuses to overwrite a .frasm source file if passed as the 2nd argument to root compile; auto-routes single-argument .pcap/.pcapng paths (such as Windows Explorer drag-and-drop) to reverse; prints actionable migration hints if legacy -o, --output, --show, --reverse, or compile flags are typed; accepts -h/--help and -V/--version.
bash
# Compile .frasm -> classic .pcap or nanosecond .pcapng
frameassembly capture.frasm capture.pcap
frameassembly capture.frasm capture.pcapng
# Dry-run packet table in stdout (CI pre-commit validation)
frameassembly show capture.frasm
# Decompile .pcap or .pcapng -> editable .frasm
frameassembly reverse incident.pcapng incident.frasm
# Zero-flag self-update & version check
frameassembly update
frameassembly version
5-Stage reverse Decompiler, Self-Check Oracle, Crate API & Formal Grammars
frameassembly reverse normalizes 8 link-layer types, reconstructs high-level .frasm statements, and verifies every frame through an in-memory compiler oracle.
Link-layer normalization converts 8 LINKTYPE_* formats (ETHERNET, RAW, IPV4, IPV6, LINUX_SLL, LINUX_SLL2, NULL, LOOP) into canonical Ethernet II frames while stripping 60/64-byte trailer padding and 4-byte FCS trailers.
Self-check compiler oracle & shadow TCP state tracker: every candidate .frasm statement is compiled in memory and compared byte-for-byte against the original wire frame; encrypted snmp3 (authPriv / keyed authNoPriv) or vendor-proprietary payloads step down cleanly to hexpayload so zero wire bytes are corrupted, and IP protocol 50 emits canonical esp.
Constrained LLM decoding grammars ship alongside the compiler: ISO/IEC 14977 grammar.ebnf, frameassembly.gbnf (llama.cpp / XGrammar), and frameassembly.lark (Outlines / vLLM), plus /llms.txt and /llms-full.txt.
rust
use frameassembly::{backend, lexer, parser, reverse};
let tokens = lexer::lex(src)?;
let ast = parser::parse_program(&tokens, src)?;
parser::validation::validate_semantics(&ast, src)?;
let frames = backend::compile_program(&ast)?;
let pcap_bytes = backend::generate_pcap(&frames);
let roundtrip_frasm = reverse::reverse_pcap_bytes(&pcap_bytes)?;
Complete Compiler Lexicon · 7 Operators + 5 Time Units + 641 Keywords = 653 Tokens
All 653 `.frasm` Keywords, Operators & Modifiers
Showing 120 of 653 matching tokens
Token
Category & Scope
Syntax & Accepted Value
Wire Behavior & Default
Spec
(
Operators
flow · compile
flow ping(a, b) { ... } · ping(h1, h2)
Opening parameter parenthesis
Opens the formal parameter list on a flow declaration or the host argument list on a flow call.
Default: Required on flow definitions and flow calls
initiation | response | cookie | data | type <...>
WireGuard message type keyword
Used across wireguard, ssh: Selects Type 1 Handshake Initiation (148B), Type 2 Handshake Response (92B), Type 3 Cookie Reply (64B), or Type 4 Transport Data (>= 32B).
Used across snmp1, snmp2, snmp3: Appends an ASN.1 BER VarBind(OID, SMI-value) pair to the VarBindList SEQUENCE (null and nullval are interchangeable aliases).
Used across snmp1, snmp2, snmp3: Appends an ASN.1 BER VarBind(OID, SMI-value) pair to the VarBindList SEQUENCE (null and nullval are interchangeable aliases).