opcuaOPC Unified Architecture Binary TCP ProtocolPurdue-Level-3.5 Historian Conduits (hist <-> gateway opcua TCP 4840)
What It Does on the Wire
The protocol bridging OT plant networks to IT historians across the industrial DMZ on TCP 4840 — opcua writes little-endian HEL -> ACK -> OPN -> MSG -> CLO binary chunks with exact message-size fields.
OPC Unified Architecture (opcua, IEC 62541-6) is the cross-vendor Industry 4.0 standard used to bridge plant-floor PLCs across the Purdue Level 3.5 Industrial DMZ to historians, MES systems, and cloud analytics over TCP port 4840. Every OPC UA Binary message begins with an 8-byte header: a 3-character ASCII MessageType ("HEL", "ACK", "OPN", "MSG", "CLO", "ERR"), a 1-character ChunkType ("F" Final, "C" Intermediate, "A" Abort), and a 32-bit little-endian MessageSize.
FrameAssembly calculates the little-endian MessageSize automatically and encodes "HEL" (endpointurl), "ACK" buffer parameters, "OPN" secure channel setup, and "MSG" service calls carrying securechannelid, tokenid, seqnum, reqid, and nodeid strings.
Purdue Level 3.5 Industrial DMZ Firewall Verification (TCP 4840)
Verify that IDMZ firewalls allow TCP 4840 from the DMZ historian collector to plant OPC UA servers while blocking direct IT-to-PLC connections.
Test OT IDS Inspection of OPC UA HEL Endpoints & NodeId Reads
Replay "HEL" -> "ACK" -> "OPN" -> "MSG" conversations with specific endpointurl and nodeid tags into OT NDR sensors.
OPC UA Error ("ERR") & Chunk Reassembly ("C" / "F") Testing
Validate industrial proxy behavior on "ERR" status messages and multi-chunk message streams.
Minimal Quickstart (opcua_quickstart.frasm)
Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.
host historian { ip 10.130.35.10 }host ua_server { ip 10.130.20.48 }compile { historian -> ua_server tcp syn srcport 54840 dstport 4840 wait 1ms historian <- ua_server tcp syn ack wait 1ms historian -> ua_server tcp ack wait 1ms historian -> ua_server opcua msgtype "HEL" chunktype "F" endpointurl "opc.tcp://10.130.20.48:4840" wait 2ms historian <- ua_server opcua msgtype "ACK" chunktype "F"}What the Compiler Calculates So You Don't Have To
- Defaults to TCP destination port
4840(psh ack),msgtype "HEL",chunktype "F", and calculates the 4-byte little-endianMessageSizeacross the entire OPC UA frame. - Encodes IEC 62541-6 receive/send buffer sizes (
65535) + length-prefixed UTF-8endpointurlinside"HEL"and"ACK"frames. - Encodes
SecureChannelId,SecurityTokenId,SequenceNumber,RequestId, and ReadServicenodeidfields inside"OPN","MSG", and"CLO"frames.
Complete OPC UA Connection (HEL/ACK), OpenSecureChannel, NodeId Read & CLO
Establishes an OPC UA Binary TCP 4840 session across an Industrial DMZ, opens Secure Channel 1, reads "ns=2;s=Turbine1.RPM" via "MSG", and closes cleanly with "CLO".
host idmz_hist { ip 172.18.35.20 }host plant_ua { ip 192.168.48.10 }compile { idmz_hist -> plant_ua tcp syn srcport 51840 dstport 4840 win 65535 mss 1460 wait 1ms idmz_hist <- plant_ua tcp syn ack win 65535 mss 1460 wait 1ms idmz_hist -> plant_ua tcp ack wait 1ms // 1. Transport Hello / Acknowledge idmz_hist -> plant_ua opcua msgtype "HEL" chunktype "F" endpointurl "opc.tcp://192.168.48.10:4840/UA/PlantServer" wait 2ms idmz_hist <- plant_ua opcua msgtype "ACK" chunktype "F" wait 2ms // 2. OpenSecureChannel (OPN) idmz_hist -> plant_ua opcua msgtype "OPN" chunktype "F" securechannelid 0 seqnum 1 reqid 1 wait 2ms idmz_hist <- plant_ua opcua msgtype "OPN" chunktype "F" securechannelid 1 tokenid 1 seqnum 1 reqid 1 wait 3ms // 3. Service Read Request (MSG) for NodeId + CloseSecureChannel (CLO) idmz_hist -> plant_ua opcua msgtype "MSG" chunktype "F" securechannelid 1 tokenid 1 seqnum 2 reqid 2 nodeid "ns=2;s=Turbine1.RPM" wait 4ms idmz_hist -> plant_ua opcua msgtype "CLO" chunktype "F" securechannelid 1 tokenid 1 seqnum 3 reqid 3}# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show opcua_idmz_historian.frasm
# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly opcua_idmz_historian.frasm opcua_idmz_historian.pcap
frameassembly opcua_idmz_historian.frasm opcua_idmz_historian.pcapng
# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse opcua_idmz_historian.pcap opcua_idmz_historian_edited.frasmAll opcua 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 opcua:
src_host -> dst_host opcua [msgtype "<HEL|ACK|OPN|MSG|CLO|ERR>"] [chunktype "<F|C|A>"] [securechannelid <number>] [tokenid <number>] [seqnum <number>] [reqid <number>] [endpointurl "<text>"] [nodeid "<text>"]| Keyword / Option | Accepted Value | Default | Effect on Packet |
|---|---|---|---|
| msgtype "<HEL|ACK|OPN|MSG|CLO|ERR>" | 3-character ASCII OPC UA message type | "HEL" | Sets bytes 0..2 (HEL Hello, ACK Acknowledge, OPN OpenSecureChannel, MSG Service Message, CLO Close, ERR Error). |
| chunktype "<F|C|A>" | "F" Final chunk, "C" Intermediate chunk, "A" Abort | "F" | Sets byte 3 (IsFinal) of the 8-byte OPC UA Binary header. |
| endpointurl "<text>" | Quoted opc.tcp://... endpoint URL on "HEL" | "opc.tcp://localhost:4840" | Writes the length-prefixed EndpointUrl string inside "HEL" messages. |
| securechannelid <number> | tokenid <number> | seqnum <number> | reqid <number> | 32-bit little-endian channel, token, sequence, and request IDs | 1 | Populates the Secure Conversation and Sequence headers on "OPN", "MSG", and "CLO" frames. |
| nodeid "<text>" | Quoted OPC UA NodeId string ("ns=2;s=Line1.Pressure") | Omitted unless set | Encodes a String NodeId inside "MSG" ReadRequest payloads. |
Cross-Layer Wrappers Valid with opcua
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
11 options
Cross-Layer Wrappers Valid with opcua
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
| Option | Range / Format | Default | Effect on Packet |
|---|---|---|---|
| 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). |
| payload "<text>" | hexpayload "<hex>" | Quoted text or hex bytes (choose one) | Omitted | Appends 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 MAC | Host MAC / RFC multicast MAC | Overrides 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..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> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>] | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | Unlabeled (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..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>] | IPv4 ID, DF/MF flags, fragment offset 0..8191 | ipid 1, flags 0, fragoffset 0 | Sets 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) | 0 | Sets 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..65535 | srcport 49152 (remembered), TCP 4840 | Overrides source or destination port and remembers the port pair automatically on <- replies. |
| seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rst | TCP sequence/ack numbers, window size, flags & RFC 7323 options | psh ack, win 65535, automatic TCP seq/acknum | Overrides automatic TCP sequence tracking, flags, or RFC 7323 options (mss, wscale, sackperm, tsval, tsecr). |
Gotchas & Quick Fixes
Keep msgtype and chunktype Uppercase Inside Quotes ("HEL", "F")
historian -> ua_server opcua helhistorian -> ua_server opcua msgtype "HEL" chunktype "F"OPC UA specifies message types via msgtype "<3_CHARS>" ("HEL", "ACK", "OPN", "MSG", "CLO", "ERR") rather than bare keywords.