Protocol 81 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
opcuaOPC Unified Architecture Binary TCP Protocol

Purdue-Level-3.5 Historian Conduits (hist <-> gateway opcua TCP 4840)

Default Port / Protocol
TCP 4840
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
opcua
Standards & Specs
IEC 62541-6
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6TCP 4840OPC UA

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.

opcua_quickstart.frasm10 lines
Open in 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-endian MessageSize across the entire OPC UA frame.
  • Encodes IEC 62541-6 receive/send buffer sizes (65535) + length-prefixed UTF-8 endpointurl inside "HEL" and "ACK" frames.
  • Encodes SecureChannelId, SecurityTokenId, SequenceNumber, RequestId, and ReadService nodeid fields inside "OPN", "MSG", and "CLO" frames.
Multi-Frame Lab · Ready to Compile

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".

opcua_idmz_historian.frasm17 lines
Open in Playground
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
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 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.frasm

All 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 / OptionAccepted ValueDefaultEffect 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 IDs1Populates 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 setEncodes 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
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 4840Overrides 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

Keep msgtype and chunktype Uppercase Inside Quotes ("HEL", "F")

Avoid
historian -> ua_server opcua hel
Valid v3.1.2 Syntax
historian -> 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.

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