Disclosure of Invention
The application provides a network connection information acquisition method and a router, which are used for solving the technical problem of how to automatically acquire the network connection information of an old router by a new router.
In a first aspect, a method for acquiring network connection information is provided, which is applied to a new router having a capability of acquiring network connection information of an old router, and includes:
the new router receives data messages through a LAN interface of the new router, wherein the data messages comprise Ethernet messages sent to the LAN interface of the new router by the old router through a WAN interface of the old router;
and the new router determines the network connection information of the old router according to the data message.
In the application, the new router may receive, through a Local Area Network (LAN) interface, a data packet sent by the old router through a Wide Area Network (WAN) interface, and the data packet sent by the old router through the WAN interface is generally normally sent to a server in an uplink Network during operation, so that the new router is equivalent to intercepting the data packet sent by the old router to the server in the uplink Network. Then, the new router can directly obtain the network connection information of the old router through the received data message, so that the technical problem of how to automatically obtain the network connection information of the old router by the new router is solved, and then the new router can directly use the obtained network connection information to be connected with an uplink network without manually configuring the new router by a user, so that the starting process of the new router is simplified, the error probability caused by manual processing of the user is reduced, and meanwhile, the burden of the user is also reduced.
With reference to the first aspect, in a first possible implementation manner of the first aspect, the network connection information includes: authentication information, network connection mode or IP address.
The network access modes of the old routers may be different, so the acquired network connection information may also be different, but in any network access mode, the acquired network connection information may include one or more of authentication information, network connection modes or IP addresses, so as to ensure that the new router can acquire more complete network connection information of the old routers as much as possible.
With reference to the first possible implementation manner of the first aspect, in a second possible implementation manner of the first aspect, the determining, by the new router, network connection information of the old router according to the data packet includes:
if the data message is an Ethernet message and is a broadcast message, and the data message contains a PPPoE message, the new router determines that the network connection mode of the old router is a dialing authentication mode;
the new router receives the PPPoE session initiated by the old router; wherein, the new router works in a PPPoE Server mode;
in the PPPoE session flow of the new router and the old router, the new router acquires the authentication information of the old router.
If the new router determines that the network connection mode of the old router is the dialing authentication mode, the new router can also enter a PPPoE Server mode, and the authentication information of the old router is acquired through a PPPoE session flow with the old router, so that the uplink network can be accessed through the acquired authentication information in the dialing authentication mode, namely the new router can acquire the authentication information by itself and access the uplink network by itself without manual operation of a user, the user does not need to remember the user name, the password and the like of the old router, the burden of the user is relieved, the user experience is improved, and the intelligence and the practicability of the new router are also improved.
With reference to the first possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the determining, by the new router, network connection information of the old router according to the data packet includes:
and if the data message is an Ethernet message and is a broadcast message, and the data message contains a DHCP broadcast message, the new router determines that the network connection mode of the old router is a dynamic address allocation mode.
With reference to the first possible implementation manner of the first aspect, in a fourth possible implementation manner of the first aspect, the determining, by the new router, network connection information of the old router according to the data packet includes:
if the data message is an Ethernet message and is a non-broadcast message, and the data message contains an IP message, the new router determines whether the source address of the IP message is legal;
and if the source address of the IP message is legal, the new router determines that the network connection mode of the old router is a static address mode, and the IP address is the source address of the IP message.
The new router can determine the network connection mode of the old router according to the received data message, and can perform uplink network access according to different network connection modes without participation of users. For example, if the data packet includes an IP packet, the new router may obtain the source address of the IP packet by itself, so that the source address of the IP packet may be used as an IP address for performing uplink network connection, and a user is not required to obtain the IP address, thereby reducing the burden of the user.
With reference to the second possible implementation manner of the first aspect, in a fifth possible implementation manner of the first aspect, after obtaining the authentication information of the old router, the method further includes:
the new router is switched from the PPPoE Server mode to a PPPoE client mode;
and in the PPPoE client mode, the new router uses the acquired network connection information to carry out network connection.
When the new router acquires the authentication information, the new router works in a PPPoE Server mode, and when uplink network connection is required, the new router needs to work in a PPPoE client mode, so that after the authentication information is acquired, the new router can be switched from the PPPoE Server mode to the PPPoE client mode, the new router can acquire the authentication information by itself and can also perform the uplink network connection by itself without the participation of a user, and the new router can automatically switch the working mode and avoid errors.
With reference to the first aspect or any one possible implementation manner of the first possible implementation manner to the fifth possible implementation manner of the first aspect, in a sixth possible implementation manner of the first aspect, after the new router receives the data packet through the LAN interface of the new router, the method further includes:
and the new router records a source Media Access Control (MAC) address of the data message and sets the source MAC address as the MAC address of the WAN interface of the new router.
There are also many Internet Service Providers (ISPs) that have MAC addresses bound, i.e., only routers with a specific MAC address can make network connection, such as a home, if an old router is used for network connection for the first time, the ISP recognizes the MAC address of the old router, and then if other routers are exchanged, the ISP may not provide network connection because the MAC address of the router is changed. Therefore, in the application, a new function can be added to the new router, that is, the MAC addresses of other routers (such as the old router) can be automatically detected and obtained to serve as the MAC address of the WAN interface of the router, so that the new router can replace the old router to perform uplink network connection, and the situation that the new router cannot be connected to an uplink network is avoided as much as possible.
In a second aspect, a first router is provided, the router having a capability of acquiring network connection information of an old router, the router comprising:
the LAN interface is used for receiving data messages, and the data messages comprise Ethernet messages sent to the LAN interface by the old router through the WAN interface of the old router;
and the processor is used for determining the network connection information of the old router according to the data message.
With reference to the second aspect, in a first possible implementation manner of the second aspect, the network connection information includes: authentication information, network connection mode or IP address.
With reference to the first possible implementation manner of the second aspect, in a second possible implementation manner of the second aspect, the processor is configured to:
if the data message is an Ethernet message and is a broadcast message, and the data message contains a PPPoE message, determining that the network connection mode of the old router is a dialing authentication mode;
receiving the PPPoE session initiated by the old router; wherein, the router works in a PPPoE Server mode;
and acquiring the authentication information of the old router in the PPPoE session flows of the router and the old router.
With reference to the first possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, the processor is configured to:
and if the data message is an Ethernet message and is a broadcast message, and the data message contains a DHCP broadcast message, determining that the network connection mode of the old router is a dynamic address allocation mode.
With reference to the first possible implementation manner of the second aspect, in a fourth possible implementation manner of the second aspect, the processor is configured to:
if the data message is an Ethernet message and is a non-broadcast message, and the data message contains an IP message, determining whether the source address of the IP message is legal;
and if the source address of the IP message is legal, determining that the network connection mode of the old router is a static address mode, wherein the IP address is the source address of the IP message.
With reference to the second possible implementation manner of the second aspect, in a fifth possible implementation manner of the second aspect, the processor is further configured to:
after obtaining the authentication information of the old router, switching the router from the PPPoE Server mode to a PPPoE client mode;
and under the PPPoE client mode, performing network connection by using the acquired network connection information.
With reference to the second aspect or any possible implementation manner of the first possible implementation manner to the fifth possible implementation manner of the second aspect, in a sixth possible implementation manner of the second aspect, the processor is further configured to:
after the LAN interface receives the data message, recording a source Media Access Control (MAC) address of the data message, and setting the source MAC address as the MAC address of the WAN interface of the router.
In a third aspect, a second router is provided, the router having the capability of obtaining network connection information of an old router, the router comprising means for performing the method of the first aspect.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be described below in conjunction with the drawings in the embodiments of the present invention.
Hereinafter, some terms in the present invention will be explained.
1) The old router is a router already connected to the upstream network.
The new router, which is a router to be connected to the upstream network, is used to replace the old router.
2) "plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" generally indicates that the preceding and following related objects are in an "or" relationship, unless otherwise specified.
First, an application scenario of the embodiment of the present invention is described.
Fig. 1A is a schematic view of a scenario in which a terminal accesses an ethernet network through a router. The terminal 1 in fig. 1A is, for example, a mobile phone, the terminal 2 is, for example, a Personal Computer (PC), the terminal 1 and the terminal 2 are connected to the router 1 in a wireless manner, and the router 1 is further connected to the Internet (Internet), so that the connection between the terminal 1 and the terminal 2 and the Internet is realized.
In which a modem (modem) is integrated in the router 1, so that it can be directly connected to the internet. If the modem is not integrated in the router 1, the router 1 can connect the modem via the ethernet, and the modem is then connected to the internet, so as to connect the terminals 1 and 2 to the internet.
The embodiments of the present invention will be described in further detail with reference to the drawings attached hereto.
In the embodiment of the present invention, when the old router is to be replaced by the new router to continue working, the technical solution provided in the embodiment of the present invention may be adopted.
In addition, please refer to fig. 1B, which is a schematic diagram of a wiring manner in an embodiment of the present invention, wherein fig. 1B is an example of a home scenario. In fig. 1B, the WAN interface of the new router is connected to an ethernet port in the home to access the internet, and the LAN interface of the new router should be connected to a device in the home that needs to be connected to the network, for example, a device such as a Personal Computer (PC) may be included. However, in order to implement the technical solution of the embodiment of the present invention, a new router may be connected to an uplink network, and then a LAN interface of the new router may be connected to a device in a home, that is, when the new router is to replace an old router, the LAN interface of the new router may be connected to a WAN interface of the old router, as shown in fig. 1B, and after the two interfaces are connected, the new router may execute the network connection information obtaining method provided in the embodiment of the present invention.
Generally, the old router also needs to interact with the upstream network device frequently during operation, for example, if the old router employs a network connection in a manner of dynamically allocating addresses, the old router may interact with the upstream network device such as a DHCP server during operation. In the embodiment of the present invention, after the LAN interface of the new router is connected to the WAN interface of the old router, the old router regards the new router as an uplink network device, and therefore the new router can normally send the ethernet packet through the WAN interface, which is equivalent to intercepting all the data packets sent by the old router to the uplink network device.
The data packet may include an ethernet packet, that is, the data packet sent by the old router to the LAN interface of the new router through the WAN interface of the old router, and may include the ethernet packet sent by the old router to the LAN interface of the new router through the WAN interface of the old router.
Referring to fig. 2, an embodiment of the present invention provides a network connection information obtaining method, which can be applied to a new router having the capability of obtaining network connection information of an old router, and the flow of the method is described as follows.
Step 201: the new router receives data messages through the LAN interface of the new router, wherein the data messages comprise first Ethernet messages which are sent to the LAN interface of the new router by the old router through the WAN interface of the old router;
step 202: and the new router determines the network information of the old router according to the data message.
Alternatively, the new router may have at least two modes, such as at least a normal operation mode and a probing mode, for example. After the new router is connected to the upstream network, the new router can work in a normal working mode, and at the moment, the new router can provide normal network connection for the equipment in the home through the upstream network. The new router can work in a detection mode when the new router works for acquiring the network connection information provided by the embodiment of the invention, and the new router can acquire the network connection information of the old router in the detection mode.
For example, when the new router leaves the factory, the new router may be set to the probing mode by default, or may be automatically switched to the probing mode when the upstream network is not detected, or may be manually switched to the probing mode by the user (for example, the user may switch the mode of the new router by pressing a corresponding key on the new router), and so on.
For example, after the uplink network connection of the new router is successful, the new router may be automatically switched to the normal operating mode, or when the new router leaves the factory, the new router may be set as the normal operating mode by default, or the new router may be manually switched to the normal operating mode by the user, and so on.
Alternatively to this, the first and second parts may,
before the new router receives the data message through the LAN interface of the new router, the method further includes:
the new router starts a timer;
the new router receives the data message through the LAN interface of the new router, including:
before the timer times out, the new router receives the data message through the LAN interface of the new router.
The timer is started in order to give a time limit to the network connection information acquisition process, since it is not excluded that the old router may not send data packets over the WAN interface for a long time, and if the new router is still waiting to receive in this case, power consumption is large for the new router and useless work is done. Therefore, the new router can set a timer, after the LAN interface of the new router is connected with the WAN interface of the old router, the new router can start the timer, before the timer expires, the new router can receive the data message sent by the old router, and after the timer expires, the new router can stop receiving no matter whether the new router receives the data message, thereby reducing the power consumption of the new router. The duration of the timer may be set when the new router leaves the factory, or may be set by the user at a later time.
Generally, when the upstream network connection is stable, the old router may not send data packets through the WAN interface, or may send a small number of data packets, in which case the new router may not easily receive the data packets. Then, in order to ensure that the new router can receive the data packet sent by the old router as much as possible, after the LAN interface of the new router is connected to the WAN interface of the old router, the old router may be restarted, and after being restarted, the old router may send the data packet to the upstream network device, so that the new router can receive the data packet sent by the old router through the LAN interface.
Optionally, if the new router does not intercept any data packet after the timer expires, or the data packet is intercepted, but the network connection information of the old router cannot be obtained through the intercepted data packet, the new router may continue to perform network connection by using the method in the prior art.
Referring to fig. 3, one possible format of an ethernet message includes a Media Access Control (MAC) address (generally occupying 6 bytes), a source MAC address (generally occupying 6 bytes), a type (also referred to as a protocol type field, generally occupying 2 bytes), data (i.e., data carried by the message, generally occupying 46-1500 bytes), and a Frame Check Sequence (FCS) generally occupying 4 bytes.
Optionally, to determine the network connection information of the old router according to the ethernet packet, the type of the ethernet packet is first determined, and the network connection information indicated by different types is different. The type of an ethernet message is determined by a protocol type field in the ethernet message.
Optionally, the network connection information includes: authentication information, network connection mode or IP address.
For example, the network connection mode may include a dialing authentication mode, a dynamic address allocation mode and a static address mode. If the network connection mode of the old router obtained by the new router is a dialing authentication mode, the new router also needs to obtain authentication information of the old router, so as to perform network connection through the authentication information, wherein the authentication information may include a user name and/or a password, for example; if the network connection mode of the old router obtained by the new router is a static address mode, the new router also needs to obtain the IP address of the old router so as to perform network connection through the IP address.
The manner in which the new router obtains the network connection information is described below.
Firstly, dialing authentication mode.
The new router receives a data message sent by the old router through the LAN interface, analyzes the received data message, determines that the Ethernet message is a broadcast message if the received data message is an Ethernet message and the destination MAC address of the Ethernet message is FF, and determines that the broadcast message is a PPPoE broadcast message if the value of the protocol type field in the broadcast message is 0x8863, the new router determines that the network connection mode of the old router is a dialing authentication mode, and determines that the authentication information of the old router needs to be further acquired.
Optionally, after determining that the network connection mode of the old router is the dial-up authentication mode, the new router may enter a PPPoE Server (Server) mode. At present, a router can only work in a PPPoE Client (Client) mode generally, and a PPPoE Server mode is a working mode of a Server generally. In the embodiment of the invention, in order to enable the new router to carry out PPPoE session, some improvements need to be carried out on the new router, so that the new router can work in a PPPoE Server mode in a simulation mode.
After the new router enters the PPPoE Server mode, the new router can receive the PPPoE session initiated by the old router. Generally, after an old router sends a PPPoE broadcast message to an upstream network device (in the embodiment of the present invention, a new router receives the PPPoE broadcast message), the old router initiates a PPPoE session to the upstream network device, and then, in the embodiment of the present invention, the new router operating in a PPPoE Server mode can receive the PPPoE session initiated by the old router, and the new router can obtain authentication information of the old router through a PPPoE session flow with the old router.
Currently, a PPPoE Session flow can be divided into three phases, namely a Discovery (Discovery) phase, a Session (Session) phase and a termination (termination) phase.
Please refer to fig. 4, which is an interactive diagram of a PPPoE session flow between a new router and an old router. The Discovery phase is performed first, and consists of four processes. After the completion, both the new router and the old router know the Session identification number (Session _ ID) of PPPoE and the ethernet address of the other party, and these parameters together determine a unique PPPoE Session.
First, the old router sends a PPPoE Active Discovery Initiation (PADI) packet in a broadcast manner, where the PADI packet includes service type information that the old router wants to obtain.
After receiving the PADI message, the new router compares the service requested in the PADI message with the service which can be provided by the new router, and if the service can be provided, the new router replies a PPPoE active Discovery Offer Packet (PADO) message to the old router in a unicast mode.
After receiving the PADO message, the old router sends a PPPoE Active Discovery Request (PADR) message to the new router in a unicast manner.
The new router generates a unique Session ID (i.e., Session _ ID) that identifies the PPPoE Session with the old router. The new router sends a PPPoE Active discovery Session-confirmation (PADS) message to the old router, and carries the Session _ ID in the PADS message and sends it to the old router.
If no error occurs in the above processes, the PPPoE Session is established completely, the Discovery phase is ended, and then the Session phase is entered.
The Discovery phase works to establish a Session between the new router and the old router, and then the Session phase is entered. The Session phase can be divided into two parts, the first part is a Point-to-Point Protocol (PPP) negotiation phase, and the second part is a PPP message transmission phase which is entered after the PPP negotiation phase is finished and if the negotiation is successful.
The PPP negotiation mode in PPPoE is consistent with the ordinary PPP negotiation mode, and is divided into three phases, namely a Link Control Protocol (LCP) negotiation phase, an authentication phase, and a Network Control Protocol (NCP) phase.
The first is LCP negotiation stage, which mainly completes the work of establishing, configuring and detecting data link connection.
Generally, in the LCP negotiation stage, two communicating parties may use different Authentication manners, for example, a Password Authentication Protocol (PAP) Authentication manner may be used, or a Challenge Handshake Authentication Protocol (CHAP) Authentication manner may also be used.
In the PAP authentication mode, the old router sends the authentication information of the dial authentication mode to the new router in the clear text, as shown in fig. 4, the old router sends a PAP Request to the new router, and the authentication information is carried in the PAP Request in the clear text. In the embodiment of the present invention, the authentication information may include, for example, information such as a user name and a password for performing network connection through a dial-up authentication method.
After the new router obtains the authentication information of the old router, the new router can respond to the old router with an authentication failure (PAP NAK) because there is no need to proceed with the following session flow. Thus, the PPP session flow terminates.
Then, the new router may send a PPPoE Active Discovery Termination (PADT) message to the old router to Terminate the PPPoE session procedure, or the PADT message may also be sent by the old router to the new router.
At this point, the PPPoE session flow is finished, the new router can switch to the normal PPPoE Client mode again, and can connect to the uplink network in a dial-up authentication mode through the obtained authentication information.
In addition, after the new router is successfully connected with the uplink network, prompt information can be output, the prompt information is used for prompting a user that the uplink network is successfully connected, after the user receives the prompt information, the connection between the new router and the old router can be disconnected, and equipment needing network connection in a family can be connected to the LAN interface of the new router, so that networking can be achieved through the new router.
For example, the prompting information may be a voice prompt, or may also be a text prompt (for example, the new router sends information to a terminal used by a user), or may also be a vibration prompt, or may also be other types of prompts, for example, an indicator lamp arranged on the new router may be made to flash, and the like, as long as the prompting information can be used for prompting the user, and the embodiment of the present invention does not limit the type of the prompting information.
Now, when a user changes a router, if the user knows that the original router is connected to the network by means of dial-up authentication, the user needs to obtain the user name and password of the old router again, and if the user does not remember the user name and password for too long time, the user may need to log in the world wide Web (Web) page of the old router to obtain the user name and password, or obtain the user name and password by means of making a call to an operator, and the like, which is very troublesome anyway. By adopting the mode provided by the embodiment of the invention, even if the dialing authentication mode is adopted, the new router can automatically acquire the authentication information of the old router without manual operation of a user, so that the burden of the user is greatly reduced.
And secondly, dynamically allocating an address mode.
The new router receives the data message sent by the old router through the LAN interface, the new router analyzes the received data message, if the received data message has a data message as an Ethernet message, and the destination MAC address of the Ethernet message is FF: FF: FF: FF: FF: FF, the new router determines the Ethernet message as a broadcast message, if the value of the protocol type field in the broadcast message is 0x0800(IPv4 message) or 0x86DD (IPv6 message), it is determined that the broadcast message is an IP broadcast message, then, whether the protocol type of the IP broadcast message is User Datagram Protocol (UDP) or not is checked, if the broadcast message is a UDP broadcast message, and the original port of the broadcast message is 68 and the destination port of the broadcast message is 67, the new router may determine that the broadcast message is a DHCP broadcast message, and the new router determines that the network connection mode of the old router is a dynamic address allocation mode.
In the embodiment of the invention, if the new router determines that the network connection mode of the old router is the dynamic address allocation mode, the new router can send a request message to the DHCP server, and the request message is used for requesting the DHCP server to allocate a dynamic address to the new router. If the DHCP server assigns a dynamic address to the new router, the new router may connect to the network according to the assigned dynamic address.
And thirdly, a static address mode.
The new router receives a data message sent by the old router through the LAN interface, analyzes the received data message, determines that the Ethernet message is a non-broadcast message if the received data message is an Ethernet message and the destination MAC address of the Ethernet message is not FF, and determines that the non-broadcast message is an IP message if the value of the protocol type field in the non-broadcast message is 0x0800 or 0x86DD, the new router can determine whether the source address (namely the source IP address) of the IP message is legal, and determines that the network connection mode of the old router is a static address mode and that the IP address to be acquired is the source address of the IP message if the source address of the IP message is legal.
In the embodiment of the invention, if the new router determines that the network connection mode of the old router is the static address mode, the new router can use the source address of the IP message as the address of the WAN interface of the new router to connect the network.
At present, if the network is connected in a static address mode, a user needs to input an IP address manually, and the operations in the embodiment of the invention can be automatically completed by a new router, so that the burden of the user is reduced, and the error probability caused by the manual operation of the user is also reduced.
For the broadcast message, except for the PPPoE type broadcast message and the DHCP type broadcast message, other types of broadcast messages may not be used to acquire the network connection information of the old router, so if the new router receives the broadcast message before the timer times out and determines that the received broadcast message is neither the PPPoE type broadcast message nor the DHCP type broadcast message, the new router may discard the received broadcast message and may not acquire the network connection information of the old router.
For non-broadcast messages, other types of non-broadcast messages may not be used to obtain the network connection information of the old router, except for IP messages with legitimate source addresses, so if the new router receives a non-broadcast message before the timer expires, and the non-broadcast message is not an IP message, or is an IP message with an illegitimate source address, the new router may discard the received messages and fail to obtain the network connection information of the old router.
Optionally, although the old router may only connect to the network through one network connection, for example, through a dial-up authentication, some of the old routers may send multiple types of ethernet messages when sending the ethernet messages through the WAN interface, for example, may send PPPoE broadcast messages, may send DHCP broadcast messages, and may send IP messages. If so, the new router may receive multiple different types of ethernet packets before the timer expires, and for this situation, the embodiment of the present invention assigns priorities to each network connection mode according to the stability of the network connection, for example, the dialing authentication mode has the highest priority, the next is a dynamic address assignment mode, and the lowest priority is a static address assignment mode. The following examples are presented.
Optionally, before the timer times out, if the new router receives two different types of ethernet messages in common, for example, the two different types of ethernet messages include a first ethernet message and a second ethernet message, where the first ethernet message is, for example, a PPPoE broadcast message, and the second ethernet message is, for example, a DHCP broadcast message, the new router may determine, according to the priority of each network connection mode, that the network connection mode of the old router is the dial-up authentication mode indicated by the PPPoE broadcast message, that is, because the success rate is higher when the network connection is performed through the dial-up authentication mode, the network connection is also stable, and therefore, the embodiment of the present invention preferentially uses the dial-up authentication mode to perform the network connection.
Optionally, before the timer expires, if the new router receives two different types of ethernet messages, for example, a first ethernet message and a third ethernet message, where the first ethernet message is, for example, a PPPoE broadcast message, and the third ethernet message is, for example, an IP message (where the third ethernet message is a non-broadcast message with a legal source address), the new router may determine, according to the priority of each network connection mode, that the network connection mode of the old router is the dial-up authentication mode indicated by the PPPoE broadcast message.
Optionally, before the timer expires, if the new router receives three different types of ethernet messages, for example, a first ethernet message, a second ethernet message, and a third ethernet message, where the first ethernet message is, for example, a PPPoE broadcast message, the second ethernet message is, for example, a DHCP broadcast message, and the third ethernet message is, for example, an IP message, the new router may determine, according to the priority of each network connection mode, that the network connection mode of the old router is the dial-up authentication mode indicated by the PPPoE broadcast message.
Optionally, before the timer expires, if the new router receives two different types of ethernet messages, for example, a second ethernet message and a third ethernet message, where the second ethernet message is, for example, a DHCP broadcast message, and the third ethernet message is, for example, an IP message, the new router may determine, according to the priority of each network connection mode, that the network connection mode of the old router is the dynamic address allocation mode indicated by the DHCP broadcast message.
Optionally, when the new router receives both the PPPoE broadcast message and the DHCP broadcast message, if the new router fails to connect to the network through the dial-up authentication method, the new router may connect to the network again in the dynamic address allocation method. If the new router fails to connect to the network by dynamically allocating addresses, the new router can connect to the network by using the method provided in the prior art.
Optionally, when the new router receives both the PPPoE broadcast message and the IP message, if the new router fails to connect to the network through the dial-up authentication method, the new router may connect to the network again in the static address mode. If the new router fails to connect to the network using the static address method, the new router can connect to the network using the method provided in the prior art.
Optionally, when the new router receives both the PPPoE broadcast message and the DHCP broadcast message and the IP message, if the new router fails to connect to the network through the dial-up authentication method, the new router may re-connect to the network by dynamically allocating an address. If the new router fails to connect the network in the dynamic address allocation mode, the new router can continue to connect the network in the static address mode. If the static address mode also fails to connect to the network, the new router may connect to the network in the manner provided in the prior art.
Optionally, when the new router receives both the DHCP broadcast message and the IP message, if the new router fails to connect to the network in the dynamic address allocation manner, the new router may connect to the network in the static address manner again. If the new router fails to connect to the network using the static address method, the new router can connect to the network using the method provided in the prior art.
Optionally, in a case where the new router only receives the PPPoE broadcast packet, if the new router fails to connect to the network through the dial-up authentication method, the new router may connect to the network by using a method provided in the prior art.
Optionally, in a case where the new router only receives the DHCP broadcast packet, if the new router fails to connect to the network in a manner of dynamically allocating an address, the new router may connect to the network in a manner provided in the prior art.
Optionally, in a case where the new router only receives the non-broadcast IP packet with the legal source address, if the new router fails to connect to the network in the static address manner, the new router may connect to the network in the manner provided in the prior art.
Referring to fig. 5, a more detailed flowchart of the network connection method according to the embodiment of the present invention is shown, which generally describes the above steps. Since the steps and turning relationships related to the flowchart have been described above, they are not described in detail here.
Optionally, there are many ISPs that have MAC addresses bound, that is, only routers with specific MAC addresses can make network connection, for example, in a home, if an old router is used for network connection for the first time, the ISP recognizes the MAC address of the old router, and then if other routers are changed, the ISP may not provide network connection because the MAC address of the router is changed.
In order to solve this problem, in the embodiment of the present invention, a new function may be added to the router, that is, the MAC address of another router may be automatically detected and acquired as the MAC address of the WAN interface of the router. This function may be automatically turned on when the router leaves the factory, or may be enabled by the user when needed.
Then, if the new router has the function, after the LAN interface of the new router is connected to the WAN interface of the old router, the new router receives the data packet sent by the old router, and the new router may record the source MAC address carried in the received data packet, and use the recorded source MAC address as the MAC address of the WAN interface of the new router to perform network connection. The source MAC address carried by the data packet received by the new router through the LAN interface is the MAC address of the old router, that is, the new router is equivalent to the MAC address of the cloned old router.
The data packet of the source MAC address recorded by the new router may be a PPPoE broadcast packet, a DHCP broadcast packet, an IP packet with a legal source address, other types of broadcast packets, other types of non-broadcast packets, and so on. In addition, the data packet of the source MAC address recorded by the new router may be the first data packet sent by the old router after the LAN interface of the new router is connected to the WAN interface of the old router, or may be any data packet sent by the old router.
The apparatus of the present embodiment is described below.
Based on the same inventive concept, the embodiment of the invention provides a router, and the router can comprise a LAN interface and a processor.
Wherein the router may include one or more LAN interfaces.
Optionally, the router may further include other interfaces, for example, a WAN interface, for communicating with an upstream network device (e.g., a DHCP server, etc.).
Likewise, the router may also include one or more WAN interfaces.
The processor may be specifically a central processing unit or an Application Specific Integrated Circuit (ASIC), may be one or more integrated circuits for controlling program execution, may be a hardware Circuit developed by using a Field Programmable Gate Array (FPGA), and may be a baseband chip.
These LAN interface and WAN interface may be connected to the processor through a bus, or may be connected to the processor through dedicated connection lines, respectively.
The processor is designed and programmed to solidify the code corresponding to the method shown in the foregoing into the chip, so that the chip can execute the method shown in fig. 2 when running. How to program the processor is well known to those skilled in the art and will not be described in detail here.
The router may be adapted to perform the method described above with respect to fig. 2, and may be, for example, a new router as described above.
The LAN interface of the new router can be connected with the WAN interface of the old router, and the new router can receive the data message sent by the old router through the LAN interface, so that the processor can acquire the network connection information of the old router according to the received data message.
The new router receives the data packet sent by the old router, and the processor parses the received data packet, for example, by parsing the destination MAC address and the protocol field type of the data packet, the processor may determine the type of the data packet.
Optionally, if it is determined that the received data packet includes an ethernet packet, for example, a PPPoE broadcast packet, and the processor determines that the network connection mode of the old router is a dialing authentication mode, the processor may enable the new router to enter a PPPoE Server mode, and after the new router enters the PPPoE Server mode, the processor may receive a PPPoE session initiated by the old router, so that the processor may obtain authentication information of the old router through a PPPoE procedure with the old router. After obtaining the authentication information of the old router, the processor can connect the uplink network in a dialing authentication mode through the obtained authentication information.
Optionally, if it is determined that the received data packet includes an ethernet packet, for example, a DHCP broadcast packet, and the processor determines that the network connection mode of the old router is a dynamic address allocation mode, the processor may send a request message to the DHCP server, where the request message is used to request the DHCP server to allocate a dynamic address to the new router. If the DHCP server allocates a dynamic address to the processor, the processor may connect to the upstream network according to the allocated dynamic address.
Optionally, if it is determined that the received data packet is an ethernet packet, for example, includes a non-broadcast packet and is an IP packet, the processor may determine whether the source address of the IP packet is legal, and if the source address of the IP packet is legal, the processor determines that the network connection mode of the old router is a static address mode, and determines that the IP address to be acquired is the source address of the IP packet. After obtaining the source address of the IP packet, the processor may use the source address of the IP packet as an address of a WAN interface of the new router to connect to the upstream network.
Optionally, the new router may also clone the MAC address of the old router, if desired. For example, the processor receives a data packet sent by an old router through the LAN interface, and then the processor analyzes the data packet to obtain a source MAC address carried by the data packet, where the source MAC address carried by the data packet is also the MAC address of the old router, and then the processor may record the source MAC address carried by the data packet and set the source MAC address carried by the data packet as the MAC address of the WAN interface of the new router.
For more functions and the like implemented by each functional unit in the router, reference may be made to the description of the method portion in fig. 2, and details are not repeated.
Based on the same inventive concept, the embodiment of the present invention further provides a router, which may include a receiving module and a processing module.
In practical applications, the entity device corresponding to the processing module may be the processor as described above, and the entity device corresponding to the receiving module may be the LAN interface as described above. The processing module may be implemented via the WAN interface as described above when communicating with an upstream network device (e.g., a DHCP server, etc.).
The router may be used to perform the method described above in fig. 2, for example the router may be a new router as described above. Therefore, for the functions and the like realized by each functional unit in the router, reference may be made to the description of the method portion in fig. 2, which is not repeated.
In the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the described units or division of units is only one type of division of logical functions, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection of some interfaces, devices or units, and may be an electric or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the elements may be selected according to actual needs to implement the embodiments of the present invention.
The functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may be an independent physical module.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, all or part of the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a Universal Serial Bus flash drive (usb flash drive), a removable hard disk, a read-only memory (ROM), a random-access memory (RAM), a magnetic disk, and an optical disk.
The above embodiments are only used to describe the technical solutions of the present invention in detail, but the above embodiments are only used to help understanding the method of the embodiments of the present invention, and should not be construed as limiting the embodiments of the present invention. Variations or substitutions that may be readily apparent to one skilled in the art are intended to be included within the scope of the embodiments of the present invention.