# Layer 7 Industrial Control Systems & SCADA/OT

> **FrameAssembly v3.2.2** · Category 08 (Layer 7 · 6 Protocols) · Canonical URL: https://frameassembly-lang.dev/docs/protocols/categories/l7-industrial-ot

Validating Purdue-model OT conduit firewalls, Claroty/Dragos/Nozomi passive ICS sensors, or Suricata SCADA signatures against live PLCs and substation RTUs is never acceptable in production. FrameAssembly synthesizes all 6 flagship industrial protocols (`modbus`, `bacnet`, `dnp3`, `s7comm`, `ethernetip`, and `opcua`) completely offline.

Every industrial builder computes mandatory binary framing and integrity checks automatically—including 7-byte Modbus MBAP lengths, reflected IEEE 1815 `0x3d65` per-chunk DNP3 CRCs, RFC 1006 TPKT + ISO 8073 COTP headers on Siemens S7comm, ODVA CIP session/I/O encapsulation, and little-endian IEC 62541 OPC UA chunk sizes.

## Category Wire & Endpoint Rules

- **Modbus Request vs. `isresponse` Framing:** `modbus` defaults to TCP `502` (`transport udp` uses UDP `502`); add `isresponse` on `<-` PLC replies so read function codes emit byte-count + register data instead of request `addr`/`count` fields.
- **Automatic Per-Block IEEE 1815 DNP3 CRC-16:** `dnp3` (`0x0564` start bytes, TCP/UDP `20000`) calculates reflected `0x3d65` CRC-16 over both the 10-byte Data Link header and every 16-byte user-data block (or accepts explicit `crc <u16>` for negative tests).
- **TPKT + COTP Iso-on-TCP for Siemens S7comm:** `s7comm` wraps every `0x32` Job / Ack-Data PDU in valid 4-byte TPKT (`03 00 len`) + 3-byte COTP DT (`02 f0 80`) headers on stateful TCP `102`.
- **Explicit TCP 44818 vs. Implicit UDP 2222 CIP:** `ethernetip` uses TCP `44818` for explicit `registersession` / `sendrrdata` messaging and switches automatically to UDP `2222` on `sendunitdata` (or `transport udp`).

## Multi-Protocol Example: Purdue Conduit Audit: Modbus Read/Write, DNP3 Operate, S7comm & OPC UA (`ot_ics_conduit_audit.frasm`)

Tests an OT cell-zone conduit with a stateful TCP 502 Modbus holding-register read + blocked single-coil write, a UDP 20000 IEEE 1815 DNP3 Select/Operate pair with auto CRC-16, a UDP 47808 BACnet Who-Is, and a TCP 4840 OPC UA Hello/Acknowledge handshake.

```frameassembly
host hmi_eng { ip 10.100.10.20 }
host plc_rtu { ip 10.100.20.50 }

compile {
    hmi_eng -> plc_rtu tcp syn srcport 50502 dstport 502 win 65535 mss 1460 wait 1ms
    hmi_eng <- plc_rtu tcp syn ack win 65535 mss 1460 wait 1ms
    hmi_eng -> plc_rtu tcp ack wait 1ms
    hmi_eng -> plc_rtu modbus readholdingregisters txid 1 unitid 1 addr 100 count 4 wait 2ms
    hmi_eng <- plc_rtu modbus readholdingregisters isresponse txid 1 unitid 1 count 4 wait 2ms
    hmi_eng -> plc_rtu modbus writesinglecoil txid 2 unitid 1 addr 10 value 0xff00 wait 3ms
    hmi_eng -> plc_rtu dnp3 select transport udp src 1 dst 10 group 12 variation 1 wait 2ms
    hmi_eng -> plc_rtu dnp3 operate transport udp src 1 dst 10 group 12 variation 1 wait 2ms
    hmi_eng -> plc_rtu bacnet whois wait 2ms
    hmi_eng -> plc_rtu tcp syn srcport 50840 dstport 4840 win 65535 mss 1460 wait 1ms
    hmi_eng <- plc_rtu tcp syn ack win 65535 mss 1460 wait 1ms
    hmi_eng -> plc_rtu tcp ack wait 1ms
    hmi_eng -> plc_rtu opcua msgtype "HEL" chunktype "F" endpointurl "opc.tcp://10.100.20.50:4840" wait 1ms
    hmi_eng <- plc_rtu opcua msgtype "ACK" chunktype "F"
}
```

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

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

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

# 4. Verify dissected protocol fields in tshark
tshark -r ot_ics_conduit_audit.pcap -Y "mbtcp || dnp3 || bacnet || opcua"
```

- **Wireshark Display Filter:** `mbtcp || dnp3 || bacnet || opcua`

## Protocols in Category 08 (6 Native Builders)

| # | Keyword | Protocol | Default Port / Proto | Endpoint Rule | Wireshark Filter | Spec URL |
| --- | --- | --- | --- | --- | --- | --- |
| 76 | `modbus` | Modbus TCP / UDP Industrial Application Protocol | `TCP 502 (or UDP 502 via transport udp)` | Dual-Stack IPv4/IPv6 | `mbtcp \|\| modbus` | https://frameassembly-lang.dev/docs/protocols/modbus |
| 77 | `bacnet` | BACnet/IP Building Automation & Control Networks | `UDP 47808 (0xbac0)` | Dual-Stack IPv4/IPv6 | `bacnet \|\| bvlc \|\| bacapp` | https://frameassembly-lang.dev/docs/protocols/bacnet |
| 78 | `dnp3` | Distributed Network Protocol 3 (Electric & Water Utilities) | `TCP 20000 (or UDP 20000 via transport udp)` | Dual-Stack IPv4/IPv6 | `dnp3` | https://frameassembly-lang.dev/docs/protocols/dnp3 |
| 79 | `s7comm` | Siemens S7 Communication Protocol over ISO-on-TCP | `TCP 102 (ISO-on-TCP)` | Dual-Stack IPv4/IPv6 | `s7comm` | https://frameassembly-lang.dev/docs/protocols/s7comm |
| 80 | `ethernetip` | ODVA EtherNet/IP & Common Industrial Protocol (Rockwell) | `TCP 44818 (Explicit) / UDP 2222 (Implicit I/O)` | Dual-Stack IPv4/IPv6 | `enip \|\| cip` | https://frameassembly-lang.dev/docs/protocols/ethernetip |
| 81 | `opcua` | OPC Unified Architecture Binary TCP Protocol | `TCP 4840` | Dual-Stack IPv4/IPv6 | `opcua` | https://frameassembly-lang.dev/docs/protocols/opcua |
