NTP client configuration method, electronic equipment and storage medium
By populating the SN number of embedded network devices in the DHCP protocol, and using the DHCP server to generate response messages to configure the NTP client, the efficiency and accuracy problems caused by the need for an additional management server in the prior art are solved, and fast and efficient NTP client configuration is achieved.
Patent Information
- Application Number
- CN202411627892.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-03-04
AI Technical Summary
The prior art configuration of NTP clients requires additional deployment of management servers, resulting in lower efficiency, return and accuracy.
By populating the SN number of the NTP client to be configured in the broadcast message, sending it to the DHCP server, causing the DHCP server to generate a response message, and thus configuring the NTP client based on the response message.
It realizes the rapid configuration of the NTP client for deploying embedded network devices in DHCP server, without the need for an additional management system, reduces waiting time and additional expenses, improves efficiency and return, and improves the accuracy of NTP server configuration.
Smart Images

Figure CN119561999A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of embedded network equipment, and in particular to an NTP client configuration method, electronic equipment and storage medium. Background Art
[0002] The time of embedded network devices will return to the initial value after being shut down and powered off. When the device is deployed, it is necessary to configure the NTP client to synchronize the time. Generally, embedded network devices will be configured with a default NTP server address when they leave the factory. However, in some cases, the default NTP server does not meet the configuration requirements and needs to be reconfigured during deployment. If a large number of network devices need to be deployed, the workload of manually modifying the configuration will be very large. At this time, an automated deployment is needed to solve this problem. The currently commonly used method is to open the client program in the network device, such as TR069, SNMP, connect to the server through the client program, and then send the configuration in batches through the server.
[0003] However, this method has the following defects: 1. The premise for these client programs to link to the management server is that DHCP must first allocate an address and connect to the server. Before that, they can only wait. 2. If a management server is deployed solely for configuring the NTP client, additional expenses will be added, and the return on investment will be low. 3. The management server needs a negotiation management process to configure the NTP client through the client program. During this period, the time is not synchronized, causing some programs that are tightly coupled with time to fail. Summary of the invention
[0004] In view of this, it is necessary to provide an NTP client configuration method, an electronic device and a storage medium to solve the technical problem that the existing technology of configuring the NTP client has low efficiency, return rate and accuracy due to the need to deploy an additional management server.
[0005] In order to solve the above problems, the present invention provides an NTP client configuration method, which is applied to an embedded network device, comprising: Fill the SN number of the NTP client to be configured in the broadcast message, and send the broadcast message to the DHCP server, so that the DHCP server generates a response message based on the SN number; Receive a response message fed back by the DHCP server; The NTP client to be configured is configured based on the response message.
[0006] In a possible implementation, the SN number is set in a vendor class field in a broadcast message.
[0007] In a possible implementation manner, the broadcast message includes: a DHCP discover message or a solicitXID message.
[0008] In a possible implementation, configuring the client based on the response message includes: Parse the response message to obtain NTP configuration information; Configure the NTP client based on the NTP configuration information.
[0009] In a possible implementation, the NTP configuration information includes: an NTP server address and a time zone.
[0010] The present invention also provides an NTP client configuration method, which is applied to a DHCP server and includes: Receive broadcast messages sent by embedded network devices; Parsing the broadcast message to obtain an index; Find a matching NTP server configuration based on the index; If the search is successful, the matching NTP server configuration is filled in the response message; If no matching NTP server configuration is found, the default configuration is filled into the response message; Feedback the response message to the embedded network device.
[0011] In a possible implementation, the broadcast message includes: a DHCP discover message or a solicitXID message; The parsing of the broadcast message to obtain an index includes: Find the SN number in the vendor class field of the DHCP discover message or solicit XID message, and use the SN number as the index.
[0012] In a possible implementation, the response message includes: a DHCP offer message or an advertise XID message; Filling the matching NTP server configuration into the response message includes: If the broadcast message is a DHCP discover message, the matching NTP server configuration is filled into the DHCPoffer message; If the broadcast message is a solicit XID message, the matching NTP server configuration is filled into the advertise XID message.
[0013] The present invention also provides an electronic device, comprising: Memory, used to store programs; A processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in the NTP client configuration method described in any one of the above method items.
[0014] The present invention also provides a storage medium for storing a computer-readable program or instruction, wherein the program or instruction, when executed by a processor, can implement the steps in the NTP client configuration method described in any one of the above method items.
[0015] The beneficial effects of the present invention are as follows: the present invention provides an NTP client configuration method, which realizes the embedded network device that is quickly configured and deployed by a DHCP server through linkage between a DHCP protocol and an NTP client, and enables the NTP client to respond quickly without an additional management system, thereby reducing both waiting time and additional expenses, and improving efficiency and rate of return. At the same time, the present invention writes the SN number of the embedded network device into a broadcast message to obtain a response from the DHCP server. Since the SN number is a unique identifier of the embedded network device, the time for the DHCP server to search for a matching NTP server configuration is further reduced, and the accuracy of the search is also improved, thereby effectively solving the technical problem that the prior art configuration of the NTP client requires an additional deployment of a management server, resulting in low efficiency, rate of return and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0017] Figure 1 A schematic diagram of a flow chart of an embodiment of an NTP client configuration method for an embedded network device provided by the present invention; Figure 2 for Figure 1 A schematic diagram of a flow chart of an embodiment of step S103; Figure 3 A schematic diagram of a flow chart of an embodiment of an NTP client configuration method applied to a DHCP server provided by the present invention; Figure 4 A schematic structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0018] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0019] It should be understood that the schematic drawings are not drawn to scale. The flow chart used in the present invention shows the operations implemented according to some embodiments of the present invention. It should be understood that the operations of the flow chart can be implemented out of order, and the steps without logical context can be reversed or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flow chart under the guidance of the content of the present invention, and can also remove one or more operations from the flow chart.
[0020] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0021] like Figure 1 The present invention provides an NTP client configuration method, which is applied to an embedded network device, comprising: S101, filling the SN number of the NTP client to be configured in the broadcast message, and sending the broadcast message to the DHCP server, so that the DHCP server generates a response message based on the SN number; In a possible implementation, the SN number is set in a vendor class field in a broadcast message.
[0022] In a possible implementation manner, the broadcast message includes: a DHCP discover message or a solicit XID message.
[0023] S102, receiving a response message fed back by the DHCP server; S103: Configure the NTP client to be configured based on the response message.
[0024] Compared with the prior art, the present invention provides an NTP client configuration method, which realizes the embedded network device that is quickly configured and deployed by the DHCP server through the linkage of the DHCP protocol and the NTP client, and can make the NTP client respond quickly without an additional management system, thereby reducing both waiting time and additional expenses, and improving efficiency and return rate. At the same time, the present invention writes the SN number of the embedded network device into the broadcast message to obtain the response of the DHCP server. Since the SN number is the unique identifier of the embedded network device, the time for the DHCP server to search for the matching NTP server configuration is further reduced, and the accuracy of the search is also improved, which effectively solves the technical problem that the prior art configuration of the NTP client has low efficiency, return rate and accuracy due to the need to deploy an additional management server.
[0025] like Figure 2 In a possible implementation, step S103 includes: S201, parsing the response message to obtain NTP configuration information; S202: Configure the NTP client based on the NTP configuration information.
[0026] In a possible implementation manner, the NTP configuration information includes: an NTP server address and a time zone.
[0027] like Figure 3 The present invention also provides an NTP client configuration method, which is applied to a DHCP server and includes: S301, receiving a broadcast message sent by an embedded network device; S302, parsing the broadcast message to obtain an index; In a possible implementation, the broadcast message includes: a DHCP discover message or a solicit XID message; Step S302 includes: searching for the SN number in the vendor class field of the DHCP discover message or solicit XID message, using the SN number as an index.
[0028] S303, searching for a matching NTP server configuration based on the index; S304: If the search is successful, the matching NTP server configuration is filled into the response message; In a possible implementation, the response message includes: a DHCP offer message or an advertise XID message; Further, step S304 includes: If the broadcast message is a DHCP discover message, the matching NTP server configuration is filled into the DHCP offer message; If the broadcast message is a solicit XID message, the matching NTP server configuration is filled in the advertiseXID message.
[0029] S305: If no matching NTP server configuration is found, fill the preset default configuration into the response message; S306: Feedback the response message to the embedded network device.
[0030] It can be understood that the starting point of the present invention is that by linking the DHCP protocol and the NTP client and by modifying and expanding the DHCP server function, the NTP client configuration can be easily modified without adding network devices, thereby enabling embedded network devices to achieve fast time synchronization.
[0031] Furthermore, the specific method of the present invention is: modifying the DHCP protocol so that the DHCP server issues new NTP server related configurations while allocating IPs, and the DHCP client immediately configures the NTP client while obtaining the IP, so that the NTP client can immediately synchronize time with the NTP server.
[0032] Specifically, the present invention completes the configuration of the NTP client by transforming the DHCPv4 protocol or the DHCPv6 protocol.
[0033] The implementation method of the DHCPv4 protocol is as follows: After receiving the DHCP discover broadcast message from the network device, the DHCP server will search for the matching NTP server configuration based on the reported SN number (unique identifier of the embedded device) in the vendorclass field in the DHCP offer message in addition to the normal allocation of the IP address. According to the configuration found, fill in the client configuration information, including the NTP server address (domain name or IP address), time zone and other configurations. If no corresponding configuration is found, fill in the default configuration. After the embedded network device receives the response message of the DHCP offer, it configures the NTP client according to the NTP-related configuration information provided by the server to synchronize the system time.
[0034] The specific implementation method of DHCPv6 protocol is as follows: First, after the embedded network device is powered on, it will actively send a solicit XID multicast message to seek address allocation. After receiving the solicit XID multicast message from the network device, the DHCP server will index and search for matching NTP server configurations based on the reported SN number (embedded device unique identifier) in the vendor class field in the message in addition to the normal allocation of IP addresses in the advertise XID message. According to the configuration found, fill in the client configuration information, including NTP server address (domain name or IP address), time zone and other configurations. If no corresponding configuration is found, fill in the default configuration. Finally, after the embedded network device receives the advertise XID response message, it configures the NTP client according to the NTP-related configuration information provided by the server to synchronize the system time.
[0035] like Figure 4 The present invention further provides an electronic device 40, comprising: A memory 410, used for storing programs; The processor 420 is coupled to the memory, and is used to execute the program stored in the memory to implement the steps in the NTP client configuration method described in any one of the above method items.
[0036] The present invention also provides a storage medium for storing a computer-readable program or instruction, wherein the program or instruction, when executed by a processor, can implement the steps in the NTP client configuration method described in any one of the above method items.
[0037] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the computer program can be stored in a computer storage medium, wherein the computer storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0038] The above are only preferred specific implementations of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A NTP client configuration method, applied to an embedded network device, characterized in that: include; Fill the SN number of the NTP client to be configured in the broadcast message, and send the broadcast message to the DHCP server, so that the DHCP server generates a response message based on the SN number; Receive a response message fed back by the DHCP server; The NTP client to be configured is configured based on the response message.
2. The NTP client configuration method according to claim 1, characterized in that: The SN number is set in the vendor class field in the broadcast message.
3. The NTP client configuration method according to claim 1, characterized in that: The broadcast message includes: a DHCPdiscover message or a solicit XID message.
4. The NTP client configuration method according to claim 1, characterized in that: The configuring the client based on the response message includes: Parse the response message to obtain NTP configuration information; Configure the NTP client based on the NTP configuration information.
5. The NTP client configuration method according to claim 4, characterized in that: The NTP configuration information includes: NTP server address and time zone.
6. A NTP client configuration method, applied to a DHCP server, characterized in that: include: Receive broadcast messages sent by embedded network devices; Parsing the broadcast message to obtain an index; Find a matching NTP server configuration based on the index; If the search is successful, the matching NTP server configuration is filled in the response message; If no matching NTP server configuration is found, the default configuration is filled into the response message; Feedback the response message to the embedded network device.
7. The NTP client configuration method according to claim 6, characterized in that: The broadcast message includes: a DHCPdiscover message or a solicit XID message; The parsing of the broadcast message to obtain an index includes: Find the SN number in the vendor class field of the DHCP discover message or solicit XID message, and use the SN number as the index.
8. The NTP client configuration method according to claim 6, characterized in that: The response message includes: a DHCPoffer message or an advertise XID message; Filling the matching NTP server configuration into the response message includes: If the broadcast message is a DHCP discover message, the matching NTP server configuration is filled into the DHCP offer message; If the broadcast message is a solicit XID message, the matching NTP server configuration is filled into the advertiseXID message.
9. An electronic device, characterized in that: include: Memory, used to store programs; A processor, coupled to the memory, is used to execute the program stored in the memory to implement the steps in the NTP client configuration method described in any one of claims 1 to 8.
10. A storage medium, characterized in that: Used to store computer-readable programs or instructions, which, when executed by a processor, can implement the steps in the NTP client configuration method described in any one of claims 1 to 8 above.