# SIP/RTP VoIP, Mail, Encrypted SNMPv3 USM & Flow Telemetry

> **FrameAssembly v3.2.2** · Anthology 10 (Layer 7 · 20 Recipes) · MIT License · Canonical URL: https://frameassembly-lang.dev/docs/examples/voip-media-snmp-telemetry

Voice/media signaling (`sip`, `rtp`, `rtsp`, `stun`), mail relays (`smtp`, `imap`, `pop3`), MIB-free `snmp1`/`snmp2`/encrypted `snmp3` USM traps, `syslog`, and `netflow`/`ipfix`/`sflow` collector streams.

## Key Wire & Syntax Takeaways

- `snmp3` performs native RFC 3414/3826/7860 USM key localization (`md5`/`sha1`/`sha256` + `des`/`aes`) from even-length `engineid` hex without MIB files.
- `sip` and `syslog` accept `transport tcp` for reliable enterprise trunks and SIEM collectors; `rtsp` uses `transporthdr` for its L7 `Transport:` header.
- `netflow` (UDP 2055), `ipfix` (UDP 4739), and `sflow` (UDP 6343) generate collector-ready flow records with configurable byte/packet counters.

## 10.01 · SIP Trunk Call Setup over TCP 5060 + Bidirectional G.711 RTP Stream (`voip_sip_tcp_rtp_call.frasm`)

Combines SIP signaling over TCP (transport tcp, DSCP CS3 = 24) with a bidirectional 20ms G.711 mu-law RTP audio stream (DSCP EF = 46) and clean BYE teardown.

- **Protocols:** `tcp`, `sip`, `rtp` (8 Ethernet frames)
- **Wire Behavior:** sip accepts transport tcp for enterprise SBC trunks while rtp carries 160-sample (20ms) timestamp increments.
- **Wireshark Filter:** `sip || rtp`
- **CLI Build:** `frameassembly voip_sip_tcp_rtp_call.frasm`

```frameassembly
host ip_phone { ip 10.80.10.25 }
host sbc_gw   { ip 10.80.1.10 }

compile {
    ip_phone -> sbc_gw tcp syn srcport 51060 dstport 5060 dscp 24 wait 1ms
    ip_phone <- sbc_gw tcp syn ack dscp 24 wait 1ms
    ip_phone -> sbc_gw tcp ack dscp 24 wait 1ms
    ip_phone -> sbc_gw sip invite uri "sip:+14155550199@sbc.corp.internal" from "sip:ext204@corp.internal" to "sip:+14155550199@sbc.corp.internal" callid "call-7741@10.80.10.25" cseq 1 dscp 24 transport tcp wait 4ms
    ip_phone <- sbc_gw sip status 200 reason "OK" callid "call-7741@10.80.10.25" cseq 1 dscp 24 transport tcp wait 10ms
    ip_phone -> sbc_gw rtp srcport 16384 dstport 24000 pt 0 seq 100 timestamp 160 ssrc 0x11223344 marker 1 dscp 46 payload "g711-ulaw-frame-1" wait 20ms
    ip_phone <- sbc_gw rtp srcport 24000 dstport 16384 pt 0 seq 500 timestamp 160 ssrc 0x99887766 marker 1 dscp 46 payload "g711-ulaw-reply-1" wait 20ms
    ip_phone -> sbc_gw sip bye uri "sip:+14155550199@sbc.corp.internal" callid "call-7741@10.80.10.25" cseq 2 dscp 24 transport tcp
}
```

## 10.02 · Reliable Syslog Forwarding over TCP Port 514 (transport tcp) (`syslog_tcp_siem_forwarder.frasm`)

Verifies TCP-based SIEM log-collector ingestion on port 514 when compliance policies forbid lossy UDP Syslog.

- **Protocols:** `tcp`, `syslog` (4 Ethernet frames)
- **Wire Behavior:** transport tcp switches syslog from UDP 514 onto stateful TCP 514.
- **Wireshark Filter:** `syslog && tcp.port == 514`
- **CLI Build:** `frameassembly syslog_tcp_siem_forwarder.frasm`

```frameassembly
host fw_edge  { ip 10.90.1.1 }
host siem_ing { ip 10.90.50.20 }

compile {
    fw_edge -> siem_ing tcp syn srcport 53514 dstport 514 win 65535 mss 1460 wait 1ms
    fw_edge <- siem_ing tcp syn ack win 65535 mss 1460 wait 1ms
    fw_edge -> siem_ing tcp ack wait 1ms
    fw_edge -> siem_ing syslog facility 4 severity 2 hostname "fw-edge-01" app "policy-engine" procid "2048" msg "Denied TCP 198.51.100.99:44112 -> 10.90.10.5:22" transport tcp
}
```

## 10.03 · SNMPv2c Switch Uplink linkDown Trap (UDP 162) (`snmpv2c_linkdown_trap.frasm`)

Sends a standard SNMPv2c linkDown trap on UDP port 162 carrying sysUpTime, snmpTrapOID.0, interface name Gi1/0/24, and operational state varbinds.

- **Protocols:** `snmp2` (2 Ethernet frames)
- **Wire Behavior:** No vendor MIB files are needed: 1.3.6.1.6.3.1.1.4.1.0 is snmpTrapOID.0, and oidval 1.3.6.1.6.3.1.1.5.3 identifies standard linkDown (use .5.4 for linkUp).
- **Wireshark Filter:** `snmp && udp.port == 162`
- **CLI Build:** `frameassembly snmpv2c_linkdown_trap.frasm`

```frameassembly
// Access switch sending a Trapv2-PDU to your monitoring server
host access_sw { ip 10.30.2.14 }
host nms_srv   { ip 10.30.0.100 }

compile {
    // SNMPv2c linkDown (.5.3) trap for uplink Gi1/0/24 (ifIndex 24, ifOperStatus 2 = down)
    access_sw -> nms_srv snmp2 trap community "noc-traps" reqid 401 sysuptime 245000 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.2.2.1.2.24 string "Gi1/0/24" varbind 1.3.6.1.2.1.2.2.1.8.24 int 2 wait 500ms

    // Recovery: SNMPv2c linkUp (.5.4) trap 500ms later (ifOperStatus 1 = up)
    access_sw -> nms_srv snmp2 trap community "noc-traps" reqid 402 sysuptime 245050 varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.6.3.1.1.5.4 varbind 1.3.6.1.2.1.2.2.1.2.24 string "Gi1/0/24" varbind 1.3.6.1.2.1.2.2.1.8.24 int 1
}
```

## 10.04 · Encrypted SNMPv3 authPriv Trap (SHA-256 + AES-128) (`snmpv3_authpriv_trap.frasm`)

Generates a fully authenticated and AES-128-encrypted SNMPv3 USM trap so NOC teams can verify Zabbix, PRTG, Checkmk, or snmptrapd decryption keys safely.

- **Protocols:** `snmp3` (1 Ethernet frame)
- **Wire Behavior:** Enter user "noc-secops", engineid "80001f888001020304", SHA-256 pass "AuthPass2026!", and AES pass "PrivPass2026!" in Wireshark -> Preferences -> Protocols -> SNMP -> Users Table to decrypt.
- **Wireshark Filter:** `snmp && udp.port == 162`
- **CLI Build:** `frameassembly snmpv3_authpriv_trap.frasm`

```frameassembly
// Core distribution switch and SNMPv3 trap collector
host core_sw { ip 10.40.1.1 }
host nms_srv { ip 10.40.1.100 }

compile {
    // Encrypted SNMPv3 USM trap (HMAC-SHA-256 auth + AES-128-CFB encryption) on UDP 162
    // engineid must be an even-length hex string matching your snmptrapd createUser -e setting
    core_sw -> nms_srv snmp3 trap user "noc-secops" engineid "80001f888001020304" engineboots 5 enginetime 1840 auth sha256 "AuthPass2026!" priv aes "PrivPass2026!" sysuptime 360000 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.2.2.1.2.1 string "TenGigE0/1/0"
}
```

## 10.05 · Acknowledged SNMPv3 Inform + NMS Response (`snmpv3_inform_ack.frasm`)

Models a confirmed SNMPv3 InformRequest on UDP 162 and the matching Response-PDU returned by the NMS collector so router retry queues clear cleanly.

- **Protocols:** `snmp3` (2 Ethernet frames)
- **Wire Behavior:** Unlike fire-and-forget traps, an SNMP inform expects a response with the same reqid; use <- so the NMS reply automatically flips UDP ports (162 -> 49152).
- **Wireshark Filter:** `snmp`
- **CLI Build:** `frameassembly snmpv3_inform_ack.frasm`

```frameassembly
// WAN edge router sending a confirmed SNMPv3 Inform to the central NMS
host wan_rtr { ip 172.20.0.1 }
host nms_srv { ip 172.20.0.50 }

compile {
    // 1. Router sends encrypted SNMPv3 Inform (reqid 910) reporting BGP neighbor loss
    wan_rtr -> nms_srv snmp3 inform user "wan-ops" engineid "80001f8880aabbccdd" engineboots 8 enginetime 4200 auth sha256 "WanAuthKey99!" priv aes "WanPrivKey99!" reqid 910 sysuptime 980000 varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.2.1.15.7.2 varbind 1.3.6.1.2.1.15.3.1.7.1 string "198.51.100.1" wait 4ms

    // 2. NMS acknowledges receipt with matching reqid 910 so router stops retransmitting
    wan_rtr <- nms_srv snmp3 response user "wan-ops" engineid "80001f8880aabbccdd" engineboots 8 enginetime 4200 auth sha256 "WanAuthKey99!" priv aes "WanPrivKey99!" reqid 910 varbind 1.3.6.1.2.1.15.3.1.7.1 string "198.51.100.1"
}
```

## 10.06 · Rack UPS On-Battery Trap + Syslog Alert Correlation (`ups_battery_trap_syslog.frasm`)

Combines an RFC 5424 critical Syslog event (UDP 514) with an SNMPv2c UPS battery-power trap (UDP 162) to test NOC event deduplication and paging rules.

- **Protocols:** `syslog`, `snmp2` (2 Ethernet frames)
- **Wire Behavior:** Handy for testing Graylog/Splunk + Zabbix alert correlation without flipping the breaker on the server-room PDU.
- **Wireshark Filter:** `syslog || snmp`
- **CLI Build:** `frameassembly ups_battery_trap_syslog.frasm`

```frameassembly
// Rack UPS management card and NOC monitoring collector
host rack_ups { ip 10.40.10.15 }
host noc_srv  { ip 10.40.1.100 }

compile {
    // 1. Critical Syslog alert (facility 16 = local0, severity 2 = critical) on UDP 514
    rack_ups -> noc_srv syslog facility 16 severity 2 hostname "ups-row-b02" app "POWER" msg "Utility AC lost: switched to battery (est runtime 18 min)" wait 3ms

    // 2. Matching SNMPv2c UPS on-battery trap (1.3.6.1.2.1.33.2.1 = upsTrapOnBattery) on UDP 162
    rack_ups -> noc_srv snmp2 trap community "dc-facilities" reqid 77 sysuptime 864000 varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.2.1.33.2.1 varbind 1.3.6.1.2.1.33.1.2.3.0 int 18
}
```

## 10.07 · SIP (VoIP) (`sip`): Complete VoIP Call Setup (`INVITE` + SDP), `RTP` Audio & `BYE` Hangup (`sip_rtp_voip_call.frasm`)

Establishes a SIP call with an `application/sdp` offer on VLAN 30, streams G.711 `rtp` voice packets with `dscp 46` (EF), and hangs up cleanly via `bye` + `200 OK`.

- **Protocols:** `sip`, `vlan` (8 Ethernet frames)
- **Wire Behavior:** Defaults to UDP `5060` (`SIP/2.0/UDP`) or switches `Via` and Layer 4 to TCP `5060` (`SIP/2.0/TCP`) when `transport tcp` is added. Generates mandatory RFC 3261 headers (`Via` with `branch=z9hG4bK...`, `From`, `To`, `Call-ID`, `CSeq`, `Max-Forwards: 70`, `Contact`, and exact `Content-Length`).
- **Wireshark Filter:** `sip`
- **CLI Build:** `frameassembly show sip_rtp_voip_call.frasm`

```frameassembly
host phone_a { ip 172.16.30.101 }
host sbc_01  { ip 172.16.30.10 }

compile {
    // 1. SIP INVITE with SDP offer + 180 Ringing + 200 OK + SIP ACK
    phone_a -> sbc_01 sip invite uri "sip:2050@voice.internal" from "sip:1010@voice.internal" to "sip:2050@voice.internal" callid "voip-8801" cseq 1 contenttype "application/sdp" body "v=0\r\no=- 1 1 IN IP4 172.16.30.101\r\ns=-\r\nc=IN IP4 172.16.30.101\r\nt=0 0\r\nm=audio 5004 RTP/AVP 0\r\n" vlan 30 dscp 24 wait 2ms
    phone_a <- sbc_01 sip status 180 reason "Ringing" callid "voip-8801" cseq 1 vlan 30 dscp 24 wait 20ms
    phone_a <- sbc_01 sip status 200 reason "OK" callid "voip-8801" cseq 1 vlan 30 dscp 24 wait 2ms
    phone_a -> sbc_01 sip ack uri "sip:2050@voice.internal" callid "voip-8801" cseq 1 vlan 30 dscp 24 wait 5ms
    // 2. Bidirectional G.711 PCMU RTP audio (DSCP 46 Expedited Forwarding)
    phone_a -> sbc_01 rtp pt 0 seq 1 timestamp 160 ssrc 0x11223344 marker 1 payload "g711-audio-1" vlan 30 dscp 46 wait 20ms
    phone_a <- sbc_01 rtp pt 0 seq 1 timestamp 160 ssrc 0x55667788 marker 1 payload "g711-reply-1" vlan 30 dscp 46 wait 20ms
    // 3. Call hangup (BYE -> 200 OK)
    phone_a -> sbc_01 sip bye uri "sip:2050@voice.internal" callid "voip-8801" cseq 2 vlan 30 dscp 24 wait 2ms
    phone_a <- sbc_01 sip status 200 reason "OK" callid "voip-8801" cseq 2 vlan 30 dscp 24
}
```

## 10.08 · RTP (Media) (`rtp`): G.711 VoIP Stream With Simulated WAN Jitter & Single-Packet Drop (`rtp_qos_jitter_lab.frasm`)

Emits a G.711 PCMU (`pt 0`, 8 kHz = `+160` timestamp ticks per `20ms`) voice burst containing a skipped sequence number (`seq 3` dropped) and a `55ms` jitter spike.

- **Protocols:** `rtp` (4 Ethernet frames)
- **Wire Behavior:** Defaults to UDP destination port `5004` and writes RTP Version `2` (`0x80`) in the upper bits of byte 0. Packs the 1-bit `marker` and 7-bit Payload Type (`pt`) cleanly into byte 1 (`(marker << 7) | pt`).
- **Wireshark Filter:** `rtp`
- **CLI Build:** `frameassembly show rtp_qos_jitter_lab.frasm`

```frameassembly
host branch_phone { ip 172.16.30.21 }
host hq_gateway   { ip 172.16.1.10 }

compile {
    // Normal 20ms pacing (+160 samples at 8000 Hz)
    branch_phone -> hq_gateway rtp srcport 16384 dstport 16400 pt 0 seq 1 timestamp 160 ssrc 0xdeadbeef marker 1 dscp 46 payload "audio-pkt-1" wait 20ms
    branch_phone -> hq_gateway rtp pt 0 seq 2 timestamp 320 ssrc 0xdeadbeef marker 0 dscp 46 payload "audio-pkt-2" wait 55ms
    // seq 3 intentionally omitted to test 1-packet loss + 55ms jitter detection!
    branch_phone -> hq_gateway rtp pt 0 seq 4 timestamp 640 ssrc 0xdeadbeef marker 0 dscp 46 payload "audio-pkt-4" wait 5ms
    branch_phone -> hq_gateway rtp pt 0 seq 5 timestamp 800 ssrc 0xdeadbeef marker 0 dscp 46 payload "audio-pkt-5"
}
```

## 10.09 · RTSP (`rtsp`): Full IP Camera RTSP Setup, PLAY, RTP Video Frame & TEARDOWN (`rtsp_camera_session.frasm`)

Walks through TCP 554 connection setup, `DESCRIBE`, `SETUP` (`client_port=5004-5005`), `PLAY`, an H.264 `rtp pt 96` packet from the camera, and `TEARDOWN`.

- **Protocols:** `rtsp`, `tcp` (11 Ethernet frames)
- **Wire Behavior:** Defaults to TCP destination port `554` (`psh ack`) and writes `
`-terminated `RTSP/1.0` lines with `CSeq`. Switches from an RTSP client request to an `RTSP/1.0 <status> OK` server reply whenever `status` is set.
- **Wireshark Filter:** `rtsp`
- **CLI Build:** `frameassembly show rtsp_camera_session.frasm`

```frameassembly
host vms_nvr  { ip 192.168.60.10 }
host gate_cam { ip 192.168.60.105 }

compile {
    vms_nvr -> gate_cam tcp syn srcport 51554 dstport 554 win 65535 mss 1460 wait 1ms
    vms_nvr <- gate_cam tcp syn ack win 65535 mss 1460 wait 1ms
    vms_nvr -> gate_cam tcp ack wait 1ms
    vms_nvr -> gate_cam rtsp describe uri "rtsp://192.168.60.105/h264" cseq 1 wait 2ms
    vms_nvr <- gate_cam rtsp status 200 cseq 1 wait 2ms
    vms_nvr -> gate_cam rtsp setup uri "rtsp://192.168.60.105/h264/trackID=1" cseq 2 transporthdr "RTP/AVP;unicast;client_port=5004-5005" wait 2ms
    vms_nvr <- gate_cam rtsp status 200 cseq 2 transporthdr "RTP/AVP;unicast;client_port=5004-5005;server_port=8000-8001" session "98112233" wait 2ms
    vms_nvr -> gate_cam rtsp play uri "rtsp://192.168.60.105/h264" cseq 3 session "98112233" wait 2ms
    vms_nvr <- gate_cam rtsp status 200 cseq 3 session "98112233" wait 5ms
    // Camera sends H.264 RTP packet (pt 96) to client port 5004
    gate_cam -> vms_nvr rtp srcport 8000 dstport 5004 pt 96 seq 1 timestamp 90000 ssrc 0xcafebabe marker 1 payload "h264-nal-idr" wait 10ms
    vms_nvr -> gate_cam rtsp teardown uri "rtsp://192.168.60.105/h264" cseq 4 session "98112233"
}
```

## 10.10 · STUN (NAT) (`stun`): Dual-Stack IPv4 & IPv6 WebRTC ICE STUN Discovery + Error Response (`stun_webrtc_ice.frasm`)

Performs an IPv4 STUN check on port 19302, an IPv6 STUN check on port 3478, and a `bindingerror` (`0x0111`) test.

- **Protocols:** `stun` (5 Ethernet frames)
- **Wire Behavior:** Defaults to UDP destination port `3478` and writes the mandatory RFC 5389 magic cookie `0x2112a442` in bytes 4..7. XOR-encodes IPv4 (`32-bit ^ 0x2112a442`) and IPv6 (`128-bit ^ (0x2112a442 || txid)`) `xormappedaddr` attributes (`0x0020`) automatically.
- **Wireshark Filter:** `stun`
- **CLI Build:** `frameassembly show stun_webrtc_ice.frasm`

```frameassembly
host client_v4 { ip 172.16.10.25 }
host stun_v4   { ip 198.51.100.10 }
host client_v6 { ip 2001:db8:10::25 }
host stun_v6   { ip 2001:db8:99::3478 }

compile {
    // 1. WebRTC UDP 19302 STUN check returning NAT public IPv4 203.0.113.50
    client_v4 -> stun_v4 stun bindingrequest dstport 19302 txid 0xa1b2c3d4 software "Chromium-ICE" wait 2ms
    client_v4 <- stun_v4 stun bindingresponse txid 0xa1b2c3d4 xormappedaddr 203.0.113.50 software "coturn-4.6" wait 4ms
    // 2. IPv6 STUN Binding check + Error response
    client_v6 -> stun_v6 stun bindingrequest txid 0x55667788 wait 2ms
    client_v6 <- stun_v6 stun bindingresponse txid 0x55667788 xormappedaddr 2001:db8:10::25 wait 3ms
    client_v4 <- stun_v4 stun bindingerror txid 0x99990000
}
```

## 10.11 · SMTP (`smtp`): Complete End-to-End RFC 5321 Email Delivery Transaction (`smtp_full_envelope.frasm`)

Walks through a full TCP 25 session from `220` banner and `EHLO` through `MAIL FROM`, `RCPT TO`, `DATA` (`354`), message headers/body, `250 Queued`, and `QUIT`.

- **Protocols:** `smtp`, `tcp` (16 Ethernet frames)
- **Wire Behavior:** Defaults to TCP destination port `25` (`psh ack`; use `dstport 587` for submission) and terminates SMTP lines with `
`. Formats `MAIL FROM:<...>` (`mailfrom`) and `RCPT TO:<...>` (`rcptto`) cleanly and terminates `body` payloads with `
.
` when needed.
- **Wireshark Filter:** `smtp`
- **CLI Build:** `frameassembly show smtp_full_envelope.frasm`

```frameassembly
host alert_bot { ip 172.16.15.20 }
host smtp_relay { ip 172.16.15.25 }

compile {
    alert_bot -> smtp_relay tcp syn srcport 52025 dstport 25 win 65535 mss 1460 wait 1ms
    alert_bot <- smtp_relay tcp syn ack win 65535 mss 1460 wait 1ms
    alert_bot -> smtp_relay tcp ack wait 1ms
    alert_bot <- smtp_relay smtp code 220 reply "relay.corp.internal ESMTP" wait 2ms
    alert_bot -> smtp_relay smtp ehlo "alert-bot.corp.internal" wait 1ms
    alert_bot <- smtp_relay smtp code 250 reply "PIPELINING" wait 1ms
    alert_bot -> smtp_relay smtp mailfrom "<noc-alerts@corp.internal>" wait 1ms
    alert_bot <- smtp_relay smtp code 250 reply "2.1.0 Ok" wait 1ms
    alert_bot -> smtp_relay smtp rcptto "<oncall@corp.internal>" wait 1ms
    alert_bot <- smtp_relay smtp code 250 reply "2.1.5 Ok" wait 1ms
    alert_bot -> smtp_relay smtp data wait 1ms
    alert_bot <- smtp_relay smtp code 354 reply "End data with <CR><LF>.<CR><LF>" wait 2ms
    alert_bot -> smtp_relay smtp body "Subject: Core Link Down\r\nFrom: noc-alerts@corp.internal\r\n\r\nGi1/0/49 went down.\r\n." wait 2ms
    alert_bot <- smtp_relay smtp code 250 reply "2.0.0 Ok: queued as 9F4A1" wait 1ms
    alert_bot -> smtp_relay smtp quit wait 1ms
    alert_bot <- smtp_relay smtp code 221 reply "2.0.0 Bye"
}
```

## 10.12 · IMAP4 (`imap`): Cleartext IMAP Login Failure Followed by Authorized Inbox Selection (`imap_login_audit.frasm`)

Captures an untagged server greeting, a failed `A01 LOGIN` returning `NO`, and an authorized `A02 LOGIN` + `A03 SELECT INBOX`.

- **Protocols:** `imap`, `tcp` (10 Ethernet frames)
- **Wire Behavior:** Defaults to TCP destination port `143` (`psh ack`) and appends `
` to every IMAP command or response line. Formats `<tag> <cmd> <arg>
` on client requests and `<tag> <status> <response>
` when `status` or `response` is provided.
- **Wireshark Filter:** `imap`
- **CLI Build:** `frameassembly show imap_login_audit.frasm`

```frameassembly
host laptop   { ip 172.16.25.44 }
host mail_box { ip 172.16.25.10 }

compile {
    laptop -> mail_box tcp syn srcport 52143 dstport 143 win 65535 mss 1460 wait 1ms
    laptop <- mail_box tcp syn ack win 65535 mss 1460 wait 1ms
    laptop -> mail_box tcp ack wait 1ms
    laptop <- mail_box imap tag "*" status "OK" response "IMAP4rev1 Service Ready" wait 2ms
    // 1. Failed login -> tagged NO
    laptop -> mail_box imap tag "A01" cmd "LOGIN" arg "jdoe WrongPass1" wait 3ms
    laptop <- mail_box imap tag "A01" status "NO" response "LOGIN failed." wait 5ms
    // 2. Valid login + SELECT INBOX
    laptop -> mail_box imap tag "A02" cmd "LOGIN" arg "jdoe LabPass2026" wait 2ms
    laptop <- mail_box imap tag "A02" status "OK" response "LOGIN completed" wait 2ms
    laptop -> mail_box imap tag "A03" cmd "SELECT" arg "INBOX" wait 2ms
    laptop <- mail_box imap tag "A03" status "OK" response "[READ-WRITE] SELECT completed"
}
```

## 10.13 · POP3 (`pop3`): POP3 Failed Login (`-ERR`) + Successful Mailbox `STAT` & `QUIT` (`pop3_session_audit.frasm`)

Establishes a TCP 110 session, captures a rejected password attempt (`err`), then completes `USER` -> `PASS` -> `STAT` -> `QUIT`.

- **Protocols:** `pop3`, `tcp` (16 Ethernet frames)
- **Wire Behavior:** Defaults to TCP destination port `110` (`psh ack`) and appends `
` per RFC 1939. Formats `+OK <response>
` on `ok` and `-ERR <response>
` on `err`.
- **Wireshark Filter:** `pop`
- **CLI Build:** `frameassembly show pop3_session_audit.frasm`

```frameassembly
host workstation { ip 172.16.16.40 }
host legacy_mail { ip 172.16.16.110 }

compile {
    workstation -> legacy_mail tcp syn srcport 52110 dstport 110 win 65535 mss 1460 wait 1ms
    workstation <- legacy_mail tcp syn ack win 65535 mss 1460 wait 1ms
    workstation -> legacy_mail tcp ack wait 1ms
    workstation <- legacy_mail pop3 ok response "Dovecot POP3 ready." wait 2ms
    workstation -> legacy_mail pop3 cmd "USER" arg "ops_scanner" wait 1ms
    workstation <- legacy_mail pop3 ok response "Pass required" wait 1ms
    workstation -> legacy_mail pop3 cmd "PASS" arg "BadPass1" wait 4ms
    workstation <- legacy_mail pop3 err response "[AUTH] Authentication failed." wait 5ms
    workstation -> legacy_mail pop3 cmd "USER" arg "ops_scanner" wait 1ms
    workstation <- legacy_mail pop3 ok wait 1ms
    workstation -> legacy_mail pop3 cmd "PASS" arg "LabPass99" wait 2ms
    workstation <- legacy_mail pop3 ok response "Logged in." wait 1ms
    workstation -> legacy_mail pop3 cmd "STAT" wait 1ms
    workstation <- legacy_mail pop3 ok response "3 4096" wait 1ms
    workstation -> legacy_mail pop3 cmd "QUIT" wait 1ms
    workstation <- legacy_mail pop3 ok response "Logging out."
}
```

## 10.14 · SNMPv1 (`snmp1`): SNMPv1 System MIB Poll (`sysDescr.0` / `sysName.0`) + ColdStart & Enterprise Traps (`snmp1_poll_and_traps.frasm`)

Polls `sysDescr.0` on UDP 161, returns a multi-varbind `response`, and emits both a standard `gentrap 0` (`coldStart`) and an `enterpriseSpecific` (`gentrap 6`) hardware alarm trap on UDP 162.

- **Protocols:** `snmp1` (4 Ethernet frames)
- **Wire Behavior:** Selects UDP `dstport 162` automatically for `trap` (the default PDU) and UDP `161` (with `161 -> ephemeral` port reversal on `<- response`) for `get`, `getnext`, `set`, and `response`. Encodes dotted numeric OIDs (`1.3.6.1.4.1.318` or `.1.3.6.1...`) into compact ASN.1 BER base-128 VLQ octets (`0x2b 0x06 0x01 ...`) and computes nested SEQUENCE lengths.
- **Wireshark Filter:** `snmp`
- **CLI Build:** `frameassembly show snmp1_poll_and_traps.frasm`

```frameassembly
host poller   { ip 172.16.40.10 }
host legacy_sw { ip 172.16.40.25 }

compile {
    // 1. Poll sysDescr.0 (1.3.6.1.2.1.1.1.0) on UDP 161
    poller -> legacy_sw snmp1 get community "ops-ro" reqid 1001 oid 1.3.6.1.2.1.1.1.0 wait 2ms
    poller <- legacy_sw snmp1 response community "ops-ro" reqid 1001 varbind 1.3.6.1.2.1.1.1.0 string "Managed L2 Switch v4.2" varbind 1.3.6.1.2.1.1.3.0 timeticks 8640000 wait 5ms
    // 2. Generic coldStart trap (gentrap 0, spectrap 0) on UDP 162
    legacy_sw -> poller snmp1 trap community "ops-ro" enterprise 1.3.6.1.4.1.9.1.516 agentip 172.16.40.25 gentrap 0 spectrap 0 sysuptime 120 wait 2ms
    // 3. Enterprise-specific PSU fault trap (gentrap 6, spectrap 42) with typed varbinds
    legacy_sw -> poller snmp1 trap community "ops-ro" enterprise 1.3.6.1.4.1.9.9.13 gentrap 6 spectrap 42 sysuptime 45000 varbind 1.3.6.1.2.1.1.5.0 string "sw-idf-03" varbind 1.3.6.1.4.1.9.9.13.1.5.1.3.1 int 4
}
```

## 10.15 · SNMPv2c (`snmp2`): ifXTable 64-Bit Counter Walk + Acknowledged SNMPv2c LinkDown Inform (`snmp2_getbulk_and_inform.frasm`)

Walks 64-bit high-capacity interface counters via `getbulk` on UDP 161, then delivers a reliable `snmp2 inform` (`linkDown` `1.3.6.1.6.3.1.1.5.3`) on UDP 162 with manager `response` acknowledgment.

- **Protocols:** `snmp2` (4 Ethernet frames)
- **Wire Behavior:** Encodes `GetBulkRequest` (`0xa5`) overloading the BER error-status and error-index slots with `nonrepeaters` (default `0`) and `maxrepetitions` (default `10`) per RFC 3416. Automatically prepends `1.3.6.1.2.1.1.3.0` (`sysUpTime.0` `TimeTicks`) on `trap` (`0xa7`), `inform` (`0xa6`), and `report` (`0xa8`) when `sysuptime` is specified.
- **Wireshark Filter:** `snmp`
- **CLI Build:** `frameassembly show snmp2_getbulk_and_inform.frasm`

```frameassembly
host nms_poller { ip 10.30.10.20 }
host dist_sw    { ip 10.30.10.1 }

compile {
    // 1. High-capacity 64-bit interface counter bulk poll on UDP 161
    nms_poller -> dist_sw snmp2 getbulk community "infra-ro" reqid 2001 nonrepeaters 1 maxrepetitions 5 varbind 1.3.6.1.2.1.1.3.0 null varbind 1.3.6.1.2.1.31.1.1.1.6 null wait 2ms
    nms_poller <- dist_sw snmp2 response community "infra-ro" reqid 2001 varbind 1.3.6.1.2.1.1.3.0 timeticks 43200000 varbind 1.3.6.1.2.1.31.1.1.1.6.101 counter64 184502910440 varbind 1.3.6.1.2.1.31.1.1.1.1.101 string "TenGigabitEthernet1/0/1" wait 5ms
    // 2. Acknowledged SNMPv2c InformRequest for linkDown (1.3.6.1.6.3.1.1.5.3) on UDP 162
    dist_sw -> nms_poller snmp2 inform community "infra-trap" reqid 9001 sysuptime 43200500 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.2.2.1.1.101 int 101 varbind 1.3.6.1.2.1.2.2.1.8.101 int 2 wait 1ms
    dist_sw <- nms_poller snmp2 response community "infra-trap" reqid 9001 varbind 1.3.6.1.2.1.1.3.0 timeticks 43200500 varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.6.3.1.1.5.3
}
```

## 10.16 · SNMPv3 USM (authPriv) (`snmp3`): Full RFC 3414 Engine Discovery (`report`) + SHA-256/AES-128 `authPriv` Poll & Trap (`snmp3_usm_discovery_and_authpriv.frasm`)

Walks through RFC 3414 USM engine discovery (`usmStatsUnknownEngineIDs.0`), authenticated/encrypted `get` + `response` on UDP 161, and an `authPriv` encrypted `snmp3 trap` on UDP 162.

- **Protocols:** `snmp3` (5 Ethernet frames)
- **Wire Behavior:** Derives `msgFlags` automatically from provided credentials: `noAuthNoPriv` (neither set), `authNoPriv` (`auth` only), or `authPriv` (`auth` + `priv`, setting `0x03`, plus `0x04` Reportable on requests/informs). Runs RFC 3414 / RFC 7860 password-to-key (`Ku`, 1 MiB expansion) and engine-localized (`Kul`) derivation for `md5`, `sha` (SHA-1), `sha256`, `sha384`, and `sha512`.
- **Wireshark Filter:** `snmp`
- **CLI Build:** `frameassembly show snmp3_usm_discovery_and_authpriv.frasm`

```frameassembly
host zabbix_srv { ip 172.18.10.50 }
host core_rtr   { ip 172.18.10.1 }

compile {
    // 1. Unauthenticated USM EngineID discovery probe -> Agent replies with Report PDU
    zabbix_srv -> core_rtr snmp3 get user "" reqid 100 wait 1ms
    zabbix_srv <- core_rtr snmp3 report user "" engineid "80001f8880aabbccdd" engineboots 5 enginetime 8420 reqid 100 varbind 1.3.6.1.6.3.15.1.1.4.0 counter32 1 wait 3ms
    // 2. Encrypted authPriv (HMAC-SHA-256 + AES-128-CFB) GET & RESPONSE on UDP 161
    zabbix_srv -> core_rtr snmp3 get user "nms-v3-prod" engineid "80001f8880aabbccdd" engineboots 5 enginetime 8420 auth sha256 "StrongAuthKey2026!" priv aes "StrongPrivKey2026!" reqid 101 oid 1.3.6.1.2.1.1.5.0 wait 2ms
    zabbix_srv <- core_rtr snmp3 response user "nms-v3-prod" engineid "80001f8880aabbccdd" engineboots 5 enginetime 8420 auth sha256 "StrongAuthKey2026!" priv aes "StrongPrivKey2026!" reqid 101 varbind 1.3.6.1.2.1.1.5.0 string "core-rtr-fra1.internal" wait 5ms
    // 3. Encrypted authPriv SNMPv3 Trap on UDP 162 (authoritative sender = core_rtr)
    core_rtr -> zabbix_srv snmp3 trap user "nms-v3-prod" engineid "80001f8880aabbccdd" engineboots 5 enginetime 8425 auth sha256 "StrongAuthKey2026!" priv aes "StrongPrivKey2026!" sysuptime 842500 varbind 1.3.6.1.6.3.1.1.4.1.0 oidval 1.3.6.1.6.3.1.1.5.4 varbind 1.3.6.1.2.1.2.2.1.2.1 string "HundredGigE0/0/0/1"
}
```

## 10.17 · Syslog (`syslog`): Multi-Severity Security Audit over UDP 514 & Reliable TCP 514 (`syslog_siem_pipeline.frasm`)

Sends a firewall drop alert and OSPF adjacency warning over UDP 514, then opens a TCP 514 session to deliver a high-priority authentication alert.

- **Protocols:** `syslog`, `tcp` (6 Ethernet frames)
- **Wire Behavior:** Computes `<PRI> = facility * 8 + severity` automatically (default `facility 16` `local0`, `severity 6` `info` -> `<134>`). Formats a complete RFC 5424 `<PRI>1 TIMESTAMP HOSTNAME APP PROCID MSGID - MSG` wire payload that Wireshark and syslog-ng/rsyslog parse out of the box.
- **Wireshark Filter:** `syslog`
- **CLI Build:** `frameassembly show syslog_siem_pipeline.frasm`

```frameassembly
host branch_fw { ip 172.16.1.1 }
host log_relay { ip 172.16.100.10 }

compile {
    // 1. Stateless UDP 514 security & routing logs
    branch_fw -> log_relay syslog facility 4 severity 4 hostname "branch-fw-01" app "filterlog" msgid "DROP" msg "Blocked TCP SYN 203.0.113.99:44112 -> 172.16.1.10:3389" wait 2ms
    branch_fw -> log_relay syslog facility 16 severity 3 hostname "branch-fw-01" app "ospfd" msgid "ADJCHG" msg "Neighbor 172.16.0.2 Down: Dead timer expired" wait 4ms
    // 2. Reliable TCP 514 syslog stream (transport tcp)
    branch_fw -> log_relay tcp syn srcport 52514 dstport 514 win 65535 mss 1460 wait 1ms
    branch_fw <- log_relay tcp syn ack win 65535 mss 1460 wait 1ms
    branch_fw -> log_relay tcp ack wait 1ms
    branch_fw -> log_relay syslog facility 10 severity 2 hostname "branch-fw-01" app "sudo" procid "4812" msg "Critical privilege escalation alert" transport tcp
}
```

## 10.18 · NetFlow v5 (`netflow`): Multi-Flow Export: HTTPS Upload Spike, DNS Lookup & ICMP Probe (`netflow_collector_test.frasm`)

Exports three sequential NetFlow v5 records from a border router representing a large HTTPS transfer, a UDP DNS query, and an ICMP ping flow.

- **Protocols:** `netflow` (3 Ethernet frames)
- **Wire Behavior:** Defaults UDP destination port to `2055` and builds the exact 24-byte NetFlow v5 header + 48-byte flow record (`72` UDP payload bytes). Populates protocol defaults (`proto 6` TCP, `packets 10`, `octets 1500`) whenever counters are omitted.
- **Wireshark Filter:** `cflow`
- **CLI Build:** `frameassembly show netflow_collector_test.frasm`

```frameassembly
host border_rtr     { ip 172.16.0.1 }
host flow_collector { ip 172.16.100.55 }

compile {
    // 1. Large outbound HTTPS transfer (proto 6 = TCP)
    border_rtr -> flow_collector netflow srcip 10.20.5.14 dstip 203.0.113.80 srcport 54120 dstport 443 proto 6 packets 8500 octets 12240000 wait 2ms
    // 2. Internal-to-DMZ DNS flow (proto 17 = UDP)
    border_rtr -> flow_collector netflow srcip 10.20.5.14 dstip 172.16.10.53 srcport 59102 dstport 53 proto 17 packets 2 octets 148 wait 2ms
    // 3. ICMP reachability flow (proto 1 = ICMP)
    border_rtr -> flow_collector netflow srcip 10.20.5.14 dstip 8.8.8.8 srcport 0 dstport 0 proto 1 packets 4 octets 336
}
```

## 10.19 · IPFIX (`ipfix`): Mixed IPv4 & IPv6 VRF Flow Telemetry to an IPFIX Collector (`ipfix_dualstack_flows.frasm`)

Exports an IPv4 enterprise HTTPS flow (`domainid 10`) followed by an IPv6 service-mesh gRPC flow (`domainid 20`) to UDP port 4739.

- **Protocols:** `ipfix` (2 Ethernet frames)
- **Wire Behavior:** Defaults to UDP destination port `4739` and builds the 16-byte IPFIX Version `0x000a` header with exact total message length and Observation Domain ID. Bundles a self-describing Template Set (`Set ID 2`, Template ID `256`) plus the Data Set (`Set ID 256`) in one UDP datagram.
- **Wireshark Filter:** `cflow.version == 10`
- **CLI Build:** `frameassembly show ipfix_dualstack_flows.frasm`

```frameassembly
host spine_exporter { ip 172.20.0.1 }
host ipfix_ingest   { ip 172.20.50.10 }

compile {
    // 1. VRF 10 IPv4 flow record
    spine_exporter -> ipfix_ingest ipfix domainid 10 srcip 10.100.4.15 dstip 203.0.113.44 srcport 50112 dstport 443 proto 6 packets 420 octets 512000 wait 3ms
    // 2. VRF 20 IPv6 flow record over the same exporter session
    spine_exporter -> ipfix_ingest ipfix domainid 20 srcip 2001:db8:20::15 dstip 2001:db8:99::5051 srcport 54200 dstport 50051 proto 6 packets 95 octets 84000
}
```

## 10.20 · sFlow v5 (`sflow`): Multi-Switch Leaf-Spine sFlow v5 Telemetry Stream (`sflow_leaf_spine.frasm`)

Simulates two leaf switches exporting sequential sFlow v5 datagrams (including an IPv6 loopback agent IP) to a central collector.

- **Protocols:** `sflow` (3 Ethernet frames)
- **Wire Behavior:** Defaults UDP destination port to `6343` and aligns all fields to 4-byte XDR boundaries per the sFlow v5 specification. Sets Agent Address Type to `1` (4-byte IPv4) or `2` (16-byte IPv6) automatically from `agentip`.
- **Wireshark Filter:** `sflow`
- **CLI Build:** `frameassembly show sflow_leaf_spine.frasm`

```frameassembly
host leaf_01   { ip 172.18.1.11 }
host leaf_02   { ip 172.18.1.12 }
host collector { ip 172.18.100.50 }

compile {
    leaf_01 -> collector sflow agentip 172.18.1.11 subagentid 0 seq 101 uptime 450000 samples 1 wait 2ms
    leaf_01 -> collector sflow agentip 172.18.1.11 subagentid 0 seq 102 uptime 451000 samples 1 wait 2ms
    leaf_02 -> collector sflow agentip 2001:db8:18::12 subagentid 1 seq 55 uptime 820000 samples 1
}
```
