# Layer 7 Telecom 4G EPC & 5G Core Control Signaling

> **FrameAssembly v3.3.0** · Category 09 (Layer 7 · 5 Protocols) · Canonical URL: https://frameassembly-lang.dev/docs/protocols/categories/telecom-4g-5g-signaling

Testing 4G LTE Evolved Packet Core (EPC) and 5G Standalone (5GC) control-plane security policies, roaming firewalls, and packet-broker dissectors normally requires heavy 3GPP core simulators. FrameAssembly v3.3.0 synthesizes native 3GPP control-plane interfaces directly from `.frasm` text: GTPv2-C (`gtpc`, UDP `2123`), 5G N4 PFCP (`pfcp`, UDP `8805`), Diameter S6a/Gx/Gy (`diameter`, TCP/SCTP `3868`), 5G N2 NGAP (`ngap`, SCTP `38412` PPID `60`), and 4G S1-MME S1AP (`s1ap`, SCTP `36412` PPID `18`).

SCTP-carried radio-core protocols (`ngap`, `s1ap`, and `diameter transport sctp`) automatically maintain per-association Verification Tags (`vtag`), stream sequence numbers, IANA Payload Protocol Identifiers (`60`, `18`, `46`), and hardware-table Castagnoli CRC-32c checksums.

## Category Wire & Endpoint Rules

- **Native SCTP Associations for 5G N2 & 4G S1-MME:** `ngap` (`dstport 38412`, `ppid 60`) and `s1ap` (`dstport 36412`, `ppid 18`) run natively over RFC 9260 SCTP `DATA` chunks with ASN.1 Aligned PER encoding and automatic CRC-32c.
- **CUPS 5G N4 PFCP & 4G S11 GTPv2-C Session Control:** `pfcp` (`UDP 8805`) encodes 64-bit `seid` Session Establishment/Modification/Deletion messages, while `gtpc` (`UDP 2123`) encodes 32-bit `teid`, `imsi`, `apn`, and `rat` Information Elements.
- **Dual TCP / SCTP Diameter 3868 AAA:** `diameter` defaults to stateful TCP `3868` and switches cleanly to SCTP `3868` (`ppid 46`) when `transport sctp` is appended.
- **Pair Control Plane with Layer 3 `gtpu` User Plane:** Combine `gtpc` / `pfcp` session setup with Layer 3 `gtpu` (`UDP 2152`, `teid`, 5G `qfi`) to test complete CUPS S11/N4 + S1-U/N3 packet captures.

## Multi-Protocol Example: 5G N2 NGAP + N4 PFCP + 4G S11 GTPv2-C & Diameter Roaming Audit (`telecom_4g_5g_core_signaling.frasm`)

Captures a 5G gNB-to-AMF SCTP 38412 NGSetup exchange (`ngap`), an SMF-to-UPF UDP 8805 PFCP Session Establishment (`pfcp`), an MME-to-SGW UDP 2123 GTPv2-C Create Session (`gtpc`), and an SCTP 3868 Diameter CER/CEA handshake (`diameter`).

```frameassembly
host ran_cp  { ip 172.22.10.10 }
host core_cp { ip 172.22.10.50 }

compile {
    ran_cp -> core_cp ngap ngsetuprequest gnbid 0x000102 plmn "00101" tac 100 ranname "gnb-metro-01" wait 1ms
    ran_cp <- core_cp ngap ngsetupresponse plmn "00101" wait 2ms
    ran_cp -> core_cp pfcp sessionestablishmentrequest seid 0x0102030405060708 seqnum 1 nodeid 172.22.10.10 wait 1ms
    ran_cp <- core_cp pfcp sessionestablishmentresponse seid 0x0102030405060708 seqnum 1 cause 16 wait 2ms
    ran_cp -> core_cp gtpc createsessionrequest teid 0 seqnum 10 imsi "001010123456789" apn "internet" rat 6 wait 1ms
    ran_cp <- core_cp gtpc createsessionresponse teid 0x00010001 seqnum 10 cause 16 addr 100.64.10.25 wait 2ms
    ran_cp -> core_cp diameter cer originhost "mme01.epc.mnc001.mcc001.3gppnetwork.org" realm "epc.mnc001.mcc001.3gppnetwork.org" transport sctp wait 1ms
    ran_cp <- core_cp diameter cea originhost "hss01.epc.mnc001.mcc001.3gppnetwork.org" realm "epc.mnc001.mcc001.3gppnetwork.org" resultcode 2001 transport sctp
}
```

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

# 2. Compile .frasm -> classic .pcap, nanosecond .pcapng, or pipe via '-'
frameassembly telecom_4g_5g_core_signaling.frasm telecom_4g_5g_core_signaling.pcap
frameassembly telecom_4g_5g_core_signaling.frasm telecom_4g_5g_core_signaling.pcapng

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

# 4. Verify dissected protocol fields in tshark
tshark -r telecom_4g_5g_core_signaling.pcap -Y "ngap || pfcp || gtpv2 || diameter"
```

- **Wireshark Display Filter:** `ngap || pfcp || gtpv2 || diameter`

## Protocols in Category 09 (5 Native Builders)

| # | Keyword | Protocol | Default Port / Proto | Endpoint Rule | Wireshark Filter | Spec URL |
| --- | --- | --- | --- | --- | --- | --- |
| 83 | `gtpc` | GPRS Tunneling Protocol v2 Control Plane (4G S11 / S5-C) | `UDP 2123` | Dual-Stack IPv4/IPv6 | `gtpv2` | https://frameassembly-lang.dev/docs/protocols/gtpc |
| 84 | `pfcp` | Packet Forwarding Control Protocol (5G N4 / 4G Sxa-Sxb CUPS) | `UDP 8805` | Dual-Stack IPv4/IPv6 | `pfcp` | https://frameassembly-lang.dev/docs/protocols/pfcp |
| 85 | `diameter` | Diameter Base, Credit-Control & 3GPP S6a/Gx/Gy AAA Signaling | `TCP 3868 (or SCTP 3868 / PPID 46 via transport sctp)` | Dual-Stack IPv4/IPv6 | `diameter` | https://frameassembly-lang.dev/docs/protocols/diameter |
| 86 | `ngap` | 5G Next Generation Application Protocol (N2 gNB <-> AMF over SCTP) | `SCTP 38412 (PPID 60)` | Dual-Stack IPv4/IPv6 | `ngap` | https://frameassembly-lang.dev/docs/protocols/ngap |
| 87 | `s1ap` | 4G LTE S1 Application Protocol (S1-MME eNB <-> MME over SCTP) | `SCTP 36412 (PPID 18)` | Dual-Stack IPv4/IPv6 | `s1ap` | https://frameassembly-lang.dev/docs/protocols/s1ap |
