Protocol 78 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
dnp3Distributed Network Protocol 3 (Electric & Water Utilities)

Substation RTU Commands & Automatic Per-Block CRC-16 (master <-> rtu dnp3)

Default Port / Protocol
TCP 20000 (or UDP 20000 via transport udp)
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
dnp3
Standards & Specs
IEEE 1815-2012
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6TCP 20000 (or UDP 20000 via transport udp) (transport tcp|udp)DNP3 (IEEE 1815)

What It Does on the Wire

Hand-crafting DNP3 usually makes grown engineers cry because IEEE 1815 demands a reflected CRC-16 after the 0x0564 link header *and* every 16 payload bytes — dnp3 calculates every block CRC automatically (unless you pass crc 0xdead to test bad-CRC alarms!).

Distributed Network Protocol 3 (dnp3, IEEE 1815) is the primary SCADA telemetry and breaker-control protocol in North American electric substations, solar/wind farms, and water/wastewater utilities on TCP or UDP port 20000. Crafting valid DNP3 packets by hand is notoriously hard because DNP3 inserts a reflected IEEE 1815 CRC-16 (0x3d65, inverted) after the 8-byte 0x0564 Data Link header and after every 16-byte Data Link user-data block.

FrameAssembly calculates every per-block DNP3 CRC-16 automatically (and also lets you override crc deliberately if you want to test dissector malformed-CRC handling!).

NERC CIP Electronic Security Perimeter (ESP) Firewall Audits

Verify substation firewalls permit DNP3 read (0x01) and response (0x81) between control-center SCADA masters (src 1) and substation RTUs (dst 10) on TCP 20000.

Test Breaker Control (select / operate / directoperate) OT IDS Rules

Generate Group 12 (CROB Control Relay Output Block) select, operate, or directoperate commands to test Dragos, Nozomi, Claroty, and Suricata ICS control-operation alarms.

Negative / Corrupted CRC-16 Dissector Testing

Pass an explicit wrong crc 0xdead to verify your protocol gateway or IDS properly flags corrupted DNP3 link headers.

Minimal Quickstart (dnp3_quickstart.frasm)

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

dnp3_quickstart.frasm10 lines
Open in Playground
host scada_master { ip 10.100.1.10 }
host sub_rtu_10 { ip 10.100.2.10 }
compile {
scada_master -> sub_rtu_10 tcp syn srcport 52000 dstport 20000 wait 1ms
scada_master <- sub_rtu_10 tcp syn ack wait 1ms
scada_master -> sub_rtu_10 tcp ack wait 1ms
scada_master -> sub_rtu_10 dnp3 read src 1 dst 10 group 30 variation 1 wait 3ms
scada_master <- sub_rtu_10 dnp3 response src 10 dst 1 group 30 variation 1
}

What the Compiler Calculates So You Don't Have To

  • Defaults to TCP destination port 20000 (transport udp switches to UDP 20000) and builds the 0x0564 Data Link + Transport (FIN|FIR) + Application headers.
  • Computes the reflected IEEE 1815 0x3d65 CRC-16 across the 8-byte Data Link header and every 16-byte user-data chunk automatically.
  • Encodes src and dst 16-bit DNP3 station addresses in little-endian wire order per IEEE 1815.
Multi-Frame Lab · Ready to Compile

Substation Analog Input Poll (Group 30) + Select-Before-Operate (Group 12 CROB)

Polls Analog Inputs (group 30 variation 1), receives an RTU unsolicitedresponse event (group 2 Binary Input Change), and executes a two-step select -> operate breaker sequence.

dnp3_substation_sbo.frasm18 lines
Open in Playground
host ems_master { ip 172.25.1.5 }
host feeder_rtu { ip 172.25.10.20 }
compile {
ems_master -> feeder_rtu tcp syn srcport 53000 dstport 20000 win 65535 mss 1460 wait 1ms
ems_master <- feeder_rtu tcp syn ack win 65535 mss 1460 wait 1ms
ems_master -> feeder_rtu tcp ack wait 1ms
// 1. Class/Group 30 Analog Input Read + RTU Response
ems_master -> feeder_rtu dnp3 read src 1 dst 20 group 30 variation 1 wait 3ms
ems_master <- feeder_rtu dnp3 response src 20 dst 1 group 30 variation 1 wait 10ms
// 2. RTU Unsolicited Event (Group 2 Binary Input Event) + Master Confirm
ems_master <- feeder_rtu dnp3 unsolicitedresponse src 20 dst 1 group 2 variation 2 wait 2ms
ems_master -> feeder_rtu dnp3 confirm src 1 dst 20 wait 5ms
// 3. Select-Before-Operate (Group 12 Variation 1 CROB) -> triggers high-priority OT alert
ems_master -> feeder_rtu dnp3 select src 1 dst 20 group 12 variation 1 wait 2ms
ems_master <- feeder_rtu dnp3 response src 20 dst 1 group 12 variation 1 wait 2ms
ems_master -> feeder_rtu dnp3 operate src 1 dst 20 group 12 variation 1
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show dnp3_substation_sbo.frasm

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

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

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

src_host -> dst_host dnp3 [read | write | select | operate | directoperate | confirm | response | unsolicitedresponse | func "<text>"] [src <0..65535>] [dst <0..65535>] [group <0..255>] [variation <0..255>] [crc <hex_or_num>] [transport <tcp|udp>]
Keyword / OptionAccepted ValueDefaultEffect on Packet
read | write | select | operate | directoperate | confirm | response | unsolicitedresponse | func "<text>"DNP3 Application Function Coderead (0x01)Selects 0x00 Confirm, 0x01 Read, 0x02 Write, 0x03 Select, 0x04 Operate, 0x05 Direct Operate, 0x81 Response, or 0x82 Unsolicited Response.
src <0..65535> | dst <0..65535>16-bit DNP3 Data Link station addressessrc 1, dst 10Sets the 2-byte little-endian DNP3 Source and Destination outstation/master addresses.
group <0..255> | variation <0..255>DNP3 Object Group (1 Binary In, 12 CROB, 30 Analog In, 60 Class Data) + Variationgroup 30, variation 1Populates the Object Header (Group, Variation) inside the Application Layer.
crc <hex_or_num>Optional 16-bit link-header CRC overrideAuto-computed IEEE 1815 CRC-16Replaces the computed Data Link header CRC for negative/fuzz testing (omit for valid packets!).
transport <tcp|udp>tcp or udptcpSwitches Layer 4 between TCP 20000 and UDP 20000.

Cross-Layer Wrappers Valid with dnp3

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

12 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 20000 (or UDP 20000 via transport udp)Overrides source or destination port and remembers the port pair automatically on <- replies.
transport <tcp|udp>tcp or udp (supported on 9 dual-L4 protocols)transport tcpSwitches Layer 4 transport between TCP (psh ack + length framing where required) and UDP.
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/acknumWhen using TCP (transport tcp or default TCP): overrides automatic TCP sequence tracking, flags, or mss/wscale/sackperm/tsval/tsecr.

Gotchas & Quick Fixes

Swap DNP3 src and dst Station Addresses on <- RTU Replies

Valid v3.1.2 Syntax
master -> rtu dnp3 read src 1 dst 10 master <- rtu dnp3 response src 10 dst 1

While <- automatically flips Ethernet, IP, and TCP ports, DNP3 src and dst explicitly set the Data Link station fields (src 10 dst 1 when the RTU replies to Master 1).

Omit crc Unless You Intentionally Want a Bad Checksum

Valid v3.1.2 Syntax
scada_master -> sub_rtu_10 dnp3 read src 1 dst 10

FrameAssembly calculates the exact IEEE 1815 CRC-16 automatically whenever crc is omitted.

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