# gesrtp — Port 18245 GE Fanuc / Emerson PacSystems SRTP PLC Ops (`gesrtp`)

> **FrameAssembly v3.3.0** · Protocol 121 of 81 · Canonical URL: https://frameassembly-lang.dev/docs/protocols/gesrtp

- **Full Protocol Name:** General Electric / Emerson Service Request Transport Protocol
- **Keyword:** `gesrtp`
- **OSI Layer & Transport:** Layer 7 · TCP 18245
- **Host Endpoint Rule:** Dual-Stack IPv4/IPv6
- **Standards:** GE Fanuc / Emerson PACSystems TCP/IP Ethernet Manual (GFK-1541)
- **Wireshark Display Filter:** `tcp.port == 18245`
- **Wire Encapsulation:** `Ethernet II -> [802.1Q / QinQ / MPLS] -> IPv4 / IPv6 -> TCP 18245 -> GE SRTP (Emerson PACSystems)`

## Overview

Every GE Fanuc / Emerson PacSystems PLC packet on TCP `18245` is a fixed 56-byte little-endian SRTP header — `gesrtp` maps register areas (`%R`, `%AI`, `%Q`, `%M`), `addr`, `count`, and `value` cleanly.

Service Request Transport Protocol (`gesrtp`) is the native Ethernet HMI/engineering protocol for **GE Fanuc Series 90-30 / 90-70, VersaMax, and Emerson PACSystems RX3i / RX7i PLCs** across power generation, water treatment, and rail signaling on **TCP port `18245`**. Every GE SRTP packet is a fixed **56-byte header** (plus optional extended payload when length > 6 bytes), starting with a 2-byte `Type` (`0x0000` 56-byte Init -> `0x0100` Init ACK, `0x0200` Request -> `0x0300` Piggybacked Response), `Sequence Number`, `Text Length`, `Mailbox Source/Dest`, `Packet Type` (`0xc0` Request / `0xd4` ACK), and `Service Request Code` (`0x04` Read System Memory, `0x07` Write System Memory, `0x43` Return Controller Type) targeting PLC memory segments (`%R`, `%AI`, `%AQ`, `%I`, `%Q`, `%M`).

FrameAssembly packs exact 56-byte little-endian GE SRTP frames and memory-segment selectors over stateful TCP port `18245`.

## Minimal Quickstart (`gesrtp_quickstart.frasm`)

```frameassembly
host ifix_scada { ip 10.182.1.10 }
host rx3i_plc   { ip 10.182.1.50 }

compile {
    ifix_scada -> rx3i_plc tcp syn srcport 51245 dstport 18245 wait 1ms
    ifix_scada <- rx3i_plc tcp syn ack wait 1ms
    ifix_scada -> rx3i_plc tcp ack wait 1ms
    ifix_scada -> rx3i_plc gesrtp init wait 2ms
    ifix_scada <- rx3i_plc gesrtp initack wait 3ms
    ifix_scada -> rx3i_plc gesrtp read seqnum 1 area "R" addr 1 count 4 wait 2ms
    ifix_scada <- rx3i_plc gesrtp response seqnum 1 status 0 value 750
}
```

### Automatic Wire Calculations

- Defaults to stateful TCP port `18245` (`psh ack`, automatic TCP `seq`/`acknum` across 56-byte headers).
- Emits the exact 56-byte `0x00` Initialization frame on `init`, `0x01` Initialization ACK on `initack`, `0x02` Service Request on `read`/`write`/`request`, and `0x03` Response on `response`.
- Maps GE PLC segment selectors (`"R"` -> `0x08` `%R` Registers, `"AI"` -> `0x0a` `%AI`, `"AQ"` -> `0x0c` `%AQ`, `"I"` -> `0x10` `%I`, `"Q"` -> `0x12` `%Q`, `"M"` -> `0x16` `%M`) and writes 0-based little-endian offsets (`addr - 1` when 1-based).

## Practical Lab Example: Emerson PACSystems RX3i Turbine Control Poll: Init, %R Register Read & %Q Output Write (`gesrtp_rx3i_plc_session.frasm`)

Opens TCP `18245`, completes the 56-byte SRTP `init`/`initack` handshake, reads 4 `%R` registers starting at `%R0001`, and writes a valve setpoint to `%R0010`.

```frameassembly
host cimplicity { ip 172.19.18.10 }
host pac_rx3i   { ip 172.19.18.100 }

compile {
    cimplicity -> pac_rx3i tcp syn srcport 53245 dstport 18245 wait 1ms
    cimplicity <- pac_rx3i tcp syn ack wait 1ms
    cimplicity -> pac_rx3i tcp ack wait 1ms
    // 1. 56-byte SRTP Session Initialization (0x00 -> 0x01)
    cimplicity -> pac_rx3i gesrtp init wait 2ms
    cimplicity <- pac_rx3i gesrtp initack wait 4ms
    // 2. Service Request 0x04: Read 4 words from %R0001
    cimplicity -> pac_rx3i gesrtp read seqnum 1 area "R" addr 1 count 4 wait 2ms
    cimplicity <- pac_rx3i gesrtp response seqnum 1 area "R" status 0 value 1800 wait 10ms
    // 3. Service Request 0x07: Write setpoint 1950 to %R0010
    cimplicity -> pac_rx3i gesrtp write seqnum 2 area "R" addr 10 count 1 value 1950 wait 2ms
    cimplicity <- pac_rx3i gesrtp response seqnum 2 status 0
}
```

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

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

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

# 4. Verify dissected protocol fields in tshark
tshark -r gesrtp_rx3i_plc_session.pcap
```

## All `gesrtp` Keywords & Header Options

Packet line pattern: `src_host -> dst_host gesrtp [init | initack | request | response | read | write | type "<text>"] [seqnum <0..65535>] [func "<text_or_num>"] [area "<text_or_num>"] [addr <0..65535>] [count <0..65535>] [value <number>] [status <0..65535>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `init \| initack \| request \| response \| read \| write \| type "<text>"` | GE SRTP Packet Type (`init` 0x00, `initack` 0x01, `read`/`write`/`request` 0x02, `response` 0x03) | `read (Type 0x02, Service 0x04)` | Selects byte 0 of the 56-byte GE SRTP header and initializes the Service Request byte (`0x04` Read, `0x07` Write). |
| `seqnum <0..65535> \| func "<text_or_num>"` | Sequence Number & 8-bit Service Request Code (`0x04` Read, `0x07` Write, `0x21` Program Load, `0x23` Run/Stop, `0x43` Info) | `seqnum 1, func 0x04` | Writes byte 2 (`Sequence Number`) and byte 42 (`Service Request Code`). |
| `area "<text_or_num>" \| addr <0..65535> \| count <0..65535>` | Memory Segment ("R","AI","AQ","I","Q","M" or hex selector), Register Offset, and Word/Byte Count | `area "R" (0x08), addr 1, count 1` | Writes byte 43 (`Memory Type Selector`), bytes 44..45 (`Memory Offset`), and bytes 46..47 (`Length`). |
| `value <number> \| status <0..65535>` | Register data value & 16-bit PLC Status word (`0x0000` OK) | `value 0, status 0` | Populates piggybacked/extended data bytes and response status codes. |

## Cross-Layer Options Valid with `gesrtp`

| Option | Range / Format | Default | Effect |
| --- | --- | --- | --- |
| `wait <number><ns\|us\|ms\|s\|m>` | Time gap (ns, us, ms, s, m) | `10ms` | Advances the packet timestamp clock after sending this packet and before the next packet (`wait 0ns` sends back-to-back). |
| `comment "<text>"` | Quoted UTF-8 annotation | `Omitted` | Attaches 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) | `Omitted` | Appends 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 EtherType` | Overrides the 14-byte Ethernet II source MAC, destination MAC, or standalone Layer 2 16-bit EtherType. |
| `fcs \| badfcs` | Ethernet CRC-32 trailer flags (choose one) | `Omitted` | `fcs` 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..1 | `Untagged` | Wraps 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..4095 | `Untagged (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..3 | `ttl 64, dscp 0, ecn 0` | Sets 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 fault | `ipid 1, flags 0, fragoffset 0, valid RFC 1071 checksum` | Sets 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) | `0` | Sets 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..65535 | `srcport 49152 (remembered), TCP 18245` | Overrides source or destination port and remembers the port pair automatically on `<-` replies. |
| `transport sctp` | Optional SCTP association transport (IP Proto 132) | `TCP (TCP 18245)` | Carries this Layer 7 PDU inside a stateful RFC 9260 SCTP `DATA` chunk with automatic Verification Tag, TSN tracking, and CRC-32c. |
| `badchecksum` | L4/ICMP/SCTP checksum fault injection flag | `Valid RFC checksum / CRC-32c` | Deliberately corrupts the TCP, SCTP CRC-32c, ICMP, or ICMPv6 checksum for negative IDS/firewall testing. |
| `seq <number> \| acknum <number> \| win\|window <0..65535> \| urgent <0..65535> \| syn \| ack \| psh \| fin \| rst \| urg \| ece \| cwr` | TCP sequence/ack numbers, window, flags, SACK, TCP-MD5 & TFO options | `psh ack, win 65535, automatic TCP seq/acknum` | Overrides automatic TCP sequence tracking, flags, or RFC 7323/2018/2385/7413 options (`mss`, `wscale`, `sackperm`, `sackblock`, `tsval`, `tsecr`, `tcpmd5`, `tfo`). |

## Common Mistakes & Quick Fixes

### Do Not Confuse Industrial gesrtp (TCP 18245) with Media RTP/SRTP (UDP 5004)

- **Valid v3.3.0 Syntax:** `hmi -> plc gesrtp read seqnum 1 area "R" addr 1 count 4`

Use `gesrtp` for General Electric / Emerson PACSystems PLC traffic on TCP `18245` (and `rtp` for RFC 3550 VoIP audio/video streams on UDP `5004`).

### Include init / initack Before Service Requests in Multi-Packet Captures

- **Valid v3.3.0 Syntax:** `hmi -> plc gesrtp init
hmi <- plc gesrtp initack
hmi -> plc gesrtp read seqnum 1 area "R" addr 1`

Real GE/Emerson PLCs and stateful OT IDS engines expect the 56-byte `0x00` -> `0x01` initialization exchange at the start of every TCP `18245` connection.
