# s7commplus — Port 102 S7-1200/1500 0x72 OMS+ Symbolic Sessions (`s7commplus`)

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

- **Full Protocol Name:** Siemens SIMATIC S7-1200 / S7-1500 S7commPlus OMS Protocol
- **Keyword:** `s7commplus`
- **OSI Layer & Transport:** Layer 7 · TCP 102 (TPKT + COTP + 0x72)
- **Host Endpoint Rule:** Dual-Stack IPv4/IPv6
- **Standards:** RFC 1006 (ISO-on-TCP), ISO 8073 COTP, Siemens OMS+ / S7commPlus
- **Wireshark Display Filter:** `s7comm-plus || cotp`
- **Wire Encapsulation:** `Ethernet II -> [802.1Q / QinQ / MPLS] -> IPv4 / IPv6 -> TCP 102 (TPKT + COTP + 0x72) -> Siemens S7commPlus`

## Overview

Modern Siemens S7-1200 and S7-1500 PLCs replaced classic `0x32` `s7comm` with `0x72` `s7commplus` on TCP `102` — validate your OT IDS against TIA Portal `createobject`, `getmultivariables`, and `setmultivariables` sessions.

Siemens S7commPlus (`s7commplus`) is the modern object-oriented **Object Management System (OMS+)** protocol used by **TIA Portal, WinCC Unified, and SIMATIC S7-1200 / S7-1500 PLCs** on **TCP port `102`** (`RFC 1006 TPKT` + `ISO 8073 COTP`). Unlike classic `s7comm` (`Protocol ID 0x32`), S7commPlus frames begin with **`Protocol ID 0x72`**, a protocol `Version` (`1`, `2`, or `3` with TLS/integrity trailer), 16-bit `Data Length`, `Opcode` (`0x31` Request, `0x32` Response, `0x33` Notification), 16-bit `Function Code` (`0x04ca` CreateObject session setup, `0x0542` GetMultiVariables, `0x0552` SetMultiVariables, `0x0586` DeleteObject), `Sequence Number`, and `Session ID`.

FrameAssembly wraps `0x72` S7commPlus headers and trailing `0x72 <version> 00 00` end-markers inside valid TPKT + COTP DT frames over stateful TCP port `102`.

## Minimal Quickstart (`s7commplus_quickstart.frasm`)

```frameassembly
host tia_portal { ip 192.168.10.20 }
host s7_1500    { ip 192.168.10.100 }

compile {
    tia_portal -> s7_1500 tcp syn srcport 51102 dstport 102 wait 1ms
    tia_portal <- s7_1500 tcp syn ack wait 1ms
    tia_portal -> s7_1500 tcp ack wait 1ms
    tia_portal -> s7_1500 s7commplus version 2 opcode 0x31 func "createobject" seqnum 1 sessionid 0 wait 2ms
    tia_portal <- s7_1500 s7commplus version 2 isresponse func "createobject" seqnum 1 sessionid 0x000003e8
}
```

### Automatic Wire Calculations

- Defaults to stateful TCP port `102` and prepends the 4-byte RFC 1006 `TPKT` (`03 00 <len>`) + 3-byte ISO 8073 `COTP DT Data` (`02 f0 80`) headers automatically.
- Frames the inner `0x72` S7commPlus header, calculates the 16-bit OMS+ data block length, and appends the mandatory 4-byte `0x72 <version> 00 00` trailer.
- Sets `Opcode = 0x32` (`Response`) automatically whenever `isresponse` or `response` is specified.

## Practical Lab Example: TIA Portal <-> SIMATIC S7-1500 Session: CreateObject, GetMultiVariables & SetMultiVariables (`s7commplus_tia_portal_session.frasm`)

Opens TCP `102` to a SIMATIC S7-1500 CPU, negotiates an S7commPlus session (`CreateObject` `0x04ca`), reads symbolic PLC tags (`GetMultiVariables` `0x0542`), and executes a tag write (`SetMultiVariables` `0x0552`).

```frameassembly
host eng_laptop { ip 10.110.2.15 }
host plc_s71516 { ip 10.110.1.50 }

compile {
    eng_laptop -> plc_s71516 tcp syn srcport 53102 dstport 102 win 65535 mss 1460 wait 1ms
    eng_laptop <- plc_s71516 tcp syn ack win 65535 mss 1460 wait 1ms
    eng_laptop -> plc_s71516 tcp ack wait 1ms
    // 1. OMS+ Session Establishment: CreateObject (0x04ca) assigns Session ID 0x01000234
    eng_laptop -> plc_s71516 s7commplus version 3 opcode 0x31 func 0x04ca seqnum 1 sessionid 0 id 0x010d wait 3ms
    eng_laptop <- plc_s71516 s7commplus version 3 isresponse func 0x04ca seqnum 1 sessionid 0x01000234 wait 5ms
    // 2. Symbolic Tag Poll: GetMultiVariables (0x0542 / "read")
    eng_laptop -> plc_s71516 s7commplus version 3 func "read" seqnum 2 sessionid 0x01000234 id 0x8a0e0001 wait 2ms
    eng_laptop <- plc_s71516 s7commplus version 3 isresponse func "read" seqnum 2 sessionid 0x01000234 wait 10ms
    // 3. Tag Write: SetMultiVariables (0x0552 / "write") -> triggers OT write-policy inspection
    eng_laptop -> plc_s71516 s7commplus version 3 func "write" seqnum 3 sessionid 0x01000234 id 0x8a0e0002 wait 2ms
    eng_laptop <- plc_s71516 s7commplus version 3 isresponse func "write" seqnum 3 sessionid 0x01000234
}
```

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

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

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

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

## All `s7commplus` Keywords & Header Options

Packet line pattern: `src_host -> dst_host s7commplus [version <1..3>] [opcode "<text_or_num>"] [isresponse | response] [func "<text_or_num>"] [seqnum <0..65535>] [sessionid <number>] [id <number>] [flags <0..255>]`

| Keyword / Option | Accepted Value | Default | Effect on Packet |
| --- | --- | --- | --- |
| `version <1..3>` | 8-bit S7commPlus Protocol Version (`1`, `2`, or `3`) | `2` | Sets the Version byte immediately following the `0x72` magic byte in both header and trailer. |
| `opcode "<text_or_num>" \| isresponse \| response` | 8-bit OMS+ Opcode (`0x31` Request, `0x32` Response, `0x33` Notification) | `0x31 (Request); 0x32 when isresponse/response is set` | Sets the S7commPlus message Opcode byte. |
| `func "<text_or_num>"` | 16-bit Function Code or mnemonic ("read","write","createobject","deleteobject","explore") | `0x0542 (GetMultiVariables / read)` | Writes the 16-bit OMS+ Function Code (`0x04ca` CreateObject, `0x04d4` Explore, `0x0542` GetMultiVariables, `0x0552` SetMultiVariables, `0x0586` DeleteObject). |
| `seqnum <0..65535>` | 16-bit PDU Sequence Number | `1` | Writes the big-endian 2-byte transaction Sequence Number. |
| `sessionid <number> \| id <number> \| flags <0..255>` | 32-bit Session ID, 32-bit Object/Integrity ID, and 8-bit Transport Flags | `sessionid 1, id 0, flags 0x36` | Populates the 32-bit OMS+ Session ID, target Object ID, and transport flags. |

## Cross-Layer Options Valid with `s7commplus`

| 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 102 (TPKT + COTP + 0x72)` | Overrides source or destination port and remembers the port pair automatically on `<-` replies. |
| `transport sctp` | Optional SCTP association transport (IP Proto 132) | `TCP (TCP 102 (TPKT + COTP + 0x72))` | 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

### Use s7commplus for S7-1200/S7-1500 (0x72) and s7comm for S7-300/S7-400 (0x32)

- **Valid v3.3.0 Syntax:** `hmi -> s7_1500 s7commplus version 3 func "read" seqnum 1 sessionid 100`

Both protocols share TCP port `102` (`TPKT` + `COTP`), but S7-1200/1500 optimized data blocks use `0x72` (`s7commplus`) instead of classic `0x32` (`s7comm`).

### Match seqnum and sessionid on PLC Responses

- **Valid v3.3.0 Syntax:** `hmi -> plc s7commplus func "read" seqnum 5 sessionid 200
hmi <- plc s7commplus isresponse func "read" seqnum 5 sessionid 200`

OT IDS state engines track `(sessionid, seqnum)` pairs to correlate PLC responses and flag injected rogue `SetMultiVariables` requests.
