A method for accurately matching domain names and variable domain names with IP

Matching DNS return packets through libpcap packet capture and hashing algorithm achieves accurate matching of IP and CDN relationships in flow control, solves the problem of traditional flow control being insufficient in complex network environments, and improves the portability and ease of flow control. Operability.

CN118075227BActive Publication Date: 2024-10-29GUANGDONG LEGEND COMM CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410189197.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-20
Publication Date
2024-10-29
Estimated Expiration
2044-02-20

AI Technical Summary

Technical Problem

Existing technology is difficult to meet the needs of multi-point sending and receiving in flow control, resulting in inaccurate flow control. Especially in NAT hidden public IP and CDN distribution networks, traditional data link layer and network layer flow control is not enough. Cope with complex network environments.

Method used

Use libpcap to capture packets by listening to the DNS port, distinguish IP/ARP/RARP packets, parse the IP packets to obtain the fragment offset, calculate the protocol type, and use the hash algorithm to match the IP correspondence in the DNS return packet, and provide real-time information through shared memory Flow control further modifies the IP header TOS life cycle by identifying the IP aging period in the CDN distribution network to achieve accurate matching of domain names and the relationship between variable domain names and IPs.

Benefits of technology

It improves the portability and ease of operation of flow control, achieves accurate matching of the relationship between network traffic and IP and CDN, covers network flow control to the greatest extent, and is suitable for complex service-oriented network environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118075227B_ABST
    Figure CN118075227B_ABST
Patent Text Reader

Abstract

The present invention specifically relates to a method for accurately matching domain names and variable domain names with IP, and the method comprises the following steps: monitoring the DNS ports of all designated network ports and using libpcap to capture packets; distinguishing IP / ARP / RARP packets by shift operations; parsing IP packets to obtain slice offsets, and calculating the upper layer of the Protocol as TCP / UDP / ICMP by the offset; using a hash algorithm to match the questions and answers values ​​under the query area; obtaining the new IP correspondence in the DNS reply packet, and providing it to the flow control in real time through the shared memory, and ending the process. The present invention provides a method for accurately matching domain names and covering the relationship between network traffic and IP and CDN (variable IP) to the greatest extent, and using the libpcap library can improve the portability and operability of flow control.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention specifically relates to a method for accurately matching domain names and variable domain names with IPs. Background Art

[0002] With the advent of the 5G era for end users, traffic control can effectively prevent the impact of large amounts of data on the network in an instant, ensuring efficient and stable operation of the user network.

[0003] The traditional data link layer and network layer network traffic control mainly rely on three reliable protocols: stop-wait protocol (SW), back-off N frame protocol (GBN), and selective repeat protocol (SR). With the continuous development of the network, the second-layer flow control is not easy to meet the needs. On the one hand, it is disconnected from the application. On the other hand, if there are multiple points between the sender and the receiver, the flow control also needs to be controlled at multiple points, so naturally this business is thrown to the upper layer. At present, more flow control is based on the session layer, presentation layer, and application layer. Basically, flow control is only for IP and port control. This is not a problem in a service-based network environment, but there will still be NAT hiding the public network IP on the terminal, resulting in the widespread use of NAT traversal technology and CDN-based distribution networks. Summary of the invention

[0004] The purpose of the present invention is to provide a method for accurately matching domain names and variable domain names with IP addresses, so as to solve the problems raised in the above-mentioned background technology.

[0005] In order to solve the above technical problems, the present invention provides the following technical solutions:

[0006] The method for accurately matching domain names and variable domain names with IPs includes the following steps:

[0007] The DNS ports that monitor all specified network ports are captured using libpcap;

[0008] Distinguish IP / ARP / RARP packets through shift operations;

[0009] Parse the IP packet to obtain the fragment offset, and calculate the upper layer of the Protocol as TCP / UDP / ICMP through the offset;

[0010] The hash algorithm matches the questions and answers values ​​under the query area;

[0011] Get the new IP correspondence in the DNS reply packet, give it to the flow control in real time through shared memory, and end the process.

[0012] Furthermore, it also includes identifying the IP aging period in the CDN distribution network, the local DNS re-obtaining the cache server IP provided by the global load balancer of the CDN network, modifying the IP header TOS life cycle & 0xFF; obtaining the new IP correspondence in the DNS reply packet, and ending the process.

[0013] Furthermore, the specific steps of monitoring the DNS ports of all specified network ports using libpcap packet capture are as follows: use libpcap to capture the DNS port data packets of all specified network ports, including opening the network device: use the pcap_open_live() function to open the network device, the device name is usually "eth0" or other, the device type is "net80281", the data link layer type is "DLT_EN10MB", and the network mask of the network device interface is specified; compile the filtering policy: use the pcap_compile() function to compile the user-specified filtering policy into the filtering program; set the filter: use the pcap_setfilter() function to apply the filter compiled in the previous step to the network device; capture data packets: use the pcap_loop() or pcap_dispatch() function to capture data packets; process data packets: in the callback function, various processing can be performed on the captured data packets; close the network device: when the application completes its work, the pcap_close() function can be called to close the network device and release resources.

[0014] Furthermore, the specific steps of distinguishing IP / ARP / RARP packets by shift operation are as follows: Reading data packets: First, you need to read data packets from the network, which can be achieved by using the pcap_loop() or pcap_dispatch() function of the libpcap library, and passing the captured data packets to the specified callback function for processing; Extracting data packet headers: When processing each data packet, you need to extract its header information; the header of an IP data packet contains version, header length, service type, total length, identifier, flag, fragment offset, and time to live (TTL) fields, while the headers of ARP and RARP data packets contain different fields; Determine the protocol type: Based on the extracted packet header information, you can determine which protocol the packet is. Determine the operation type: For ARP and RARP packets, you also need to determine their operation type. The operation type field of the ARP packet is 0x0001, indicating a request (Request), and 0x0002, indicating a response (Reply). The operation type field of the RARP packet is 0x8035, indicating a request (Request), and 0x8036, indicating a response (Reply). Process packets: Different packets can be processed differently based on the determined protocol type and operation type.

[0015] Furthermore, it is necessary to parse the IP packet and obtain the fragment offset, and then calculate the upper layer of the protocol as TCP, UDP or ICMP based on the offset. The specific steps are as follows: Read the IP packet: First, the IP packet needs to be captured from the network, and the captured IP packet will be passed to the processing function as a parameter of the callback function; parse the IP packet: In the processing function, the captured IP packet needs to be parsed. The structure of the IP packet includes version, header length, service type, total length, identifier, flag, fragment offset and time to live (TTL) field. The structure can be used to represent the various fields of the IP packet; extract the fragment offset: after parsing the IP packet, the fragment offset field can be extracted; determine the protocol type: the protocol type can be determined according to the value of the fragment offset; process the protocol data: different protocol data can be processed differently according to the determined protocol type.

[0016] Compared with the prior art, the present invention has the following beneficial effects:

[0017] The present invention provides a method for accurately matching domain names and maximally covering the relationship between network traffic and IP and CDN (variable IP). The use of the libpcap library can improve the portability and operability of flow control. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 This is a flow chart of the invention for accurately matching domain names and variable domain names (CDN) with IP;

[0019] Figure 2 This is a flow chart of the corresponding relationship of identifying the CDN aging period and automatically unbinding the CDN according to the present invention. DETAILED DESCRIPTION

[0020] The following will be combined with the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0021] like Figure 1 , a method for accurately matching domain names and variable domain names with IP, comprising the following steps:

[0022] ①Monitor the DNS ports of all specified network ports and use libpcap to capture packets;

[0023] ②Distinguish IP / ARP / RARP packets through shift operations;

[0024] ③ Parse the IP packet to obtain the fragment offset, and calculate the upper layer of the Protocol as TCP / UDP / ICMP through the offset;

[0025] ④Hash algorithm matches questions, answers and other values ​​in the query area;

[0026] By identifying the IP aging period in the CDN distribution network, the local DNS obtains the cache server IP provided by the global load balancer of the CDN network for the second time, modifies the IP header TOS lifecycle & 0xFF; obtains the new IP correspondence in the DNS reply packet, and ends the process.

[0027] The specific steps of using libpcap to capture packets for the DNS ports of all specified network ports include: 1. Open the network device: Use the pcap_open_live() function to open the network device. The device name is usually "eth0" or other, the device type is "net80281", the data link layer type is "DLT_EN10MB", and the network mask of the network device interface is specified. 2. Compile the filtering policy: Use the pcap_compile() function to compile the user-specified filtering policy into the filtering program. For example, if you are only interested in DNS packets, you can use filtering rules to filter out packets from UDP port 53. 3. Set the filter: Use the pcap_setfilter() function to apply the filter compiled in the previous step to the network device, so that the captured packets will only include data that meets the filtering rules. 4. Capture packets: Use the pcap_loop() or pcap_dispatch() function to capture packets. These functions will process each captured packet according to the specified callback function. If you need more precise control, you can also use the pcap_next() or pcap_next_ex() functions to get packets one by one. 5. Processing packets: In the callback function, you can perform various processing on the captured packets, such as resolving DNS records, analyzing HTTP requests, etc. 6. Turning off network devices: When the application finishes its work, you can call the pcap_close() function to turn off the network device and release resources.

[0028] Distinguish IP / ARP / RARP packets by shift operation Specific steps: 1. Read data packets: First, you need to read data packets from the network. This can be achieved by using the pcap_loop() or pcap_dispatch() functions of the libpcap library. These functions pass the captured data packets to the specified callback function for processing. 2. Extract the packet header: When processing each data packet, you need to extract its header information. The header of the IP data packet contains fields such as version, header length, service type, total length, identifier, flag, fragment offset, and survival time (TTL). The headers of ARP and RARP data packets contain different fields. 3. Determine the protocol type: Based on the extracted data packet header information, you can determine which protocol it is. The version field of the IP data packet indicates whether it is an IPv4 or IPv6 data packet. If the version field is 4, it is an IPv4 data packet; if the version field is 6, it is an IPv6 data packet. The protocol type field of the ARP packet is 0x0806, while the protocol type field of the RARP packet is 0x8035. 4. Determine the operation type: For ARP and RARP packets, you also need to determine their operation type. The operation type field of the ARP packet is 0x0001, which means it is a request, and 0x0002, which means it is a response. The operation type field of the RARP packet is 0x8035, which means it is a request, and 0x8036, which means it is a response. 5. Process the packet: Different packets can be processed differently based on the determined protocol type and operation type. For example, for IP packets, you can parse their header information and extract the IP address and port number, etc.; for ARP and RARP packets, you can extract their hardware address information and process them accordingly. The above are the steps to distinguish IP, ARP, and RARP packets through shift operations.

[0029] To parse the IP packet and get the fragment offset, and then calculate the upper layer of the protocol as TCP, UDP or ICMP based on the offset, the specific steps are as follows: 1. Read the IP packet: First, you need to capture the IP packet from the network. This can be achieved by using the pcap_loop() or pcap_dispatch() function of the libpcap library. The captured IP packet will be passed to the processing function as a parameter of the callback function. 2. Parse the IP packet: In the processing function, you need to parse the captured IP packet. The structure of the IP packet includes fields such as version, header length, service type, total length, identifier, flag, fragment offset and life time (TTL). The structure can be used to represent the various fields of the IP packet. 3. Extract the fragment offset: After parsing the IP packet, you can extract the fragment offset field. The fragment offset indicates the offset position of the IP datagram in the fragment. Based on the offset, you can determine whether the IP datagram is fragmented and the order of the fragments. 4. Determine the protocol type: The protocol type can be determined based on the value of the fragment offset. Generally speaking, if the fragment offset is 0, the protocol type is TCP; if the fragment offset is 40, the protocol type is UDP; if the fragment offset is 8, the protocol type is ICMP. Of course, this is not absolute, because different operating systems or network environments may be different. Therefore, it is best to combine other fields to determine the protocol type. 5. Processing protocol data: Different protocol data can be processed differently according to the determined protocol type. For example, if the protocol type is TCP, the TCP header information can be extracted and the port number and sequence number can be parsed out; if the protocol type is UDP, the UDP header information can be extracted and the port number can be parsed out; if the protocol type is ICMP, the ICMP header information can be extracted and the type, code, and checksum can be parsed out.

[0030] The present invention provides a method for accurately matching domain names and maximally covering the relationship between network traffic and IP and CDN (variable IP). The use of the libpcap library can improve the portability and operability of flow control.

[0031] The embodiments that require protection in this application include:

[0032] The method for accurately matching domain names and variable domain names with IPs includes the following steps:

[0033] The DNS ports that monitor all specified network ports are captured using libpcap;

[0034] Distinguish IP / ARP / RARP packets through shift operations;

[0035] Parse the IP packet to obtain the fragment offset, and calculate the upper layer of the Protocol as TCP / UDP / ICMP through the offset;

[0036] The hash algorithm matches the questions and answers values ​​under the query area;

[0037] Get the new IP correspondence in the DNS reply packet, give it to the flow control in real time through shared memory, and end the process.

[0038] Preferably, it also includes identifying the IP aging period in the CDN distribution network, the local DNS secondary obtaining the cache server IP provided by the global load balancer of the CDN network, modifying the IP header TOS life cycle & 0xFF; obtaining the new IP correspondence in the DNS response packet, and ending the process.

[0039] Preferably, the specific steps of monitoring the DNS ports of all designated network ports using libpcap to capture packets are as follows, and libpcap is used to capture the DNS port data packets of all designated network ports, including opening the network device: using the pcap_open_live() function to open the network device, the device name is usually "eth0" or other, the device type is "net80281", the data link layer type is "DLT_EN10MB", and the network mask of the network device interface is specified; compiling the filtering policy: using the pcap_compile() function to compile the user-specified filtering policy into the filtering program; setting the filter: using the pcap_setfilter() function to apply the filter compiled in the previous step to the network device; capturing data packets: using the pcap_loop() or pcap_dispatch() function to capture data packets; processing data packets: in the callback function, various processing can be performed on the captured data packets; closing the network device: when the application completes its work, the pcap_close() function can be called to close the network device and release resources.

[0040] Preferably, the specific steps of distinguishing IP / ARP / RARP packets by shift operation are as follows: Reading data packets: First, it is necessary to read data packets from the network, and use the pcap_loop() or pcap_dispatch() function of the libpcap library to achieve this, and pass the captured data packets to the specified callback function for processing; Extracting data packet headers: When processing each data packet, it is necessary to extract its header information; the header of the IP data packet contains version, header length, service type, total length, identifier, flag, fragment offset and time to live (TTL) fields, while the headers of the ARP and RARP data packets contain different fields; Determine the protocol type: Based on the extracted packet header information, you can determine which protocol the packet is. Determine the operation type: For ARP and RARP packets, you also need to determine their operation type. The operation type field of the ARP packet is 0x0001, indicating a request (Request), and 0x0002, indicating a response (Reply). The operation type field of the RARP packet is 0x8035, indicating a request (Request), and 0x8036, indicating a response (Reply). Process packets: Different packets can be processed differently based on the determined protocol type and operation type.

[0041] Preferably, it is necessary to parse the IP packet and obtain the fragment offset, and then calculate the upper layer of the protocol as TCP, UDP or ICMP based on the offset. The specific steps are as follows: read the IP packet: first, it is necessary to capture the IP packet from the network, and the captured IP packet will be passed to the processing function as a parameter of the callback function; parse the IP packet: in the processing function, it is necessary to parse the captured IP packet, and the structure of the IP packet includes version, header length, service type, total length, identifier, flag, fragment offset and time to live (TTL) field, and a structure can be used to represent each field of the IP packet; extract the fragment offset: after parsing the IP packet, the fragment offset field can be extracted; determine the protocol type: the protocol type can be determined according to the value of the fragment offset; process the protocol data: according to the determined protocol type, different protocol data can be processed differently.

[0042] The embodiment of the present application further provides a computer device, which may include a terminal device or a server, and the data calculation program of the aforementioned method of accurately matching domain names and variable domain names with IP addresses may be configured in the computer device. The computer device is introduced below.

[0043] If the computer device is a terminal device, the present application embodiment provides a terminal device, taking the terminal device as a mobile phone as an example:

[0044] The mobile phone includes components such as a radio frequency (RF) circuit, a memory, an input unit, a display unit, a sensor, an audio circuit, a wireless fidelity (WiFi) module, a processor, and a power supply.

[0045] RF circuits can be used for receiving and sending signals during information transmission or calls. In particular, after receiving the downlink information of the base station, it is processed by the processor; in addition, the designed uplink data is sent to the base station. Usually, the RF circuit includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA for short), a duplexer, etc. In addition, the RF circuit can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobile communication (GSM for short), General Packet Radio Service (GPRS for short), Code Division Multiple Access (CDMA for short), Wideband Code Division Multiple Access (WCDMA for short), Long Term Evolution (LTE for short), email, Short Messaging Service (SMS for short), etc.

[0046] The memory can be used to store software programs and modules. The processor executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0047] The input unit can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone. Specifically, the input unit may include a touch panel and other input devices. The touch panel, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on or near the touch panel using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the contact coordinates, and then sends it to the processor, and can receive the command sent by the processor and execute it. In addition, the touch panel can be implemented using multiple types such as resistive, capacitive, infrared and surface acoustic waves. In addition to the touch panel, the input unit may also include other input devices. Specifically, other input devices may include but are not limited to one or more of a physical keyboard, a function key (such as a volume control key, a switch key, etc.), a trackball, a mouse, a joystick, etc.

[0048] The display unit can be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit may include a display panel, and optionally, the display panel may be configured in the form of a liquid crystal display (LiquidCrystal Display, LCD for short), an organic light-emitting diode (Organic Light-Emitting Diode, OLED for short), etc. Further, the touch panel may cover the display panel, and when the touch panel detects a touch operation on or near it, it is transmitted to the processor to determine the type of touch event, and then the processor provides corresponding visual output on the display panel according to the type of touch event. Although in the figure, the touch panel and the display panel are used as two independent components to realize the input and output functions of the mobile phone, in some embodiments, the touch panel and the display panel can be integrated to realize the input and output functions of the mobile phone.

[0049] The mobile phone may also include at least one sensor, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may configure the brightness of the display panel according to the brightness of the ambient light, and the proximity sensor may turn off the display panel and / or backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.

[0050] The audio circuit, speaker, and microphone can provide an audio interface between the user and the mobile phone. The audio circuit can convert the received audio data into an electrical signal and transmit it to the speaker, which converts it into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit and converted into audio data. The audio data is then processed by the output processor and sent to, for example, another mobile phone through the RF circuit, or the audio data is output to the memory for further processing.

[0051] WiFi is a short-range wireless transmission technology. A mobile phone can help users send and receive emails, browse web pages, and access streaming media through a WiFi module, which provides users with wireless broadband Internet access. Although the WiFi module is shown in the figure, it is understandable that it is not a necessary component of the mobile phone and can be omitted as needed without changing the essence of the invention.

[0052] The processor is the control center of the mobile phone. It uses various interfaces and lines to connect the various parts of the entire mobile phone. It executes various functions of the mobile phone and processes data by running or executing software programs and / or modules stored in the memory, and calling data stored in the memory, so as to monitor the mobile phone as a whole. Optionally, the processor may include one or more processing units; preferably, the processor may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface and application programs, etc., and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor.

[0053] The mobile phone also includes a power source (such as a battery) for supplying power to various components. Preferably, the power source can be logically connected to the processor through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.

[0054] Although not shown, the mobile phone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0055] In this embodiment, the processor included in the terminal device also has the following functions:

[0056] A data calculation program that performs methods for accurately matching domain names and variable domain names with IP.

[0057] If the computer device is a server, an embodiment of the present application also provides a server, which may have relatively large differences due to different configurations or performances, and may include one or more central processing units (CPU) (for example, one or more processors) and memories, and one or more storage media for storing applications or data (for example, one or more mass storage devices). Among them, the memory and the storage medium can be short-term storage or permanent storage. The program stored in the storage medium may include one or more modules, each of which may include a series of instruction operations on the server. Furthermore, the central processing unit may be configured to communicate with the storage medium and execute a series of instruction operations in the storage medium on the server.

[0058] The server may also include one or more power supplies, one or more wired or wireless network interfaces, one or more input and output interfaces, and / or one or more operating systems, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0059] In addition, an embodiment of the present application further provides a storage medium, wherein the storage medium is used to store a computer program, and the computer program is used to execute the method provided in the above embodiment.

[0060] The embodiments of the present application also provide a computer program product including instructions, which, when executed on a computer, enables the computer to execute the method provided in the above embodiments.

[0061] A person of ordinary skill in the art can understand that all or part of the steps of implementing the above method embodiment can be completed by hardware related to program instructions, and the aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it executes the steps of the above method embodiment; and the aforementioned storage medium can be at least one of the following media: read-only memory (English: Read-only Memory, abbreviated: ROM), RAM, magnetic disk or optical disk, etc. Various media that can store program codes.

[0062] It should be noted that each embodiment in this specification is described in a progressive manner, and the same and similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The device and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without creative work.

Claims

1. A method for accurately matching domain names and variable domain names with IP, characterized in that: The following steps are involved: The DNS ports that monitor all specified network ports are captured using libpcap; Distinguish IP / ARP / RARP packets through shift operations; Parse the IP packet to obtain the fragment offset, and calculate the upper layer of the Protocol as TCP / UDP / ICMP through the offset; The hash algorithm matches the questions and answers values ​​under the query area; Get the new IP correspondence in the DNS reply packet, and give it to the flow control in real time through the shared memory to end the process; Distinguish IP / ARP / RARP packets by shift operation Specific steps: Read data packets: First, you need to read data packets from the network, use the pcap_loop() or pcap_dispatch() function of the libpcap library to achieve this, and pass the captured data packets to the specified callback function for processing; Extract data packet header: When processing each data packet, you need to extract its header information; The header of the IP data packet contains version, header length, service type, total length, identifier, flag, fragment offset and time to live (TTL) fields, while the headers of ARP and RARP data packets contain different fields; Determine the protocol type: According to the extracted packet header information, it can be determined which protocol the packet is; Determine the operation type: For ARP and RARP packets, it is also necessary to determine their operation type. The operation type field 0x0001 of the ARP packet indicates a request, and 0x0002 indicates a response. The operation type field 0x8035 of the RARP packet indicates a request, and 0x8036 indicates a response; Process the packet: According to the determined protocol type and operation type, different packets can be processed differently; To parse the IP packet and obtain the fragment offset, and then calculate the upper layer of the protocol as TCP, UDP or ICMP based on the offset, the specific steps are as follows: Read the IP packet: First, you need to capture the IP packet from the network, and the captured IP packet will be passed to the processing function as a parameter of the callback function; parse the IP packet: In the processing function, you need to parse the captured IP packet. The structure of the IP packet includes version, header length, service type, total length, identifier, flag, fragment offset and time to live (TTL) field. The structure can be used to represent the various fields of the IP packet; extract the fragment offset: After parsing the IP packet, you can extract the fragment offset field; determine the protocol type: The protocol type can be determined based on the value of the fragment offset; process the protocol data: Different protocol data can be processed differently based on the determined protocol type.

2. The method for accurately matching domain names and variable domain names with IPs according to claim 1, characterized in that: It also includes identifying the IP aging period in the CDN distribution network, the local DNS re-obtaining the cache server IP provided by the global load balancer of the CDN network, modifying the IP header TOS life cycle & 0xFF; obtaining the new IP correspondence in the DNS reply packet, and ending the process.

3. The method for accurately matching domain names and variable domain names with IPs according to claim 1, characterized in that: Monitor the DNS ports of all specified network ports using libpcap. Use libpcap to capture the DNS port data packets of all specified network ports, including opening the network device: use the pcap_open_live() function to open the network device. The device name is usually "eth0", the device type is "net80281", the data link layer type is "DLT_EN10MB", and the network mask of the network device interface is specified; Compile filtering policy: Use the pcap_compile() function to compile the user-specified filtering policy into the filtering program; Set the filter: Use the pcap_setfilter() function to apply the filter compiled in the previous step to the network device; Capture data packets: Use the pcap_loop() or pcap_dispatch() function to capture data packets; Process data packets: In the callback function, you can perform various operations on the captured data packets; Close the network device: When the application completes its work, you can call the pcap_close() function to close the network device and release resources.

Citation Information

Patent Citations

  • Correlating network traffic to their OS processes using packet capture libraries and kernel monitoring mechanisms

    US20200099600A1