Instrument configuration method and device supporting DHCP (Dynamic Host Configuration Protocol) function, and readable storage medium

By negotiating with a DHCP master server over Ethernet to automatically configure IP addresses for the instruments, the problem of low instrument configuration efficiency is solved, enabling flexible and efficient IP address allocation and system redundancy switching, thereby improving instrument configuration efficiency and system stability.

CN121887776APending Publication Date: 2026-04-17HANGZHOU KANGJISEN AUTOMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU KANGJISEN AUTOMATION TECH CO LTD
Filing Date
2025-12-22
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

The configuration efficiency of meters that support DHCP in existing Ethernet networks is low, especially when the number of meters is large, making it difficult to configure them flexibly and efficiently.

Method used

The first gateway negotiates with each gateway in the local area network to become the DHCP master server by multicasting messages, carrying IP addresses, fault information and address pool, and obtains the response results. After negotiation, it automatically configures IP addresses for connected instruments through the DHCP function, and can select a backup server for redundancy switching.

Benefits of technology

Automatic allocation of instrument IP addresses is achieved, improving configuration efficiency. It significantly enhances operational convenience and flexibility, especially when there are a large number of instruments. It also has redundancy functionality for switching between primary and backup servers, ensuring system stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121887776A_ABST
    Figure CN121887776A_ABST
Patent Text Reader

Abstract

The invention discloses an instrument configuration method and device supporting a DHCP (Dynamic Host Configuration Protocol) function and a readable storage medium, relates to the technical field of Ethernet, is applied to a first gateway, and comprises the following steps: after determining that the DHCP function can be started by analyzing gateway configuration information, multicasting a first message to each second gateway in a local area network where the first gateway is located, the first message is used for negotiating with each second gateway to become a DHCP main server and carrying an IP address, fault information and a belonging address pool of the gateway; obtaining a response result of each second gateway to the first message; if the first gateway is negotiated to become a DHCP main server based on the response result, IP addresses are configured for instruments which are connected with third gateways and support the DHCP function through the DHCP function, and the third gateways comprise the first gateway and a second gateway which has the same address pool as the first gateway. Therefore, automatic distribution of the IP address of the instrument is realized, and the configuration efficiency is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Ethernet technology, and in particular to a meter configuration method and apparatus that supports DHCP function, and a readable storage medium. Background Technology

[0002] With the widespread adoption of the Ethernet Advanced Physical Layer (APL) standard, existing APL gateways require users to manually configure IP addresses and other information for each meter connected to the gateway within the local area network (LAN) when communicating with APL-enabled DHCP-enabled meters. Typically, a LAN can have multiple gateways and switches, with each switch connecting multiple gateways upstream and multiple meters downstream. Each gateway then establishes its communication network with the meters through its corresponding switch, requiring manual configuration to assign IP addresses to each meter within the LAN. This manual operation is cumbersome, inflexible, and inefficient, making it particularly difficult to handle scenarios with a large number of meters.

[0003] Improving the configuration efficiency of meters that support DHCP over Ethernet is a technical problem that needs to be solved. Summary of the Invention

[0004] The purpose of this application is to provide a meter configuration method and apparatus, and a readable storage medium that support DHCP functionality, in order to solve the problem of low configuration efficiency of meters supporting DHCP functionality in existing Ethernet networks.

[0005] To solve the above-mentioned technical problems, this specification is implemented as follows: Firstly, a meter configuration method supporting DHCP functionality is provided, applied to a first gateway, the method comprising: After determining that the DHCP function can be enabled by parsing the gateway configuration information, the first message is multicast to each second gateway in the local area network where the first gateway is located. The first message is used to negotiate with each second gateway to become the DHCP master server and carries the gateway's IP address, fault information and the address pool to which it belongs. Obtain the response results of each second gateway to the first message; If the first gateway is negotiated to become the DHCP master server based on the response result, then the IP address is configured for each DHCP-enabled meter connected to the third gateway through the DHCP function. The third gateway includes the first gateway and the second gateway that belongs to the same address pool as the first gateway.

[0006] Optionally, the response result includes the existence of a response to the first message. Based on the response result, negotiate for the first gateway to become the DHCP master server, including: The system receives a second message that responds to the first message multicast from at least one target third gateway. The target third gateway is a second gateway that belongs to the same address pool as the first gateway. The second message carries the IP address, fault information and address pool of the corresponding target third gateway. Parse the second message to obtain the IP address of the at least one target third gateway; If, by comparing the IP address of the at least one target third gateway with the IP address of the first gateway, it is determined that the IP address of the first gateway conforms to the first preset rule, then the first gateway is negotiated to become the DHCP master server.

[0007] Optionally, the response result includes the absence of a response to the first message. Based on the response result, negotiate for the first gateway to become the DHCP master server, including: If no response to the first message is received from any second gateway within a first preset time, the first gateway shall negotiate to become the DHCP master server.

[0008] Optionally, after configuring IP addresses for DHCP-enabled meters connected to each third gateway via DHCP, the method further includes: if the IP address of the target third gateway conforms to a second preset rule by comparing the IP address of the at least one target third gateway with the IP address of the first gateway, then selecting the target third gateway from the at least one target third gateway as the DHCP backup server for the first gateway. Synchronize DHCP lease information to the target third gateway, wherein the DHCP lease information carries the IP address, MAC address and instrument name of the instrument connected to each third gateway; The fourth message is periodically multicast to the target third gateway and received from the target third gateway. The fourth message is used to monitor whether the first gateway or the target third gateway has a fault and carries the corresponding fault information. Based on the fourth message, the target third gateway is switched to become the DHCP master server, or a new target third gateway is selected to replace the target third gateway as the DHCP backup server of the first gateway.

[0009] Optionally, based on the fourth message, switching the target third gateway to become the DHCP master server includes: If a fault is detected in the first gateway, and the fault information carried in the fourth message of the target third gateway's timed multicast indicates that the target third gateway is not faulty, then a fifth message is sent to the target third gateway. The fifth message is used to indicate that the target third gateway needs to switch to become the DHCP master server and carries the fault information and IP address of the first gateway. The latest DHCP lease information is synchronized to the target third gateway. The latest DHCP lease information carries the IP address, MAC address and instrument name of the instrument currently connected to each third gateway.

[0010] Optionally, based on the fourth message, selecting a new target third gateway to replace the target third gateway as the DHCP backup server of the first gateway includes: If the fault information carried in the fourth message of the timed multicast of the target third gateway indicates that the target third gateway is faulty, then a new target third gateway is selected from the at least one target third gateway and replaces the target third gateway as the DHCP backup server of the first gateway; or If the fourth message multicast by the target third gateway is not received within the second preset time, a new target third gateway is selected from the at least one target third gateway and replaced as the DHCP backup server of the first gateway.

[0011] Optionally, the DHCP backup server does not respond to the first message received by the corresponding gateway multicast within the local area network.

[0012] Optionally, it also includes: If a sixth message is received from the target third gateway multicast, the first gateway is negotiated not to become the DHCP master server. The target third gateway is the second gateway among the second gateways that has the same address pool as the first gateway. The sixth message is used to respond to the first message and indicate that the target third gateway has become the DHCP master server.

[0013] In a second aspect, an instrument configuration device supporting DHCP functionality is provided, including a processor and a memory, the memory storing programs or instructions executable on the processor, the programs or instructions, when executed by the processor, implementing the steps of the method described in the first aspect.

[0014] Thirdly, a readable storage medium is provided that stores a program or instructions which, when executed by a processor, implement the steps of the method described in the first aspect.

[0015] In this embodiment, after determining that DHCP can be enabled by parsing the gateway configuration information, the first gateway multicasts a first message to each second gateway in the local area network where the first gateway is located. The first message is used to negotiate with each second gateway to become the DHCP master server and carries the gateway's IP address, fault information, and address pool. The first gateway obtains the response results from each second gateway to the first message. If the first gateway is negotiated to become the DHCP master server based on the response results, then IP addresses are configured for the DHCP-enabled meters connected to each third gateway via the DHCP function. The third gateway includes the first gateway and second gateways that share the same address pool as the first gateway. Therefore, by acting as a DHCP master server, the IP addresses of multiple connected DHCP-enabled meters can be automatically allocated. This is convenient and flexible, improving the efficiency of meter configuration, especially in scenarios with a large number of meters. Attached Figure Description

[0016] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a flowchart illustrating the meter configuration method supporting DHCP functionality according to an embodiment of this application.

[0017] Figure 2 This is a schematic diagram illustrating an application scenario of the meter configuration method supporting DHCP functionality according to an embodiment of this application.

[0018] Figure 3 This is a structural block diagram of an instrument configuration device supporting DHCP function according to an embodiment of this application. Detailed Implementation

[0019] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. The drawing numbers in this application are only used to distinguish the various steps in the solution and are not used to limit the execution order of the various steps. The specific execution order is subject to the description in the specification.

[0020] To address the problems existing in the prior art, this application provides a meter configuration method that supports DHCP functionality, applied to a first gateway, which is any gateway within the local area network.

[0021] like Figure 1As shown, the process includes steps 102 to 106.

[0022] Step 102: After determining that the DHCP function can be enabled by parsing the gateway configuration information, a first message is multicast to each second gateway in the local area network where the first gateway is located. The first message is used to negotiate with each second gateway to become the DHCP master server and carries the gateway's IP address, fault information and the address pool to which it belongs.

[0023] After each gateway in the local area network is powered on, it will determine whether to enable the DHCP function based on the gateway configuration information configured by the user through the front-end client.

[0024] Combination Figure 2 Application scenarios include, for example, users can configure the configuration information of each gateway, including the first gateway 220 in the local area network, through client 100. Users can configure the corresponding "yes" or "no" gateway configuration information through client 100, indicating whether the corresponding gateway needs to enable DHCP function.

[0025] If the first gateway 220 determines that the DHCP function can be enabled by parsing the gateway configuration information, then each second gateway in the local area network where the first gateway 220 is located will multicast the first message.

[0026] The second gateway is any other gateway within the local area network (LAN) where the first gateway 220 is located. A LAN can have multiple gateways and multiple switches. A single switch connects multiple gateways upstream and multiple meters downstream, thus enabling each gateway to establish a communication network with the meters through its corresponding switch.

[0027] Combination Figure 2 Gateway 200 includes multiple gateways that correspond to the same address pool, and the same address pool corresponds to the same switch. Figure 2 The intermediate switch 300 includes an industrial switch, an optical switch, and an APL switch connected in series, and is considered as a single switch unit, corresponding to the same address pool. The gateway 200 includes multiple gateways, such as the first gateway 220 and the second gateway 240. It connects to the client 100 uplink and to the switch 300 downlink. The switch 300 connects to multiple instruments 400 downlink.

[0028] It should be noted that the local area network also includes Figure 2 Other switches and their corresponding connected gateways and meters not shown are connected in the same way as gateway 200, switch 300, and meter.

[0029] After determining that DHCP can be enabled, the first gateway 220 multicasts a first message to other second gateways 240 within the local area network (LAN). These second gateways 240 include all gateways within the LAN other than the first gateway 220, including gateways belonging to the same address pool and gateways not belonging to the same address pool. The first message is used to negotiate with each of the second gateways 240, determining whether it can become the DHCP master server through self-negotiation among the gateways within the LAN. Similarly, after each second gateway 240 within the LAN determines that DHCP can be enabled by parsing its gateway configuration information, it also multicasts a first message to other second gateways, including the first gateway.

[0030] From the perspective of the first gateway 220, the first message sent carries the IP address of the first gateway, fault information, and the address pool to which it belongs. The fault information indicates whether the first gateway has a fault, and if so, the corresponding fault level. The address pool to which the first gateway belongs is related to the downstream connected switch 300. Different switches 300 correspond to different address pools, while multiple gateways within the same gateway 200 connected to the same switch 300 share the same address pool. The IP address carried in the first message is the IP address used by the first gateway 220 to communicate with the upstream client 100. The IP address of the address pool carried in the first message corresponds to the IP address used by the first gateway 220 to communicate with the downstream switch 300. The upstream IP address of the first gateway 220 is different from its downstream IP address.

[0031] Step 104: Obtain the response results of each second gateway to the first message.

[0032] As mentioned above, the second gateway is a gateway within the local area network other than the first gateway 220. It may be connected to the same switch 300 as the first gateway 220 and belong to the same address pool. Alternatively, it may be connected to a different switch 300 and belong to a different address pool. Second gateways with different address pools may respond differently to the first packet. That is, some second gateways may respond to the first packet, while others may not.

[0033] Step 106: If the first gateway is negotiated to become the DHCP master server based on the response result, then the IP address is configured for each DHCP-enabled meter connected to the third gateway through the DHCP function. The third gateway includes the first gateway and the second gateway that has the same address pool as the first gateway.

[0034] In this step, based on the response results of each second gateway to the first multicast message from the first gateway 220, the first gateway can be negotiated to become the DHCP master server. Among the multiple gateways included in the gateway 200 connected to a switch 300, only one gateway can become the DHCP master server. In application scenarios where the local area network includes multiple switches 300, each switch 300 will select one gateway from its connected gateways 200 to become the DHCP master server.

[0035] The primary gateway 220, acting as the DHCP master server, is used to automatically configure IP addresses for the DHCP-enabled meters 400 connected to each gateway in its address pool. Gateways belonging to the same address pool can be defined as third gateways, for example... Figure 2 Multiple gateways in gateway 200 that are connected to the same switch 300 are third gateways, including first gateway 220 and other second gateways 240.

[0036] That is, the first gateway 220, acting as the DHCP master server, can automatically assign IP addresses to each third gateway, including itself and other third gateways connected to multiple meters 400 via switch 300, through the DHCP function. If Figure 2 If the target instrument 400 does not support DHCP, the first gateway 220 cannot automatically assign an IP address to the instrument.

[0037] In one specific embodiment, the response result includes the existence of a response to the first message. Negotiating that the first gateway becomes the DHCP master server based on the response result includes: receiving a second message from at least one target third gateway multicasting the first message, wherein the target third gateway is a second gateway among the second gateways that belongs to the same address pool as the first gateway, and the second message carries the IP address, fault information, and address pool of the corresponding target third gateway; parsing the second message to obtain the IP address of the at least one target third gateway; and if, by comparing the IP address of the at least one target third gateway with the IP address of the first gateway, it is determined that the IP address of the first gateway conforms to a first preset rule, then negotiating that the first gateway becomes the DHCP master server.

[0038] The first gateway 220 notifies other second gateways in the local area network that it will soon become the DHCP master server by multicasting a first message. Upon receiving the first message, the other second gateways will parse the address pool to which the first gateway 220 belongs and determine if it matches their own address pool. In this embodiment, since only one gateway is selected as the DHCP master server from among multiple gateways belonging to the same address pool, only second gateways belonging to the same address pool will respond to the first message. Second gateways not belonging to the same address pool will not respond even if they receive the first message.

[0039] In this embodiment, based on the response of the second gateway 240 to the first gateway 220, it is negotiated whether the first gateway 220 can become a DHCP master server. If the first gateway 220 receives a second message multicast in response to the first message from a second gateway that belongs to the same address pool as the first gateway 220, i.e., the target third gateway (or a third gateway other than the first gateway 220), the second message is parsed to obtain the IP address of the target third gateway, and compared with the IP address of the first gateway 2220 itself.

[0040] The first gateway 220 may receive a response from at least one target third gateway to the first message, for example... Figure 2 In the context of gateway 200, there are eight third gateways belonging to the same address pool, including one first gateway 220 and seven second gateways 240. If the first gateway 220 receives a second message responding to its multicast first message from the other seven second gateways 240, it obtains the IP addresses of the seven second gateways 240 from the second messages from the seven second gateways 240, and compares them with the IP address of the first gateway 220.

[0041] If, through comparison, the IP address of the first gateway 220 is determined to conform to a first preset rule—for example, the IP address with the smaller size is given priority to become the DHCP master server—then, if the comparison determines that the IP address of the first gateway 220 is smaller than the IP addresses of the other seven second gateways 240, then the first gateway 220 will negotiate to become the sole DHCP master server among the eight third gateways. Prioritizing the IP address with the smaller size as the DHCP master server facilitates the decision-making process.

[0042] If the comparison determines that the IP address of the first gateway 220 does not conform to the first preset rule, then through the same self-negotiation method, one of the other 7 second gateways 240 that conforms to the first preset rule will negotiate to become the only DHCP master server among the 8 third gateways.

[0043] In another specific embodiment, the response result includes the absence of a response to the first message. Negotiating that the first gateway becomes the DHCP master server based on the response result includes: if no response to the first message is received from any second gateway within a first preset time, then negotiating that the first gateway becomes the DHCP master server.

[0044] Any second gateway is any gateway in the local area network other than the first gateway 220, including second gateways belonging to the same address pool and second gateways not belonging to the same address pool. As mentioned above, second gateways not belonging to the same address pool will not respond to the first message. Therefore, if the first gateway 220 does not receive responses to the first message from any of the second gateways in the same address pool, it means that the second gateways in the same address pool are not currently powered on and running. Under the same switch 300, only the first gateway 220 is powered on and configured to enable DHCP. In this case, the first gateway 220 will be treated as the default DHCP master server for the multiple meters 400 connected to the switch 300, and IP addresses will be automatically configured for the corresponding meters 400.

[0045] Optionally, after configuring IP addresses for DHCP-enabled meters connected to each third gateway via DHCP, the process further includes: if, by comparing the IP addresses of the at least one target third gateway with the IP address of the first gateway, it is determined that the IP address of the target third gateway conforms to a second preset rule, then the target third gateway is selected from the at least one target third gateway as the DHCP backup server of the first gateway; DHCP lease information is synchronized to the target third gateway, the DHCP lease information carrying the IP address, MAC address, and meter name of the meter connected to each third gateway; a fourth message is periodically multicast to the target third gateway and received from the periodically multicast fourth message of the target third gateway, the fourth message being used to monitor whether the first gateway or the target third gateway has a fault and carrying corresponding fault information; based on the fourth message, the target third gateway is switched to become the DHCP master server or a new target third gateway is selected to replace the target third gateway as the DHCP backup server of the first gateway.

[0046] In this embodiment, after selecting the first gateway 220 as the DHCP master server among the multiple third gateways belonging to the address pool, a gateway is further selected from the third gateways as the DHCP backup server. The DHCP backup server is a redundant server for the DHCP master server, and can perform redundancy switching when the first gateway 220, which is the DHCP master server, fails, and the target third gateway, which is the DHCP backup server, takes over as the DHCP master server.

[0047] When selecting a target third gateway as the DHCP backup server for the first gateway 220, the IP address of at least one target third gateway responding to the first message is also compared with the IP address of the first gateway 220.

[0048] If the IP address of the target third gateway is determined to conform to the second preset rule through comparison, for example, the principle is to select the next fault-free third gateway whose IP address is closest to that of the first gateway 220, that is, the fault-free third gateway whose IP address is closest to and greater than that of the first gateway 220 (if the IP address of the first gateway 220 is the largest, then the third gateway with the smallest IP address is selected), then the IP address is determined through comparison. Figure 2 If the IP address of one of the seven second gateways 240 matches the second preset rule, then that gateway is selected as the only DHCP backup server among the eight third gateways.

[0049] By selecting the third gateway with the closest IP address that is not faulty as the DHCP backup server for the DHCP master server, the proximity of the IP addresses facilitates redundant switching in case either gateway fails.

[0050] The second preset rule is to preferentially select two third-party gateways with adjacent IP addresses as the DHCP master server and DHCP backup server, for example... Figure 2 As shown, if the first gateway 220 negotiates to become the DHCP master server, then the second gateway 240, which is adjacent to the IP address of the first gateway 220 and is configured in pairs, will be preferentially selected as the DHCP backup server.

[0051] After selecting a DHCP standby server, the first gateway 220, which acts as the DHCP master server, will synchronize DHCP lease information with the target third gateway, which acts as the DHCP standby server. The DHCP lease information carries the IP address, MAC address, and meter name of the meter connected to each third gateway.

[0052] Synchronizing DHCP lease information facilitates the process after the target third gateway, acting as a DHCP backup server, replaces the first gateway 220 as the DHCP master server. The first gateway 220, acting as the DHCP master server, not only synchronizes DHCP lease information with the target third gateway after the initial selection of the DHCP backup server, but also synchronizes it to the DHCP backup server whenever the DHCP lease information is subsequently updated. When a new third gateway is added to the address pool of the first gateway, the DHCP lease information is updated, and the first gateway 220, acting as the DHCP master server, saves the new DHCP lease information and synchronizes it to the target third gateway acting as the DHCP backup server.

[0053] In addition, to promptly detect the presence of the DHCP master or backup server, the first gateway 220, acting as the DHCP master, informs the backup server of its status via periodic multicast. The target third gateway, acting as the backup server, also needs to periodically multicast its own status to the first gateway 220, acting as the master. If no fault is found, they continuously monitor each other. Mutual monitoring can be achieved by periodically multicasting a fourth message to each other. This fourth message carries corresponding fault information. Based on the fault level indicated by the fault information in the received fourth message multicast by the peer gateway, or based on whether the fourth message can be received, it is possible to monitor whether the first gateway 220, acting as the DHCP master, or the target third gateway, acting as the DHCP backup, is faulty.

[0054] Based on the fourth message, the target third gateway currently acting as a DHCP backup server is switched to become the DHCP master server, or a new target third gateway is selected to replace the target third gateway as the DHCP backup server of the first gateway.

[0055] Based on the solution provided in the above embodiments, optionally, switching the target third gateway to become the DHCP master server based on the fourth message includes: if a fault is detected in the first gateway, and the fault information carried in the fourth message periodically multicast by the target third gateway indicates that the target third gateway is not faulty, then a fifth message is sent to the target third gateway, the fifth message being used to indicate that the target third gateway needs to switch to become the DHCP master server and carrying the fault information and IP address of the first gateway; synchronizing the latest DHCP lease information to the target third gateway, the latest DHCP lease information carrying the IP address, MAC address, and meter name of the meter currently connected to each third gateway.

[0056] As mentioned above, the gateway acting as the DHCP master server and the gateway acting as the DHCP backup server synchronize and periodically multicast messages to each other, monitoring each other's fault status. When the primary gateway acting as the DHCP master server is switched over by another third gateway, the switching process primarily considers both active and passive mechanisms.

[0057] The above embodiment corresponds to active switching. Active switching applies when the first gateway 220, acting as the DHCP master server, detects a fault, such as a downlink network failure. In this case, it actively queries the fourth multicast message from the DHCP backup server's gateway to analyze the corresponding fault status. If the fourth message indicates that the DHCP backup server is fault-free, including no serious faults and no downlink network failures, the first gateway 220 actively sends a fifth message to the gateway acting as the DHCP backup server to initiate a DHCP master server switch. The fifth message indicates that the gateway acting as the DHCP backup server needs to switch to become the DHCP master server, and also carries the fault information and IP address of the first gateway 220.

[0058] Then, before the switchover, the first gateway 220 actively synchronizes the DHCP lease information with the gateway acting as the DHCP backup server. That is, it synchronizes the latest DHCP lease information. The latest DHCP lease information carries the IP address, MAC address and meter name of the meter connected to each third gateway, as well as other DHCP lease information that needs to be synchronized, such as the usage period of the IP address allocated to each meter. This period indicates that the corresponding meter needs to change its IP address or renew the lease after it expires.

[0059] Passive failover applies when the target third gateway, acting as a DHCP backup server, continuously monitors the fourth multicast message from the first gateway (acting as the DHCP master server) via timed 220. If the DHCP master server has not performed a multicast for an extended period (defined by a preset timeframe), meaning the DHCP backup server has not received the fourth multicast message from the DHCP master server, the target third gateway, acting as the DHCP backup server, proactively sends a multicast message to the DHCP master server attempting to become the DHCP master server. If the DHCP master server does not respond within the waiting period, the target third gateway, acting as the DHCP backup server, switches itself to become the DHCP master server and uses the most recently synchronized lease information from the original DHCP master server to maintain the address pool.

[0060] In another embodiment, when the first gateway 220, which is acting as the DHCP master server, detects a failure in the DHCP backup server, a new target third gateway needs to be selected to replace the failed target third gateway as the DHCP backup server.

[0061] Specifically, based on the fourth message, selecting a new target third gateway to replace the target third gateway as the DHCP backup server of the first gateway includes: if the fault information carried in the fourth message periodically multicast by the target third gateway indicates that the target third gateway is faulty, then selecting a new target third gateway from the at least one target third gateway and replacing the target third gateway as the DHCP backup server of the first gateway; or if the fourth message multicast by the target third gateway is not received within a second preset time, then selecting a new target third gateway from the at least one target third gateway and replacing the target third gateway as the DHCP backup server of the first gateway.

[0062] As the primary DHCP server, the first gateway 220 can proactively select a new DHCP backup server in two situations and immediately synchronize the lease information with the gateway corresponding to the newly selected DHCP backup server.

[0063] Scenario 1 involves the target third gateway, acting as a DHCP backup server, proactively reporting its own fault status (e.g., uplink and / or downlink network failure) via a multicast fourth message. If the DHCP master server parses the DHCP backup server's multicast fourth message and finds that the fault information indicates a fault in the target third gateway acting as the DHCP backup server, it selects a new target third gateway and replaces the original target third gateway as the DHCP backup server for the first gateway 220.

[0064] Scenario 2 is that if the first gateway 220, which is the DHCP master server, does not receive the fourth message from the target third gateway, which is the backup server, within a certain period of time (which can be defined by the second preset time), then a new target third gateway is selected and the original target third gateway is replaced as the DHCP backup server of the first gateway 220.

[0065] The method for selecting a new target third gateway as the DHCP backup server for the first gateway 220 is as described above. By comparing the IP address of each target third gateway with the IP address of the first gateway, if the IP address of the target third gateway is determined to meet the second preset rule, then the target third gateway is selected as the DHCP backup server for the first gateway.

[0066] In this embodiment of the application, the DHCP backup server does not respond to the first message received by the corresponding gateway multicast within the local area network.

[0067] The above embodiment describes that after the first gateway 220 determines that the DHCP function can be enabled, when it multicasts the first message to each second gateway in the local area network, for a gateway that has been selected as a DHCP backup server and belongs to the same address pool as the first gateway 220 (i.e., the target third gateway), even if it is found to belong to the same address pool as the first gateway 220 after parsing the first message, it will not respond. This is because if a DHCP backup server exists, a DHCP master server naturally already exists, and a gateway that has confirmed itself as a DHCP backup server will not respond to the first gateway 220's request to negotiate to become the DHCP master server.

[0068] In one embodiment, the method further includes: if a sixth message is received from a target second gateway multicast, negotiating that the first gateway will not become a DHCP master server, wherein the target second gateway is a gateway among the second gateways that has the same address pool as the first gateway, and the sixth message is used to respond to the first message and indicate that the target second gateway has become a DHCP master server.

[0069] The above embodiment describes that after the first gateway 220 determines that the DHCP function can be enabled, when it multicasts the first message to each second gateway in the local area network, the gateway that has negotiated to be the DHCP master server and belongs to the same address pool as the first gateway 220 (i.e., the target third gateway) will respond after receiving the first message and parsing it to find that it belongs to the same address pool as the first gateway 220.

[0070] The target third gateway, acting as the DHCP master server, responds to the first message via a multicast sixth message, indicating that it has become the DHCP master server. Thus, upon receiving this first message, the first gateway 220 negotiates not to become the DHCP master server. This is because only one DHCP master server can exist among the third gateways in the same address pool; if a DHCP master server already exists, the first gateway 220, which is applying to become the DHCP master server, will be unable to successfully negotiate.

[0071] In summary, when the first gateway multicasts the first message to all the second gateways within its local area network to negotiate becoming the DHCP master server, the other second gateways, upon receiving the message, parse whether the address pool carried in the first message is the same as their own address pool. If they are the same, they respond accordingly based on the following: 1. If the gateway has become the DHCP master server of this address pool, then the first gateway for responding to the first multicast message is the address pool that already has a DHCP master server. 2. Similarly, the gateway that is negotiating to become the DHCP master server will respond with its own IP address in the first multicast message. The two parties will negotiate to become the gateway of the pool DHCP master server for that address by comparing their IP addresses. 3. The gateway, which has become the DHCP backup server for this address pool, is not responding.

[0072] In this embodiment, after determining that DHCP can be enabled by parsing the gateway configuration information, the first gateway multicasts a first message to each second gateway in the local area network where the first gateway is located. The first message is used to negotiate with each second gateway to become the DHCP master server and carries the gateway's IP address, fault information, and address pool. The first gateway obtains the response results from each second gateway to the first message. If the first gateway is negotiated to become the DHCP master server based on the response results, then IP addresses are configured for the DHCP-enabled meters connected to each third gateway via the DHCP function. The third gateway includes the first gateway and second gateways that share the same address pool as the first gateway. Therefore, by acting as a DHCP master server, the IP addresses of multiple connected DHCP-enabled meters can be automatically allocated. This is convenient and flexible, improving the efficiency of meter configuration, especially in scenarios with a large number of meters.

[0073] Furthermore, after each meter's IP address is automatically configured, the associated information, including the meter's IP address, MAC address, and meter name, is automatically saved and output to the front-end user. This allows the user to distinguish different meters simply by remembering the meter name, making it more convenient and easier to manually distinguish meters than those with fixed IP addresses.

[0074] In addition, by selecting a gateway as a backup server for the DHCP master server, the backup server can take over when the master server fails. The redundancy function of master-slave switching meets the security requirements of the communication network and prevents system failure due to partial failure.

[0075] Optionally, such as Figure 3 As shown in the figure, this application embodiment also provides an instrument configuration device 2000 that supports DHCP function, including a processor 2400 and a memory 2200. The memory 2200 stores a program or instructions that can run on the processor 2400. When the program or instructions are executed by the processor 2400, they implement the various steps of the above-described instrument configuration method embodiment that supports DHCP function and can achieve the same technical effect. To avoid repetition, they will not be described again here.

[0076] This application also provides a readable storage medium storing a program or instructions. When executed by a processor, the program or instructions implement the various processes of any of the above-described embodiments of the instrument configuration method supporting DHCP function, and achieve the same technical effect. To avoid repetition, further details are omitted here. The readable storage medium includes computer-readable storage media, such as read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.

[0077] This application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. The computer program is operable to cause a computer to execute the various processes of any of the above-described embodiments of the meter configuration method supporting DHCP function, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0078] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0079] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0080] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A method for configuring an instrument that supports DHCP functionality, characterized in that, Applied to a first gateway, the method includes: After determining that the DHCP function can be enabled by parsing the gateway configuration information, the first message is multicast to each second gateway in the local area network where the first gateway is located. The first message is used to negotiate with each second gateway to become the DHCP master server and carries the gateway's IP address, fault information and the address pool to which it belongs. Obtain the response results of each second gateway to the first message; If the first gateway is negotiated to become the DHCP master server based on the response result, then the IP address is configured for each DHCP-enabled meter connected to the third gateway through the DHCP function. The third gateway includes the first gateway and the second gateway that belongs to the same address pool as the first gateway.

2. The method according to claim 1, characterized in that, The response result includes the existence of a response to the first message. Based on the response result, negotiate for the first gateway to become the DHCP master server, including: The system receives a second message that responds to the first message multicast from at least one target third gateway. The target third gateway is a second gateway that belongs to the same address pool as the first gateway. The second message carries the IP address, fault information and address pool of the corresponding target third gateway. Parse the second message to obtain the IP address of the at least one target third gateway; If, by comparing the IP address of the at least one target third gateway with the IP address of the first gateway, it is determined that the IP address of the first gateway conforms to the first preset rule, then the first gateway is negotiated to become the DHCP master server.

3. The method according to claim 1, characterized in that, The response result includes the absence of a response to the first message. Based on the response result, negotiate for the first gateway to become the DHCP master server, including: If no response to the first message is received from any second gateway within a first preset time, the first gateway shall negotiate to become the DHCP master server.

4. The method according to claim 2, characterized in that, After configuring IP addresses for each DHCP-enabled meter connected to the third-party gateway via DHCP, the following is also included: If, by comparing the IP address of the at least one target third gateway with the IP address of the first gateway, it is determined that the IP address of the target third gateway conforms to the second preset rule, then the target third gateway is selected from the at least one target third gateway as the DHCP backup server of the first gateway. Synchronize DHCP lease information to the target third gateway, wherein the DHCP lease information carries the IP address, MAC address and instrument name of the instrument connected to each third gateway; The fourth message is periodically multicast to the target third gateway and received from the target third gateway. The fourth message is used to monitor whether the first gateway or the target third gateway has a fault and carries the corresponding fault information. Based on the fourth message, the target third gateway is switched to become the DHCP master server, or a new target third gateway is selected to replace the target third gateway as the DHCP backup server of the first gateway.

5. The method according to claim 4, characterized in that, Based on the fourth message, switching the target third gateway to become the DHCP master server includes: If a fault is detected in the first gateway and the fault information carried in the fourth message of the target third gateway's timed multicast indicates that the target third gateway is not faulty, then a fifth message is sent to the target third gateway. The fifth message is used to indicate that the target third gateway needs to switch to become the DHCP master server and carries the fault information and IP address of the first gateway. The latest DHCP lease information is synchronized to the target third gateway. The latest DHCP lease information carries the IP address, MAC address and instrument name of the instrument currently connected to each third gateway.

6. The method according to claim 4, characterized in that, Based on the fourth message, selecting a new target third gateway to replace the target third gateway as the DHCP backup server for the first gateway includes: If the fault information carried in the fourth message of the timed multicast of the target third gateway indicates that the target third gateway is faulty, then a new target third gateway is selected from the at least one target third gateway and replaces the target third gateway as the DHCP backup server of the first gateway; or If the fourth message multicast by the target third gateway is not received within the second preset time, a new target third gateway is selected from the at least one target third gateway and replaced as the DHCP backup server of the first gateway.

7. The method according to claim 4, characterized in that, The DHCP backup server does not respond to the first multicast message received from the corresponding gateway within the local area network.

8. The method according to claim 1, characterized in that, Also includes: If a sixth message is received from the target third gateway multicast, the first gateway is negotiated not to become the DHCP master server. The target third gateway is the second gateway among the second gateways that has the same address pool as the first gateway. The sixth message is used to respond to the first message and indicate that the target third gateway has become the DHCP master server.

9. An instrument configuration device supporting DHCP function, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the steps of the method as described in any one of claims 1-8.

10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the method as described in any one of claims 1-8.