K8S network topology automatic discovery system and method based on IP packet analysis
Through the K8S network topology automatic discovery system based on IP packet analysis, IP packet header data is captured and parsed, which solves the problem of being unable to obtain non-TCP protocol data in the existing technology, improves the efficiency and accuracy of data collection, and realizes real-time network access. of capture.
Patent Information
- Application Number
- CN202211594404.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-13
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-12-13
AI Technical Summary
When obtaining the server network topology, the existing technology cannot capture non-connection-based protocols such as the UDP protocol, resulting in data omissions, low efficiency, and a large impact on the business.
The K8S network topology automatic discovery system based on IP packet analysis is used to capture and parse IP packet header data through the Agent module, and is combined with the Collector module for data preprocessing and label printing to generate network topology snapshots and traffic indicators, which are stored in the database.
It improves the efficiency of data collection, reduces the data omission rate, obtains more detailed network information, reduces server resource occupation, and realizes the capture of real-time network access conditions.
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of IT and software development, and in particular to a K8S network topology automatic discovery method based on IP packet analysis. Background Art
[0002] The current method for obtaining server network topology is generally to obtain network connection information by periodically executing operating system commands, that is, based on the time slice batch polling method, periodically executing operating system commands (for example: netstats, ss) on the K8S node to obtain the current server's network connection status, and send the command execution results to the server for aggregation processing.
[0003] The method of periodically executing operating system commands has the following disadvantages: 1. It can only obtain the situation of the connection-based TCP protocol, and cannot obtain UDP and three-layer network protocols that are not connection-based; 2. For the TCP protocol, it can only obtain the network connection status when the command is executed, and there may be omissions; 3. The method of collecting data through commands is not efficient, and considering the impact on the business, the execution frequency cannot be too high. Summary of the invention
[0004] The purpose of the present invention is to provide a K8S network topology automatic discovery system and method based on IP packet analysis, so that the IP packet headers on the third and fourth layers of the OSI standard model can be captured for generating network topology, and the probability of data omission is greatly reduced; so that the efficiency of data collection can be improved and the loss can be reduced.
[0005] The technical solution adopted by the present invention is:
[0006] K8S network topology automatic discovery system based on IP packet analysis, which includes Agent module and Collector module;
[0007] The Agent module includes:
[0008] IP packet capture module: monitors and captures the first 60 bytes of header data of all IP packets on the node;
[0009] IP header parsing module: parses the information of IP packet header to obtain key information such as source IP port, target IP port, packet size, etc.
[0010] Preprocessing module: classifies data according to protocol, source, and target, and pre-aggregates data according to a certain time window;
[0011] Data transmission module: packages the pre-aggregation results and sends them to the data analysis server Collector;
[0012] The Collector module includes:
[0013] Metadata synchronization module: obtains and monitors the mapping relationship between IP, port and resources from the K8S apiserver;
[0014] Data monitoring module: receives data sent by Agent;
[0015] Automatic labeling module: finds the corresponding relationship from the mapping relationship according to the IP port in the data and labels it;
[0016] Topology analysis module: Analyzes the network status of resources to resources based on labeled data and time windows, namely, topology snapshots and traffic indicators;
[0017] Persistence module: stores network topology snapshot data in the database and sends network traffic indicators to the indicator center;
[0018] Query interface service: provides query service for network topology snapshot.
[0019] Furthermore, the Metrics Center provides queries for network traffic metrics through its API service.
[0020] The K8S network topology automatic discovery method based on IP packet analysis includes the following steps:
[0021] Step 1: Deploy the collection agent on the K8S node;
[0022] Step 2: Deploy the data collection service Collector on the K8S node;
[0023] Step 3: When the Agent is running, it monitors and captures the header data of all IP packets on the node through the IP packet capture module;
[0024] Step 4, the IP header parsing module of the Agent parses the header data of the IP packet to obtain the source IP port, the destination IP port, and the packet size information;
[0025] Step 5: The Agent's preprocessing module classifies the information obtained from the packet header data, and pre-aggregates the data according to a certain time window. The pre-aggregation result is then packaged and sent to the unified collection server Collector through the Agent's data transmission module.
[0026] Step 6: Collector receives the data sent by Agent and adds labels according to the corresponding relationships in the data;
[0027] Step 7: The Collector topology analysis module analyzes the resource-to-resource network situation based on the labeled data and time window.
[0028] In step 8, the persistence module of Collector stores the analyzed network topology snapshot data in the database and sends the network traffic indicators aggregated according to the resource dimension to the indicator center interface.
[0029] Furthermore, in step 1, the collection agent is deployed through DaemonSet and HostNetwork.
[0030] Furthermore, in step 2, the data collection service Collector is deployed in a Deployment manner.
[0031] Furthermore, in step 3, the first 120 bytes of packet header data of all IP packets on the node are monitored and captured.
[0032] Furthermore, in step 5, classification is performed according to the dimensions of protocol, source, and target.
[0033] Furthermore, the specific steps of step 6 are:
[0034] Step 6-1, Collector obtains and monitors the mapping relationship between IP, port and resources through K8S apiserver;
[0035] Step 6-2, the data monitoring module of the Collector receives the data sent by the Agent, finds the corresponding relationship from the mapping relationship according to the IP port in the data, and adds a label.
[0036] Furthermore, Collector provides query services for network topology snapshots through its API service.
[0037] The present invention adopts the above technical solution, which can capture data located on the third and fourth layers of the OSI network model and obtain more detailed information. The event-driven processing method based on IP header capture makes it difficult to miss data, thereby improving the accuracy of indicator calculation; based on the self-contained data architecture design of sharding, the collection and analysis are independent, and the collection layer does not need to access centralized cache or storage, thereby improving the efficiency of data processing and reducing the occupation of server resources. The present invention is based on IP packet capture, that is, based on IP event drive, which can improve the efficiency of data processing and reduce the occupation of server resources; it can capture the network access situation from IP to IP and IP port to IP port in real time. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in combination with the embodiments of the present application.
[0039] The present invention discloses a K8S network topology automatic discovery system based on IP packet analysis, which includes an Agent module and a Collector module;
[0040] The Agent module includes:
[0041] IP packet capture module: monitors and captures the first 60 bytes of header data of all IP packets on the node;
[0042] IP header parsing module: parses the information of IP packet header to obtain key information such as source IP port, target IP port, packet size, etc.
[0043] Preprocessing module: classifies data according to protocol, source, and target, and pre-aggregates data according to a certain time window;
[0044] Data transmission module: packages the pre-aggregation results and sends them to the data analysis server Collector;
[0045] The Collector module includes:
[0046] Metadata synchronization module: obtains and monitors the mapping relationship between IP, port and resources from the K8S apiserver;
[0047] Data monitoring module: receives data sent by Agent;
[0048] Automatic labeling module: finds the corresponding relationship from the mapping relationship according to the IP port in the data and labels it;
[0049] Topology analysis module: Analyzes the network status of resources to resources based on labeled data and time windows, namely, topology snapshots and traffic indicators;
[0050] Persistence module: stores network topology snapshot data in the database and sends network traffic indicators to the indicator center;
[0051] Query interface service: provides query service for network topology snapshot.
[0052] Furthermore, the Metrics Center provides queries for network traffic metrics through its API service.
[0053] The K8S network topology automatic discovery method based on IP packet analysis includes the following steps:
[0054] Step 1: Deploy the collection agent on the K8S node;
[0055] Step 2: Deploy the data collection service Collector on the K8S node;
[0056] Step 3: When the Agent is running, it monitors and captures the header data of all IP packets on the node through the IP packet capture module;
[0057] Step 4, the IP header parsing module of the Agent parses the header data of the IP packet to obtain the source IP port, the destination IP port, and the packet size information;
[0058] Step 5: The Agent's preprocessing module classifies the information obtained from the packet header data, and pre-aggregates the data according to a certain time window. The pre-aggregation result is then packaged and sent to the unified collection server Collector through the Agent's data transmission module.
[0059] Step 6: Collector receives the data sent by Agent and adds labels according to the corresponding relationships in the data;
[0060] Step 7: The Collector topology analysis module analyzes the resource-to-resource network situation based on the labeled data and time window.
[0061] In step 8, the persistence module of Collector stores the analyzed network topology snapshot data in the database and sends the network traffic indicators aggregated according to the resource dimension to the indicator center interface.
[0062] Furthermore, in step 1, the collection agent is deployed through DaemonSet and HostNetwork.
[0063] Furthermore, in step 2, the data collection service Collector is deployed in a Deployment manner.
[0064] Furthermore, in step 3, the first 120 bytes of packet header data of all IP packets on the node are monitored and captured.
[0065] Furthermore, in step 5, classification is performed according to the dimensions of protocol, source, and target.
[0066] Furthermore, the specific steps of step 6 are:
[0067] Step 6-1, Collector obtains and monitors the mapping relationship between IP, port and resources through K8S apiserver;
[0068] Step 6-2, the data monitoring module of the Collector receives the data sent by the Agent, finds the corresponding relationship from the mapping relationship according to the IP port in the data, and adds a label.
[0069] Furthermore, Collector provides query services for network topology snapshots through its API service.
[0070] The present invention adopts the above technical solution, and the data source of network analysis is usually from the Pod on K8S; the IP header is captured in the Node collection and preprocessing unit for parsing, extraction, grouping, and sending to the calculation unit. The calculation unit completes the aggregation calculation and stores the results in the topology snapshot library and the indicator library; the topology snapshot library and the indicator library are stored according to the time and resource dimensions; the query service is extracted from the database by conditions and then provided to the application layer. The present invention can capture data located on the third and fourth layers of the OSI network model and can obtain more detailed information. Based on the event-driven processing method captured by the IP header, data is not easily missed, and the accuracy of indicator calculation is improved; based on the self-contained data architecture design of the sharding, the collection and analysis are independent, and the collection layer does not need to access the centralized cache or storage, thereby improving the efficiency of data processing and reducing the occupancy of server resources. The present invention is based on IP packet capture, that is, based on IP event drive, which can improve the efficiency of data processing and reduce the occupancy of server resources; it can capture the network access situation from IP to IP and IP port to IP port in real time.
[0071] Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be combined with each other. Therefore, the detailed description of the embodiments of the present application is not intended to limit the scope of the present application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.
Claims
1. K8S network topology automatic discovery system based on IP packet analysis, characterized by: It includes Agent module and Collector module; The Agent module includes: IP packet capture module: monitors and captures the first 60 bytes of header data of all IP packets on the node; IP header parsing module: parses the information of IP packet header to obtain key information such as source IP port, target IP port, packet size, etc. Preprocessing module: classifies data according to protocol, source, and target, and pre-aggregates data according to a certain time window; Data transmission module: packages the pre-aggregation results and sends them to the data analysis server Collector; The Collector module includes: Metadata synchronization module: obtains and monitors the mapping relationship between IP, port and resources from the K8S apiserver; Data monitoring module: receives data sent by Agent; Automatic labeling module: finds the corresponding relationship from the mapping relationship according to the IP port in the data and labels it; Topology analysis module: Analyzes the network status of resources to resources based on labeled data and time windows, namely, topology snapshots and traffic indicators; Persistence module: stores network topology snapshot data in the database and sends network traffic indicators to the indicator center; Query interface service: provides query service for network topology snapshot.
2. According to the K8S network topology automatic discovery method based on IP packet analysis according to claim 1, it is characterized in that: The Metrics Center provides network traffic metrics queries through its API service.
3. A K8S network topology automatic discovery method based on IP packet analysis, using the K8S network topology automatic discovery system based on IP packet analysis according to claim 1 or 2, characterized in that: The method comprises the following steps: Step 1: Deploy the collection agent on the K8S node; Step 2: Deploy the data collection service Collector on the K8S node; Step 3: When the Agent is running, it monitors and captures the header data of all IP packets on the node through the IP packet capture module; Step 4, the IP header parsing module of the Agent parses the header data of the IP packet to obtain the source IP port, the destination IP port, and the packet size information; Step 5: The Agent's preprocessing module classifies the information obtained from the packet header data, and pre-aggregates the data according to a certain time window. The pre-aggregation result is then packaged and sent to the unified collection server Collector through the Agent's data transmission module. Step 6: Collector receives the data sent by Agent and adds labels according to the corresponding relationships in the data; Step 7: The Collector topology analysis module analyzes the resource-to-resource network situation based on the labeled data and time window. In step 8, the persistence module of Collector stores the analyzed network topology snapshot data in the database and sends the network traffic indicators aggregated according to the resource dimension to the indicator center interface.
4. The K8S network topology automatic discovery method based on IP packet analysis according to claim 3 is characterized in that: In step 1, the collection agent is deployed through DaemonSet and HostNetwork.
5. The K8S network topology automatic discovery method based on IP packet analysis according to claim 3 is characterized in that: In step 2, deploy the data collection service Collector through the Deployment method.
6. The K8S network topology automatic discovery method based on IP packet analysis according to claim 3 is characterized in that: In step 3, the first 120 bytes of packet header data of all IP packets on the node are monitored and captured.
7. The K8S network topology automatic discovery method based on IP packet analysis according to claim 3 is characterized in that: In step 5, classification is performed based on the dimensions of protocol, source, and target.
8. The K8S network topology automatic discovery method based on IP packet analysis according to claim 3 is characterized in that: The specific steps of step 6 are: Step 6-1, Collector obtains and monitors the mapping relationship between IP, port and resources through K8S apiserver; Step 6-2, the data monitoring module of the Collector receives the data sent by the Agent, finds the corresponding relationship from the mapping relationship according to the IP port in the data, and adds a label.
