Automatic access method for interval unit of protection and measurement integrated DTU (Data Terminal Unit)
By predefining the binding rules between IP addresses and switch numbers in the integrated DTU system, and combining ICMP detection and dynamic creation of TCP client instances, the problems of cumbersome configuration, poor adaptability, and disconnected security configuration of the integrated DTU interval unit are solved. This achieves plug-and-play functionality and automated management throughout the entire lifecycle, improving deployment efficiency and security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-17
- Publication Date
- 2026-05-26
Smart Images

Figure CN122093365A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power distribution automation technology, specifically relating to an automatic connection method for DTU bay units that integrate protection and testing. Background Technology
[0002] The new type of distribution automation terminal, the "Integrated Protection and Testing DTU," is a standardized core device in the current field of distribution network automation, and has formed a mature fixed hardware architecture and communication framework. (See attached instruction manual.) Figure 1 As shown, this type of distribution terminal includes a common unit and multiple bay units. The common unit is responsible for communication aggregation and forwarding functions, aggregating uplink business data from all bay units and forwarding control commands issued by the distribution master station to the bay units. To meet the security requirements of distribution network communication, both the common unit and the bay units have built-in national cryptographic encryption chips. The distribution master station establishes an encrypted communication link only with the common unit. The common unit achieves bidirectional transparent transmission of business data between the bay units and the distribution master station through multi-port forwarding.
[0003] In practical engineering applications of this existing standard architecture, the following shortcomings exist:
[0004] On-site deployment and access configuration are cumbersome. Accessing the bay unit requires maintenance personnel to manually complete a series of operations in the common unit, such as configuring the IP whitelist, manually entering the mapping relationship between the physical location identifier of the switch (such as the switch number) and the network address (IP address), and creating the communication channel. The more bay units a single site has, the greater the configuration workload becomes. Moreover, manual operation is prone to problems such as mapping errors and configuration omissions, which significantly reduces the efficiency of on-site deployment and increases the cost of subsequent maintenance.
[0005] Poor adaptability to scale of access. In existing technologies, the communication channels and data processing instances of the common unit are pre-configured in fixed quantities at the factory. They cannot be dynamically adjusted according to the actual number of bay units accessed on site. This can easily lead to channel redundancy that wastes system resources, or insufficient pre-configured quantities that cannot adapt to bay unit expansion scenarios, resulting in insufficient flexibility in scenario adaptation.
[0006] The automation level of equipment lifecycle management is low. Existing technologies lack an automatic discovery and lifecycle management mechanism for bay unit status based on network detection. They cannot automatically identify the addition, online, offline, and removal status of bay units. Changes in bay unit status require manual inspection and confirmation, and manual updates to the configuration of common units. At the same time, there is a lack of a threshold determination mechanism based on continuous detection results. Instantaneous network communication anomalies can easily lead to erroneous equipment status switching, causing abnormal interruptions in communication links and affecting the stable operation of power distribution services.
[0007] There is a disconnect between device access and security encryption configuration. In existing technologies, network access and encrypted communication link configuration of the intermediate unit are implemented in two separate steps. After the device is connected, encryption parameters need to be manually configured and the encryption chip needs to be adapted. This can easily lead to oversights in encryption configuration and create risks that do not comply with the security communication standards of the power distribution network. Summary of the Invention
[0008] To address the shortcomings and deficiencies of existing technologies, this invention provides an automatic access method and device for DTU (Distributed Terminal Unit) bay units with integrated protection and testing capabilities. This invention predefines a unique binding rule between the last segment of the bay unit's IP address and the last two digits of its corresponding field switch number, allowing the bay unit's network address to directly reflect its physical location. Based on this binding rule, the common unit sends ICMP probe packets to a pre-generated range of IP addresses at fixed intervals and updates the bay unit's access status using a dual-threshold differential judgment mechanism: when the number of consecutive successful probes reaches a first preset threshold (e.g., 3 times), it is marked as being in a pending access state; when the number of consecutive failed probes reaches a second preset threshold (e.g., 5 times), it is marked as being in an offline state. The common unit dynamically creates a unique, independent TCP client instance for each bay unit in the pending access state, establishing a one-to-one matching relationship with currently accessible bay units. The TCP client instance initiates a connection request to the fixed port of the corresponding bay unit, establishing a dedicated one-to-one communication link. After the communication link is established, the common unit and the bay unit automatically configure encryption parameters using a built-in national cryptographic encryption chip, achieving end-to-end encrypted transmission of business data on the dedicated link. This invention also provides a corresponding integrated DTU device with integrated protection and testing capabilities. This invention enables plug-and-play, adaptive access, and automated lifecycle management of the bay unit, effectively solving problems such as cumbersome on-site configuration, inability to dynamically match resources, reliance on manual status management, and easy omissions in security configuration.
[0009] The specific technical solution adopted by this invention to solve its technical problem is as follows:
[0010] An automatic access method for integrated protection and testing DTU bay units is provided, applied to an integrated protection and testing DTU system. The integrated protection and testing DTU system includes a common unit and multiple bay units connected via a local area network switch. The common unit is used to establish encrypted communication with the distribution master station. Each bay unit corresponds to a field switchgear. Both the common unit and each bay unit have built-in encryption chips. The method is executed by the common unit and includes:
[0011] A unique binding rule between address and physical location is pre-defined, and the last segment of the IP address of each interval unit is matched one by one with the last two digits of its corresponding field switch number. Based on the binding rule, a range of IP addresses to be detected is generated.
[0012] Based on the binding rules, ICMP probe packets are periodically sent to each IP address within the range of IP addresses to be detected. The access status of the corresponding interval unit is updated according to the response results of continuous probes: when the number of consecutive successful probes for any IP address reaches a first preset threshold, the corresponding interval unit is marked as pending access; when the number of consecutive failed probes for any IP address corresponding to an already accessed interval unit reaches a second preset threshold, the corresponding interval unit is marked as offline; the first preset threshold is less than the second preset threshold.
[0013] Create a unique, independent TCP client instance for each interval unit marked as pending access, and release the TCP client instances corresponding to each interval unit marked as offline, so that the TCP client instances and the currently accessible interval units form a one-to-one matching relationship.
[0014] The TCP client instance initiates a TCP connection request to its unique corresponding interval unit to establish a one-to-one dedicated communication link, and the end-to-end encrypted transmission of business data is achieved on the dedicated communication link through the encryption chips built into both parties.
[0015] Furthermore, the last segment of the IP address of the local area network port used by the common unit to communicate with the interval unit is fixed to 200. The common unit and all interval units are in the same Class C local area network segment, and the subnet mask is 255.255.255.0.
[0016] Furthermore, the first preset threshold is 3 consecutive successful detections, and the second preset threshold is 5 consecutive failed detections.
[0017] Furthermore, the common unit executes ICMP probe message sending at a fixed period of 5 seconds. In the ICMP probe message sent, the identifier field carries the last two digits of the switch sequence number bound to the corresponding target IP address, so that the common unit can directly locate the corresponding interval unit node when receiving the echo reply message.
[0018] Furthermore, each interval unit that the common unit communicates with pre-starts a TCP server program with a fixed port of 2404 to continuously listen for TCP connection requests from the common unit; the common unit initiates a TCP connection request to port 2404 of the corresponding interval unit through a TCP client instance, and the created TCP client instance uses a dynamically assigned port number by the system.
[0019] Furthermore, the common unit allocates a shared storage area in memory to manage the access status of all interval units and their corresponding client instances. It is managed using a combination of structure arrays and hash mapping. The shared storage area uses read-write mutex locks to ensure data consistency during concurrent read and write operations by multiple threads.
[0020] Furthermore, the hash mapping uses the last two digits of the switch number corresponding to the interval unit or the IP address as the key to achieve fast lookup of the interval unit node; the structure array supports the management of up to 64 interval unit nodes.
[0021] Furthermore, after the TCP communication link is successfully established, the TCP client instance of the public unit and the corresponding interval unit maintain the link connection through a custom heartbeat message and exchange heartbeat messages according to a preset period. When no heartbeat message is received from the other end after a preset timeout period or when the received data is abnormal, the corresponding link is automatically disconnected. If the TCP connection fails, the public unit performs an exponential backoff reconnection operation through the corresponding TCP client instance.
[0022] Furthermore, the encryption chips built into the common unit and the interval unit use the national cryptographic SM2 encryption algorithm to complete the encryption and decryption of business data; the common unit sends the encrypted downlink control command of the distribution master station to the target interval unit through a dedicated communication link, and at the same time receives the encrypted field collection data uploaded by the corresponding interval unit, and forwards it to the distribution master station after aggregation.
[0023] Furthermore, a DTU device integrating protection and testing includes a common unit and multiple bay units connected via a local area network switch. The common unit is used to establish encrypted communication with the power distribution master station, and each bay unit corresponds to a field switchgear. Both the common unit and each bay unit have built-in encryption chips. The common unit is configured to execute the method described above.
[0024] Compared to existing technologies, this invention and its preferred solution significantly simplify the on-site deployment and subsequent operation and maintenance process of the integrated DTU interval unit. Through predefined address and physical location binding rules, it eliminates the need for tedious manual operations such as IP whitelist configuration, mapping relationship entry, and communication channel creation, effectively avoiding configuration errors and omissions caused by manual operation and reducing the labor costs and operational threshold of on-site operation and maintenance. It achieves dynamic adaptive matching of the interval unit access scale, eliminating the need for pre-configuration of a fixed number of communication channels and data processing instances at the factory. Client resources can be dynamically adjusted according to the actual number of interval units accessed on-site, avoiding system resource waste caused by channel redundancy and flexibly adapting to interval unit expansion scenarios, thus improving the device's adaptability to different application scenarios. It also achieves self-regulation throughout the entire lifecycle of the interval unit. The automated management system, through differentiated access and offline status determination mechanisms, can automatically identify the addition, online, offline, and removal status of interval units without manual inspection, confirmation, or configuration updates. It effectively avoids misjudgments of equipment status caused by momentary network jitter in industrial settings, reduces abnormal communication link interruptions, and ensures stable operation of power distribution services. It integrates equipment access procedures with secure encryption configuration. After the communication link is established, it automatically completes the interactive adaptation of encryption chips at both ends and end-to-end encrypted transmission, eliminating the need for step-by-step manual configuration of encryption parameters. This effectively avoids oversights in encryption configuration, adapts to relevant specifications for power distribution network communication security protection, and eliminates compliance risks. Furthermore, the overall solution is fully compatible with the standard hardware architecture of existing integrated protection and testing DTUs, requiring no modifications to the existing hardware topology and possessing excellent adaptability to the current network. Attached Figure Description
[0025] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments:
[0026] Figure 1 This is a diagram of the integrated DTU standard communication architecture used in the embodiments of the present invention;
[0027] Figure 2 This is a diagram showing the client-server one-to-one mapping and encrypted communication distribution of the common unit and the interval unit in an embodiment of the present invention.
[0028] Figure 3 This is a flowchart illustrating the implementation process of automatic access to the integrated DTU bay unit for protection and testing in this invention. Detailed Implementation
[0029] To make the features and advantages of the present invention more apparent and understandable, specific embodiments are described below in detail:
[0030] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used in this specification have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.
[0031] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0032] To address the shortcomings of existing technologies and achieve adaptive matching of the number of interval units connected to the integrated DTU for protection and testing, as well as fully automatic, configuration-free access of interval units, this invention provides an automatic access method for interval units in an integrated DTU for protection and testing. This invention is fully compatible with the standard hardware communication architecture of existing integrated DTUs for protection and testing, requiring no modifications to the existing hardware topology. Core functional innovation is achieved solely through software logic optimization of the common unit. The core technical concept is as follows: by defining strong binding rules between IP addresses and corresponding field switch numbers of interval units, automatic scanning and discovery of interval units and status management are achieved based on ICMP Ping commands. The number of client instances within the common unit is dynamically adjusted according to the scanned IP list, establishing a one-to-one client-server encrypted communication channel, ultimately achieving plug-and-play, adaptive access, and fully automated lifecycle management of interval units.
[0033] The specific technical solution of the present invention is as follows:
[0034] The integrated DTU standard communication architecture used in this invention is as follows: Figure 1 As shown, this architecture is a mature existing technology. The specific topology is as follows: the power distribution master station establishes a wide area network communication connection with the DTU common unit through optical fiber communication; the common unit establishes a local area network communication connection with multiple DTU bay units through a local area network switch and network cable; each bay unit corresponds to one switch device on site, and the common unit and all bay units have built-in national cryptographic encryption chips for encryption and decryption processing of business communication data.
[0035] This invention predefines the mapping rules between the IP address of the interval unit and the serial number of the field switch: the last segment of the IP address of the interval unit is bound to the last two digits of the serial number of the corresponding field switch. For example: if the field switch number is "01", then the last segment of the IP address of the corresponding interval unit is "01"; if the switch number is "12", then the last segment of the IP address of the corresponding interval unit is "12"; if the switch number is "17", then the last segment of the IP address of the corresponding interval unit is "17".
[0036] Meanwhile, the last segment of the IP address of the LAN port connecting the common unit and the interval unit is fixed to "200", i.e., the IP format is "xxx.xxx.xxx.200", placing it in the same Class C network segment (subnet mask 255.255.255.0) as all interval units, ensuring LAN communication reachability. All interval units create a TCP server program with a fixed port number of 2404 to receive connection requests from the common unit.
[0037] The public unit, through the LAN switch, sends ICMP Ping commands to all predefined IP addresses within the target network segment at a fixed 5-second interval to scan, discover, add, and delete nodes in the access list. The specific judgment rules are as follows: when a new IP address is discovered, if three consecutive Ping attempts are successful, the corresponding interval unit node is added to the access list; if an IP address in the access list fails to be Pinged five times consecutively, the node is removed from the access list, thus completing the cleanup of offline nodes.
[0038] The communication mapping architecture between the common unit and the interval unit of the present invention is as follows: Figure 2 As shown, the number of TCP client programs created within the public unit is exactly the same as the number of interval units in the access list discovered by the Ping scan, achieving a one-to-one mapping between client instances and interval units. Specifically, the public unit creates an independent TCP client program for each interval unit in the access list, with a randomly assigned client port number. The client then initiates a connection request via the local area network to the TCP server on the corresponding interval unit's fixed port 2404, establishing a one-to-one TCP communication link.
[0039] The common unit and the interval unit adopt a TCP "client-server" full-duplex communication mode. The client and server maintain the connection status of the communication link through a custom heartbeat message. When the heartbeat message from the other end is not received for a preset time, or when the received data is abnormal, the corresponding TCP connection is automatically disconnected, triggering a reconnection or node cleanup process.
[0040] After the communication link is established, the client program of the common unit interacts with its built-in encryption chip to encrypt the plaintext data and sends the ciphertext data to the target interval unit through the corresponding communication link. After receiving the ciphertext data, the server program of the interval unit interacts with its built-in encryption chip to decrypt the ciphertext and process the plaintext, and replies to the common unit with encrypted response data, thus realizing end-to-end encrypted transmission between the two ends.
[0041] To achieve the binding of IP addresses to physical locations and status tracking, the system allocates a shared storage area in memory and manages it using a combination of structure arrays and hash mapping. This data structure system is the core underlying support for the automated management of the entire lifecycle of the interval unit in this invention, and it must simultaneously meet three core requirements: First, it must carry a strong binding relationship between IP addresses and field switch numbers, facilitating rapid tracing of the device's physical location; second, it must support concurrent and secure read and write operations by multiple threads (Ping scanning thread, connection management thread, and main control business thread) to avoid data conflicts; and third, it must provide efficient node lookup, status update, and triggering mechanisms to ensure the real-time nature of the access / offline process.
[0042] The specific data structure is defined as follows:
[0043] Single-interval unit node state structure:
[0044] / / Single-interval unit node state structure
[0045] typedef struct {
[0046] uint8_t switch_id_suffix; / / Last two digits of the switch number (physical location identifier)
[0047] uint32_t ip_address; / / The IP address to bind (format: xxxswitch_id_suffix)
[0048] uint8_t ping_success_count; / / Counter for consecutive successful pings (threshold: 3)
[0049] uint8_t ping_fail_count; / / Counter for consecutive failed pings (threshold: 5)
[0050] uint8_t connection_status; / / Connection status: 0 - offline, 1 - waiting to connect, 2 - connected
[0051] uint32_t last_heartbeat_ts; / / Timestamp of the last heartbeat
[0052] void* client_instance_ptr; / / Pointer to the corresponding client instance
[0053] uint8_t retry_count; / / Number of retry attempts (used in the backoff algorithm)
[0054] IntervalUnitNode;
[0055] This structure is a "digital twin" of a single interval unit, which fully records its end-to-end status information from discovery, access, keep-alive to offline.
[0056] / / Management container for the list of devices to be integrated
[0057] typedef struct {
[0058] IntervalUnitNode nodes
[64] ; / / Maximum support of 64 interval units
[0059] pthread_mutex_t list_lock; / / Read-write mutex
[0060] uint8_t active_count; / / Number of currently active nodes
[0061] AccessListManager;
[0062] This container serves as a unified scheduling pool for all interval unit nodes, employing a combined design of: structure array + read-write mutex lock + hash mapping. The maximum capacity of the structure array is set to 64, fully adapting to the common maximum interval unit configuration of the State Grid's integrated monitoring and testing DTU. The read-write mutex lock is used to ensure data consistency during concurrent read and write operations by multiple threads. The hash mapping uses switch_id_suffix or ip_address as the key to achieve millisecond-level fast lookup of nodes, avoiding the efficiency loss of traversing the entire array.
[0063] As a further preferred implementation, the hash mapping adopts a key-value pair structure, where the key is the last two digits of the switch number of the interval unit or the bound IP address, and the value is the index value of the IntervalUnitNode node corresponding to the interval unit in the structure array; during system initialization, the hash mapping and the pre-filling of the structure array are completed synchronously to ensure a one-to-one correspondence between the switch number, IP address and node index.
[0064] To facilitate understanding of the design logic of the two core data structures mentioned above, the key fields are explained one by one through the data structures, as shown in Table 1 below:
[0065] Table 1
[0066]
[0067] The value range and threshold parameters of the above fields have been verified through engineering practice, ensuring the stability of the access / offline process while taking into account the efficiency of system resource utilization.
[0068] Once the data structure design is complete, initialization must be performed before the system starts to build the basic framework for the subsequent automatic access process.
[0069] During system initialization, the `switch_id_suffix` and `ip_address` fields are pre-populated based on a preset network segment (e.g., 192.168.1.x) and switch number range, while the `connection_status` field is initially set to 0. This structure serves as a shared resource between the Ping scanning thread and the connection management thread, ensuring data consistency through a mutex lock. Pre-populating nodes instead of dynamically creating them avoids the memory allocation overhead when the Ping scanning thread discovers new devices, further improving the real-time performance of the access process.
[0070] After the shared resources are initialized, an independent background thread needs to be started to drive the update of the node status. The design of this thread should avoid affecting the normal operation of the main control business (such as data forwarding and encrypted communication).
[0071] As a further preferred implementation, the execution flow of the read-write mutex is as follows: when the Ping scanning thread, connection management thread, or main control business thread needs to read or modify the data in the node structure, it must first call the pthread_mutex_lock function to lock the list_lock mutex, and after completing the read-write operation, immediately call the pthread_mutex_unlock function to unlock it; only one thread is allowed to hold the mutex at the same time, completely avoiding data competition and state abnormalities caused by concurrent read and write operations by multiple threads.
[0072] The management mechanism of the Ping scanning thread employs a single, persistent thread combined with non-blocking I / O to implement periodic Ping scans. This thread runs independently and is responsible for actively discovering interval cells and maintaining their online status.
[0073] A single persistent thread can avoid complex synchronization problems caused by multi-threaded contention; low priority settings (implied in background thread attributes) ensure that it only occupies CPU resources when the main control business is idle; non-blocking I / O combined with select() / epoll() can achieve efficient ICMP echo listening and avoid thread blocking during polling.
[0074] To clearly illustrate the full lifecycle execution logic of this thread, the thread management process is shown in Table 2 below:
[0075] Table 2
[0076]
[0077] As a further preferred implementation, the identifier field of the ICMP Echo Request message is a 16-bit unsigned integer, and its value is exactly the same as the last two digits of the switch sequence number bound to the corresponding target IP address. When the common unit receives the ICMP Echo Reply message, it can directly extract the value of the identifier field in the message to match the corresponding interval unit node without traversing the entire node array, thus further improving the real-time performance of the status update.
[0078] This process, through the design of "the identifier field carrying the switch sequence number", can directly locate the corresponding node after receiving the ICMP echo, without having to traverse the hash map again, further improving the efficiency of state update.
[0079] The state machine transition rules are as follows: when the number of successful pings is greater than or equal to 3 and the connection_status is equal to 0 (offline), the state is changed to 1 (pending connection), and the main control thread is notified via a semaphore to create a client connection; when the number of consecutive failed pings is greater than or equal to 5 and the connection status is equal to 2, the state is changed to 0 (offline), and the client destruction process is triggered. A mutual exclusion update mechanism for the counter ensures data accuracy in concurrent scenarios.
[0080] The state machine transitions are executed by an independent connection management thread (or a submodule of the main control business thread) based on the semaphore / condition variable triggered by the Ping scan thread, ensuring the atomicity and consistency of state changes; the counter's mutual exclusion update mechanism further avoids counting errors in concurrent scenarios.
[0081] The specific design of the heartbeat message for the common unit and the interval unit is as follows, and the heartbeat initiation frame structure is shown in Table 3 below:
[0082] Table 3
[0083]
[0084] The heartbeat response frames are shown in Table 4 below:
[0085] Table 4
[0086]
[0087] The aforementioned data structure, thread model, and state machine together constitute the core underlying support for the automatic access and full lifecycle management of the interval unit in this invention. Based on this, this invention further designs a communication link keep-alive and encrypted transmission mechanism. For the specific communication architecture and process, please refer to the accompanying drawings and subsequent specific implementation methods.
[0088] In summary, compared with the prior art, the advantages of the improvements provided by this invention are as follows:
[0089] 1. Significantly improved efficiency in on-site deployment and access configuration. Through strong binding rules between IP addresses and on-site switch numbers, the interval unit only needs to set the IP end segment according to the switch number. There is no need for maintenance personnel to manually complete IP whitelist configuration, mapping relationship entry, communication channel creation and other operations in the common unit. This completely eliminates the dependence on manual configuration, and the deployment time of a single site can be shortened by more than 90%, and the risk of errors from manual operation is completely avoided.
[0090] 2. Significantly enhanced adaptability to access scale. The number of TCP client instances in the public unit dynamically matches the number of online interval units discovered by scanning, eliminating the need for a fixed number pre-configured at the factory. This allows for access in all scenarios, from 1 to 64 interval units, while maximizing the conservation of system memory and CPU resources and avoiding issues of channel redundancy or insufficient configuration.
[0091] 3. The automation level of equipment lifecycle management has been greatly improved. Through a dual threshold judgment mechanism of "three consecutive successful pings triggering access and five consecutive failed pings triggering offline", the system effectively avoids misjudgments of status caused by network jitter. Through the cooperation of a three-level state machine of "offline-waiting for access-connected" and independent threads, the system realizes the automatic discovery, addition, keep-alive and offline cleanup of interval units, achieving unmanned management of the entire process. No manual inspection and confirmation is required, which greatly reduces the later operation and maintenance costs and improves the stable operation rate of power distribution services.
[0092] 4. Equipment access and security encryption configuration are fully integrated. After the communication link is established, the interaction between the built-in national cryptographic encryption chips of the common unit and the bay unit is automatically triggered, seamlessly completing the establishment of the end-to-end encrypted transmission link. There is no need to manually configure encryption parameters, which fully complies with the power distribution network security communication protection specifications and completely eliminates compliance risks.
[0093] The complete implementation process of the automatic access method for the integrated protection and testing DTU bay unit of the present invention is as follows: Figure 3 As shown below, the specific implementation process of this solution will be explained in detail and completely, taking into account the actual engineering deployment scenario of a 10kV substation in China. Those skilled in the field of power distribution automation technology can completely reproduce all the technical effects of this invention based on this embodiment.
[0094] The application scenario of this embodiment is as follows: A State Grid standard integrated protection and testing DTU is configured with one common unit, corresponding to four 10kV outgoing line switches on site. The switch field numbers are 01, 12, 21, and 35, and each switch corresponds to one independent integrated protection and testing DTU bay unit. All common units and bay units are physically networked through an industrial-grade LAN switch. Both the common unit and all bay units have built-in SM2 national cryptographic encryption chips, fully complying with the State Grid distribution network security protection specifications. Specific implementation steps are as follows: Figure 3 As shown:
[0095] Step 1: Pre-configure basic equipment parameters
[0096] 1. In accordance with the strong binding rule between IP address and switch number defined in this invention, complete the IP address configuration for the four interval units: the switch numbers corresponding to the four interval units are 01, 12, 21, and 35, so their local area network IP addresses are set to 192.168.1.1, 192.168.1.12, 192.168.1.21, and 192.168.1.35 respectively, and the subnet mask is uniformly set to 255.255.255.0, which is in the same Class C network segment as the common unit.
[0097] 2. Each bay unit starts and initializes a TCP server program with a fixed port number of 2404, continuously listening for TCP connection requests from the common unit; at the same time, it completes the initialization of its own built-in national cryptographic encryption chip and prepares for encrypted data exchange.
[0098] 3. Complete the LAN port IP configuration of the common unit: According to the fixed rules of this invention, set the last segment of the LAN port IP address connecting the common unit and the interval unit to 200, that is, the complete IP is 192.168.1.200, and the subnet mask is 255.255.255.0, to ensure network reachability with all interval units.
[0099] Step Two: Initialization of Common Unit System and Creation of Core Resources
[0100] After the common unit is powered on and started, it first completes the initialization of the core management resources of this invention to build the underlying framework for the subsequent automatic access process. The specific operations are as follows:
[0101] 1. Allocate a shared storage area in memory, initialize the AccessListManager container defined in this invention for managing the access list, and pre-fill the IntervalUnitNode node structure array, which supports a maximum of 64 interval units; based on the preset 192.168.1.x network segment and the switch number range of 01-64, pre-fill the switch_id_suffix suffix and ip_address bound IP address fields of each node, set the connection_status of all nodes to 0 (offline) initially, and initialize the pthread_mutex_t read-write mutex lock for the list to ensure data consistency during concurrent read and write operations by multiple threads.
[0102] 2. Create and start a low-priority background thread Thread_PingScan (i.e., the Ping scanning thread defined in this invention). After the thread is initialized, it enters a standby state and waits to execute periodic scanning tasks. At the same time, initialize the connection management master thread and listen for the state change semaphores issued by the scanning thread.
[0103] Step 3: Automatic scanning and online status detection of interval units
[0104] 1. The Ping scanning thread of the public unit sends standard ICMP Echo Request (Ping) messages sequentially to all pre-configured node IP addresses in the 192.168.1.0 / 24 network segment through the local area network switch at a preset fixed period of 5 seconds. The identifier field in the message carries the corresponding node's switch sequence number suffix to facilitate quick location of the echo results.
[0105] 2. The scanning thread listens for ICMP echo reply packets via the epoll mechanism, with a timeout threshold set to 1 second. For each IP address, the counter in the corresponding node structure is updated based on the reply result: when a valid echo reply is received, the ping_success_count consecutive successful ping counter is incremented by 1, and the ping_fail_count consecutive failed ping counter is cleared; when no valid reply is received, ping_fail_count is incremented by 1, and the ping_success_count is cleared.
[0106] 3. Perform status update according to the dual threshold determination rule defined in this invention:
[0107] For the four online interval unit IPs 01, 12, 21, and 35, when the scanning thread successfully pings three times in a row, the ping_success_count of the corresponding node reaches the threshold of 3, and the current connection_status is 0 (offline). Therefore, the node status is automatically changed to 1 (pending access), and the connection management master thread is notified through a semaphore to add the node to the pending access list.
[0108] For IP addresses within the network segment that have no online devices, no valid ICMP echo response is received, so they remain offline and are not added to the access list.
[0109] 4. In this embodiment, the public unit finally confirms through scanning that the number of online interval units waiting to be accessed is 4, and the list of nodes to be accessed includes 4 nodes corresponding to switch numbers 01, 12, 21, and 35.
[0110] Step 4: Dynamically create adaptive client instances
[0111] 1. After receiving the state change semaphore, the connection management master thread of the common unit locks the list of waiting accesses through a read-write mutex lock, reads that the number of interval units waiting to be accessed is 4, and then creates 4 independent TCP client program instances according to the rule that "the number of clients is exactly the same as the number of interval units waiting to be accessed". The client port number adopts a dynamic port randomly assigned by the system to avoid port conflicts.
[0112] 2. Complete the one-to-one binding between client instances and node structures: Assign the memory address of each client instance to the client_instance_ptr pointer in the corresponding node structure, realizing a dedicated mapping of "one client instance corresponding to one interval unit node," laying the foundation for subsequent one-to-one communication. The specific mapping relationship and communication architecture are as follows: Figure 2 As shown.
[0113] Step 5: Establishing a one-to-one TCP communication link
[0114] 1. The four client instances of the common unit initiate TCP connection requests to the corresponding bound interval unit IP address and fixed port 2404, and establish a full-duplex communication link with the TCP server of the corresponding interval unit through a three-way handshake.
[0115] 2. After the communication link is successfully established, the connection_status of the corresponding node changes from 1 (pending access) to 2 (connected), and the reconnection counter is cleared, completing the formal access of the interval unit; if the connection fails, the client will perform exponential backoff reconnection based on the retry_count reconnection counter in the node structure to ensure the reliability of the link establishment.
[0116] 3. After the link is established, the client and the server immediately start the heartbeat message interaction mechanism defined in this invention: the common unit client sends a heartbeat request frame at a fixed period, and the interval unit server replies with a heartbeat response frame after receiving it. Both parties update the last heartbeat timestamp of last_heartbeat_ts in real time through heartbeat messages, and at the same time synchronize the device's CPU load, memory usage, network status and other operating information; if no heartbeat message is received from the other end within the preset time, the TCP connection is automatically disconnected and the reconnection process is triggered.
[0117] Step Six: End-to-end encrypted communication and bidirectional interaction of business data
[0118] 1. After the communication link is stably established, the client program of the common unit interacts with its built-in national cryptographic encryption chip to encrypt the plaintext data such as the power distribution master station control commands and parameter configurations that need to be sent to the bay unit using the SM2 algorithm, and generate encrypted ciphertext data.
[0119] 2. The common unit sends encrypted ciphertext data to the target interval unit through a dedicated client-server communication link bound to the corresponding interval unit, completely avoiding data crosstalk and mistransmission.
[0120] 3. After receiving encrypted data from the network, the server program of the interval unit interacts with its built-in national cryptographic encryption chip to complete the decryption of encrypted data and parsing of plaintext data, and executes the corresponding control commands or parameter configuration operations; at the same time, it encrypts the upstream business data such as switch quantities, analog quantities, and fault waveforms collected by itself through the encryption chip, and replies to the corresponding client instance of the common unit through the same communication link.
[0121] 4. The common unit collects the uplink encrypted data from all bay units and forwards it to the power distribution master station in a unified manner, completing the bidirectional transparent transmission process of the entire business data and realizing the integrated completion of access and encrypted transmission.
[0122] Step 7: Dynamic Adaptive Processing of Equipment Status Changes
[0123] This embodiment simultaneously verifies the offline removal and new access adaptive capabilities of the present invention. The specific process is as follows:
[0124] 1. When the interval unit numbered 35 is offline due to power outage for equipment maintenance, the Ping scanning thread of the common unit continuously sends Ping packets to 192.168.1.35. After 5 consecutive Ping failures, the ping_fail_count of the corresponding node reaches the threshold of 5, and the current connection_status is 2 (connected). Then, the node status is automatically changed to 0 (offline), triggering the client destruction process, disconnecting and releasing the corresponding TCP client instance, and deleting the node from the access list, thus completing the automatic cleanup of offline devices.
[0125] 2. After maintenance is completed, the No. 35 bay unit is powered on and back online. After the scanning thread detects that the IP has been successfully pinged 3 times in a row, it automatically triggers the access process again, completes client creation, link establishment and encrypted communication, without any manual configuration intervention, and fully realizes dynamic adaptation of access scale.
[0126] Based on the same inventive concept, this invention also provides a computer device, comprising: one or more processors, and a memory for storing one or more computer programs; the programs include program instructions, and the processor executes the program instructions stored in the memory. The processor may be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. It is the computing and control core of the terminal, used to implement one or more instructions, specifically for loading and executing one or more instructions stored in a computer storage medium to implement the above-described method.
[0127] It should be further explained that, based on the same inventive concept, the present invention also provides a computer storage medium storing a computer program, which, when executed by a processor, performs the above-described method. This storage medium can be any combination of one or more computer-readable media. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of computer-readable storage media (a non-exhaustive list) include: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0128] It should be noted that, unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0129] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.
[0130] This invention is not limited to the above-described preferred embodiment. Anyone inspired by this invention can derive other forms of automatic access method for DTU bay units that integrate protection and testing. All equivalent changes and modifications made within the scope of the claims of this invention shall fall within the scope of this invention.
Claims
1. An automatic access method for integrated protection and testing DTU bay units, applied to an integrated protection and testing DTU system, the integrated protection and testing DTU system comprising a common unit and multiple bay units connected via a local area network switch, the common unit being used to establish encrypted communication with the distribution master station, each bay unit corresponding to a field switchgear, and both the common unit and each bay unit having a built-in encryption chip, characterized in that... The method is executed by a common unit and includes: A unique binding rule between address and physical location is pre-defined, and the last segment of the IP address of each interval unit is matched one by one with the last two digits of its corresponding field switch number. Based on the binding rule, a range of IP addresses to be detected is generated. Based on the binding rules, ICMP probe packets are periodically sent to each IP address within the range of IP addresses to be detected. The access status of the corresponding interval unit is updated according to the response results of continuous probes: when the number of consecutive successful probes for any IP address reaches a first preset threshold, the corresponding interval unit is marked as pending access; when the number of consecutive failed probes for any IP address corresponding to an already accessed interval unit reaches a second preset threshold, the corresponding interval unit is marked as offline; the first preset threshold is less than the second preset threshold. Create a unique, independent TCP client instance for each interval unit marked as pending access, and release the TCP client instances corresponding to each interval unit marked as offline, so that the TCP client instances and the currently accessible interval units form a one-to-one matching relationship. The TCP client instance initiates a TCP connection request to its unique corresponding interval unit to establish a one-to-one dedicated communication link, and the end-to-end encrypted transmission of business data is achieved on the dedicated communication link through the encryption chips built into both parties.
2. The automatic access method for a DTU bay unit integrating protection and testing according to claim 1, characterized in that: The last segment of the IP address of the local area network port used by the common unit to communicate with the interval unit is fixed to 200. The common unit is in the same Class C local area network segment as all interval units, and the subnet mask is 255.255.255.
0.
3. The automatic access method for a DTU bay unit integrating protection and testing according to claim 1, characterized in that: The first preset threshold is 3 consecutive successful detections, and the second preset threshold is 5 consecutive failed detections.
4. The automatic access method for a DTU bay unit integrating protection and testing according to claim 1, characterized in that: The common unit executes ICMP probe message sending at a fixed interval of 5 seconds. In the ICMP probe message sent, the identifier field carries the last two digits of the switch sequence number bound to the corresponding target IP address, so that the common unit can directly locate the corresponding interval unit node when receiving the echo reply message.
5. The automatic access method for a DTU bay unit integrating protection and testing according to claim 1, characterized in that: Each interval unit that the common unit communicates with pre-starts a TCP server program with a fixed port of 2404 to continuously listen for TCP connection requests from the common unit; the common unit initiates a TCP connection request to the corresponding interval unit's port 2404 through a TCP client instance, and the created TCP client instance uses a dynamically assigned port number randomly assigned by the system.
6. The automatic access method for a DTU bay unit integrating protection and testing according to claim 1, characterized in that: The common unit allocates a shared storage area in memory to manage the access status of all interval units and their corresponding client instances. It is managed using a combination of structure arrays and hash mapping. The shared storage area uses read-write mutex locks to ensure data consistency for concurrent read and write operations by multiple threads.
7. The automatic access method for a DTU bay unit integrating protection and testing according to claim 1, characterized in that: The hash mapping uses the last two digits of the switch number corresponding to the interval unit or the IP address as the key to achieve fast lookup of interval unit nodes; the structure array supports the management of up to 64 interval unit nodes.
8. The automatic access method for a DTU bay unit integrating protection and testing according to claim 1, characterized in that: After the TCP communication link is successfully established, the TCP client instance of the public unit and the corresponding interval unit maintain the link connection through a custom heartbeat message and exchange heartbeat messages according to a preset period. When no heartbeat message is received from the other end after a preset timeout period or when the received data is abnormal, the corresponding link is automatically disconnected. If the TCP connection fails, the public unit performs an exponential backoff reconnection operation through the corresponding TCP client instance.
9. The automatic access method for a DTU bay unit integrating protection and testing according to claim 1, characterized in that: The encryption chips built into the common unit and the interval unit use the national cryptographic SM2 encryption algorithm to complete the encryption and decryption of business data. The common unit sends the encrypted downlink control command of the distribution master station to the target interval unit through a dedicated communication link, and at the same time receives the encrypted field collection data uploaded by the corresponding interval unit, and forwards it to the distribution master station after aggregation.
10. A DTU device integrating protection and testing, characterized in that, The system includes a common unit and multiple bay units connected via a local area network switch. The common unit is used to establish encrypted communication with the power distribution master station. Each bay unit corresponds to a field switchgear. Both the common unit and each bay unit have built-in encryption chips. The common unit is configured to perform the method of any one of claims 1 to 9.