Disclosure of Invention
The technical problem to be solved by the embodiment of the invention is to provide a network device and a method for automatically detecting an address configuration mode supported by an IPv6 network, which can simplify the process of automatically detecting the address configuration mode, improve the speed of automatically detecting the address configuration mode and improve the user experience.
In order to solve the above technical problems, in a first aspect, the present invention provides a network device for automatically detecting an address configuration mode supported by an IPv6 network, where the network device includes a WAN port and an automatic detection module connected to the WAN port, where the automatic detection module is specifically configured to:
Responding to an automatic detection instruction, sending a router request message from the WAN port according to a preset sending period, triggering an upper gateway of the network equipment to generate a router advertisement message aiming at the router request message, and sending the router advertisement message to the network equipment;
when receiving the router advertisement message, acquiring a managed address configuration zone bit in the router advertisement message;
And determining an address configuration mode supported by the IPv6 network accessed by the network equipment according to the managed configuration flag bit.
Further, the network device further comprises an IPv6 dialing control module, wherein before the automatic detection module responds to the automatic detection instruction, the IPv6 dialing control module is used for:
After the network equipment is accessed to an IPv6 network, detecting whether a user inputs a dial-up connection creation instruction or not;
When the dial-up connection creation instruction is detected, triggering the response of the automatic detection instruction, and creating a dial-up connection with an unspecified address configuration mode according to the connection information input by the user so that the network equipment can communicate with the superior gateway.
Further, the automatic detection module is further configured to:
setting parameter values of dialing zone bits according to the determined address configuration mode, wherein different parameter values of the dialing zone bits correspond to different address configuration modes;
the network device further includes an IPv6 dial control module, where the IPv6 dial control module is configured to:
obtaining the parameter value of the dialing zone bit according to a preset obtaining mode and a obtaining period;
And automatically starting an address configuration process of the address configuration mode corresponding to the parameter value of the dialing zone bit according to the acquired parameter value of the dialing zone bit.
Further, the learning mode is an active learning mode that the IPv6 dialing control module actively queries the automatic detection module for the parameter value of the dialing zone bit, or,
The learning mode is a passive learning mode that the automatic detection module reports the parameter value of the dialing zone bit to the IPv6 dialing control module.
Further, the automatic detection module is further configured to:
For each transmitted router solicitation message, when the router advertisement message corresponding to the router solicitation message is not received, increasing the value of the preset transmission times statistics parameter according to the preset value step length, and,
Judging whether the numerical value of the sending frequency statistical parameter is larger than a preset frequency threshold value or not;
When the numerical value of the sending frequency statistical parameter is larger than the frequency threshold, determining a preset default address configuration mode according to an address configuration mode supported by an IPv6 network accessed by the network equipment, and setting the parameter value of the dialing zone bit to correspond to the default address configuration mode;
Then, after the IPv6 dial control module automatically starts an address configuration process of the address configuration mode corresponding to the parameter value of the dial indicator, the automatic detection module is further configured to:
and restoring the numerical value of the sending frequency statistical parameter to a preset initial numerical value.
Further, the default address configuration mode is a static configuration mode.
Further, the managed address configuration flag bit is in a flag bit field of the router advertisement message, and the numerical value of the managed address configuration flag bit includes 1 and 0, and when determining, according to the managed configuration flag bit, an address configuration mode supported by an IPv6 network accessed by the network device, the automatic detection module is specifically configured to:
When the value of the managed address configuration flag bit is 1, determining that the address configuration mode is a stateful address configuration mode based on a DHCPv6 protocol;
When the value of the managed address configuration flag bit is 0, judging whether a prefix option in the router advertisement message is a valid prefix option, when the prefix option is the valid prefix option, determining that the address configuration mode is a stateless address configuration mode based on the SLAAC protocol, and when the prefix option is not the valid prefix option, determining that the address configuration mode is a static configuration mode.
Further, when determining whether the prefix option in the router advertisement message is a valid prefix option, the automatic detection module is specifically configured to:
judging whether the format of the prefix option in the router advertisement message accords with SLAAC protocol regulation;
If the format of the prefix option accords with SLAAC protocol regulation, judging that the prefix option is a valid prefix option;
And if the format of the prefix option does not accord with SLAAC protocol regulation, judging that the prefix option is not a valid prefix option.
In order to solve the corresponding technical problem, in a second aspect, the present invention further provides a method for automatically detecting an address configuration mode supported by an IPv6 network, where the method is performed by a network device, and the network device includes a WAN port and an automatic detection module connected to the WAN port, and the method includes:
the automatic detection module responds to an automatic detection instruction, and sends a router solicitation message from the WAN port according to a preset sending period so as to trigger an upper gateway of the network equipment to generate a router advertisement message aiming at the router solicitation message, and sends the router advertisement message to the network equipment;
when receiving the router advertisement message, the automatic detection module acquires a managed address configuration zone bit in the router advertisement message;
and the automatic detection module determines an address configuration mode supported by the IPv6 network accessed by the network equipment according to the managed configuration zone bit.
Further, the network device further comprises an IPv6 dialing control module, wherein before the automatic detection module responds to the automatic detection instruction, the method further comprises the following steps:
The IPv6 dialing control module detects whether a user inputs a dialing connection creation instruction after the network equipment is accessed to an IPv6 network;
When the dial-up connection creation instruction is detected, the IPv6 dial-up control module triggers the response of the automatic detection instruction, and creates a dial-up connection with an unspecified address configuration mode according to the connection information input by the user so that the network equipment can communicate with the superior gateway.
According to the network equipment and the method for automatically detecting the address configuration mode supported by the IPv6 network, the RS message can be actively sent to the upper gateway during detection, the RA message replied by the upper gateway is received, the address configuration mode supported by the IPv6 network which is accessed by the network equipment can be directly determined according to the address configuration mode required to be adopted by the network equipment indicated by the upper gateway, the network equipment can acquire the IPv6 address of the network equipment according to the determined address configuration mode, and the network equipment does not need to continuously probe different address configuration modes to detect the address configuration mode.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The invention provides a network device for automatically detecting an address configuration mode supported by an IPv6 network, referring to fig. 1 to 2, fig. 1 is a schematic diagram of a first application scenario of the network device provided by the invention, fig. 2 is a flowchart of a first preferred embodiment of the execution steps of the network device provided by the invention, specifically, the network device 1 includes a WAN port 12 and an automatic detection module 11 connected with the WAN port 12, wherein the automatic detection module 11 is specifically configured to:
responding to an automatic detection instruction, sending a router request message from the WAN port according to a preset sending period to trigger an upper gateway 2 of the network equipment to generate a router advertisement message aiming at the router request message, and sending the router advertisement message to the network equipment;
when receiving the router advertisement message, acquiring a managed address configuration zone bit in the router advertisement message;
And determining an address configuration mode supported by the IPv6 network accessed by the network equipment according to the managed configuration flag bit.
It should be noted that, the router requests the message, i.e. RS (Router Solicitation) message, and the network device broadcasts and sends the message outwards, the router announces the message, i.e. RA (Router Advertisement) message, and the upper gateway receiving the RS message generates the message aiming at the RS message and replies the message to the network device. The RA message contains a 64-bit prefix option, which is used for generating a 128-bit IPv6 address by combining with the MAC address of the network equipment at the user side in a stateless address configuration mode, and in the current communication protocol, the RFC 4861 (Neighbor Discovery for IPv) specifies that the RA message also contains a Flag field (zone bit field), wherein the RA message contains a managed configuration zone bit (MANAGED ADDRESS Configuration Flag or called M bit), and the value of the Flag field represents which protocol the upper gateway informs the network equipment of acquiring the address according to.
Specifically, when the automatic detection instruction is triggered, an automatic detection module of the network device responds to the automatic detection instruction, periodically sends a router request message from a WAN port according to a sending period, generates a router advertisement message and sends the router advertisement message outwards if the upper gateway receives the router request message, and when the network device receives the router advertisement message, acquires a managed address configuration flag bit in the router advertisement message to determine an address configuration mode supported by an IPv6 network accessed by the network device.
It should be noted that, when determining the address configuration mode according to the managed address configuration flag bit in the RA packet, the address configuration mode may be directly determined according to the managed address configuration flag bit, or may be determined according to the managed address configuration flag bit in combination with other information.
The triggering of the response of the automatic detection instruction may be that the response is triggered by receiving a corresponding operation of the user when the user needs to acquire the address configuration mode, or may be that the response of the automatic detection instruction is triggered when other modules of the network device execute a certain operation. Preferably, the automatic detection module comprises an RA/RS transceiver unit in the network device core, for performing all or part of the steps performed by the automatic detection module.
The network equipment for automatically detecting the address configuration mode supported by the IPv6 network can actively send the RS message to the upper gateway during detection, receive the RA message replied by the upper gateway, directly determine the address configuration mode supported by the IPv6 network to which the network equipment is connected according to the address configuration mode required to be adopted by the network equipment indicated by the upper gateway, acquire the IPv6 address of the network equipment according to the determined address configuration mode, and detect the address configuration mode without the network equipment continuously exploring different address configuration modes.
Preferably, referring to fig. 3, fig. 3 is a schematic diagram of a second application scenario of the network device provided by the present invention, and specifically, the network device 1 further includes an IPv6 dial control module 13, where before the automatic detection module 11 responds to an automatic detection instruction, the IPv6 dial control module 13 is configured to:
After the network equipment is accessed to an IPv6 network, detecting whether a user inputs a dial-up connection creation instruction or not;
When the dial-up connection creation instruction is detected, triggering the response of the automatic detection instruction, and creating a dial-up connection with an unspecified address configuration mode according to the connection information input by the user so that the network equipment can communicate with the superior gateway.
Specifically, after the network device accesses the IPv6 network, when the user needs to create a dial-up connection, the network device creates a dial-up connection with an unspecified address configuration mode according to a dial-up connection creation instruction input by the user, and for the address configuration mode, needs to trigger an automatic detection instruction to perform detection and determination. When creating dial-up connection, it can select IPoE dial-up or PPPoE dial-up according to user, if PPPoE dial-up, it needs user to provide user name and cipher to make authentication, in the course of dial-up negotiation the server can send out local link address, and has local link address, and the network equipment can only have the ability to communicate with upper gateway, and can only make interaction process of RS/RA message to obtain global IPv6 address for surfing Internet after detecting address configuration mode, if IPoE dial-up, network equipment already possesses local link address for local area network communication when creating IPoE interface, and network equipment has the ability to communicate with upper gateway, and can make interaction process of RS/RA message, and after further detecting address configuration mode, can obtain global IPv6 address for surfing Internet.
Preferably, as shown in fig. 2, the automatic detection module 11 is further configured to:
setting parameter values of dialing zone bits according to the determined address configuration mode, wherein different parameter values of the dialing zone bits correspond to different address configuration modes;
The network device further comprises an IPv6 dial control module 13, the IPv6 dial control module 13 being configured to:
obtaining the parameter value of the dialing zone bit according to a preset obtaining mode and a obtaining period;
And automatically starting an address configuration process of the address configuration mode corresponding to the parameter value of the dialing zone bit according to the acquired parameter value of the dialing zone bit.
Specifically, because the automatic detection module and the IPv6 dial control module for performing address configuration are relatively and independently set, generally, the RA message is not sent to the IPv6 dial control module for processing, and a condition that the RA message is not received may occur, so in order to ensure that the IPv6 dial control module has a basis for performing address configuration, the present invention informs the IPv6 dial control module of the address configuration mode to be performed by setting the dial flag bit. Specifically, the automatic detection module sets the parameter value of the dialing zone bit according to the address configuration mode determined by detection, the IPv6 dialing control module periodically acquires the parameter value of the dialing zone bit according to a feasible learning means, for example, the parameter value of the dialing zone bit set by the automatic detection module is queried according to a preset query period, or the parameter value of the dialing zone bit is periodically reported to the IPv6 dialing control module through the automatic detection module, and the IPv6 dialing control module automatically starts the address configuration process of the address configuration mode corresponding to the parameter value of the dialing zone bit after acquiring the parameter value of the dialing zone bit.
It should be noted that, parameter values of dialing flag bits corresponding to different address configuration modes may be set according to actual needs, for example, when the parameter value of the dialing flag bit is "N", the corresponding configuration process may be a static configuration mode, and the corresponding configuration process may be prompting a user to manually configure information such as an IPv6 address, a routing gateway, an IPv6 domain name server, etc. of the network device, and/or directly display an input interface of the static configuration for the user to input information, when the parameter value of the dialing flag bit is "D", the corresponding configuration process may be starting up DHCPv6 stateful dialing logic, and when the parameter value of the dialing flag bit is "S", the corresponding configuration process may be starting up SLAAC stateless dialing logic.
The network equipment for automatically detecting the address configuration mode supported by the IPv6 network can automatically detect the address configuration mode, automatically start the corresponding configuration process after the detection is completed, improve the configuration time of a user, and further improve the user experience without the need of the user to know network knowledge to select to start the corresponding configuration process.
Preferably, as shown in fig. 2, the automatic detection module 11 is further configured to:
For each transmitted router solicitation message, when the router advertisement message corresponding to the router solicitation message is not received, increasing the value of the preset transmission times statistics parameter according to the preset value step length, and,
Judging whether the numerical value of the sending frequency statistical parameter is larger than a preset frequency threshold value or not;
When the numerical value of the sending frequency statistical parameter is larger than the frequency threshold, determining a preset default address configuration mode according to an address configuration mode supported by an IPv6 network accessed by the network equipment, and setting the parameter value of the dialing zone bit to correspond to the default address configuration mode;
then, after the IPv6 dial control module 4 automatically starts the address configuration process of the address configuration mode corresponding to the parameter value of the dial indicator, the automatic detection module 1 is further configured to:
and restoring the numerical value of the sending frequency statistical parameter to a preset initial numerical value.
The automatic detection module sequentially sends the RS messages according to the sending period, if the corresponding RA messages are not received in five times, the number of the sending times statistics is gradually increased from the initial number 0 to 5, if the corresponding RA messages are still received in the RS messages sent in the sixth time, the number of the sending times statistics is increased to 6 and exceeds the number threshold 5, at the moment, the automatic detection module determines a preset default address configuration mode according to the address configuration mode supported by the IPv6 network accessed by the network equipment, and sets the parameter value of the dialing flag bit to correspond to the default address configuration mode. Thus, even if the RA message is not received, the following IPv6 dialing control module can still execute the corresponding configuration process, and the waiting time of the user is reduced.
Furthermore, when the RA message is not received, whether the accessed IPv6 network supports a stateful address configuration mode and a stateless address configuration mode cannot be determined, so that the default address configuration mode is a static configuration mode, and related addresses are manually configured by a user. Preferably, the parameter value of the dial flag bit is set to "N" at this time, and may be set to other parameter values according to actual needs.
Preferably, referring to fig. 4, fig. 4 is a flowchart of a second preferred embodiment of the step of executing a network device provided by the present invention, specifically, the managed address configuration flag bit is in a flag bit field of the router advertisement message, and the value of the managed address configuration flag bit includes 1 and 0, and when determining, according to the managed configuration flag bit, an address configuration mode supported by an IPv6 network accessed by the network device, the automatic detection module is specifically configured to:
When the value of the managed address configuration flag bit is 1, determining that the address configuration mode is a stateful address configuration mode based on a DHCPv6 protocol;
When the value of the managed address configuration flag bit is 0, judging whether a prefix option in the router advertisement message is a valid prefix option, when the prefix option is the valid prefix option, determining that the address configuration mode is a stateless address configuration mode based on the SLAAC protocol, and when the prefix option is not the valid prefix option, determining that the address configuration mode is a static configuration mode.
Specifically, in the existing communication rule, when the managed configuration flag bit (M bit) is specified to be 1, the managed configuration flag bit (M bit) is used for indicating that the network device obtains the IPv6 address through the stateful address configuration mode, then the address configuration mode is determined to be the stateful address configuration mode based on the DHCPv6 protocol, when the managed configuration flag bit (M bit) is 0, the managed configuration flag bit (M bit) is used for indicating that the network device obtains the IPv6 address through the stateless address configuration mode, but because the stateless address configuration mode needs to generate a complete IPv6 address according to the prefix option of the RA message, when the prefix option of the RA message is illegal, the address cannot be obtained through the stateless address configuration mode, so that when the managed configuration flag bit (M bit) is 0, if the prefix option is effective and legal, then the address configuration mode is determined to be the stateless address configuration mode based on the SLAAC protocol, and if the prefix option is not effective, then the address configuration mode is determined to be the static configuration mode, and the corresponding address information is manually configured by the user.
Preferably, when determining whether the prefix option in the router advertisement message is a valid prefix option, the automatic detection module 2 is specifically configured to:
judging whether the format of the prefix option in the router advertisement message accords with SLAAC protocol regulation;
If the format of the prefix option accords with SLAAC protocol regulation, judging that the prefix option is a valid prefix option;
And if the format of the prefix option does not accord with SLAAC protocol regulation, judging that the prefix option is not a valid prefix option.
Specifically, whether the prefix option in the router advertisement message is a valid prefix option is determined, whether the format of the prefix option in the router advertisement message accords with the SLAAC protocol specification or not needs to be determined, and when the format accords with the SLAAC protocol specification, the prefix option is determined to be the valid prefix option, otherwise, the prefix option is not the valid prefix option.
In specific implementation, the network device for automatically detecting the address configuration mode supported by the IPv6 network provided by any embodiment of the present invention can both implement that when the automatic detection instruction is triggered, the automatic detection module of the network device responds to the automatic detection instruction, and periodically sends, according to a sending period, a router request packet from the WAN port; and when the network equipment receives the router advertisement message, acquiring a managed address configuration flag bit in the router advertisement message, and determining an address configuration mode supported by an IPv6 network accessed by the network equipment.
The network equipment for automatically detecting the address configuration mode supported by the IPv6 network can actively send the RS message to the upper gateway during detection, receive the RA message replied by the upper gateway, directly determine the address configuration mode supported by the IPv6 network to which the network equipment is connected according to the address configuration mode required to be adopted by the network equipment indicated by the upper gateway, acquire the IPv6 address of the network equipment according to the determined address configuration mode, and detect the address configuration mode without the network equipment continuously exploring different address configuration modes.
The invention also provides a method for automatically detecting the address configuration mode supported by the IPv6 network, please refer to FIG. 5, FIG. 5 is a flow chart of a preferred embodiment of the method for automatically detecting the address configuration mode supported by the IPv6 network, the method is executed by a network device, the network device comprises a WAN port and an automatic detection module connected with the WAN port, the method comprises:
s1, the automatic detection module responds to an automatic detection instruction, sends a router request message from the WAN port according to a preset sending period, triggers a superior gateway of the network equipment to generate a router advertisement message aiming at the router request message, and sends the router advertisement message to the network equipment;
S2, when receiving the router advertisement message, the automatic detection module acquires a managed address configuration flag bit in the router advertisement message;
And S3, the automatic detection module determines an address configuration mode supported by the IPv6 network accessed by the network equipment according to the managed configuration zone bit.
Preferably, the network device further comprises an IPv6 dial control module, wherein before the automatic detection module responds to the automatic detection instruction, the method further comprises:
The IPv6 dialing control module detects whether a user inputs a dialing connection creation instruction after the network equipment is accessed to an IPv6 network;
When the dial-up connection creation instruction is detected, the IPv6 dial-up control module triggers the response of the automatic detection instruction, and creates a dial-up connection with an unspecified address configuration mode according to the connection information input by the user so that the network equipment can communicate with the superior gateway.
Preferably, the method further comprises:
The automatic detection module sets parameter values of the dialing zone bit according to the determined address configuration mode, wherein different parameter values of the dialing zone bit correspond to different address configuration modes;
the network device further comprises an IPv6 dial control module, the method comprising:
The IPv6 dialing control module acquires the parameter value of the dialing zone bit according to a preset acquisition mode and an acquisition period;
And the IPv6 dialing control module automatically starts an address configuration process of the address configuration mode corresponding to the parameter value of the dialing zone bit according to the acquired parameter value of the dialing zone bit.
Further, the learning mode is an active learning mode that the IPv6 dialing control module actively queries the automatic detection module for the parameter value of the dialing zone bit, or,
The learning mode is a passive learning mode that the automatic detection module reports the parameter value of the dialing zone bit to the IPv6 dialing control module.
Further, the method further comprises:
the automatic detection module increases the value of a preset sending frequency statistical parameter according to a preset value step length when the router advertisement message corresponding to the router request message is not received for each sent router request message;
The automatic detection module judges whether the numerical value of the sending frequency statistical parameter is larger than a preset frequency threshold value or not;
When the numerical value of the sending number statistics parameter is larger than the number threshold, the automatic detection module determines a preset default address configuration mode according to an address configuration mode supported by an IPv6 network accessed by the network equipment, and sets the parameter value of the dialing zone bit to correspond to the default address configuration mode;
Then, after the IPv6 dial control module automatically starts an address configuration process of the address configuration mode corresponding to the parameter value of the dial indicator, the method further includes:
And the automatic detection module restores the numerical value of the sending frequency statistical parameter to a preset initial numerical value.
Further, the default address configuration mode is a static configuration mode.
Further, the managed address configuration flag bit is in a flag bit field of the router advertisement message, and the numerical value of the managed address configuration flag bit comprises 1 and 0, and the automatic detection module determines, according to the managed configuration flag bit, that the address configuration mode supported by the IPv6 network to which the network device is connected is specifically:
When the value of the managed address configuration zone bit is 1, the automatic detection module determines that the address configuration mode is a stateful address configuration mode based on a DHCPv6 protocol;
When the value of the managed address configuration flag bit is 0, the automatic detection module judges whether a prefix option in the router advertisement message is a valid prefix option, when the prefix option is the valid prefix option, the automatic detection module determines that the address configuration mode is a stateless address configuration mode based on the SLAAC protocol, and when the prefix option is not the valid prefix option, the automatic detection module determines that the address configuration mode is a static configuration mode.
Further, the automatic detection module determines whether the prefix option in the router advertisement message is a valid prefix option, which specifically includes:
The automatic detection module judges whether the format of the prefix option in the router advertisement message accords with SLAAC protocol regulation;
If the format of the prefix option accords with SLAAC protocol regulation, the automatic detection module judges that the prefix option is a valid prefix option;
If the format of the prefix option does not accord with SLAAC protocol, the automatic detection module judges that the prefix option is not a valid prefix option.
According to the method for automatically detecting the address configuration mode supported by the IPv6 network, the RS message can be actively sent to the upper gateway during detection, the RA message replied by the upper gateway is received, the address configuration mode supported by the IPv6 network which is accessed by the network equipment can be directly determined according to the address configuration mode required to be adopted by the network equipment indicated by the upper gateway, the network equipment can acquire the IPv6 address of the network equipment according to the determined address configuration mode, and the network equipment does not need to continuously probe different address configuration modes to detect the address configuration mode.
It should be noted that, the method for automatically detecting the address configuration mode supported by the IPv6 network provided by the embodiment of the present invention corresponds to the functions of the network device described in the foregoing embodiment, and the working principles and beneficial effects of the two correspond to each other one by one, so that a detailed description is omitted.
While the foregoing is directed to the preferred embodiments of the present invention, it will be appreciated by those skilled in the art that changes and modifications may be made without departing from the principles of the invention, such changes and modifications are also intended to be within the scope of the invention.