Protocol 79 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
s7commSiemens S7 Communication Protocol over ISO-on-TCP

Siemens S7 PLC Reads, Writes & plcstop Alarms (eng_ws <-> plc s7comm TCP 102)

Default Port / Protocol
TCP 102 (ISO-on-TCP)
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
s7comm
Standards & Specs
RFC 1006 (TPKT), ISO 8073 (COTP), Siemens S7comm
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6TCP 102 (ISO-on-TCP)Siemens S7comm

What It Does on the Wire

Wrapped inside RFC 1006 TPKT + ISO 8073 COTP on TCP 102, s7comm builds Siemens 0x32 readvar, writevar, and high-severity plcstop frames so you can verify OT IDS signatures safely.

Siemens S7 Communication (s7comm) connects TIA Portal / STEP 7 engineering stations and WinCC HMIs to SIMATIC S7-300, S7-400, S7-1200, and S7-1500 PLCs over ISO-on-TCP port 102. Every S7comm packet wraps the 0x32 S7 PDU inside a 4-byte RFC 1006 TPKT header (0x03 0x00 + 16-bit total length) and a 3-byte ISO 8073 COTP Data header (0x02 0xf0 0x80).

FrameAssembly builds the complete TPKT + COTP + S7comm stack for connection negotiation (setupcomm), Data Block variable reads (readvar), variable writes (writevar), and high-impact plccontrol CPU Run/Stop commands—ideal for testing IEC 62443 OT firewalls and ICS threat detections safely offline.

Test OT IDS Alarms for PLCControl Stop & Unauthorized WriteVar

Generate s7comm rosctr "job" plccontrol (0x28) and writevar area 0x84 dbnum 1 packets to verify Claroty, Dragos, Nozomi, Zeek, and Suricata Siemens S7 alerts without touching a running PLC.

Purdue Level 1/2 Industrial Firewall Conduit Verification (TCP 102)

Confirm cell/area firewalls permit readvar from approved WinCC HMI IPs while blocking engineering writevar / plccontrol from unauthorized subnets.

Validate S7 Data Block (DB) Historian Polling Parsers

Pair rosctr "job" readvar requests with rosctr "ackdata" PLC replies carrying matched pduref IDs.

Minimal Quickstart (s7comm_quickstart.frasm)

Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.

s7comm_quickstart.frasm11 lines
Open in Playground
host wincc_hmi { ip 192.168.10.20 }
host s7_plc { ip 192.168.10.100 }
compile {
wincc_hmi -> s7_plc tcp syn srcport 50102 dstport 102 wait 1ms
wincc_hmi <- s7_plc tcp syn ack wait 1ms
wincc_hmi -> s7_plc tcp ack wait 1ms
wincc_hmi -> s7_plc s7comm rosctr "job" setupcomm pduref 1 wait 2ms
wincc_hmi <- s7_plc s7comm rosctr "ackdata" setupcomm pduref 1 wait 2ms
wincc_hmi -> s7_plc s7comm rosctr "job" readvar pduref 2 area 0x84 dbnum 1 offset 0 count 4
}

What the Compiler Calculates So You Don't Have To

  • Defaults to TCP destination port 102 (psh ack) and computes the outer 4-byte TPKT (0x03 0x00 <len>) + 3-byte COTP DT (0x02 0xf0 0x80) framing automatically.
  • Writes the 0x32 S7 Protocol ID, ROSCTR (0x01 Job, 0x02 Ack, 0x03 Ack_Data, 0x07 Userdata), 2-byte error class/code on ackdata, and exact Parameter/Data lengths.
  • Encodes 12-byte S7Any (0x12 0x0a 0x10) variable item addressing (area, dbnum, bit-shifted offset * 8, and count) automatically on readvar/writevar Jobs.
Multi-Frame Lab · Ready to Compile

S7 Communication Setup, DB1 Read Poll, DB1 Write & PLC CPU Control Alert

Negotiates S7 PDU parameters (setupcomm), polls 4 bytes from DB1.DBB0 (area 0x84 dbnum 1), writes to DB1, and emits a plccontrol Job to test critical OT security alerts.

s7comm_plc_security_lab.frasm18 lines
Open in Playground
host tia_ws { ip 10.110.1.15 }
host plc_315 { ip 10.110.2.102 }
compile {
tia_ws -> plc_315 tcp syn srcport 51102 dstport 102 win 65535 mss 1460 wait 1ms
tia_ws <- plc_315 tcp syn ack win 65535 mss 1460 wait 1ms
tia_ws -> plc_315 tcp ack wait 1ms
// 1. S7 Setup Communication (Func 0xf0)
tia_ws -> plc_315 s7comm rosctr "job" setupcomm pduref 100 wait 2ms
tia_ws <- plc_315 s7comm rosctr "ackdata" setupcomm pduref 100 wait 2ms
// 2. Read 4 bytes from Data Block 1 (area 0x84 = DB, dbnum 1, offset 0)
tia_ws -> plc_315 s7comm rosctr "job" readvar pduref 101 area 0x84 dbnum 1 offset 0 count 4 wait 2ms
tia_ws <- plc_315 s7comm rosctr "ackdata" readvar pduref 101 count 4 wait 5ms
// 3. WriteVar (0x05) + PLCControl (0x28) -> critical OT IDS signatures
tia_ws -> plc_315 s7comm rosctr "job" writevar pduref 102 area 0x84 dbnum 1 offset 0 count 2 wait 3ms
tia_ws <- plc_315 s7comm rosctr "ackdata" writevar pduref 102 wait 3ms
tia_ws -> plc_315 s7comm rosctr "job" plccontrol pduref 103
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show s7comm_plc_security_lab.frasm

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

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

All s7comm 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 s7comm:

src_host -> dst_host s7comm [setupcomm | readvar | writevar | plccontrol | func "<text>"] [rosctr "<job|ack|ackdata|userdata>"] [pduref <0..65535>] [area <hex_or_str>] [dbnum <0..65535>] [offset <number>] [count <0..65535>]
Keyword / OptionAccepted ValueDefaultEffect on Packet
setupcomm | readvar | writevar | plccontrol | func "<text>"S7 Parameter Function (0xf0 Setup, 0x04 ReadVar, 0x05 WriteVar, 0x28 PLCControl)setupcomm (0xf0)Selects the S7comm Parameter Function code.
rosctr "<job|ack|ackdata|userdata>"Remote Operating Service Control type"job" (0x01)Sets 0x01 Job (HMI/engineering request), 0x02 Ack, 0x03 Ack_Data (PLC reply with 2-byte error status), or 0x07 Userdata.
pduref <0..65535>16-bit PDU Reference ID1Correlates each PLC ackdata response with its initiating job.
area <hex_or_str> | dbnum <0..65535>0x84 Data Blocks (DB), 0x81 Inputs (I), 0x82 Outputs (Q), 0x83 Merkers (M) + DB numberarea 0x84 (DB), dbnum 1Sets the memory area and Data Block number in S7Any item addressing.
offset <number> | count <0..65535>Byte offset + item byte countoffset 0, count 1Encodes the 24-bit bit-addressed start offset and 16-bit read/write length.

Cross-Layer Wrappers Valid with s7comm

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

11 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).
payload "<text>" | hexpayload "<hex>"Quoted text or hex bytes (choose one)OmittedAppends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac>Colon, hyphen, or Cisco dot MACHost MAC / RFC multicast MACOverrides the 14-byte Ethernet II source or destination MAC address for this single packet.
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> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255Unlabeled (at most 1 mpls tag per packet)Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header.
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>]IPv4 ID, DF/MF flags, fragment offset 0..8191ipid 1, flags 0, fragoffset 0Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6).
flowlabel <0..1048575>20-bit IPv6 Flow Label (0..1048575)0Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts).
srcport <0..65535> | dstport <0..65535>Port number 0..65535srcport 49152 (remembered), TCP 102 (ISO-on-TCP)Overrides source or destination port and remembers the port pair automatically on <- replies.
seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rstTCP sequence/ack numbers, window size, flags & RFC 7323 optionspsh ack, win 65535, automatic TCP seq/acknumOverrides automatic TCP sequence tracking, flags, or RFC 7323 options (mss, wscale, sackperm, tsval, tsecr).

Gotchas & Quick Fixes

Set rosctr "ackdata" on <- PLC Replies

Avoid
wincc_hmi <- s7_plc s7comm readvar pduref 2 count 4
Valid v3.1.2 Syntax
wincc_hmi <- s7_plc s7comm rosctr "ackdata" readvar pduref 2 count 4

rosctr defaults to "job" (a request from HMI to PLC). On <- replies from the PLC, specify rosctr "ackdata" so the 12-byte S7 Ack_Data header (with Error Class/Code 0x0000) is written.

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