Network resource path matching method and device and internet of vehicles system
By using hash table lookup instead of full traversal matching in the vehicle networking platform, and combining it with a parent path wildcard priority strategy, the problem of low efficiency in resource path matching is solved, achieving efficient path matching and saving hardware resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAMEN YAXON ZHILLAN TECHNOLOGY CO LTD
- Filing Date
- 2024-11-28
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies suffer from low efficiency and high hardware resource consumption when matching resource paths in vehicle networking platforms. In particular, frequent fuzzy string matching in large-scale systems leads to serious performance impact.
Instead of the traditional full traversal matching, a hash table lookup is used. By calculating the hash value of the allowed access path and storing it in the hash table, combined with a parent path wildcard priority strategy, the client request path is quickly matched.
It significantly reduces the number of matching attempts and resource overhead, improves matching efficiency, reduces hardware resource requirements, and enhances the operational efficiency of the vehicle networking platform.
Smart Images

Figure CN122120198A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a network resource path matching method, apparatus, and vehicle networking system. Background Technology
[0002] When a central platform grants external access to resources, it needs to match and filter the path of each requested resource. For example, a vehicle-to-everything (V2X) platform provides services to users via the internet, but these services are selective, requiring flexible configuration of allowed functions for different users. Current technology typically pre-generates a set of allowed paths based on user access permission configuration data. When the central platform receives a request, it iterates through this set of allowed paths. If a matching path is found, the system allows the request; otherwise, if no matching path is found after the entire iterative process, the system rejects the request.
[0003] Existing technologies have significant drawbacks. Since resource paths typically use a parent path wildcard to authorize child paths, for example, if the path set contains a path " / a / **", then requests for " / a / aa / ", " / a / aa / aaa", and subsequent deeper-level paths are all allowed. Existing technologies also require fuzzy matching when traversing the path set. Drawback 1: Path fuzzy matching is a type of string fuzzy matching, resulting in low matching efficiency. Drawback 2: Assuming each user's allowed path set is 1000, each user request requires matching 1000 paths. In a large-scale system with tens of thousands of requests per second, the system needs to perform tens of millions of matches per second (1000 * 10,000), consuming significant hardware resources and impacting response performance. Summary of the Invention
[0004] The purpose of this invention is to provide a network resource path matching method, device, and vehicle networking system. It uses hash table lookup, which eliminates the need to traverse and match the set of allowed paths one by one, thereby reducing the resource overhead of matching and the number of matching operations, resulting in a significant improvement in matching efficiency.
[0005] The present invention adopts the following technical solution:
[0006] A method for matching network resource paths, comprising:
[0007] Get the set of allowed paths;
[0008] Calculate the hash value of all elements in the allowed path set and store them in a hash table structure;
[0009] Receive the request path sent by the client;
[0010] The received request paths are split and reorganized hierarchically to obtain a set of paths to be matched;
[0011] Each data item in the set of paths to be matched is hashed one by one to obtain the corresponding hash value;
[0012] The hash values of each data item in the set of paths to be matched are used sequentially to perform hash lookups in the hash table;
[0013] The request is responded to when any data item is successfully found; the request is rejected if all data items are not found.
[0014] Preferably, the paths in the allowed path set can be configured to support both full matches and wildcards.
[0015] Preferably, the paths in the allowed path set are configured with parent path wildcard priority.
[0016] Preferably, the step of performing hash calculations on each data item in the set of paths to be matched to obtain the corresponding hash value specifically includes:
[0017] Each data item in the set of paths to be matched is hashed one by one in order of priority of the parent path to obtain the corresponding hash value.
[0018] Preferably, the received request path is split and reorganized hierarchically to obtain a set of paths to be matched, including:
[0019] Remove the request headers from the client's request path;
[0020] The request path with the request header removed is split by " / " to obtain several hierarchical paths;
[0021] The split hierarchical paths are recombined by adding the " / **" wildcard to the first level and by successively concatenating each level and the " / **" wildcard based on the first level, so as to obtain at least one recombined path.
[0022] The obtained reconstructed path and the original request path with the request header stripped are combined to form a set of paths to be matched.
[0023] Preferably, after calculating the hash values of all elements in the allowed path set and storing them in a hash table structure, the method further includes:
[0024] Enter listening mode and wait for client requests.
[0025] Preferably, the set of allowed access paths is obtained from the database and is a list of resource paths configured in the database according to business requirements.
[0026] On the other hand, a network resource path matching device includes:
[0027] The allowed access path set acquisition module is used to obtain the set of allowed access paths;
[0028] The hash table building module is used to calculate the hash value of all elements in the allowed path set and store them in a hash table structure.
[0029] The request path receiving module is used to receive the request path sent by the client.
[0030] The splitting and recombining module is used to split and recombine the received request paths hierarchically to obtain a set of paths to be matched;
[0031] The request hash value calculation module is used to perform hash calculations on each data item in the path set to be matched to obtain the corresponding hash value.
[0032] The hash lookup module is used to perform hash lookups in the hash table by sequentially using the hash values of each data item in the set of paths to be matched.
[0033] The matching and determination module is used to respond to the request when a data item is successfully found; if all data items fail to be found, the request is rejected.
[0034] Preferably, a vehicle-to-everything (V2X) system includes: a client and a V2X platform with communication connection; the V2X platform is used to implement the network resource path matching method.
[0035] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0036] (1) This invention first performs hash calculation on the set of paths that users are allowed to access and caches it. Then, when a client user requests a request, the requested path is also hashed. Finally, a hash table lookup is used instead of a full traversal. When a request is received, this invention no longer uses inefficient string fuzzy matching, but instead uses a hash table lookup, which reduces memory overhead. At the same time, it does not need to traverse and match the set of paths that are allowed to access one by one. Using a hash table lookup, the time complexity can be reduced from O(n) to O(1). As a result, after adopting the network resource path matching method of this invention, the resource overhead of matching is reduced, the number of matching times is reduced, the matching efficiency of the system is greatly improved, and the operating efficiency of the vehicle network platform server is improved, saving hardware resource investment and reducing deployment and maintenance costs.
[0037] (2) Based on usage habits, this invention uses the parent path wildcard priority method to configure the paths in the allowed path set, and prioritizes matching elements with high probability, thereby reducing the number of matching times and further improving matching efficiency. Attached Figure Description
[0038] Figure 1This is a simplified flowchart of the network resource path matching method according to an embodiment of the present invention;
[0039] Figure 2 This is a schematic diagram of the complete process of the method according to an embodiment of the present invention;
[0040] Figure 3 This is a structural block diagram of the network resource path matching device according to an embodiment of the present invention;
[0041] Figure 4 This is a structural block diagram of a vehicle networking system according to an embodiment of the present invention. Detailed Implementation
[0042] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. Furthermore, it should be understood that after reading the teachings of this invention, those skilled in the art can make various alterations or modifications to the invention, and these equivalent forms also fall within the scope defined by the appended claims.
[0043] See Figure 1 and Figure 2 As shown, the present invention provides a network resource path matching method, the execution subject of which is a server, specifically a vehicle network platform, and includes the following steps.
[0044] S101, obtain the set of allowed paths.
[0045] Specifically, based on the business needs of the vehicle network platform, the administrator pre-configures a list of allowed resource paths (the set of allowed paths) using a parent path wildcard priority approach, hereinafter referred to as the "whitelist" and denoted by "set A", and saves the configuration data to the database.
[0046] When the vehicle networking platform initializes, it loads whitelist data from the database to obtain the set of allowed access paths.
[0047] S102, calculate the hash value of all elements in the allowed path set and store them in a hash table structure.
[0048] Specifically, the vehicle-to-everything (V2X) platform calculates the hash value of all elements in the whitelist and stores it in a high-speed cache in the form of a hash table, hereinafter referred to as the "whitelist hash table" or "set B". The whitelist paths in the hash table can be configured using both full matches and wildcards. For example, {" / a / **", " / a / aa"} means that request paths starting with / a / are allowed, or request paths like / a / aa are also allowed. After this, the V2X platform initializes and enters a listening state, waiting for client requests.
[0049] S103 receives the request path sent by the client.
[0050] S104, split and reorganize the received request path according to the hierarchy to obtain the set of paths to be matched.
[0051] Specifically, upon receiving a client's request, the vehicle network platform first splits and reassembles the requested resource path using " / ", resulting in a set of paths to be matched. For example, if a requested path is " / a / aa", it will be split and reassembled into " / a / **", " / a / aa / **", and " / a / aa", denoted by "set C". If any of " / a / **", " / a / aa / **", or " / a / aa" exists in set B, then the access is permitted.
[0052] The following example uses a user request to http: / / a / aa to illustrate the splitting and reorganization process.
[0053] (1) First, remove the http: / / request header from the path requested by the user to get the path / a / aa;
[0054] (2) Split the above / a / aa by " / to get the first-level path / a and the second-level path / aa;
[0055] (3) Concatenate the split paths into first-level, first-level + second-level, first-level + second-level + third-level, and so on, and add the wildcard " / **" at the end. For example: / a / **, / a / aa / **.
[0056] (4) Add the original path ( / a / aa) to the result set obtained in (3). Since the results obtained in (3) are all wildcard matches, adding the original path can simultaneously achieve both wildcard fuzzy matching and full path complete matching modes.
[0057] S105, perform hash calculations on each data item in the set of paths to be matched to obtain the corresponding hash value.
[0058] S106, use the hash value of each data item in the set of paths to be matched to perform a hash lookup in the hash table in turn.
[0059] The specific implementations of S105 and S106 are as follows. Data items in set C are hashed one by one according to the parent path priority order. Then, based on the calculated hash value, the data is retrieved from set B using a hash lookup method. Since the average time complexity of hash table lookup is generally considered to be O(1), while the time complexity of the traditional full traversal matching method is O(n), where n is the total number of elements in set A, the time complexity of this proposed method will be significantly reduced. Taking the request path " / a / aa" as an example, it first searches for " / a / **" in set B. If found, it returns a successful match; if not found, it continues searching for " / a / aa / **", and so on, until " / a / aa" is found. According to the example, this request can be completed in 1 to 3 searches. If no match is found after all searches, it returns a failure to match. Since elements in set B are generally configured using parent path wildcards, i.e., " / a / **" indicates that paths starting with " / a" are allowed, a parent path priority matching strategy is adopted, prioritizing elements with higher probabilities, further improving the hit efficiency.
[0060] S107: If a data item is found successfully, respond to the request; if all data items are not found, reject the request.
[0061] As shown above, this invention uses hash table lookup instead of traditional full traversal fuzzy matching, reducing the time complexity of each matching request from O(n) to O(1), which greatly improves the efficiency of network path matching; and according to usage habits, it adopts a parent path priority matching strategy to match elements with high probability first, reducing the number of matching times and further improving matching efficiency.
[0062] See Figure 3 As shown, this embodiment also discloses a network resource path matching device, including:
[0063] The allowed access path set acquisition module 301 is used to acquire the allowed access path set;
[0064] Hash table building module 302 is used to calculate the hash value of all elements in the allowed access path set and store them in the structure of a hash table;
[0065] The request path receiving module 303 is used to receive the request path sent by the client;
[0066] The splitting and recombining module 304 is used to split and recombine the received request path according to the hierarchy to obtain a set of paths to be matched;
[0067] The request hash value calculation module 305 is used to perform hash calculations on each data item in the path set to be matched to obtain the corresponding hash value.
[0068] The hash lookup module 306 is used to perform hash lookups in the hash table by sequentially using the hash values of each data item in the path set to be matched.
[0069] The matching determination module 307 is used to respond to the request when a data item is successfully found; if all data items are not found, the request is rejected.
[0070] The specific implementation of each module of the network resource path matching device and the same network resource path matching method will not be described again in this embodiment.
[0071] See Figure 4 As shown, this embodiment also discloses a vehicle networking system, including: a client 401 and a vehicle networking platform 402 connected by communication; the vehicle networking platform 402 acts as a server to implement the network resource path matching method.
[0072] While specific embodiments of the present invention have been described above, those skilled in the art should understand that the specific embodiments described in this patent are merely illustrative and not intended to limit the scope of the present invention. Equivalent modifications and variations made by those skilled in the art in accordance with the spirit of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A method for matching network resource paths, characterized in that, include: Get the set of allowed paths; Calculate the hash value of all elements in the allowed path set and store them in a hash table structure; Receive the request path sent by the client; The received request paths are split and reorganized hierarchically to obtain a set of paths to be matched; Each data item in the set of paths to be matched is hashed one by one to obtain the corresponding hash value; The hash values of each data item in the set of paths to be matched are used sequentially to perform hash lookups in the hash table; The request is responded to when any data item is successfully found; the request is rejected if all data items are not found.
2. The network resource path matching method according to claim 1, characterized in that, The paths in the allowed path set can be configured using both full matches and wildcards.
3. The network resource path matching method according to claim 1, characterized in that, The paths in the allowed path set are configured with parent path wildcard priority.
4. The network resource path matching method according to claim 1, characterized in that, The step of performing hash calculations on each data item in the set of paths to be matched to obtain the corresponding hash value specifically includes: Each data item in the set of paths to be matched is hashed one by one in order of priority of the parent path to obtain the corresponding hash value.
5. The network resource path matching method according to claim 1, characterized in that, The received request paths are split and reorganized hierarchically to obtain a set of paths to be matched, including: Remove the request headers from the client's request path; The request path with the request header removed is split by " / " to obtain several hierarchical paths; The split hierarchical paths are recombined by adding the " / **" wildcard to the first level, and by successively concatenating each level and the " / **" wildcard based on the first level, to obtain at least one recombined path; The obtained reconstructed path and the original request path with the request header stripped are combined to form a set of paths to be matched.
6. The network resource path matching method according to claim 1, characterized in that, After calculating the hash values of all elements in the allowed path set and storing them in a hash table structure, the process also includes: Enter listening mode and wait for client requests.
7. The network resource path matching method according to claim 1, characterized in that, The set of allowed access paths is obtained from the database and is a list of resource paths configured in the database according to business requirements.
8. A network resource path matching device, characterized in that, include: The allowed access path set acquisition module is used to obtain the set of allowed access paths; The hash table building module is used to calculate the hash value of all elements in the allowed path set and store them in a hash table structure. The request path receiving module is used to receive the request path sent by the client. The splitting and recombining module is used to split and recombine the received request paths hierarchically to obtain a set of paths to be matched; The request hash value calculation module is used to perform hash calculations on each data item in the path set to be matched to obtain the corresponding hash value. The hash lookup module is used to perform hash lookups in the hash table by sequentially using the hash values of each data item in the set of paths to be matched. The matching and determination module is used to respond to the request when a data item is successfully found; if all data items fail to be found, the request is rejected.
9. A vehicle networking system, characterized in that, include: A client and a vehicle networking platform with communication connection; the vehicle networking platform is used to implement the network resource path matching method as described in any one of claims 1 to 7.