DNP3 Parser Update - Understanding a DNP3 Packet
This week I finished parsing DNP3 Group 1 Variation 1, the first object type supported by the parser. That means the parser can now decode binary input status values from real DNP3 traffic instead of just stopping at the object header.
I also got some practice using GDB to debug my programs! Super useful as I ran into some segmentation faults that would have been impossible to fix without it!
How a DNP3 Packet Works
DNP3 (Distributed Network Protocol 3) is an industrial control protocol used by electric utilities, water systems, and other critical infrastructure. Communication happens between a Master (SCADA server) and one or more Outstations (RTUs, relays, PLCs, etc.).
A packet is made up of several layers:
- Data Link Layer
- Transport Layer
- Application Header
- Object Header(s)
- Object Data
Data Link Layer
The packet always begins with the start bytes:
0x05 0x64
These identify the frame as DNP3.
The rest of the link header contains:
- Length
- Control byte
- Destination address
- Source address
- CRC
This layer is responsible for moving frames between devices and detecting transmission errors.
Transport Layer
The transport header is only one byte long, but it’s important because it:
- Marks the start and end of fragmented messages
- Provides a sequence number so fragments can be reassembled
Application Layer
The application header tells the receiver what operation is being requested.
Examples include:
- Read
- Write
- Response
- Confirm
It also contains application control flags and an application sequence number.
Object Headers
After the application header come one or more object headers. These tell the parser what type of data follows.
An object header contains:
- Group number
- Variation number
- Qualifier
For example:
Group 1 Variation 1
represents packed binary input values.
The qualifier then specifies how many objects are present and how they are indexed.
Object Data
Finally comes the actual payload.
For Group 1 Variation 1, each bit represents the current state of a binary input:
-
1= ON -
0= OFF
The parser reads these bytes and expands them into individual points that can be displayed or analyzed.
Completed Sections
- Data Link Layer parsing
- Transport Header parsing
- Application Header parsing
- Object Header parsing
- Group 1 Variation 1 object parsing
Next up is adding support for additional object groups and variations so the parser can decode more real-world DNP3 traffic.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.