Introduction of DNP3.0 Protocol
Introduction of DNP3.0 Protocol
0 Protocol
Specification defines 3 building blocks in any DNP3 implementation:
Application layer
Transport layer
Link layer
The frame format:
An FT3 frame is defined as a fixed-length header, followed by optional data blocks, and each data block is accompanied by a 16-bit CRC check
code. The fixed header contains a 2-byte start word (0x0564), a 1-byte length (LEN), a 1-byte link layer control word, a 2-byte destination address,
a 2-byte source address and a 2-byte CRC code.
Link layer control Destination Source
Start word Length CRC User data
word address address
(2 bytes) (1 byte) (2 bytes) block
(1 byte) (2 bytes) (2 bytes)
The sum of
The communication
control word,
control word contains
destination
the transmission
address, source
direction of the frame, Low Byte Low Byte High Byte
fixed:0x0564 address and user
the type of the frame Ahead Ahead Ahead
data,
and the control
(255≥length≥5)
information of the data
Exclude all
flow.
CRC bytes
Remarks:
User data = TH (Transport layer header) (1Byte) + Data block
Data block= Application header + Object title + data
Application message header is divided into request header and response header
3. FCB: The frame counter bit is used to prevent the same slave station from losing or repeating
the information frame, each time the send and confirm (SEND-CONFIRM) service is
successfully completed (It is started by the same origin after sending service to the same slave
station), the bit will be flipped once.
4. FCV: Frame count valid bit (frame count valid), it can make FCB take effect.
The pseudo transport layer takes a TSDU (user data) and splits it into a number of sequential
TPDUS (each with "Protocol Control Information" (TPCI)).
Each TPDU is transmitted to the data link layer as "Link Service Data Unit" (LSDU) for
transmission.
It will also work in the opposite way. "Pseudo transmission" receives multiple TPDUS from
the data link and assembles them into one TSDU.
LSDUS are all segments of user data, and they are all short enough to fit into the defined FT3
frame format. When an original station sends a message to the slave station, the transmission
function divides the message into multiple LSDUS. These functions add a "Transport Layer
Header" (TH) byte at the beginning of the user data segment, which contains the information
needed for the slave station to rebuild the complete message. All pseudo-transport layer messages
have a TH.
When the slave station receives each LSDU, it checks its TH byte in order to know the correct
sequence and construct a TSDU message for the upper layer.
TH contains information that can identify the first frame, the last frame, and use a six-digit
sequence number to identify a frame. This kind of information is needed to reassemble the
message and also prevents the upper layer from receiving misleading or incomplete messages.
TH USER DATA
Transport layer Header (single byte) User data (1-249 bytes)
Field Size
Application Control (AC) 1 byte
Function code (FC) 1 byte
Field Size
Application Control
1 byte
(AC)
Function code (FC) 1 byte
Internal signal (IIN) 2 bytes
The length of the application control field is an 8-bit byte. It provides the information needed to
construct a multi-segment application message. The message of the application control field is
shown in the figure below:
FIR: If this bit is set to "1", it means that this message segment is the first segment of the
entire application message.
FIN: If this bit is set to "1", it means that this message segment is the last segment of the
entire application message.
CON: If this bit is set to "1", it means that the sender of the application message expects that
the party receiving the segment will confirm the receiver's confirmation in the application
message of the receiving party, and use an application function code ( 0).
SEQUENCE: Indicates the number of the segment. Segment numbers 0 to 15 are reserved
for the request of the master station and the responses of all external stations (not actively
reported responses). Segment numbers 16 to 31 are reserved for unsolicited reports from
outside stations. Regarding the actively reported response, each successive segment from or
to the same external station must also have an ascending sequence number (this number
overflows from 15 to 0).
The response of the master station and the slave station application timed out. These time
outs specify how long an application must wait for a response, or how long it must wait for
a CONFIRM response before retransmission or abnormally interrupting the communication
round.
The retransmission count of the master station and the external station application. The
application may or may not support retransmission at the application layer. The
retransmission count specifies how many times the request can be retransmitted if the
response fails, or how many times the original response can be retransmitted if the
CONFIRM response is not received.
Before an outside station starts to process the second request, it must completely process
the previous request and respond to it. It cannot handle multiple requests at the same time.
The sequence numbers of all requests sent by the master station to the outside stations are
from 0 to 15. The sequence numbers of unsolicited responses sent from outside stations are
included within 16 to 31.
Note: An unsolicited response is a message sent by an external station, usually it contains event
data, it will be automatically sent to the master station, the master station does not need to query
the external station for this data.
Note: It is recommended that any changed data reported by the external station requires
confirmation in the response when it is sent.
Serial number working rules:
The serial number rolls from 15 to 0 or 31 to 16. Each successive request segment sent from the
DNP master station has an ascending sequence number. An exception is the retransmission of
request messages. When a request for a single segment is retransmitted, its sequence number is
not incremented. As for the retransmission of a multi-segment request, the sequence number of
the first segment in the retransmitted request is the sequence number of the last segment of the
request that just failed.
For a single-segment request, the single-segment response has the same sequence number as
the request.
For a multi-segment response to a single-segment request, its first segment has the same
sequence number as the request. As for the subsequent segments of the multi-segment
response, the sequence number is increasing
For a multi-segment response to a multi-segment request, the sequence number of the first
segment is the same as the sequence number of the last segment of the multi-segment request
Retransmission processing rules
When a response is not received after the time limit expires, if the system uses application
layer retransmission, the request will still be retransmitted with the same sequence number.
If the two messages received have the same sequence number, it usually means that the
response of the message has not been received by the opposite station. In this case, the
response is retransmitted (it is not necessary to reprocess this message).
If the two CONFIRM responses received have the same sequence number, the second
response is ignored.
3.2.4 Conflict between the request of the master station and the unsolicited response
When an unsolicited response occurs from an outside station, there is a possibility that an
unsolicited response is sent from the outside station and the master station is also sending a
request at the same time. When the outside station receives a request from the master station
instead of a response to its unsolicited CONFIRM, it will cause the master to receive an
unsolicited response not an expected response to its request.
The handling of the above and similar situations depends on the type of request sent by the master
station.
The master station will always process the unsolicited response immediately. Even if the master
station is expecting a response to the previously sent request, it will also process the unsolicited
response immediately. If the outside station asks for confirmation (which is a CON bit), the
master station must immediately send a response to the unsolicited CONFIRM.
Usually, the outside station will process the request immediately, even if it is expecting a
response to the previously requested CONFIRM. Except for the request of the system data (such
as binary input data, event count data, etc.), all requests should be handled in this mode. This
mode of operation is called IMMEDIATE_PROCESS mode. Another way is if the outside station
is waiting for the previous unsolicited response of CONFIRM, it will not deal with the read
request of the main station before processing CONFIRM. The purpose of this functional variation
is to prevent the loss or duplication of data events. This mode of operation is called
PROCES_AFTER_CONFIRM mode.
IMMEDIATE PROCESS
PROCESS AFTER CONFIRM
When the outside station receives a READ request, and the previous unsolicited response has not
yet been confirmed, the outside stations will not process the READ request until the unsolicited
response is confirmed. If the outside station handles the READ request immediately, there will be
the risk of data loss or data duplication. That is because the data of READ is possibly among in
progress of those unconfirmed unsolicited responses.
Data recovery after error
The DNP application layer relies on the data link layer for sending, receiving, and error detection
of all messages, and the application layer is not responsible for the recovery of communication
problems. If a failure of a communication round is reported by the data link layer, the application
layer should suspend the communication round of the application layer and report the error to the
user. In addition, the application layer of the master station should indicate the internal signal
values in all external station responses. The user layer is responsible for initiating any kind of
error recovery steps. The user layer should especially use the internal signal (IIN) sent back from
any external station in response.
The function code identifies the purpose of the message. The length of this field is an 8-Bit byte.
There are two sets of function codes; one for request and the other for response.
Internal signal(IIN)Field is a field with two octets,It follows the function code in all responses.
When a request cannot be processed due to a format error or invalid data requested,IINYou can
always return with proper placement.
The object header of the message specifies the data object (or I/O) contained in the message or
the number used to respond to the message.
According to the object (or I/O). The format of the object header in the request and response is
the same, but the interpretation of the header depends on whether it is a request or a response and
the function code accompanying the header.
1. Object segment
The object segment specifies an object group and the object variants in the group(VARIATION).
The combination of object group and variant can uniquely specify the object referred to in the
message.
Objects can be assigned to one of the four levels. When the object segment specifies an object
level instead of a specific object type, the object segment indirectly refers to all data objects
assigned to this level rather than any specific object type.
The object segment is two bytes long. First8Bit byte specifies the basic type of data(E.g. analog
input),the second8Bit byte specifies the variant of the data type(E.g16Bit analog input or32Bit
analog input). On the requesting side,If the object variant is specified as zero,This shows that all
object variants belong to the same group(I.e. all or any analog input type). However on the
responder,Variants0Cannot be used to specify objects. The specific variant must be specified.
2. Determinants
The qualifier section defines the meaning of the variable range section. The variable range is used
to index data or as an identifier. The use and structure of the variable range depends on the scale
of the indicator(INDEX SIZE)Segment and qualifier codes(QUALIFIER CODE)Value in the
segment, When the variable range value and the end variable range value. Together, they define
the range of an object for the data following the object title. Segments for each start range and
stop range(SUB_FIELD)Known as indicators(INDEX).
When the QUALIFIER code is equal to 11, it is in the header of a requested object (INDEX
SIZE)
Qualifier code ()
3. Variation