Protocol 83 of 81Layer 7FrameAssembly v3.3.0
Raw .mdllms-full.txt
gtpcGPRS Tunneling Protocol v2 Control Plane (4G S11 / S5-C)

gtpc — 3GPP S11/N26 GTPv2-C Session & Bearer Signaling

Default Port / Protocol
UDP 2123
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
gtpv2
Standards & Specs
3GPP TS 29.274, RFC 768
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6UDP 2123GTPv2-C (3GPP TS 29.274)
L2 Tagging: vlan · qinq · repeatable mpls · fcsHost Family: Dual-Stack IPv4/IPv6L3 QoS & TTL: ttl · dscp · ecnL4 State: UDP

What It Does on the Wire

Need to test S11 or S5/S8 roaming firewalls on UDP 2123 without spinning up Open5GS? gtpc packs 3GPP TS 29.274 GTPv2-C headers, TBCD-encoded imsi, DNS-label apn, teid, and cause IEs automatically.

GPRS Tunneling Protocol version 2 Control Plane (gtpc, 3GPP TS 29.274) orchestrates subscriber bearer sessions across 4G LTE Evolved Packet Core (S11 MME <-> SGW, S5/S8 SGW <-> PGW) and 4G/5G interworking (N26 AMF <-> MME) interfaces on UDP port 2123. Every GTPv2-C PDU starts with a Version 2 header (Flags with T-bit TEID presence, 1-byte Message Type, 16-bit Message Length, optional 32-bit TEID, 24-bit Sequence Number, and spare byte) followed by TLV Information Elements (IMSI, Access Point Name, RAT Type, Cause, Recovery, PDN Address Allocation).

FrameAssembly encodes valid BCD-packed IMSI digits, DNS-label-encoded APN strings, 24-bit sequence numbers, and automatic T-bit header formatting (omitting the 4-byte TEID slot on path-management echorequest/echoreply messages per TS 29.274 Section 5.1).

01. Application

S11 / S5-C Create Session & Bearer Lifecycle Verification

Script createsessionrequest -> createsessionresponse -> modifybearerrequest -> deletesessionrequest exchanges with explicit teid, imsi, apn, and subscriber addr IEs for Open5GS, Magma, or packet-core probe testing.

02. Application

GRX / IPX Roaming Firewall (S8 UDP 2123) Security Audits

Test GTP firewall inspection policies against roaming createsessionrequest messages carrying unauthorized Home/Visited IMSI prefixes, rogue APNs, or abnormal recovery restart counters.

03. Application

GTP Path-Management Echo Health Checks (T=0)

Emit TEID-less gtpc echorequest and echoreply heartbeats (recovery IE) to validate SGW/PGW liveness monitors and Wireshark gtpv2 correlation.

Fig. 1 · RFC Octet & Bit Schematic

RFC Wire Header Layout (gtpc)

Select any 32-bit wire word or field slice below to inspect which .frasm modifiers control those octets and what defaults the compiler writes.

0 ··············· 15 · 16 ··············· 31 bit
Selected Wire Segment
GTPv2-C (3GPP TS 29.274) Wire PDU & Payload (Variable)
Controlling .frasm Modifiers
gtpc echorequest · teid · seqnum · cause · imsi · payload · hexpayload
Compiler Default Behavior
RFC-compliant GTPv2-C (3GPP TS 29.274) defaults (3GPP TS 29.274)

Minimal Quickstart (gtpc_quickstart.frasm)

Select Preview Packets to compile in-browser and inspect timestamps + wire byte lengths, or open directly in the Playground.

gtpc_quickstart.frasm7 lines
Open in Playground
host mme_s11 { ip 10.200.11.10 }
host sgw_s11 { ip 10.200.11.20 }
compile {
mme_s11 -> sgw_s11 gtpc createsessionrequest teid 0x00000000 seqnum 101 imsi "001010123456789" apn "internet" rat 6 wait 4ms
mme_s11 <- sgw_s11 gtpc createsessionresponse teid 0x10012002 seqnum 101 cause 16 addr 100.64.10.25
}

Handled Automatically on the Wire

  • Defaults to UDP destination port 2123 (swapping ports automatically on <- responses) and computes the 16-bit GTPv2-C Message Length (excluding the initial 4 octets per 3GPP TS 29.274).
  • Packs imsi decimal strings into TBCD octets (0xf filler nibble on odd-length IMSIs) and encodes apn labels in RFC 1035 length-prefixed wire format.
  • Clears the T flag (8-byte header without TEID) on echorequest / echoreply and sets T=1 (12-byte header with 32-bit teid) on session/bearer messages.
Multi-Frame Example

4G LTE S11 Session Setup, S1-U Bearer Handshake & Session Teardown

Simulates an MME and Serving Gateway running an Echo liveness check, establishing an E-UTRAN (rat 6) subscriber session (cause 16 Request Accepted), modifying the bearer after eNodeB S1-U setup, and tearing down the session.

gtpc_s11_bearer_lifecycle.frasm17 lines
Open in Playground
host mme_01 { ip 172.22.11.5 }
host sgw_01 { ip 172.22.11.50 }
compile {
// 1. S11 GTPv2-C Path Management Echo (T-bit = 0)
mme_01 -> sgw_01 gtpc echorequest seqnum 1 recovery 14 wait 2ms
mme_01 <- sgw_01 gtpc echoreply seqnum 1 recovery 8 wait 5ms
// 2. Initial Attach: Create Session Request (initial TEID 0) & Accepted Response (cause 16)
mme_01 -> sgw_01 gtpc createsessionrequest teid 0x00000000 seqnum 2 imsi "310260987654321" apn "ims" rat 6 dscp 46 wait 6ms
mme_01 <- sgw_01 gtpc createsessionresponse teid 0x00a10001 seqnum 2 cause 16 addr 10.96.0.42 dscp 46 wait 4ms
// 3. Modify Bearer after eNodeB allocates S1-U downlink TEID
mme_01 -> sgw_01 gtpc modifybearerrequest teid 0x00b20001 seqnum 3 rat 6 wait 3ms
mme_01 <- sgw_01 gtpc modifybearerresponse teid 0x00a10001 seqnum 3 cause 16 wait 20ms
// 4. Detach: Delete Session Request / Response
mme_01 -> sgw_01 gtpc deletesessionrequest teid 0x00b20001 seqnum 4 wait 3ms
mme_01 <- sgw_01 gtpc deletesessionresponse teid 0x00a10001 seqnum 4 cause 16
}
Terminal Commands (FrameAssembly CLI v3.3.0)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show gtpc_s11_bearer_lifecycle.frasm

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

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

# 4. Verify dissected protocol fields in tshark
tshark -r gtpc_s11_bearer_lifecycle.pcap -Y "gtpv2"

All gtpc Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after gtpc:

src_host -> dst_host gtpc [echorequest | echoreply | echoresponse | createsessionrequest | createsessionresponse | modifybearerrequest | modifybearerresponse | deletesessionrequest | deletesessionresponse | msgtype "<text>"] [teid <number>] [seqnum <0..16777215>] [cause <0..255>] [imsi "<text>"] [apn "<text>"] [rat <0..255>] [recovery <0..255>] [addr <ip>]
Keyword / OptionAccepted ValueDefaultEffect on Packet
echorequest | echoreply | echoresponse | createsessionrequest | createsessionresponse | modifybearerrequest | modifybearerresponse | deletesessionrequest | deletesessionresponse | msgtype "<text>"3GPP TS 29.274 Message Type keyword or nameechorequest (1)Sets byte 1 of the GTPv2-C header (1 Echo Req, 2 Echo Resp, 32/33 Create Session, 34/35 Modify Bearer, 36/37 Delete Session).
teid <number>32-bit Tunnel Endpoint Identifier0Writes bytes 4..7 of the GTPv2-C header when T=1 (0x00000000 on initial createsessionrequest).
seqnum <0..16777215>24-bit GTPv2-C Sequence Number1Writes the big-endian 3-byte transaction Sequence Number matching requests to responses.
cause <0..255>8-bit GTPv2 Cause value (IE Type 2)16 (Request accepted) on responsesAppends the Cause TLV IE (16 Request accepted, 64 Context not found, 72 No resources available).
imsi "<text>"15-digit International Mobile Subscriber Identity string (IE Type 1)Omitted (or default on Create Session)Encodes the subscriber IMSI in 3GPP TBCD nibble-swapped format inside IE Type 1.
apn "<text>"Access Point Name string (IE Type 71)OmittedAppends IE Type 71 (APN, e.g. "internet" or "ims.mnc001.mcc001.gprs").
rat <0..255>8-bit RAT Type (IE Type 82)6 (EUTRAN) when setAppends IE Type 82 (1 UTRAN, 2 GERAN, 3 WLAN, 6 EUTRAN/LTE, 8 NR/5G).
recovery <0..255>8-bit Restart Counter (IE Type 3)OmittedAppends IE Type 3 (Recovery node restart counter) for peer reboot detection.
addr <ip>IPv4 or IPv6 subscriber PDN address (IE Type 79 PAA)OmittedAppends IE Type 79 (PDN Address Allocation) with PDN Type IPv4 (1) or IPv6 (2).

Cross-Layer Wrappers Valid with gtpc

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

14 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back).
comment "<text>"Quoted UTF-8 annotationOmittedAttaches an Enhanced Packet Block opt_comment annotation when compiling to .pcapng (Wireshark pkt_comment filter).
payload "<text>" | hexpayload "<hex>"Quoted text or hex bytes (choose one)OmittedAppends or overrides raw payload bytes ("deadbeef", "de:ad:be:ef", or "\x01\x02") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac> | ethertype <0..65535>Colon/hyphen/Cisco MAC · EtherType 0..65535 (e.g. 0x0800)Host MAC / RFC multicast MAC / auto EtherTypeOverrides the 14-byte Ethernet II source MAC, destination MAC, or standalone Layer 2 16-bit EtherType.
fcs | badfcsEthernet CRC-32 trailer flags (choose one)Omittedfcs appends a valid IEEE 802.3 4-byte CRC-32 Frame Check Sequence trailer; badfcs XOR-corrupts the CRC-32 for NIC/tap negative tests.
vlan <0..4095> [pcp <0..7>] [dei <0|1>]VLAN ID 0..4095, PCP 0..7, DEI 0..1UntaggedWraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority.
qinq <0..4095> [innervlan <0..4095>]Outer S-VLAN 0..4095, Inner C-VLAN 0..4095Untagged (innervlan 1 when qinq is set)Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100).
mpls <0..1048575> [label <0..1048575>] [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Repeatable label stack (0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255)Unlabeled (auto bos=0 on outer labels, bos=1 on bottom)Prepends one or more 32-bit MPLS label shims (0x8847, e.g. mpls 16000 mpls 24010) ahead of Layer 2 EoMPLS or Layer 3 payloads.
ttl <0..255> [dscp <0..63>] [ecn <0..3>]TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3ttl 64, dscp 0, ecn 0Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings.
ipid <0..65535> [df] [mf] [fragoffset <0..8191>] [routeralert] [badipchecksum]IPv4 ID, DF/MF flags, offset 0..8191, Router Alert & checksum faultipid 1, flags 0, fragoffset 0, valid RFC 1071 checksumSets IPv4 Identification/fragmentation, injects RFC 2113 Router Alert (20 04 00 00), or corrupts the 16-bit IPv4 header checksum (badipchecksum).
flowlabel <0..1048575>20-bit IPv6 Flow Label (0..1048575)0Sets the 20-bit IPv6 Flow Label for ECMP routing tests (valid on IPv6 endpoint pairs only).
srcport <0..65535> | dstport <0..65535>Port number 0..65535srcport 49152 (remembered), UDP 2123Overrides source or destination port and remembers the port pair automatically on <- replies.
transport sctpOptional SCTP association transport (IP Proto 132)UDP (UDP 2123)Carries this Layer 7 PDU inside a stateful RFC 9260 SCTP DATA chunk with automatic Verification Tag, TSN tracking, and CRC-32c.
badchecksum | nochecksumL4 checksum fault or UDP zero-checksum flagValid RFC checksum / CRC-32cbadchecksum corrupts the L4 checksum for negative firewall/NIC offload tests; nochecksum writes 0x0000 in UDP headers.

Gotchas & Quick Fixes

Use gtpc (UDP 2123) for Control Signaling and gtpu (UDP 2152) for User Data

Rejected
mme -> sgw gtpu createsessionrequest teid 0x100 imsi "001010123456789"
Valid v3.3.0 Syntax
mme -> sgw gtpc createsessionrequest teid 0x0 seqnum 1 imsi "001010123456789"

GTPv2-C (gtpc, UDP 2123) negotiates control-plane tunnels and TEIDs, whereas GTPv1-U (gtpu, UDP 2152) encapsulates subscriber user-plane IP packets (gpdu).

Quote 15-Digit IMSI Values That Begin with Leading Zeros

Rejected
mme -> sgw gtpc createsessionrequest imsi 001010123456789
Valid v3.3.0 Syntax
mme -> sgw gtpc createsessionrequest imsi "001010123456789"

Test PLMN IMSIs (00101...) start with leading zeros that an unquoted integer would strip; pass imsi as a double-quoted string so all 15 TBCD digits are preserved.

Field Guide 03
Poke Stateful Firewalls, Suricata, Zeek & OT Conduits