# Troubleshooting & Error Reference (`E01`–`E14`)

> **FrameAssembly v3.2.2** · Reference Guide R4 · Canonical URL: https://frameassembly-lang.dev/docs/diagnostics

Every syntax, block/modifier, and IP/port/protocol validation rule in FrameAssembly v3.2.2 — paste your error message or filter by category to see the exact broken vs. valid `.frasm` fix.

## Key Takeaways

- FrameAssembly catches syntax typos, mismatched IPv4/IPv6 host pairs, unsupported `transport` overrides, and out-of-range header values *before* writing a single `.pcap` byte.
- All built-in keywords match `^[a-z0-9]+$` (zero underscores, zero hyphens), while your own `host` and `flow` names freely allow capitals, `_`, and internal `-`.
- Use the interactive filter below (or press `⌘K` anywhere on the site) to paste any error fragment and jump straight to a working fix.

## 1. Three Checks Before Any Byte Hits `.pcap`

Unlike raw hex builders that happily write broken headers and leave you staring at red Wireshark warnings, FrameAssembly checks your file in three plain groups before generating packets: **Syntax & Typos** (comment markers, quotes, and lowercase keyword suggestions), **Blocks & Modifiers** (`host`/`flow`/`compile` layout, `->`/`<-` lines, and close-match typo hints), and **IP, Port & Protocol Rules** (matching IPv4/IPv6 endpoints, allowed `transport` overrides, and field bit-width ranges).

Filter all 14 error rules below by category or keyword, and click **Preview Valid Fix** on any card to inspect the resulting packets directly in your browser.

## Diagnostic Rules (`E01`–`E14`)

### E01 (Syntax & Typos): Uppercase, Underscore, or Hyphenated Built-In Keyword

- **Compiler Message:** `replace 'echo_request' with 'echorequest'`
- **Why It Happens:** Every built-in protocol name, modifier, TCP flag, and time unit in FrameAssembly is strictly lowercase alphanumeric ([a-z0-9]+) with zero underscores and zero hyphens. User-defined host and flow names may still use capitals, underscores, or internal hyphens.

```frameassembly
host Laptop_01 { ip 10.0.0.10 }
host Core-GW   { ip 10.0.0.1 }

compile {
    Laptop_01 -> Core-GW icmp echorequest wait 5ms
}
```

### E02 (Blocks & Modifiers): CIDR Subnet Mask (/24), Equals Sign, or Quotes Inside host Block

- **Compiler Message:** `expected plain IPv4 or IPv6 address literal inside host block`
- **Why It Happens:** Ethernet frames carry 32-bit IPv4 or 128-bit IPv6 host addresses on the wire—never subnet masks. Declare plain IP literals without /24 suffixes, quotes, commas, or = signs.

```frameassembly
host firewall { ip 10.10.1.1 }
host server   { ip 10.10.1.20 }

compile {
    firewall -> server icmp echorequest
}
```

### E03 (Syntax & Typos): Hash (#) Comments or Single-Quoted Strings

- **Compiler Message:** `unexpected character: use // for comments and "..." for text literals`
- **Why It Happens:** FrameAssembly uses // line comments and double-quoted UTF-8 strings ("...") exclusively so shell-style # comments and single quotes never create escaping ambiguity.

```frameassembly
// DNS lookup test
host client   { ip 192.168.1.10 }
host resolver { ip 192.168.1.53 }

compile {
    client -> resolver dns query qname "portal.internal" qtype "A"
}
```

### E04 (Blocks & Modifiers): Using sport / dport Instead of srcport / dstport, or ack 1001 Instead of acknum 1001

- **Compiler Message:** `unknown modifier 'sport'; did you mean 'srcport'?`
- **Why It Happens:** Bare ack sets the 1-bit TCP ACK control flag, whereas acknum sets the 32-bit acknowledgment header value. Transport ports always use explicit srcport and dstport.

```frameassembly
host c { ip 10.0.0.1 }
host s { ip 10.0.0.2 }

compile {
    c -> s tcp syn srcport 51000 dstport 443 seq 1000 wait 1ms
    c <- s tcp syn ack seq 5000 acknum 1001
}
```

### E05 (Blocks & Modifiers): Writing host on HTTP/SSDP Instead of hosthdr, or transport on RTSP Instead of transporthdr

- **Compiler Message:** `unexpected keyword 'host' inside frame statement; use 'hosthdr' for HTTP Host header`
- **Why It Happens:** Top-level host opens an endpoint declaration and transport selects L4 TCP vs UDP on the 9 dual-transport protocols. HTTP/SSDP use hosthdr and RTSP uses transporthdr to set their Layer 7 text headers unambiguously.

```frameassembly
host cam_client { ip 10.10.2.15 }
host nvr_srv    { ip 10.10.2.80 }

compile {
    cam_client -> nvr_srv tcp syn srcport 53100 dstport 80 wait 1ms
    cam_client <- nvr_srv tcp syn ack wait 1ms
    cam_client -> nvr_srv tcp ack wait 1ms
    cam_client -> nvr_srv http get uri "/status" hosthdr "nvr.lab.local"
}
```

### E06 (Blocks & Modifiers): Using a Removed loop Block, Leading wait Before Frame 1, or Parameterless flow

- **Compiler Message:** `unexpected identifier 'loop' inside compile block; repeat flow calls or frame statements explicitly`
- **Why It Happens:** FrameAssembly v3.2.2 has no loop keyword (removed in v2.0.0), requires every flow template to declare at least one formal parameter flow name(a, b), and only accepts wait as a trailing modifier after a frame statement (never before Frame 1).

```frameassembly
host a { ip 10.0.0.1 }
host b { ip 10.0.0.2 }

flow ping_pair(src, dst) {
    src -> dst icmp echorequest id 1 seq 1 wait 5ms
    src <- dst icmp echoreply id 1 seq 1 wait 5ms
}

compile {
    ping_pair(a, b)
    ping_pair(a, b)
}
```

### E07 (IP, Port & Protocol Rules): MAC-Only Host Used on a Layer 3, Layer 4, or Layer 7 Protocol

- **Compiler Message:** `protocol requires an IPv4 or IPv6 address on both source and destination hosts`
- **Why It Happens:** MAC-only host declarations are valid for the 8 pure Layer 2 protocols (arp, vlan, qinq, lldp, stp, lacp, eapol, mpls). All 73 Layer 3–7 protocols build an IPv4 or IPv6 header and require ip on both endpoints.

```frameassembly
host sw1 { ip 10.255.0.1 mac 00:1c:73:00:00:01 }
host sw2 { ip 10.255.0.2 mac 00:1c:73:00:00:02 }

compile {
    sw1 -> sw2 ospf hello area 0.0.0.0
}
```

### E08 (IP, Port & Protocol Rules): Mixing an IPv4 Source Host with an IPv6 Destination Host

- **Compiler Message:** `source and destination hosts must share the same IP address family (both IPv4 or both IPv6)`
- **Why It Happens:** A single IP packet header is either IPv4 (EtherType 0x0800) or IPv6 (EtherType 0x86dd). To run the same exchange across both families, define a parameterized flow(c, s) and call it once with IPv4 hosts and once with IPv6 hosts.

```frameassembly
host v4_client { ip 10.10.1.10 }
host v4_server { ip 10.10.1.20 }
host v6_client { ip 2001:db8::10 }
host v6_server { ip 2001:db8::20 }

flow tls_open(c, s) {
    c -> s tcp syn srcport 50100 dstport 443 wait 1ms
    c <- s tcp syn ack
}

compile {
    tls_open(v4_client, v4_server)
    tls_open(v6_client, v6_server)
}
```

### E09 (IP, Port & Protocol Rules): Running igmp Over IPv6 Hosts or ndp / mld Over IPv4 Hosts

- **Compiler Message:** `igmp requires IPv4 endpoints (use mld for IPv6 multicast listener discovery)`
- **Why It Happens:** While 70 of the 73 IP protocols automatically adapt between IPv4 and IPv6, IGMP (IP protocol 2) exists only in IPv4, and NDP / MLD (ICMPv6 types 130–136) exist only in IPv6.

```frameassembly
host listener_v6 { ip fe80::10 }
host querier_v6  { ip fe80::1 }

compile {
    listener_v6 -> querier_v6 mld report group ff02::1:ff00:10
}
```

### E10 (IP, Port & Protocol Rules): Using transport tcp|udp Outside the 9 Dual-Transport Protocols

- **Compiler Message:** `transport override is only allowed on dns, sip, syslog, kerberos, memcached, dnp3, modbus, nfs, and ethernetip`
- **Why It Happens:** Fixed-transport protocols (such as HTTP over TCP or NTP/SNMP over UDP) have a fixed RFC L4 binding. Only the 9 dual-L4 protocols (dns, sip, syslog, kerberos, memcached, dnp3, modbus, nfs, ethernetip) accept transport tcp or transport udp.

```frameassembly
host client   { ip 10.0.0.10 }
host resolver { ip 10.0.0.53 }

compile {
    client -> resolver tcp syn srcport 53120 dstport 53 wait 1ms
    client <- resolver tcp syn ack wait 1ms
    client -> resolver tcp ack wait 1ms
    client -> resolver dns query txid 0x4410 qname "zone.corp.local" qtype "AXFR" transport tcp
}
```

### E11 (IP, Port & Protocol Rules): Applying TCP Flags (syn, ack, rst) or TCP Options (mss, wscale) to UDP or L3 Protocols

- **Compiler Message:** `TCP header flags and options are only valid on tcp and TCP-based Layer 7 protocols`
- **Why It Happens:** UDP, ICMP, and pure L2/L3 headers have no sequence numbers, window fields, or control flags. Restrict syn, ack, fin, rst, psh, seq, acknum, win, mss, wscale, and sackperm to tcp and TCP-carried L7 protocols.

```frameassembly
host a { ip 10.0.0.1 }
host b { ip 10.0.0.2 }

compile {
    a -> b udp srcport 12000 dstport 9000 payload "probe"
}
```

### E12 (IP, Port & Protocol Rules): Out-of-Range VLAN ID (>4095), DSCP (>63), TTL (>255), or Duplicate MPLS Clause

- **Compiler Message:** `vlan ID 5000 exceeds 12-bit IEEE 802.1Q maximum (0..=4095)`
- **Why It Happens:** FrameAssembly checks every header field width before writing bytes: VLAN/QinQ VIDs are 12 bits (0..4095), PCP is 3 bits (0..7), DSCP is 6 bits (0..63), ECN is 2 bits (0..3), MPLS label is 20 bits (0..1048575), and each frame takes at most one mpls shim.

```frameassembly
host pe1 { ip 10.1.1.1 }
host pe2 { ip 10.1.1.2 }

compile {
    pe1 -> pe2 icmp echorequest qinq 500 innervlan 20 pcp 6 dscp 46
}
```

### E13 (IP, Port & Protocol Rules): Odd-Length SNMPv3 engineid Hex or Invalid varbind Value Type

- **Compiler Message:** `snmp3 engineid must contain an even number of hexadecimal digits`
- **Why It Happens:** SNMPv3 USM key localization hashes raw engine ID octets, so engineid requires even-length hex (such as "80001f888001020304"). Also use varbind <oid> string "..." or oidval <oid> (never str or trapoid).

```frameassembly
host rtr { ip 10.40.1.1 }
host nms { ip 10.40.1.100 }

compile {
    rtr -> nms snmp3 trap user "ops" engineid "80001f888001020304" auth sha256 "AuthPass123!" priv aes "PrivPass123!" varbind 1.3.6.1.2.1.1.5.0 string "core1"
}
```

### E14 (IP, Port & Protocol Rules): DNS / mDNS Label Longer Than 63 Bytes or Payload + HexPayload Collision

- **Compiler Message:** `DNS label exceeds RFC 1035 maximum of 63 octets per label (253 total)`
- **Why It Happens:** DNS wire compression uses the top 2 bits of each label length byte as pointer flags, capping single labels at 63 octets and full domain names at 253 characters. Separately, payload and hexpayload are mutually exclusive on the same frame.

```frameassembly
host ws { ip 10.0.0.10 }
host ns { ip 10.0.0.53 }

compile {
    ws -> ns dns query txid 0x2201 qname "sub-01.telemetry-ingest.internal" qtype "AAAA"
}
```
