Internet protocol version 4 (IPv4) and Internet protocol version 6 (IPv6) dual-stack-based interaction realization method, equipment, medium and product
By automatically detecting and adapting IPv4 and IPv6 network parameters, the problem of cumbersome operation and inconsistency caused by manual configuration is solved, and efficient and accurate dynamic configuration of network devices is achieved.
Patent Information
- Application Number
- CN202511238907.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-01
- Publication Date
- 2025-12-05
AI Technical Summary
In existing technologies, configuring dual-stack IPv4 and IPv6 networks relies on manual settings, which leads to cumbersome operations and is prone to inconsistencies, especially when the network environment changes and needs to be readjusted.
By constructing probe packets when the network device starts up, it automatically detects and parses response packets from the communication network, obtains network parameters, and configures dual-stack protocol stack parameters according to predefined rules, thereby achieving automatic detection and adaptation of IPv4 and IPv6 network parameters.
It simplifies network management, improves configuration efficiency and accuracy, and enables dynamic adjustment of network configuration, avoiding errors and inconsistencies caused by manual configuration.
Smart Images

Figure CN121077892A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of network communication technology, and in particular to an IPv4 and IPv6 dual stack based interaction implementation method, device, medium and product. BACKGROUND
[0002] In the field of network communication, IPV4 and IPV6 are two main versions of Internet Protocol. IPV4 uses 32-bit address and has been widely used for many years, but the address space is limited. IPV6 uses 128-bit address and has huge address space, which can meet the future network development needs. Dual stack technology allows network devices to run IPV4 and IPV6 protocol stacks simultaneously, and realizes the interconnection of two protocol networks. This is the basic technology widely used in the current IPV4 to IPV6 transition phase.
[0003] In the existing dual stack transition technology, network configuration mainly depends on manual setting. Network administrators need to manually input IPV4 and IPV6 network mask, gateway, DNS server and other parameters to configure the dual stack protocol stack of the device according to the network environment. For example, when deploying new network devices in an enterprise network, the administrator needs to fill in the corresponding network parameters one by one in the device management interface for IPV4 and IPV6 protocols respectively. SUMMARY
[0004] The present application provides an IPv4 and IPv6 dual stack based interaction implementation method, device, medium and product to solve the technical problems of tedious operation and inconsistent configuration caused by manual configuration and adjustment of configuration parameters in the prior art.
[0005] According to an aspect of the present application, an IPv4 and IPv6 dual stack based interaction implementation method is provided, comprising:
[0006] In response to a start operation of a network device, a corresponding probe data packet is constructed based on a data packet format matching a current protocol stack adopted by the network device, and the probe data packet is sent to a communication network matching the protocol stack;
[0007] The response data packet returned by the communication network is received and parsed to obtain corresponding network parameters;
[0008] The corresponding dual stack protocol stack parameters are configured according to a predefined rule and the network parameters.
[0009] According to another aspect of the present application, an IPv4 and IPv6 dual stack based interaction implementation device is provided, comprising:
[0010] The constructing module is configured to, in response to a starting operation of the network device, construct a corresponding probe data packet based on a data packet format matching a current protocol stack adopted by the network device, and send the probe data packet to a communication network matching the protocol stack.
[0011] The receiving and analyzing module is configured to receive and analyze a response data packet returned by the communication network to obtain corresponding network parameters.
[0012] The configuring module is configured to configure corresponding dual-stack protocol stack parameters according to a predefined rule and the network parameters.
[0013] According to another aspect of the present application, an electronic device is provided, which comprises:
[0014] at least one processor; and
[0015] a memory connected to the at least one processor in communication; wherein,
[0016] the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the IPv4 and IPv6 dual-stack based interaction implementation method according to any one of the embodiments of the present application.
[0017] According to another aspect of the present application, a computer readable storage medium is provided, which stores computer instructions for enabling a processor to execute the IPv4 and IPv6 dual-stack based interaction implementation method according to any one of the embodiments of the present application when executed by the processor.
[0018] According to another aspect of the present application, a computer program product is provided, which comprises a computer program for enabling a processor to execute the IPv4 and IPv6 dual-stack based interaction implementation method according to any one of the embodiments of the present application when executed by the processor.
[0019] The technical scheme of the embodiment of the present application is that when the network device is started, a corresponding probe data packet is constructed based on a data packet format matched with a current protocol stack adopted by the network device, and the probe data packet is sent to a communication network matched with the protocol stack; a response data packet returned by the communication network is received and analyzed to obtain corresponding network parameters; and corresponding dual-stack protocol stack parameters are configured according to a predefined rule and the network parameters, thereby solving the technical problem in the prior art that manual configuration of network parameters consumes a large amount of time and manpower, is prone to errors, and needs to be manually adjusted and configured again when the network environment changes, such as addition of a network device or change of a network topology, which is tedious and prone to cause inconsistent configuration, and realizing automatic detection and adaptation of IPV4 and IPV6 network parameters of the network device, dynamic adjustment of network configuration, simplification of network management work, and improvement of configuration efficiency and accuracy.
[0020] It should be understood that the content described in this part is not intended to identify key or important features of the embodiments of the present application, nor is it intended to limit the scope of the present application. Other features of the present application will become apparent from the following description. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort.
[0022] Figure 1 is a flow chart of an interactive implementation method based on IPv4 and IPv6 dual stacks provided by the embodiment of the present application;
[0023] Figure 2 is a structural schematic diagram of an interactive implementation device based on IPv4 and IPv6 dual stacks provided by the embodiment of the present application;
[0024] Figure 3 is a structural block diagram of an electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the present application scheme, the technical solutions in the embodiments of the present application will be described clearly and completely in the following with reference to the drawings of the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort should be within the scope of protection of the present application.
[0026] It is to be understood that the terms "first", "second", and the like used in the description and the claims of the present application as well as the above-described drawings do not necessarily have to connote any ordinal, sequential or priority relationship, and are merely intended to distinguish different classes or groups of objects for the sake of description. It is to be understood that the use of the terms "including", "comprising", or "having" and variations thereof herein are meant to encompass the inclusion of one or more steps or units, for example, of a process, method, system, product or apparatus, without necessarily limiting those steps or units to the clearly corresponding ones recited in the description. Further, the use of the terms "first", "second", and the like does not connote any ordinal, sequential or priority relationship, and are merely intended to distinguish different classes or groups of objects for the sake of description.
[0027] In an embodiment, Figure 1 is a flowchart of an IPv4 and IPv6 dual stack based interaction implementation method provided by an embodiment of the present application. The embodiment can be applied to automatically detect and adapt network parameters and dynamically adjust network configuration parameters of a dual stack protocol stack. The method can be executed by an IPv4 and IPv6 dual stack based interaction implementation device. The device can be implemented in the form of hardware and / or software, and can be configured in a network device. As shown in the figure, the method comprises the following steps. Figure 1
[0028] S110, in response to a start operation of the network device, constructing a corresponding probe data packet based on a data packet format matched with a current protocol stack adopted by the network device, and sending the probe data packet to a communication network matched with the protocol stack.
[0029] In an example, the current protocol stack refers to a protocol stack currently adopted by the network device. For example, the current protocol stack can include an IPv4 protocol stack, an IPv6 protocol stack, or both an IPv4 protocol stack and an IPv6 protocol stack. It can be understood that the data packet format corresponding to different protocol stacks is different.
[0030] In an example, after the network device is started, an intelligent detection program is loaded. The intelligent detection program can include a network communication module, a data analysis module, and a parameter storage module. The network communication module is used to construct and send a probe data packet and receive a response data packet, and is implemented based on a Python socket library. The data analysis module is used to analyze the received response data packet, extract network parameters, and use regular expressions and bit operations. The parameter storage module temporarily stores the analyzed parameters for subsequent configuration and use, and uses a Python dictionary data structure.
[0031] In an example, for IPV4 network detection, the constructed data packet format is as follows:
[0032] The data packet header includes an IPV4 packet header with a fixed length of 20 bytes, wherein the version field is 4, the header length field is 5 (indicating 20 bytes), the differentiated service field is 0, the total length field is the overall length of the data packet (including the packet header and the data part), the identification field is a randomly generated 16-bit integer for data packet identification, the flag field is 0, the fragment offset field is 0, the time to live field is set to 64, the protocol field is 17 (indicating the UDP protocol), the header checksum field is initially set to 0 (which will be calculated and filled in by the network device later), the source IP address field is set to the temporary IP address of the network device itself (such as 0.0.0.0), and the destination IP address field is set to the broadcast address 255.255.255.255.
[0033] The data packet data part includes custom detection request data with a length of 10 bytes. The first 4 bytes are a specific request identifier with a value of 0x12345678, which is used to identify that the data packet is a network parameter detection request; the last 6 bytes are a reserved field, which is initially set to 0.
[0034] In an example, for IPV6 network detection, the constructed data packet format is as follows:
[0035] The data packet header includes an IPV6 packet header with a fixed length of 40 bytes, wherein the version field is 6, the traffic class field is 0, the flow label field is 0, the payload length field is the length of the data packet data part, the next header field is 17 (indicating the UDP protocol), the hop limit field is set to 64, the source IP address field is set to the temporary IPV6 address of the network device itself (such as ::), and the destination IP address field is set to the multicast address ff02::1 (used for all nodes within the link-local scope).
[0036] The data packet data part also includes custom detection request data with a length of 10 bytes. The first 4 bytes are a request identifier with a value of 0x87654321, which is different from the IPV4 detection request identifier, and the last 6 bytes are a reserved field, which is initially set to 0.
[0037] In an embodiment, the network device can send the constructed IPV4 and IPV6 detection data packets to the corresponding network through the socket library.
[0038] S120, receiving and analyzing the response data packet returned by the communication network to obtain the corresponding network parameters.
[0039] In an example, the network device can continuously monitor the network port, waiting to receive a response data packet. When an IPV4 response data packet is received, the header checksum field of the IPV4 packet header is first checked to ensure data packet integrity, and if the checksum is correct, the data packet is passed to the data parsing module; if it is incorrect, the data packet is discarded and the probe data packet is resent. For IPV6 response data packets, the data packet integrity is also checked first, by verifying the correctness of the next header field and the checksum of the IPV6 packet header (the IPV6 packet header does not contain a special checksum field, but the integrity is ensured through mechanisms such as header extension), and if it is complete, it is passed to the data parsing module.
[0040] In an example, the IPV4 network parameter parsing process includes the following steps:
[0041] Step 1, the data parsing module extracts the network mask from the packet header of the IPV4 response data packet. By converting the network mask field value to binary form, the number of consecutive 1s is detected from high to low bit by bit, and the network mask bit number is determined.
[0042] Step 2, the gateway address is extracted. In a specific field of the response data packet (such as the sender IP address field in ARP response, if the response is sent by a router, the address is the gateway address), the address string that meets the format is matched according to the IPV4 address format specification through a string matching algorithm.
[0043] Step 3, the DNS server address is extracted. In the DNS related field of the response data packet, the IP address of the DNS server is obtained according to the same IPV4 address format matching rule.
[0044] In an example, the IPV6 network parameter parsing process includes the following steps:
[0045] Step 1, the network prefix is extracted from the packet header of the IPV6 response data packet. The network prefix is obtained by parsing the first 64 bits of the IPV6 address.
[0046] Step 2, the gateway address is extracted. In the response data packet of the IPV6 Neighbor Discovery Protocol (NDP), the IPV6 address of the gateway is obtained according to the target address option field.
[0047] Step 3, the DNS server address is extracted. In the IPV6 record of the DNS response data packet, the resource record containing the DNS server address is found, and the IPV6 address of the DNS server is obtained.
[0048] S130, according to the predefined rule and the network parameter configuration, the corresponding dual stack protocol stack parameter is configured.
[0049] In an example, the predefined rule is as follows:
[0050] If the network device is a router, and the detected IPV4 network mask is 255.255.255.0, the gateway is 192.168.1.1, and the DNS server is 192.168.1.2; the IPV6 network prefix is 2001:db8:: / 64, the gateway is 2001:db8::1, and the DNS server is 2001:db8::2. In the dual stack protocol stack configuration, the network mask of the IPV4 protocol stack is set to 255.255.255.0, the gateway is set to 192.168.1.1, and the DNS server list is added to 192.168.1.2; the network prefix of the IPV6 protocol stack is set to 2001:db8:: / 64, the gateway is set to 2001:db8::1, and the DNS server list is added to 2001:db8::2.
[0051] If the network device is a terminal device, in addition to the above parameter settings, the IPV4 address is set to automatic acquisition (through the DHCP protocol) when configuring the IPV4 protocol stack; when configuring the IPV6 protocol stack, if stateless address autoconfiguration (SLAAC) is supported, the IPV6 address is automatically generated and configured according to the detected network prefix.
[0052] In an example, the configuration strategy can include:
[0053] For the IPV4 protocol stack, the network mask, gateway, and DNS server address parsed are written into the corresponding configuration file through the network configuration interface of the operating system or directly set through the command.
[0054] For the IPV6 protocol stack, in the case of supporting SLAAC, the device automatically generates an interface ID according to the network prefix, combines it into a complete IPV6 address, and configures it. For parameters such as DNS server addresses, the network configuration interface of the operating system is also used for configuration.
[0055] The technical scheme of the embodiment solves the technical problems in the prior art that manual configuration of network parameters consumes a lot of time and manpower, is prone to errors, and when the network environment changes, such as the addition of a network device or changes in the network topology, the configuration needs to be manually adjusted again, which is tedious and prone to inconsistent configurations, by constructing a corresponding probe data packet based on a data packet format matching the current protocol stack used by the network device when the network device starts, sending the probe data packet to a communication network matching the protocol stack, receiving and parsing the response data packet returned by the communication network to obtain corresponding network parameters, and configuring corresponding dual stack protocol stack parameters according to predefined rules and network parameters, which realizes automatic detection and adaptation of IPV4 and IPV6 network parameters by the network device, as well as dynamic adjustment of network configuration, simplifies network management work, and improves configuration efficiency and accuracy.
[0056] In an embodiment, the method for implementing IPv4 and IPv6 dual stack based interaction further comprises the following steps in case of updating the DNS server address in the dual stack protocol stack parameter:
[0057] backing up the original DNS server address in the dual stack protocol stack parameter into a temporary file;
[0058] In the process of modifying the DNS server address, if an update error occurs, the original DNS server address is used for configuration recovery.
[0059] In an example, the intelligent network configuration module sets the network message listening frequency to 10 times per second. The network message listening operation is triggered once every 0.1 second using the timing task library, and the change information such as route advertisement messages and ARP update messages in the network is captured in time.
[0060] In the process of adjusting the configuration, the strategy of first backup and then modification can be used. When the DNS server address in the dual stack protocol stack needs to be updated, the original DNS server configuration information is first backed up into a temporary file. If an error occurs in the modification process, the original DNS server address can be used to quickly restore the original configuration to ensure that the network communication is not affected.
[0061] In an embodiment, the method for implementing IPv4 and IPv6 dual stack based interaction further comprises the following steps:
[0062] Upon receiving the route advertisement message, the message type of the route advertisement message is obtained;
[0063] If the message type is a new route message, the related information of the new route is obtained, and the related information of the new route is added to the corresponding route table;
[0064] If the message type is a delete route message, the network prefix of the route to be deleted is extracted, and the route entry corresponding to the route to be deleted is deleted from the route table;
[0065] If the message type is a modify route message, the related information of the route to be modified is extracted, and the route entry corresponding to the route to be modified is updated in the route table.
[0066] In an example, the route advertisement message monitoring algorithm based on the state machine comprises:
[0067] The state machine is initially in a "waiting state". When the module receives a route advertisement message, it enters a "message analysis state". In this state, the message type of the route advertisement message (such as a new route message, a delete route message, a modify route message, etc.) is analyzed.
[0068] If it is a new route message, the network prefix, next hop address and other information of the new route are extracted, and the "route table updating state" is entered. In this state, the new route information is added to the IPV4 or IPV6 route table (determined according to the protocol type to which the message belongs). After the update is completed, the "waiting state" is returned to.
[0069] If it is a delete route message, the network prefix of the route to be deleted is extracted, and the "route table deletion state" is entered. In this state, the corresponding route entry is deleted from the route table, and then the "waiting state" is returned to.
[0070] If it is a modify route message, the modified route information is extracted, and the "route table modification state" is entered. In this state, the corresponding route entry in the route table is updated, and then the "waiting state" is returned to.
[0071] In an embodiment, the method for realizing interaction based on IPv4 and IPv6 dual stack further comprises:
[0072] sending a query request to a known DNS server to obtain the latest DNS server list;
[0073] based on the original DNS server list and the latest DNS server list, corresponding hash tables are respectively constituted, and an original hash table and a new hash table are obtained;
[0074] based on the key-value pairs contained in the new hash table and the original hash table, the DNS server addition and deletion situation is determined.
[0075] In an example, the hash table comparison algorithm is used in the DNS server list updating process, which comprises:
[0076] The module periodically sends a query request to a known DNS server to obtain the latest DNS server list. The original DNS server list and the newly obtained list are respectively constructed into hash tables.
[0077] For the original DNS server list, the IP address of the DNS server is taken as the key value to construct a hash table. For example, if the original list has DNS servers 192.168.1.2 and 2001:db8::2, the corresponding key-value pairs in the hash table are {“192.168.1.2”: None, “2001:db8::2”: None} (the value is None because only the existence of the address is concerned here).
[0078] For the newly obtained DNS server list, the IP address is also taken as the key value to construct a hash table. Then, the key-value pairs of the two hash tables are compared.
[0079] If there is a key-value pair in the new hash table that does not exist in the original hash table, it indicates that there is a new DNS server. If there is a key-value pair in the original hash table that does not exist in the new hash table, it indicates that a DNS server is deleted. In this way, the newly added or deleted DNS server address is quickly found, so as to perform subsequent dual stack protocol stack configuration update.
[0080] In an example, the implementation process of the dual stack protocol stack parameter includes the following steps:
[0081] Step 1, starting the monitoring program: the intelligent network configuration module starts a continuously running monitoring thread, and after the thread is started, the message listening loop is entered.
[0082] Step 2, listening to network messages: every 0.1 seconds, the monitoring thread obtains the route advertisement message, ARP update message and the like in the network through the network interface of the operating system.
[0083] Step 3, judging the message type: for the received message, first judge its type. If it is a route advertisement message, the message is passed to the route advertisement message monitoring algorithm based on the state machine for processing; if it is an ARP update message, it is judged whether it is related to the IPV4 or IPV6 network parameter (such as ARP update involving gateway address change, etc.), if it is related, the corresponding parameter update process is entered. If the message is a DNS server query response message, the newly obtained DNS server list is passed to the hash table comparison algorithm for comparison with the original DNS server list.
[0084] Step 4, performing corresponding adjustment operation:
[0085] If it is a route advertisement message:
[0086] If it is a new route, the new route information obtained according to the algorithm based on the state machine is called to update the function of the route table of the operating system, and the new route is added to the route table of IPV4 or IPV6.
[0087] If it is a deleted route, the route network prefix to be deleted obtained by parsing is called to the corresponding route table deletion function, and the route entry is deleted from the route table.
[0088] If it is a modified route, the modified route information obtained by parsing is also called to update the function of the route table, and the corresponding entry in the route table is updated.
[0089] If it is a DNS server list update:
[0090] According to the hash table comparison algorithm, if there is a new DNS server, the new DNS server address is added to the DNS server list of the IPV6 protocol stack through the network configuration interface of the operating system.
[0091] If there is a deleted DNS server, the corresponding address is removed from the DNS server list of the IPV6 protocol stack. The same operation is also applied to the DNS server list update of the IPV4 protocol stack.
[0092] Step 5: Complete dynamic adjustment: after completing the above operations such as route table update or DNS server list update, record the adjustment operation log, including adjustment time, adjustment content and other information.
[0093] In an embodiment, the method for implementing interaction based on IPv4 and IPv6 dual stack further comprises:
[0094] In response to receiving the address conversion request, the address conversion request is added to a pre-created request queue;
[0095] An IPv4 address in one address conversion request is obtained from the request queue, and the IPv4 address is taken as a key value to query a corresponding IPv6 address from a cache area;
[0096] If no valid IPv6 address is queried in the cache area, a matching IPv6 address is found based on the IPv4 address in a first address conversion table; wherein the first address conversion table stores a mapping relationship between a hash value and an IPv4-IPv6 address mapping relationship in a two-dimensional array;
[0097] If no matching IPv6 address is queried in the first address conversion table, a matching IPv6 address is found based on the IPv4 address in a second address conversion table; wherein the second address conversion table stores a mapping relationship between a hash value and an IPv4-IPv6 address mapping relationship in a linear linked list structure;
[0098] The IPv6 address is returned to the requester.
[0099] In an example, the cache area can be a high-speed cache area.
[0100] In an example, the operation flow of the optimized NAT-PT algorithm comprises the following steps:
[0101] Step 1, receiving address translation request: When the network device receives an IPV4 to IPV6 address translation request, the request first enters the request queue of the address translation engine. The queue uses a first-in first-out (FIFO) data structure to ensure that requests are processed in the order of receipt. In the Python implementation, the Queue class of the queue module can be used to build the request queue.
[0102] Step 2, cache query: Take an address translation request from the request queue and get the IPV4 address in the address translation request. Use the IPV4 address as the key value to query the corresponding IPV6 address mapping in the cache area. The cache area is implemented using the dictionary data structure of Python, for example, the cache dictionary is cache = {}, and the query operation is performed through the cache.get(ipv4_address) method. If the query hits, that is, cache.get(ipv4_address) returns a valid IPV6 address, then the IPV6 address is directly returned as the conversion result to the requester, completing the address translation; if the query does not hit, then the address translation table lookup process is entered.
[0103] Step 3, address translation table lookup: Hash operation is performed on the IPV4 address. The division hash method is used to convert the IPV4 address to a 32-bit integer (for example, the IPV4 address 192.168.1.1 is converted to 3232235777), and then the integer is divided by the size of the address translation table (assuming the size of the address translation table is 1024), and the remainder is taken as the hash value. For example, 3232235777 % 1024 = 897, the hash value 897 is obtained.
[0104] According to the obtained hash value, the corresponding hash bucket position in the address translation table is located. The address translation table (i.e. the first address translation table mentioned above) is implemented using a two-dimensional array, for example, address_translation_table = [[], [], …, []], the length is 1024, and each element is a linked list (i.e. a hash bucket). The hash bucket corresponding to the hash value 897 is address_translation_table
[897] .
[0105] Exact matching is performed in the hash bucket. Each element in the hash bucket (each element is an IPV4-IPV6 address mapping pair (also referred to as an IPv4-IPv6 address mapping relationship)) is traversed, and it is found whether there is a mapping relationship matching the IPV4 address in the request by comparing the IPV4 address. If the matching mapping relationship is found, the corresponding IPV6 address is returned as the conversion result to the requester, and the mapping relationship is stored in the cache area for subsequent use. If the matching mapping relationship is not found in the hash bucket, other backup conversion strategies (such as starting the traditional NAT-PT algorithm for conversion) are performed.
[0106] Step 4, backup conversion strategy execution: when the matching mapping relationship is not found in the address conversion table, the traditional NAT-PT algorithm is started for conversion. First, the IPV4-IPV6 address mapping is sequentially traversed and found in the traditional address conversion table (the mapping relationship is stored in a linear linked list structure, that is, the second address conversion table described above). If the matching relationship is found, the conversion result is returned, and the mapping relationship is stored in the hash bucket of the optimized address conversion table and the cache area at the same time, so as to facilitate subsequent fast search; if the matching relationship is not found after traversing the traditional address conversion table, the address conversion failure information is returned to the requester.
[0107] The technical scheme of the embodiment can automatically detect and adapt the algorithm, so that the network device can quickly and automatically complete network configuration when accessing the network, without manual operation of the administrator, thereby saving a large amount of time and manpower. The dynamic adjustment mechanism can respond to network environment changes in real time, automatically update the configuration, avoid errors and inconsistencies that may occur during manual adjustment, and improve the accuracy and efficiency of network configuration.
[0108] In an embodiment, the IPv4 and IPv6 dual-stack interaction implementation method further includes:
[0109] In the case that the new IPV4-IPV6 address mapping relationship is detected to be stored in the cache area and the cache area is not full, a new cache item node is created, the IPV4 address is taken as a key value, and the IPV6 address is taken as a value, which are inserted into the head of the double-linked list and the corresponding key value pair is added in the hash table;
[0110] In the case that the new IPV4-IPV6 address mapping relationship is detected to be stored in the cache area and the cache area is full, the cache item that is not used within a preset time length is deleted from the tail of the double-linked list, and the corresponding key value pair is deleted in the hash table;
[0111] When the mapping relationship query operation is detected, the corresponding double-linked list node is located through the hash table, and the double-linked list node is moved from the current position to the head of the double-linked list, and the IPV6 address mapping result in the double-linked list node is returned.
[0112] In an example, the implementation process of the cache management algorithm (LRU algorithm) includes:
[0113] The cache area adopts a data structure combining a double-linked list and a hash table to implement the LRU algorithm. The double-linked list is used to maintain the access order of the cache items, and the hash table is used to quickly locate the position of the cache item in the double-linked list.
[0114] When a new IPV4-IPV6 address mapping relationship needs to be stored in the cache:
[0115] First, check whether the cache area is full. If not, create a new cache item node, take the IPV4 address as the key value, and the IPV6 address as the value, and insert it into the head of the double-linked list (indicating recent use), and add the corresponding key-value pair in the hash table (the key is the IPV4 address, and the value is the reference of the double-linked list node).
[0116] If the cache area is full, according to the LRU algorithm, the least recently used cache item needs to be evicted. Find the tail node of the double-linked list (i.e. the least recently used node), delete the node from the double-linked list, and delete the corresponding key-value pair in the hash table. Then create a new cache item node, insert it into the head of the double-linked list, and update the hash table.
[0117] When performing cache query: quickly locate the corresponding double-linked list node through the hash table. If the node is found, move the node from the current position to the head of the double-linked list (indicating recent use), and then return the IPV6 address mapping result in the node. If the corresponding key-value pair is not found in the hash table, it means that the cache is not hit.
[0118] In an embodiment, the IPv4 and IPv6 dual-stack interaction implementation method further includes:
[0119] In response to receiving the address conversion request, adding the address conversion request to a pre-created request queue;
[0120] Using a load balancing algorithm to distribute the address conversion tasks corresponding to the address conversion requests in the request queue to multiple processing units, so that each processing unit performs address conversion operations in parallel to obtain address conversion results;
[0121] According to the request order, the address conversion results are returned to the requestor in sequence.
[0122] In an example, the parallel conversion processing process for efficient address conversion includes the following steps:
[0123] Step 1, receive the address conversion request queue:
[0124] The address translation request of the network device first enters a unified request queue, which is implemented by the Queue class of the Python queue module to ensure that the requests are arranged in the order of reception.
[0125] Step 2, task allocation module starts:
[0126] The task allocation module is implemented based on Python's multi-threading or multi-processing technology (in a multi-core processor environment, multi-processing is preferred to fully utilize CPU resources). The task allocation module allocates address translation tasks in the request queue to multiple processing units according to a load balancing algorithm.
[0127] Step 3, load balancing algorithm execution:
[0128] Round-robin algorithm example: Assuming the network device has 8 processing units (corresponding to an 8-core processor), the task allocation module assigns requests to the 8 processing units in order. For example, the 1st request is assigned to processing unit 1, the 2nd request is assigned to processing unit 2,..., the 8th request is assigned to processing unit 8, and the 9th request is assigned to processing unit 1, and so on.
[0129] Weight-based load balancing algorithm example: Each processing unit is assigned a weight based on its performance indicators (such as CPU frequency, cache size, etc.). Assuming that processing unit 1 has a weight of 2, processing unit 2 has a weight of 3,..., and processing unit 8 has a weight of 1. The task allocation module assigns requests according to the number of requests in the request queue and the weight proportion. For example, if there are 10 requests, according to the weight sum (2+3+…+1=28), processing unit 1 is assigned approximately 10*(2 / 28)≈1 requests, processing unit 2 is assigned approximately 10*(3 / 28)≈1 requests (rounded up or down according to the specific implementation strategy), and so on, ensuring that the load of each processing unit is relatively balanced.
[0130] Step 4, processing unit performs address translation:
[0131] Each processing unit independently performs address translation operations after receiving the assigned tasks. Each processing unit has its own independent cache and address translation table copy. Taking processing unit 1 as an example, when it receives an IPV4 to IPV6 address translation request, it first queries in its own cache. The cache query process is consistent with that in the optimized NAT-PT algorithm. If the cache hits, it returns the translation result directly; if the cache misses, it searches in its own address translation table copy. The address translation table lookup process is also consistent with that in the optimized NAT-PT algorithm.
[0132] Step 5, result aggregation and return:
[0133] After each processing unit completes address translation, the result is returned to the task allocation module. The task allocation module aggregates all the results returned by the processing units, and returns the translation results to the requester in the original order of the request. For example, the requester sends 3 address translation requests, processing units 1, 3 and 5 process the 3 requests respectively, and the task allocation module receives the results returned by processing units 1, 3 and 5, and returns the results to the requester in the order of the request.
[0134] The technical scheme of the embodiment optimizes the NAT-PT algorithm by using the cache mechanism and the hash table structure, greatly shortens the address translation lookup time, and the parallel conversion processing mechanism fully utilizes the multi-core processor resources. In the case of a large number of address translation requests, the conversion can be quickly completed, the network communication efficiency is improved, and compared with the traditional way, the address translation speed can be improved by several times or even dozens of times. Moreover, the protocol adaptive technology can automatically select the optimal protocol according to the network application and scene, and improve the network performance. The data format adaptation module ensures correct data transmission between different protocol networks, enhances the compatibility of the dual-stack network, reduces data transmission errors, and improves user experience.
[0135] In an embodiment, Figure 2 is a structural schematic diagram of an interactive implementation device based on IPv4 and IPv6 dual stack provided by the embodiment of the application. As Figure 2 shown, the device comprises a configuration module 210, a receiving and analyzing module 220 and a configuration module 230.
[0136] The configuration module 210 is configured to, in response to a start operation of a network device, construct a corresponding probe data packet based on a data packet format matched with a current protocol stack adopted by the network device, and send the probe data packet to a communication network matched with the protocol stack.
[0137] The receiving and analyzing module 220 is configured to receive and analyze a response data packet returned by the communication network to obtain corresponding network parameters.
[0138] The configuration module 230 is configured to configure corresponding dual-stack protocol stack parameters according to a predefined rule and network parameters.
[0139] In an embodiment, in the case of updating the DNS server address in the dual-stack protocol stack parameters, the interactive implementation device based on IPv4 and IPv6 dual stack further comprises:
[0140] The backup module is configured to backup the original DNS server address in the dual-stack protocol stack parameters to a temporary file.
[0141] The recovery module is configured to, in the process of modifying the DNS server address, if an update error occurs, configure recovery using the original DNS server address.
[0142] In an embodiment, the device for implementing interaction based on IPv4 and IPv6 dual stacks further comprises:
[0143] The acquisition module is configured to, when receiving the route advertisement message, acquire a message type of the route advertisement message.
[0144] The adding module is configured to, if the message type is a new route message, acquire related information of a new route, and add the related information of the new route into a corresponding route table.
[0145] The deleting module is configured to, if the message type is a delete route message, extract a network prefix of a route to be deleted, and delete a route entry corresponding to the route to be deleted from the route table.
[0146] The modifying module is configured to, if the message type is a modify route message, extract related information of a route to be modified, and update a route entry corresponding to the route to be modified in the route table.
[0147] In an embodiment, the device for implementing interaction based on IPv4 and IPv6 dual stacks further comprises:
[0148] The acquisition module is further configured to send a query request to a known DNS server, and acquire a latest DNS server list.
[0149] The construction module is configured to respectively construct corresponding hash tables based on an original DNS server list and the latest DNS server list, to obtain an original hash table and a new hash table.
[0150] The determination module is configured to determine DNS server addition and deletion based on key-value pairs contained in the new hash table and the original hash table.
[0151] In an embodiment, the device for implementing interaction based on IPv4 and IPv6 dual stacks further comprises:
[0152] The adding module is configured to, in response to receiving an address conversion request, add the address conversion request into a request queue created in advance.
[0153] The query module is configured to acquire an IPv4 address in an address conversion request from the request queue, and query a corresponding IPv6 address from the cache area using the IPv4 address as a key value.
[0154] The finding module is configured to find the matched IPv6 address based on the IPv4 address in the first address conversion table if the valid IPv6 address is not found in the cache area; wherein the first address conversion table stores the mapping relationship between the hash value and the IPv4-IPv6 address mapping relationship in a two-dimensional array;
[0155] The finding module is further configured to find the matched IPv6 address based on the IPv4 address in the second address conversion table if the matched IPv6 address is not found in the first address conversion table; wherein the second address conversion table stores the mapping relationship between the hash value and the IPv4-IPv6 address mapping relationship in a linear linked list structure;
[0156] The sending module is configured to return the IPv6 address to the requester.
[0157] In an embodiment, the device for implementing the interaction based on the IPv4 and IPv6 dual stack further comprises:
[0158] The inserting module is configured to, in the case that the new IPv4-IPv6 address mapping relationship is detected to be stored in the cache area and the cache area is not full, create a new cache item node, insert the IPv4 address as the key value and the IPv6 address as the value into the head of the double linked list, and add the corresponding key value pair in the hash table;
[0159] The deleting module is configured to, in the case that the new IPv4-IPv6 address mapping relationship is detected to be stored in the cache area and the cache area is full, delete the cache item that is not used within the preset time length from the tail of the double linked list, and delete the corresponding key value pair in the hash table;
[0160] The returning module is configured to, in the case that the mapping relationship query operation is detected, locate the corresponding double linked list node through the hash table, move the double linked list node from the current position to the head of the double linked list, and return the IPv6 address mapping result in the double linked list node.
[0161] In an embodiment, the device for implementing the interaction based on the IPv4 and IPv6 dual stack further comprises:
[0162] The adding module is further configured to, in response to receiving the address conversion request, add the address conversion request into the request queue created in advance;
[0163] The allocating module is configured to distribute the address conversion task corresponding to the address conversion request in the request queue into the plurality of processing units by using the load balancing algorithm, so that each processing unit performs the address conversion operation in parallel to obtain the address conversion result;
[0164] The returning module is configured to return the address conversion result to the requester in sequence according to the request order.
[0165] The device for implementing interaction based on IPv4 and IPv6 dual stack provided by the embodiment of the present application can execute the method for implementing interaction based on IPv4 and IPv6 dual stack provided by any embodiment of the present application, and has the corresponding function modules and beneficial effects of the execution method.
[0166] In an embodiment, Figure 3 is a structural block diagram of an electronic device provided by an embodiment of the present application, as Figure 3 shown, a structural schematic diagram of an electronic device 10 that can be used to implement embodiments of the present application is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices (such as headsets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit the implementations of the present application described and / or claimed in this document.
[0167] As Figure 3 shown, the electronic device 10 includes at least one processor 11, and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11, wherein the memory stores a computer program that can be executed by the at least one processor, and the processor 11 can execute various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0168] A plurality of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network, such as the Internet, and / or various telecommunications networks.
[0169] The processor 11 can be various general and / or special purpose processing components having processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 performs various methods and processes described above, such as the IPv4 and IPv6 dual stack based interactive implementation method.
[0170] In some embodiments, the IPv4 and IPv6 dual stack based interactive implementation method can be implemented as a computer program tangibly embodied in a computer readable storage medium, such as the storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed onto the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded onto the RAM 13 and executed by the processor 11, one or more steps of the IPv4 and IPv6 dual stack based interactive implementation method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the IPv4 and IPv6 dual stack based interactive implementation method by any other appropriate means, such as by means of firmware.
[0171] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on a chip (SOC), a programmable logic device (PLD), a computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0172] Computer programs for implementing the methods of the present application can be written in any combination of one or more programming languages. These computer programs can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer program, when executed, can cause instructions defined in the flow charts and / or block diagrams to be implemented. The computer program can be executed entirely on a machine, partially on a machine, partially on a machine as a stand-alone software package, and partially on a remote machine or entirely on a remote machine or server.
[0173] In the context of the present application, a computer-readable storage medium can be a tangible medium that can contain or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. A computer-readable storage medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium can be a machine-readable signal medium. More specific examples of a machine-readable storage medium will include one or more lines of a program of instructions in a transitory signal, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0174] To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the electronic device. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0175] The systems and techniques described here can be implemented in a computing system that includes a back end component, e.g., as a data server, or that includes a middleware component, e.g., an application server, or that includes a front end component, e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here, or any combination of such back end, middleware, or front end components. The components of the system can be interconnected by any form or medium of digital data communication, e.g., a communication network. Examples of communication networks include a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0176] The computing system can include clients and servers. A client and server are generally remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. A server can be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system, to solve the defects of large management difficulty and weak business scalability in traditional physical host and VPS service.
[0177] The embodiment of the present application further provides a computer program product, comprising a computer program which can realize the IPv4 and IPv6 dual stack based interaction implementation method provided in any embodiment of the present application when executed by a processor.
[0178] The computer program code implementing the operations of the present application can be written in one or more programming languages or combinations of languages including object oriented languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).
[0179] It should be understood that the various forms of flow shown above can be used to reorder, add, or remove steps. For example, the steps recited in the present application can be performed in parallel, in series, or in a different order, as long as the desired results of the technical solutions of the present application can be achieved, which are not limited herein.
[0180] The above detailed description does not constitute a limitation on the protection scope of the present application. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for implementing IPv4 and IPv6 dual stack-based interaction, characterized in that, The method comprises: in response to a start operation of a network device, constructing a corresponding probe data packet based on a data packet format matching a current protocol stack adopted by the network device, and sending the probe data packet to a communication network matching the protocol stack; receiving and parsing a response data packet returned by the communication network to obtain corresponding network parameters; configuring corresponding dual-stack protocol stack parameters according to a predefined rule and the network parameters.
2. The method of claim 1, wherein, In the case of updating the DNS server address in the dual-stack protocol stack parameters, the method further comprises: backing up the original DNS server address in the dual-stack protocol stack parameters to a temporary file; in the process of modifying the DNS server address, if an update error occurs, the original DNS server address is used for configuration recovery.
3. The method of claim 1, wherein, The method further comprises: when a route advertisement message is received, obtaining the message type of the route advertisement message; if the message type is an added route message, obtaining the related information of the new route and adding the related information of the new route to a corresponding route table; if the message type is a deleted route message, extracting the network prefix of the route to be deleted, and deleting the route entry corresponding to the route to be deleted from the route table; if the message type is a modified route message, extracting the related information of the route to be modified, and updating the route entry corresponding to the route to be modified in the route table.
4. The method of claim 1, wherein, The method further comprises: sending a query request to a known DNS server to obtain the latest DNS server list; based on the original DNS server list and the latest DNS server list, respectively constructing corresponding hash tables to obtain an original hash table and a new hash table; based on the key-value pairs contained in the new hash table and the original hash table, determining the addition and deletion of DNS servers.
5. The method of claim 1, wherein, The method further comprises: in response to receiving an address conversion request, adding the address conversion request to a pre-created request queue; obtaining an IPv4 address in an address conversion request from the request queue, and querying a corresponding IPv6 address from a cache area using the IPv4 address as a key value; if no valid IPv6 address is queried in the cache area, finding a matching IPv6 address based on the IPv4 address in a first address conversion table; wherein the first address conversion table uses a two-dimensional array to store the mapping relationship between hash values and IPv4-IPv6 address mapping relationships; if no matching IPv6 address is queried in the first address conversion table, finding a matching IPv6 address based on the IPv4 address in a second address conversion table; wherein the second address conversion table uses a linear linked list structure to store the mapping relationship between hash values and IPv4-IPv6 address mapping relationships; returning the IPv6 address to the requester.
6. The method of claim 1, wherein, The method further comprises: In a case that a new IPv4-IPv6 address mapping relationship is detected to be stored in the cache area and the cache area is not full, a new cache item node is created, the IPv4 address is taken as a key value, and the IPv6 address is taken as a value, and is inserted into a head of the double-linked list, and a corresponding key value pair is added in the hash table; In a case that a new IPv4-IPv6 address mapping relationship is detected to be stored in the cache area and the cache area is full, a cache item that is not used within a preset time length is deleted from a tail of the double-linked list, and a corresponding key value pair is deleted in the hash table; In a case that a mapping relationship query operation is detected, a corresponding double-linked list node is located through the hash table, and the double-linked list node is moved from a current position to a head of the double-linked list, and an IPv6 address mapping result in the double-linked list node is returned.
7. The method of claim 1, wherein, The method further comprises: In response to receiving an address conversion request, adding the address conversion request into a request queue created in advance; Using a load balancing algorithm to distribute address conversion tasks corresponding to the address conversion requests in the request queue to a plurality of processing units, so that each processing unit performs an address conversion operation in parallel to obtain an address conversion result; Returning the address conversion result to a request party in a request order.
8. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected in communication with the at least one processor; wherein The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the IPv4 and IPv6 double stack based interaction implementation method in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for enabling the processor to execute the IPv4 and IPv6 double stack based interaction implementation method in any one of claims 1-7 when executed.
10. A computer program product, characterised in that, The computer program product comprises a computer program that, when executed by the processor, implements the IPv4 and IPv6 double stack based interaction implementation method according to any one of claims 1-7. The computer program product comprises a computer program that, when executed by the processor, implements the IPv4 and IPv6 double stack based interaction implementation method according to any one of claims 1-7.