# Layer 7 Web, TLS/QUIC, VoIP & Remote Access

> **FrameAssembly v3.2.2** · Category 06 (Layer 7 · 16 Protocols) · Canonical URL: https://frameassembly-lang.dev/docs/protocols/categories/l7-web-cloud-voip

WAF rules, TLS SNI/ALPN inspection policies, HTTP/2 & gRPC service meshes, and VoIP Session Border Controllers depend on exact application-layer framing riding atop established transport state. FrameAssembly synthesizes 16 web, encrypted transport, remote-administration, and real-time media protocols without spinning up web servers, SIP softphones, or TLS certificate chains.

Every TCP-based protocol in this tier (`http`, `http2`, `grpc`, `websocket`, `tls`, `ssh`, `telnet`, `ftp`, `whois`, `rtsp`, and `sip transport tcp`) shares the canonical 4-tuple TCP sequence state machine so multi-frame handshakes, HTTP/2 binary streams, XOR-masked WebSocket payloads, and RTSP camera sessions decode cleanly in Wireshark and Suricata.

## Category Wire & Endpoint Rules

- **`hosthdr` & `transporthdr` Disambiguation:** Use `hosthdr "app.example.com"` on `http`/`ssdp` (because `host` opens a top-level endpoint block) and `transporthdr "RTP/AVP;unicast;client_port=5004-5005"` on `rtsp` (because `transport` is reserved for L4 `tcp|udp`).
- **Nested TLS, HTTP/2 & gRPC Length Framing:** `tls` computes outer 5-byte record lengths, 3-byte handshake lengths, SNI (`0x0000`), and ALPN (`0x0010`); `grpc` wraps Protobuf payloads in 5-byte length-prefixed HTTP/2 frames.
- **Genuine XOR Masking on WebSocket & STUN:** `websocket maskkey <u32>` XOR-masks client payload bytes per RFC 6455, and `stun xormappedaddr <ip>` XOR-encodes NAT bindings with `0x2112a442`.
- **Matched VoIP SIP + RTP + DSCP EF Workflows:** Combine `sip invite` (`Call-ID`, `z9hG4bK` `Via`, SDP `body`) with `rtp pt 0 dscp 46` to audit SBC NAT pinholes and WAN QoS remarking.

## Multi-Protocol Example: Stateful TLS 1.3 SNI + HTTP/2 Stream & VoIP SIP/RTP Call Setup (`web_tls_http2_voip.frasm`)

Establishes a TCP 443 connection carrying TLS 1.3 ClientHello/ServerHello (`alpn "h2"`) + HTTP/2 connection preface and HEADERS, followed by a STUN NAT check, SIP INVITE/200 OK, and DSCP-46 G.711 RTP voice frame.

```frameassembly
host endpoint { ip 10.60.1.25 }
host edge_gw  { ip 10.60.1.10 }

compile {
    endpoint -> edge_gw tcp syn srcport 52400 dstport 443 win 65535 mss 1460 wait 1ms
    endpoint <- edge_gw tcp syn ack win 65535 mss 1460 wait 1ms
    endpoint -> edge_gw tcp ack wait 1ms
    endpoint -> edge_gw tls clienthello sni "api.corp.example" alpn "h2" ciphersuite 0x1301 wait 2ms
    endpoint <- edge_gw tls serverhello ciphersuite 0x1301 wait 1ms
    endpoint -> edge_gw http2 preface wait 1ms
    endpoint -> edge_gw http2 headers streamid 1 wait 3ms
    endpoint -> edge_gw stun bindingrequest txid 0x10203040 wait 1ms
    endpoint <- edge_gw stun bindingresponse txid 0x10203040 xormappedaddr 198.51.100.25 wait 2ms
    endpoint -> edge_gw sip invite uri "sip:noc@edge.example" callid "call-9001" cseq 1 wait 2ms
    endpoint <- edge_gw sip status 200 reason "OK" callid "call-9001" cseq 1 wait 2ms
    endpoint -> edge_gw rtp pt 0 seq 1 timestamp 160 ssrc 0x12345678 dscp 46
}
```

```bash
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show web_tls_http2_voip.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly web_tls_http2_voip.frasm web_tls_http2_voip.pcap
frameassembly web_tls_http2_voip.frasm web_tls_http2_voip.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse web_tls_http2_voip.pcap web_tls_http2_voip_edited.frasm

# 4. Verify dissected protocol fields in tshark
tshark -r web_tls_http2_voip.pcap -Y "tls || http2 || stun || sip || rtp"
```

- **Wireshark Display Filter:** `tls || http2 || stun || sip || rtp`

## Protocols in Category 06 (16 Native Builders)

| # | Keyword | Protocol | Default Port / Proto | Endpoint Rule | Wireshark Filter | Spec URL |
| --- | --- | --- | --- | --- | --- | --- |
| 46 | `http` | Hypertext Transfer Protocol HTTP/1.1 | `TCP 80` | Dual-Stack IPv4/IPv6 | `http` | https://frameassembly-lang.dev/docs/protocols/http |
| 47 | `http2` | Hypertext Transfer Protocol Version 2 Binary Framing | `TCP 443` | Dual-Stack IPv4/IPv6 | `http2` | https://frameassembly-lang.dev/docs/protocols/http2 |
| 48 | `grpc` | gRPC Remote Procedure Calls over HTTP/2 | `TCP 50051` | Dual-Stack IPv4/IPv6 | `grpc \|\| http2` | https://frameassembly-lang.dev/docs/protocols/grpc |
| 49 | `websocket` | WebSocket Framed Bidirectional Messaging | `TCP 80` | Dual-Stack IPv4/IPv6 | `websocket` | https://frameassembly-lang.dev/docs/protocols/websocket |
| 50 | `tls` | Transport Layer Security Record & Handshake Layer | `TCP 443` | Dual-Stack IPv4/IPv6 | `tls` | https://frameassembly-lang.dev/docs/protocols/tls |
| 51 | `quic` | QUIC v1 & v2 Encrypted UDP Transport | `UDP 443` | Dual-Stack IPv4/IPv6 | `quic` | https://frameassembly-lang.dev/docs/protocols/quic |
| 52 | `ssh` | Secure Shell Transport Layer Protocol | `TCP 22` | Dual-Stack IPv4/IPv6 | `ssh` | https://frameassembly-lang.dev/docs/protocols/ssh |
| 53 | `telnet` | Telnet Cleartext Terminal & IAC Negotiation | `TCP 23` | Dual-Stack IPv4/IPv6 | `telnet` | https://frameassembly-lang.dev/docs/protocols/telnet |
| 54 | `tftp` | Trivial File Transfer Protocol | `UDP 69` | Dual-Stack IPv4/IPv6 | `tftp` | https://frameassembly-lang.dev/docs/protocols/tftp |
| 55 | `ftp` | File Transfer Protocol Control Channel | `TCP 21` | Dual-Stack IPv4/IPv6 | `ftp` | https://frameassembly-lang.dev/docs/protocols/ftp |
| 56 | `whois` | WHOIS Domain & IP Directory Query Protocol | `TCP 43` | Dual-Stack IPv4/IPv6 | `whois` | https://frameassembly-lang.dev/docs/protocols/whois |
| 57 | `sip` | Session Initiation Protocol VoIP Signaling | `UDP 5060 (or TCP 5060 via transport tcp)` | Dual-Stack IPv4/IPv6 | `sip` | https://frameassembly-lang.dev/docs/protocols/sip |
| 58 | `rtp` | Real-time Transport Protocol Audio & Video Streams | `UDP 5004` | Dual-Stack IPv4/IPv6 | `rtp` | https://frameassembly-lang.dev/docs/protocols/rtp |
| 59 | `rtsp` | Real Time Streaming Protocol IP Camera & Media Control | `TCP 554` | Dual-Stack IPv4/IPv6 | `rtsp` | https://frameassembly-lang.dev/docs/protocols/rtsp |
| 60 | `stun` | Session Traversal Utilities for NAT | `UDP 3478` | Dual-Stack IPv4/IPv6 | `stun` | https://frameassembly-lang.dev/docs/protocols/stun |
| 61 | `ssdp` | Simple Service Discovery Protocol & UPnP Multicast | `UDP 1900 (239.255.255.250 / ff02::c)` | Dual-Stack IPv4/IPv6 | `ssdp` | https://frameassembly-lang.dev/docs/protocols/ssdp |
