# Wireshark / tcpdump / Scapy -> `.frasm` Rosetta Stone

> **FrameAssembly v3.2.2** · Reference Guide R1 · Canonical URL: https://frameassembly-lang.dev/docs/cheat-sheet

One-page translation map from Wireshark display filters, `tcpdump`, Scapy, and `tcprewrite` to exact FrameAssembly v3.2.2 keywords.

## Key Takeaways

- Every built-in `.frasm` v3.2.2 keyword, protocol, flag, and time unit is strictly `[a-z0-9]+` — zero underscores, zero hyphens.
- Frame #1 = `0ns`; inline `wait <n><ns|us|ms|s|m>` sets the gap *before* the next frame (default `+10ms` when omitted).
- 8 L2 protocols allow MAC-only hosts · 9 dual-L4 protocols accept `transport tcp|udp` · 70 L3–L7 protocols run over both IPv4 & IPv6.

## 1. Wireshark Display Filter -> `.frasm` Modifier Map

Know the Wireshark filter? Here is the exact `.frasm` token to type:

### `rosetta_all_in_one.frasm`

```frameassembly
host client { ip 10.10.20.15 mac 001a.2b3c.4d15 }
host edge   { ip 10.10.20.1  mac 001a.2b3c.4d01 }

compile {
    client -> edge tcp syn srcport 51443 dstport 443 win 65535 mss 1460 sackperm vlan 100 pcp 5 dscp 46 wait 1ms
    client <- edge tcp syn ack win 65535 mss 1460 sackperm vlan 100 pcp 5 dscp 46 wait 1ms
    client -> edge tcp ack vlan 100 pcp 5 dscp 46 wait 1ms
    client -> edge tls clienthello sni "portal.corp.local" alpn "h2" vlan 100 pcp 5 dscp 46
}
```

| Intent | Wireshark Filter | FrameAssembly v3.2.2 (`.frasm`) |
| --- | --- | --- |
| 802.1Q VLAN + 802.1p Priority | `vlan.id == 100 && vlan.priority == 5` | `vlan 100 pcp 5 dei 0` |
| 802.1ad QinQ S-Tag + C-Tag | `vlan.etype == 0x88a8` | `qinq 2000 innervlan 150` |
| MPLS Shim Label | `mpls.label == 24010 && mpls.bottom == 1` | `mpls 24010 exp 5 bos 1 mplsttl 64` |
| IPv4/IPv6 Hop Limit & DiffServ | `ip.ttl == 64 && ip.dsfield.dscp == 46` | `ttl 64 dscp 46 ecn 0` |
| IPv4 DF / Fragmentation | `ip.flags.df == 1` / `ip.frag_offset > 0` | `df` or `ipid 0x1234 mf fragoffset 0` |
| TCP Ports, Flags & Options | `tcp.dstport == 443 && tcp.flags.syn == 1` | `tcp syn srcport 51234 dstport 443 win 65535 mss 1460 wscale 7 sackperm` |
| Explicit TCP SEQ & ACK Numbers | `tcp.seq == 1000 && tcp.ack == 5001` | `tcp ack seq 1000 acknum 5001` (bare `ack` = flag bit!) |
| HTTP Request + Host Header | `http.host == "api.internal" && http.request.method == "POST"` | `http post uri "/v1/login" hosthdr "api.internal"` |
| TLS ClientHello SNI & ALPN | `tls.handshake.extensions_server_name == "app.corp.local"` | `tls clienthello sni "app.corp.local" alpn "h2"` |
| SNMPv2c / v3 Trap OID + String | `snmp.name == 1.3.6.1.6.3.1.1.4.1.0` | `varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.6.3.1.1.5.3 varbind 1.3.6.1.2.1.1.5.0 string "sw1"` |

## 2. Scapy, `tcprewrite`, TraceWrangler, `text2pcap` & Packetdrill -> FrameAssembly

How common packet-crafting and capture-editing tools map to `.frasm` — and when you should still reach for one of the others:

| Job / Tool | Traditional Workflow | FrameAssembly (`v3.2.2`) |
| --- | --- | --- |
| Stateful TCP + L7 stream (`Scapy`) | 25+ lines of Python tracking `seq`, `ack`, `len(payload)`, and virtualenvs | 3 handshake lines (`->` / `<-`) + 1 L7 line inside `compile { ... }` |
| Scrub IPs, VLANs & L7 hostnames (`tcprewrite`) | `tcprewrite --srcipmap=... --fixcsum` (fast L2–L4 bulk NAT, but breaks if L7 string length changes) | `frameassembly reverse in.pcap edit.frasm` -> edit IPs, `sni`, `qname`, `hosthdr` -> recompile |
| Redact customer captures (`TraceWrangler`) | Windows GUI batch anonymizer for bulk IP/MAC/DHCP profiles across multi-file captures | Cross-platform CLI or zero-upload browser Playground that turns captures into diffable `.frasm` text |
| Build a `.pcap` from hex / ASCII (`text2pcap`) | `od -Ax -tx1` hex-offset dumps + dummy `-e` / `-i` / `-u` header flags | Named L2–L7 protocol fields (`dns`, `tls`, `bgp`, `modbus`) + `hexpayload "..."` only where needed |
| Test TCP timing & anomalies (`Packetdrill`) | Live kernel-socket script testing a host OS TCP stack (`+0.010 < S ...`) | Offline `.pcap` / `.pcapng` file generation across 81 L2–L7 protocols for Suricata, Zeek, Wireshark & `tcpreplay` |
| Encrypted SNMPv3 `authPriv` trap (`snmptrap`) | `snmptrap -v 3 -e 0x...` + missing vendor MIB errors + live UDP socket | `snmp3 trap user "..." engineid "..." auth sha256 "..." priv aes "..."` straight to `.pcap` |

> **When to Pick Scapy, Packetdrill, or `tcprewrite` Instead:** Use Scapy or Packetdrill when conversing live with a remote kernel TCP stack over raw sockets or running 100,000-packet fuzzing loops, and use `tcprewrite` or `editcap` when rewriting multi-gigabyte captures in bulk without changing Layer 7 string lengths.

## 3. Timing & Protocol Whitelist Cheat Matrix

Four compiler rules worth keeping in your back pocket:

| Rule | Exact Set / Behavior | Notes |
| --- | --- | --- |
| Post-packet `wait` clock | Frame #1 = `0ns`. `wait <n><ns\|us\|ms\|s\|m>` advances clock before the *next* frame. | Omitted `wait` = `+10ms` · `wait 0ns` = zero-gap burst · never standalone. |
| 8 MAC-only L2 protocols | `arp`, `vlan`, `qinq`, `lldp`, `stp`, `lacp`, `eapol`, `mpls` | `host sw1 { mac 00:1c:73:00:00:01 }` works here; all 73 L3-L7 protocols require matching IPs. |
| IPv4 vs IPv6 rules | IPv4-only: `igmp` · IPv6-only: `ndp`, `mld` · Dual-stack: all other 70 L3-L7 protocols | `icmp`, `ospf`, `rip`, `vrrp`, `hsrp`, and `dhcp` morph v4 <-> v6 automatically (`ospf routerid` stays dotted-quad). |
| 9 `transport tcp\|udp` protocols | Default UDP: `dns`, `sip`, `syslog`, `kerberos`, `memcached` · Default TCP: `dnp3`, `modbus`, `nfs`, `ethernetip` | Rejected on single-transport protocols (`http`, `bgp`, `quic`, `ntp`, ...). |

## 4. Six Deliberate Keyword Disambiguations

Six modifier names avoid colliding with top-level blocks or flag bits:

- `hosthdr "api.internal"` — HTTP / SSDP `Host:` header (`host` declares network boxes).
- `transporthdr "RTP/AVP;unicast;client_port=5004-5005"` — RTSP `Transport:` header (`transport tcp|udp` picks L4).
- `acknum 1001` — 32-bit TCP acknowledgment number (bare `ack` = ACK flag bit).
- `srcport` / `dstport` — L4 ports (`sport` / `dport` are rejected).
- `varbind <oid> string "<txt>"` & `varbind 1.3.6.1.6.3.1.1.4.1.0 oidval <oid>` — SNMP varbinds (`str` and `trapoid` do not exist).
- CoAP shorthands (`get`, `post`, `put`, `delete`, `created`, `changed`, `notfound`) and `code "0.01"` are mutually exclusive on the same frame.
