Protocol updating method, apparatus, device, and storage medium
By using TLV data format and hash table locking/unlocking mechanism, the problem of needing to restart the device to update the protocol stack is solved, realizing dynamic updates and secure switching of protocol files, improving update efficiency and user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING TOPSEC NETWORK SECURITY TECH
- Filing Date
- 2022-12-29
- Publication Date
- 2026-04-21
AI Technical Summary
In existing technologies, updating the protocol stack requires restarting the software or device, which makes updating difficult in products that handle business operations, affecting user experience and efficiency.
The protocol configuration is stored using TLV data format and a hash table. Dynamic updates of the protocol file are achieved by monitoring threads and using mutex locks. The protocol frame format update and parsing processes are separated, and the locking and unlocking mechanism of the hash table is used to ensure safe switching.
It enables dynamic updates of the protocol stack without affecting product operations, improving update efficiency and user experience, avoiding device restarts, and enhancing the security and applicability of protocol processing.
Smart Images

Figure CN116320047B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of network security technology, and more specifically, to a protocol update method, apparatus, device, and storage medium. Background Technology
[0002] A protocol stack refers to the sum of all layers of protocols in a network, vividly reflecting the process of file transfer within a network: from upper-layer protocols to lower-layer protocols, and then from lower-layer protocols to upper-layer protocols. Protocols define how to communicate with other systems, describing the timing of signals and the structure of communication data. Lower layers of the protocol stack define the rules that manufacturers can follow to enable their devices to interconnect with devices from other manufacturers; higher layers define how to manage different types of communication sessions and how user applications can interoperate. In the past decade or so, network security technology has evolved rapidly, giving rise to various protocol stacks. The flexibility and diversity of protocols have increased the efficiency of protocol stack maintenance and updates.
[0003] Currently, most methods for updating the protocol stack require restarting the software or device. If a product is currently processing business logic, updating the protocol may not be permitted by users, thus increasing the difficulty of protocol stack maintenance. Therefore, finding a way to update and maintain the protocol without affecting the product's current business logic is particularly important. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a protocol update method, apparatus, device, and storage medium. By configuring a simple protocol with TLV (Type-length-value) data format as the frame format of the protocol file, a hash table is created to store the protocol file content in the frame format. By locking and unlocking the hash table, a dynamically configurable protocol update is achieved. This enables the update and maintenance of the protocol stack without affecting product business, thereby solving the aforementioned technical problem of "how to update and maintain the protocol without affecting the current business of the product".
[0005] In a first aspect, embodiments of this application provide a protocol update method, the method comprising: obtaining the content of a protocol file and storing it in a hash table; wherein the hash table comprises: a monitoring table and a query table, the query table being used to store the protocol file in a protocol frame format, and the monitoring table being used to store updated protocol files; creating a monitoring thread to monitor whether the protocol file is updated; if it is determined that the protocol file is updated, swapping the monitoring table and the query table in an encrypted / unlocked manner to obtain an updated query table; and parsing the content of the updated query table to obtain the updated protocol file.
[0006] In the above implementation process, by using two hash tables to store the protocol file in frame format, creating a monitoring thread to monitor updates, and locking and unlocking the hash tables when updates occur, dynamic configurable protocol updates are achieved. This ensures the security of switching between the query table and the monitoring table, and enables the updating and maintenance of the protocol stack without affecting product business. It also separates the protocol frame format update from the protocol parsing process, improves protocol processing efficiency, and enhances user experience.
[0007] Optionally, obtaining the content of the protocol file and storing it in a hash table includes: obtaining the content of the protocol file and creating a monitoring table and a query table; initializing the query table to store the content of the protocol file in protocol frame format; and creating a mutex lock for the monitoring table and the query table to swap the lock and unlock locks when an update is detected.
[0008] In the above implementation process, by creating monitoring table and query table storage protocol files, initialization is made convenient for subsequent updates. Mutex lock flags are set for query table and monitoring table to avoid hash collisions when query table and monitoring table are swapped. The locking and unlocking of mutex locks ensures the security of switching between query table and monitoring table, thereby realizing the function of updating the protocol parsing process without restarting the device, improving the protocol update efficiency and practicality.
[0009] Optionally, the step of swapping the monitoring table and the query table in an unlocked manner if it is determined that the protocol file has been updated to obtain an updated query table includes: if it is determined that the protocol file has been updated, obtaining the entire content of the latest protocol file and storing it in the monitoring table to obtain an updated monitoring table; locking the mutex lock; swapping the updated monitoring table and the query table to obtain an updated query table; and unlocking the mutex lock.
[0010] In the above implementation process, by monitoring updates in the monitoring thread, when an update is found, the query table and the monitoring table are swapped after the monitoring table is updated. Locks are applied before the swap and unlocked after the swap is completed, thus avoiding hash collisions when the query table and the monitoring table are swapped. The locking and unlocking of mutex locks ensures the security of switching between the query table and the monitoring table, thereby realizing the function of updating the protocol parsing process without restarting the device, improving the efficiency and practicality of the protocol update.
[0011] Optionally, the step of creating a monitoring thread to monitor whether the protocol file has been updated includes: creating a monitoring thread to periodically scan the protocol file; and determining whether the protocol file has been updated based on whether the final modification time of the protocol file has changed.
[0012] In the above implementation process, by providing monitoring functions in the form of an interface, a thread is created and started during system initialization, and the modification time of the protocol file is used to determine whether there is an update, thus realizing unified management of the protocol file and improving the processing efficiency of protocol updates.
[0013] Optionally, parsing the contents of the update query table to obtain the updated protocol file includes: querying and obtaining the update query table based on the protocol name; and parsing the update query table to obtain the updated protocol file.
[0014] In the above implementation process, by querying the lookup table based on the protocol name, the data plane parses the protocol data in a new way, realizing the instant acquisition of protocol file updates, improving the processing efficiency of protocol updates, and enhancing the user experience.
[0015] Optionally, the protocol file includes at least one protocol frame format file from among XML files, JSON files, and custom files.
[0016] In the above implementation process, multiple protocol frame format files such as XML files, JSON files, and custom files can be updated, realizing unified management of multiple protocol frame format protocols and improving the applicability of the update method.
[0017] Optionally, the protocol type of the protocol file includes any one of the following transport protocols: Address Resolution Protocol, Internet Control Message Protocol, Routing Information Protocol, RIPNG Protocol, and SKINNY Protocol.
[0018] In the above implementation process, files of various protocol types such as Address Resolution Protocol, Internet Control Message Protocol, Routing Information Protocol, RIPNG Protocol, and Skinny Protocol can be updated, realizing unified management of simple protocols and improving the applicability of the update method.
[0019] Secondly, embodiments of this application provide a protocol update apparatus, the apparatus comprising: an initialization storage module, configured to acquire the content of a protocol file and store it in a hash table; wherein the hash table includes: a monitoring table and a query table, the query table being used to store the protocol file in a protocol frame format, and the monitoring table being used to store updated protocol files; a monitoring module, configured to create a monitoring thread to monitor whether the protocol file is updated; an update query table module, configured to, if it is determined that the protocol file is updated, swap the monitoring table and the query table in an encrypted / unlocked manner to obtain an update query table; and an update protocol module, configured to parse the content of the update query table to obtain the updated protocol file.
[0020] Thirdly, embodiments of this application also provide an electronic device, including: a processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the above-described method.
[0021] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the above-described method.
[0022] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, specific embodiments are described below in conjunction with the accompanying drawings. Attached Figure Description
[0023] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0024] Figure 1 A flowchart illustrating a protocol update method provided in this application embodiment;
[0025] Figure 2 Example diagram of a protocol update method provided in an embodiment of this application;
[0026] Figure 3 This is a schematic diagram of the functional modules of a protocol update device provided in an embodiment of this application;
[0027] Figure 4 This is a block diagram of an electronic device that provides a protocol update apparatus according to an embodiment of this application.
[0028] Icons: 210 - Initialization storage module; 220 - Monitoring module; 230 - Update lookup table module; 240 - Update protocol module; 300 - Electronic device; 311 - Memory; 312 - Storage controller; 313 - Processor; 314 - Peripheral interface; 315 - Input / output unit; 316 - Display unit. Detailed Implementation
[0029] 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 a part of the embodiments of this application, and not all of the embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely represents selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0030] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. 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 said element. The terms "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0031] Before introducing the embodiments of this application, the technical concepts involved in this application will be briefly introduced first.
[0032] Protocol stack: Also known as a protocol layer, it is the sum of all protocols in a computer network. It represents the sum of protocols at each layer in a network, visually reflecting the process of file transfer within a network, from upper-layer protocols to lower-layer protocols, and then from lower-layer protocols to upper-layer protocols. A protocol is a standard, a convention; the protocol stack is the implementation of the protocols, which can be understood as code, function libraries, and calls from upper-layer applications. Specifically, protocols define how to communicate with other systems, describing the timing of signals and the structure of communication data. Lower layers of the protocol stack define the rules that manufacturers can follow to enable their devices to interconnect with devices from other manufacturers; higher layers define how to manage different types of communication sessions and how user applications can interoperate. Protocol stacks are mainly divided into the following types: (1) OSI protocol stack: defined by the International Organization for Standardization to promote worldwide interoperability, it is usually used as a standard for comparison with other protocol stacks; (2) TCP / IP protocol suite: Transmission Control Protocol / Internet Protocol (TCP / IP) is one of the earliest network protocol stacks. The IP part provides a best definition of the Internet connection and is used by many manufacturers in local area or wide area interconnection products; (3) ZigBee protocol stack: built on the IEEE 802.15.4 standard, it defines the MAC and PHY layers of the protocol. ZigBee devices should include the IEEE 802.15.4 PHY and MAC layers, as well as the ZigBee stack layers: network layer, application layer and security service provider layer.
[0033] Hash Table: Also known as a hash table, it is a data structure that allows direct access based on key and value. That is, it calculates the corresponding value using a key and a mapping function Hash(key), and then maps the key-value pair to a location in the table to access the record, thus speeding up the search. This mapping function is called a hash function, and the array used to store the records is called a hash table. The key idea of a hash table is to use a hash function to map the key and value to a specific block in the table. The algorithm can be divided into two parts: (1) Inserting a key into the hash table: The hash function determines which block in the table the corresponding value should be stored in, and stores the corresponding value in that block; (2) Searching for a key in the hash table: Using the same hash function, the corresponding block is searched in the hash table, and the value corresponding to the key is searched in that specific block.
[0034] Mutexes: In programming, the concept of object mutexes is introduced to ensure the integrity of shared data operations. Each object corresponds to a marker called a "mutex," which ensures that only one thread can access the object at any given time. 1. Mutex Creation and Destruction. There are two methods to create mutexes: static and dynamic. Static mutexes are initialized using the POSIX macro `PTHREAD_MUTEX_INITIALIZER`, while dynamic mutexes are initialized using the `pthread_mutex_init()` function. 2. Mutex Attributes. Mutex attributes are specified when the lock is created. In the LinuxThreads implementation, there is only one lock type attribute. Different lock types behave differently when attempting to acquire an already locked mutex. Once a thread acquires the lock, other threads requesting the lock form a waiting queue and acquire the lock according to priority after unlocking. This locking strategy ensures fairness in resource allocation. 3. Mutex Operations. Lock operations mainly include three parts: locking, unlocking, and test locking. Regardless of the lock type, it is impossible for two different threads to acquire it simultaneously; they must wait for it to be unlocked. For ordinary locks and adaptive locks, the unlocker can be any thread within the same process; however, error-checking locks are only valid if the lock-acquirer unlocks them, otherwise an EPERM is returned. For nested locks, the documentation and implementation require that the lock-acquirer must unlock them, but experimental results show that this restriction does not exist, and this difference remains unexplained. Within the same process, if a thread acquires a lock and does not unlock it, no other thread can acquire the lock.
[0035] The inventors of this application have noted that protocols define the methods of communication with other systems, describing the timing of signals and the structure of communication data. Lower layers of the protocol stack define the rules that manufacturers can follow to enable their devices to interconnect with devices from other manufacturers; higher layers define how to manage different types of communication sessions and how user applications can interoperate. In the past decade or so, network security technology has evolved rapidly, giving rise to various protocol stacks. The flexibility and diversity of protocols have increased the efficiency of protocol stack maintenance and updates. Currently, most methods for updating protocol stacks require restarting the software or device. If a protocol update is performed on a product currently processing business, it may not be permitted by the user, thus increasing the difficulty of protocol stack maintenance. Therefore, how to update and maintain protocols without affecting the current business operations of the product is particularly important. In view of this, this application provides a protocol update method as described below.
[0036] Please see Figure 1 , Figure 1This is a flowchart illustrating a protocol update method provided in an embodiment of this application. The embodiment of this application will be explained in detail below. The method includes steps 100, 120, 140, and 160.
[0037] Step 100: Obtain the content of the protocol file and store it in a hash table; wherein, the hash table includes a monitoring table and a query table, the query table is used to store the protocol file in protocol frame format, and the monitoring table is used to store updated protocol files;
[0038] Step 120: Create a monitoring thread to monitor whether the protocol file has been updated;
[0039] Step 140: If it is determined that the protocol file has been updated, the monitoring table and the query table are swapped by locking and unlocking to obtain the updated query table;
[0040] Step 160: Parse the contents of the update query table to obtain the updated protocol file.
[0041] For example, the protocol file can be any simple protocol compiled according to the TLV(type, length, value) protocol format in the protocol stack, which can express the protocol frame format in the form of a file, such as an XML (Extensible Markup Language) file; where, in the TLV format data packet, the type indicates the meaning of the current packet, and the type is the type of a single packet or a nested packet; the length indicates the size of the current packet, and note that this size includes the total length occupied by the type, length, and value; the value includes the actual content of the data packet, and if it is a nested packet, the content is the sum of the contents of all the sub-packets. The monitoring table and query table can be two hash tables with completely identical data structures, both used to store the content of the protocol file. They play different roles during the protocol update process. The former only stores data briefly when an update occurs, while the latter can store the protocol file before or after the update for long-term access by users. The storage method can be: calculating the corresponding value using a key and a mapping function Hash(key), then converting the protocol frame format into corresponding key-value pairs and mapping them to a location in the table to access the protocol file content. This mapping function is called a hash function, and the array used to store the protocol file content is called a hash table. The lock / unlock mechanism can be used when swapping the monitoring table and query table. It's not simply locking and unlocking a single table. When an update to the protocol file is detected, the monitoring table and query table are swapped. Locking and unlocking are performed during this swapping process. After the monitoring table update is complete, the swap is performed again, at which point the lock is applied, and the table is unlocked upon completion of the swap.
[0042] like Figure 2 As shown, the protocol file uses an XML file as an example to introduce the embodiment of this application. The figure can be roughly divided into three steps: (1) system initialization; (2) monitoring the XML file; (3) protocol data parsing. Specifically, it can be: first, read the content of the XML file, perform a hash mapping with the protocol name, store the protocol frame format in the query table, and provide the query table for data surface query to parse the protocol; then, initialize the monitoring table space for backup during updates; finally, start the monitoring thread to monitor the XML file; in the monitoring thread, monitor whether the XML protocol file in the specified directory is updated. If there is an update, swap the monitoring table and the query table in a lock-and-unlock manner. This process of swapping the two tables is lock-and-unlocked. After the monitoring table is updated, the swap will be performed. At this time, the lock is applied, and the lock is unlocked after the swap is completed; perform protocol parsing on the finally updated table content to obtain the updated XML file content.
[0043] Optionally, upon system startup, the management plane initializes the hash table and mutex lock and starts the monitoring thread, while the data plane queries the lookup table to parse the protocol; the web uploads the protocol stack configuration update and uploads the XML file to the firewall device; the uploaded XML file is used to overwrite the original XML file; the underlying monitoring thread implements the update and maintenance of the protocol stack; the web displays a message indicating that the update is complete; and the data plane parses the protocol data according to the new method.
[0044] The XML file stores the protocol frame format in file format. When the XML file is updated, the monitoring table content is updated. Mutex locks are used to ensure the security of switching between the query table and the monitoring table, achieving the function of updating the protocol parsing process without restarting the device. Simultaneously, it separates the protocol frame format update from the protocol parsing process; the monitoring table is responsible for monitoring updates, while the query table is provided for use by the protocol stack without blocking the protocol processing.
[0045] By using two hash tables to store the protocol file in frame format, a monitoring thread is created to monitor updates. When an update occurs, the hash tables are locked and unlocked to achieve dynamically configurable protocol updates. This ensures the security of switching between the query table and the monitoring table, and enables the protocol stack to be updated and maintained without affecting product business. It separates the protocol frame format update from the protocol parsing process, improves protocol processing efficiency, and enhances the user experience.
[0046] In one embodiment, step 100 may include steps 101, 102, and 103.
[0047] Step 101: Obtain the contents of the protocol file and create a monitoring table and a query table;
[0048] Step 102: Initialize the lookup table to store the contents of the protocol file in protocol frame format;
[0049] Step 103: Create a mutex lock for the monitoring table and the query table to swap the lock and unlock when an update is detected.
[0050] For example, creating a mutex lock can be done by adding a mutex lock flag to two hash tables, such as a monitoring table and a query table, that have completely identical data structures. This flag ensures that at any given time, only one thread can access the table object with the flag set. Within the same process, if a thread acquires the lock and does not unlock it, no other thread can acquire the lock. After creating the two hash tables, the mutex lock can be statically initialized using the POSIX-defined macro `PTHREAD_MUTEX_INITIALIZER`. For example: `pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER`, where `pthread_mutex_t` is a structure, and `PTHREAD_MUTEX_INITIALIZER` is a structure constant.
[0051] like Figure 2 As shown, during system initialization, the created monitoring table and query table need to be initialized first. Initialization mainly involves initializing the query table by reading the protocol frame format into memory, and then initializing the monitoring table space for later use. Next, mutex lock flags are set for both the query table and the monitoring table. The mutex locks are initialized to avoid conflicts when replacing the hash table. Finally, the monitoring thread is started to monitor the XML file.
[0052] By creating monitoring and query table storage protocol files, initialization facilitates subsequent updates. Mutex lock flags are set for the query and monitoring tables to avoid hash collisions when they are swapped. The locking and unlocking of the mutex locks ensures the security of switching between the query and monitoring tables, thus enabling the update of the protocol parsing process without restarting the device, improving the efficiency and practicality of the protocol update.
[0053] In one embodiment, step 140 may include steps 141, 142, 143, and 144.
[0054] Step 141: If it is determined that the protocol file has been updated, then obtain the full content of the latest protocol file and store it in the monitoring table to obtain the update monitoring table;
[0055] Step 142: Lock the mutex;
[0056] Step 143: Swap the update monitoring table and the query table to obtain the update query table;
[0057] Step 144: Unlock the mutex.
[0058] For example, locking a mutex can be implemented using the `pthread_mutex_lock()` lock operation command, such as `int pthread_mutex_lock(pthread_mutex_t*mutex)`. Unlocking a mutex can be implemented using the `pthread_mutex_unlock()` lock operation command, such as `int pthread_mutex_unlock(pthread_mutex_t*mutex)`. Regardless of the type of mutex, it is impossible for two different threads to acquire it simultaneously; they must wait for it to be unlocked. Within the same process, if a thread acquires a mutex but does not unlock it, no other thread can acquire the lock.
[0059] like Figure 2 As shown, when the monitoring process starts, it monitors the XML files in the specified directory to see if they have been updated. If not, monitoring continues; if updated, it reads the entire content of the XML file to update the monitoring table; it locks the mutexes of the monitoring table and the query table; it replaces the monitoring table and the query table, at which point their functions are swapped (the replacement is not a content replacement, but a direct swap); it unlocks the mutexes of the monitoring table and the query table; and it returns the results to the monitoring thread. The locking and unlocking processes are used only when the monitoring table and the query table are swapped, and they are not limited to locking and unlocking a single hash table. Essentially, it locks and unlocks the entire process of swapping two hash tables. After the monitoring table update is complete, the swap will occur, at which point the lock is applied, and it is unlocked upon completion of the swap.
[0060] By monitoring updates in the monitoring thread, when an update is available, the query table and the monitoring table are swapped after the monitoring table update is completed. Locks are applied before the swap and unlocked after the swap is completed, avoiding hash collisions when the query table and the monitoring table are swapped. The locking and unlocking of mutex locks ensures the security of switching between the query table and the monitoring table, thereby realizing the function of updating the protocol parsing process without restarting the device, improving the efficiency and practicality of the protocol update.
[0061] In one embodiment, step 120 may include steps 121 and 122.
[0062] Step 121: Create a monitoring thread for periodic scanning of the protocol file;
[0063] Step 122: Determine whether the protocol file has been updated based on whether the final modification time of the protocol file has changed.
[0064] For example, there are four common ways to create a monitoring thread: inheriting the Thread class, implementing the Runnable interface, using Callable and Future, and using a thread pool (using the java.util.concurrent.Executor interface). For instance, using the Callable interface and Future to create a monitoring thread involves the following steps: creating an implementation class of the Callable interface and implementing the call() method; then creating an instance of this implementation class (starting from Java 8, a Callable object can be created directly using a lambda expression); wrapping the Callable object with the FutureTask class, which encapsulates the return value of the Callable object's call() method; using the FutureTask object as the target of the Thread object to create and start the thread (because FutureTask implements the Runnable interface); and calling the get() method of the FutureTask object to obtain the return value after the child thread finishes execution.
[0065] like Figure 2 As shown, the monitoring function can be provided through the aforementioned interface. A thread is created and started during system initialization, scanning the XML file at regular intervals to check for changes. Whether the XML file has been changed or not is determined by the last modification time of the XML file under the Linux system; any change in the modification time is considered a change. The monitoring thread uses the last modification time of the XML file as its basis.
[0066] By providing monitoring functionality through an interface, a thread is created and started during system initialization. The thread determines whether an update exists based on the modification time of the protocol file, thereby achieving unified management of the protocol file and improving the efficiency of protocol update processing.
[0067] In one embodiment, step 160 may include steps 161 and 162.
[0068] Step 161: Query and obtain the update query table based on the protocol name;
[0069] Step 162: Perform protocol parsing on the update query table to obtain the updated protocol file.
[0070] For example, updating the query table can be achieved by swapping the updated monitoring table and the query table. The resulting query table is the one with updated content. Since the query table and the monitoring table have identical structures (both are hash mapping tables), the protocol frame and content can be retrieved by the protocol name. Figure 2As shown, the data plane identifies the protocol by querying and updating the lookup table using the protocol name to obtain the corresponding protocol's frame format. This allows for the identification of data packet frame formats and the corresponding protocol type based on the data packet frame format characteristics. Once the protocol type corresponding to the data packet frame format is determined, protocol parsing can be performed on the data packet based on the protocol type, and then the protocol content can be parsed for data output.
[0071] By querying the table based on the protocol name, the data plane parses the protocol data in a new way, enabling real-time acquisition of protocol file updates, improving the processing efficiency of protocol updates, and enhancing the user experience.
[0072] In one embodiment, the protocol file includes at least one protocol frame format file from among XML files, JSON files, and custom files.
[0073] For example, the protocol file can be, in addition to being, Figure 2 The XML file, JSON file, and custom files can all be used to express the protocol frame format in file form. Custom files can have each section header consisting of square brackets containing the type and parameters. The four section types are represented by the text characters "connect," "sql," "userlist," or "logs," and the parameters are text strings, default values, user-specified identifiers, or no content. The protocol frame format can be understood as follows: when sending data, each layer encapsulates its own header for a data frame, while the header of the upper layer is removed when receiving data. For example, the Ethernet frame format includes four parts: destination address, source address, type, and data. The IP data frame format can contain a fixed 20-byte IP header and data fields that can be divided into TCP packets, UDP packets, ICMP packets, etc. This method can update various protocol frame format files, including XML, JSON, and custom files, achieving unified management of multiple protocol frame formats and improving the applicability of the update method.
[0074] In one embodiment, the protocol type of the protocol file includes any one of the following transport protocols: Address Resolution Protocol, Internet Control Message Protocol, Routing Information Protocol, RIPNG Protocol, and Skinny Protocol.
[0075] For example, the protocol file type can be any simple protocol compiled according to the TLV(type, length, value) protocol format in the protocol stack. In the TLV format, the type (type) indicates the meaning of the current packet; it can be a single packet or a nested packet. The length indicates the size of the current packet, including the total length occupied by the type, length, and value. The value includes the actual content of the packet; if it is a nested packet, the content is the sum of all its sub-packets. Simple protocols can be: ARP (Forward Address Resolution Protocol), ICMP (Internet Control Message Protocol), RIPNG (RIP protocol compatibility issues with IPv6 have led to improvements in the RIP protocol, resulting in the IPv6-based RIPng (RIP next generation) standard protocol), RIP (Routing Information Protocol), and SKINNY (Thin Call Control Protocol). Files of various protocol types, such as Address Resolution Protocol, Internet Control Message Protocol, Routing Information Protocol, RIPNG, and SKINNY, can be updated, achieving unified management of simple protocols and improving the applicability of this update method.
[0076] Please see Figure 3 , Figure 3 This is a schematic diagram of the module functions of a protocol update device provided in an embodiment of this application. The device includes: an initialization storage module 210, a monitoring module 220, an update query table module 230, and an update protocol module 240.
[0077] The storage module 210 is initialized to obtain the contents of the protocol file and store them in a hash table. The hash table includes a monitoring table and a query table. The query table is used to store the protocol file in protocol frame format, and the monitoring table is used to store updated protocol files.
[0078] Monitoring module 220 is used to create monitoring threads to monitor whether the protocol file has been updated;
[0079] The update query table module 230 is used to swap the monitoring table and the query table in an encrypted / unlocked manner if it is determined that the protocol file has been updated, so as to obtain the updated query table.
[0080] The update protocol module 240 is used to parse the contents of the update query table to obtain the updated protocol file.
[0081] Optionally, the initialization storage module 210 can be used for:
[0082] Obtain the contents of the protocol file and create monitoring and query tables;
[0083] The lookup table is initialized to store the contents of the protocol file in protocol frame format;
[0084] Create a mutex lock for the monitoring table and the query table so that when an update is detected, the lock and unlock locks are swapped.
[0085] Optionally, the update query table module 230 can be used for:
[0086] If it is determined that the protocol file has been updated, then the entire content of the latest protocol file is obtained and stored in the monitoring table to obtain the update monitoring table;
[0087] Lock the mutex lock;
[0088] The update monitoring table and the query table are swapped to obtain the update query table;
[0089] Unlock the mutex.
[0090] Optionally, the monitoring module 220 can be used for:
[0091] Create a monitoring thread to periodically scan the protocol file;
[0092] Based on whether the final modification time of the protocol file has changed, it is determined whether the protocol file has been updated.
[0093] Optionally, the update protocol module 240 can be used for:
[0094] The update query table is retrieved based on the protocol name.
[0095] The update query table is parsed to obtain the updated protocol file.
[0096] Optionally, the protocol file includes at least one protocol frame format file from among XML files, JSON files, and custom files.
[0097] Optionally, the protocol type of the protocol file includes any one of the following transport protocols: Address Resolution Protocol, Internet Control Message Protocol, Routing Information Protocol, RIPNG Protocol, and SKINNY Protocol.
[0098] Please see Figure 4 , Figure 4 This is a block diagram of an electronic device. The electronic device 300 may include a memory 311, a memory controller 312, a processor 313, a peripheral interface 314, an input / output unit 315, and a display unit 316. Those skilled in the art will understand that... Figure 4The structure shown is for illustrative purposes only and does not limit the structure of the electronic device 300. For example, the electronic device 300 may also include components that are more... Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown.
[0099] The aforementioned memory 311, memory controller 312, processor 313, peripheral interface 314, input / output unit 315, and display unit 316 are electrically connected directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines. The aforementioned processor 313 is used to execute executable modules stored in the memory.
[0100] The memory 311 can be, but is not limited to, Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), etc. The memory 311 stores programs, and the processor 313 executes these programs upon receiving execution instructions. The methods executed by the electronic device 300, as defined in any embodiment of this application, can be applied to or implemented by the processor 313.
[0101] The aforementioned processor 313 may be an integrated circuit chip with signal processing capabilities. The processor 313 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a digital signal processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor.
[0102] The peripheral interface 314 described above couples various input / output devices to the processor 313 and the memory 311. In some embodiments, the peripheral interface 314, the processor 313, and the memory controller 312 can be implemented in a single chip. In other instances, they can be implemented by separate chips.
[0103] The input / output unit 315 described above is used to provide user input data. The input / output unit 315 may be, but is not limited to, a mouse and keyboard.
[0104] The aforementioned display unit 316 provides an interactive interface (e.g., a user interface) for the user to reference between the electronic device 300 and the user. In this embodiment, the display unit 316 may be a liquid crystal display (LCD) or a touch screen display. The LCD or touch screen display can show the process of the processor executing the program.
[0105] The electronic device 300 in this embodiment can be used to perform the various steps in the various methods provided in the embodiments of this application.
[0106] Furthermore, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps described in the above method embodiments.
[0107] The computer program product of the above-described method provided in this application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the steps in the above-described method embodiments. For details, please refer to the above-described method embodiments, which will not be repeated here.
[0108] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms. The functional modules in the embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0109] It should be noted that if the function is implemented as a software module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0110] In this document, relational terms such as first and second are used only to distinguish one entity or operation from another entity or operation, without necessarily requiring or implying any such actual relationship or order between these entities or operations.
[0111] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A protocol update method, characterized in that, The method includes: The contents of the protocol file are obtained and stored in a hash table; wherein the hash table includes a monitoring table and a query table, the query table is used to store the protocol file in protocol frame format, and the monitoring table is used to store the updated protocol file; Create a monitoring thread to monitor whether the protocol file has been updated; If it is determined that the protocol file has been updated, the monitoring table and the query table are swapped by encryption and unlocking to obtain the updated query table; The contents of the update query table are parsed to obtain the updated protocol file.
2. The method according to claim 1, characterized in that, The process of obtaining the content of the protocol file and storing it in a hash table includes: Obtain the contents of the protocol file and create monitoring and query tables; The lookup table is initialized to store the contents of the protocol file in protocol frame format; Create a mutex lock for the monitoring table and the query table so that when an update is detected, the lock and unlock locks are swapped.
3. The method according to claim 2, characterized in that, If it is determined that the protocol file has been updated, the monitoring table and the query table are swapped (encrypted / unlocked) to obtain an updated query table, including: If it is determined that the protocol file has been updated, then the entire content of the latest protocol file is obtained and stored in the monitoring table to obtain the update monitoring table; Lock the mutex lock; The update monitoring table and the query table are swapped to obtain the update query table; Unlock the mutex.
4. The method according to claim 1, characterized in that, The creation of a monitoring thread to monitor whether the protocol file has been updated includes: Create a monitoring thread to periodically scan the protocol file; Based on whether the final modification time of the protocol file has changed, it is determined whether the protocol file has been updated.
5. The method according to claim 1, characterized in that, The step of parsing the contents of the update query table to obtain the updated protocol file includes: The update query table is retrieved based on the protocol name. The update query table is parsed to obtain the updated protocol file.
6. The method according to any one of claims 1-5, characterized in that, in, The protocol file includes at least one protocol frame format file from XML files, JSON files, and custom files.
7. The method according to any one of claims 1-5, characterized in that, in, The protocol type of the protocol file includes any one of the following: Address Resolution Protocol, Internet Control Message Protocol, Routing Information Protocol, RIPNG Protocol, and Skinny Protocol.
8. A protocol update apparatus, characterized in that, The device includes: An initialization storage module is used to obtain the content of the protocol file and store it in a hash table; wherein, the hash table includes a monitoring table and a query table, the query table is used to store the protocol file in protocol frame format, and the monitoring table is used to store the updated protocol file; The monitoring module is used to create monitoring threads to monitor whether the protocol file has been updated; The update query table module is used to swap the monitoring table and the query table in an encrypted / unlocked manner if it is determined that the protocol file has been updated, so as to obtain the updated query table; The update protocol module is used to parse the contents of the update query table to obtain the updated protocol file.
9. An electronic device, characterized in that, include: The processor and memory, wherein the memory stores machine-readable instructions executable by the processor, wherein when the electronic device is running, the machine-readable instructions are executed by the processor to perform the steps of the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
METHOD, APPARATUS, AND COMPUTER PROGRAM PRODUCT FOR MANAGING Hash TABLES
CN110109915A
Index updating system, method and device of search engine, electronic equipment and storage medium
CN112052247A