dnp3 — Substation RTU Commands & Automatic Per-Chunk CRC-16
- 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
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.
RFC Wire Header Layout (dnp3)
Select any 32-bit wire word or field slice below to inspect which .frasm modifiers control those octets and what defaults the compiler writes.
FrameAssembly computes valid DNP3 Data Link 0x0564 sync headers and per-16-byte chunk CRC-16 checksums so Wireshark dnp3 dissects transport and application objects with zero CRC warnings.
Minimal Quickstart (dnp3_quickstart.frasm)
Select Preview Packets to compile in-browser and inspect timestamps + wire byte lengths, or open directly in the 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
}Handled Automatically on the Wire
- Defaults to TCP destination port
20000(transport udpswitches to UDP20000) and builds the0x0564Data Link + Transport (FIN|FIR) + Application headers. - Computes the reflected IEEE 1815
0x3d65CRC-16 across the 8-byte Data Link header and every 16-byte user-data chunk automatically. - Encodes
srcanddst16-bit DNP3 station addresses in little-endian wire order per IEEE 1815.
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.
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
}# 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
# 4. Verify dissected protocol fields in tshark
tshark -r dnp3_substation_sbo.pcap -Y "dnp3"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 / Option | Accepted Value | Default | Effect on Packet |
|---|---|---|---|
| read | write | select | operate | directoperate | confirm | response | unsolicitedresponse | func "<text>" | DNP3 Application Function Code | read (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 addresses | src 1, dst 10 | Sets 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) + Variation | group 30, variation 1 | Populates the Object Header (Group, Variation) inside the Application Layer. |
| crc <hex_or_num> | Optional 16-bit link-header CRC override | Auto-computed IEEE 1815 CRC-16 | Replaces the computed Data Link header CRC for negative/fuzz testing (omit for valid packets!). |
| transport <tcp|udp> | tcp or udp | tcp | Switches 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
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
| 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> | ethertype <0..65535> | Colon/hyphen/Cisco MAC · EtherType u16 (e.g. 0x0800) | Host MAC / RFC multicast MAC / auto EtherType | Overrides the 14-byte Ethernet II source MAC, destination MAC, or 16-bit EtherType 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> [label <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 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 tcp | Switches Layer 4 transport between TCP (psh ack + length framing where required) and UDP. |
| seq <number> | acknum <number> | win|window <0..65535> | urgent <0..65535> | syn | ack | psh | fin | rst | urg | ece | cwr | TCP sequence/ack numbers, window size, flags & RFC 7323 options | psh ack, win 65535, automatic TCP seq/acknum | When 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
master -> rtu dnp3 read src 1 dst 10
master <- rtu dnp3 response src 10 dst 1While <- 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
scada_master -> sub_rtu_10 dnp3 read src 1 dst 10FrameAssembly calculates the exact IEEE 1815 CRC-16 automatically whenever crc is omitted.