Router network interface identification method, device, storage medium and chip system
By sending Router Solicitation and DHCPv6 Solicit messages in the router to identify the IPv6 single-stack uplink environment, the problem of the router being unable to recognize the IPv6 single-stack uplink environment is solved, simplifying the user's Internet access operation and improving the user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2024-11-27
- Publication Date
- 2026-05-29
AI Technical Summary
Existing routers cannot recognize IPv6 single-stack uplink environments through the blind port insertion function, which complicates the user's Internet access operation and reduces the user experience.
The router sends multiple probe messages, including Router Solicitation messages and/or DHCPv6 Solicit messages, to identify the IPv6 single-stack uplink environment, and sets the target network port as the WAN port after receiving the corresponding message.
It improves the compatibility of the router's blind port insertion function, simplifies the Internet access process, and enhances the user experience.
Smart Images

Figure CN122120193A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of terminal technology, and in particular to a router network port identification method, device, storage medium and chip system. Background Technology
[0002] Currently, some routers support blind-plugging of network ports. Routers with blind-plugging capability can automatically identify whether the other end of the network cable connected to the router is in an uplink environment. In other words, routers with blind-plugging capability can automatically determine whether they can connect to the Internet to access it.
[0003] However, in some scenarios, routers cannot identify the upstream environment through the blind-plug function of the network port. In this case, the router will identify the other end of the network cable connected to the router as a device within the local area network, such as a computer, printer, or switch, thus increasing the difficulty of accessing the Internet. Summary of the Invention
[0004] This application provides a router network port identification method, device, storage medium, and chip system. The probe messages sent by the router may include relevant messages supporting IPv6 single-stack uplink environment to detect whether the other end of the network cable connected to the router is in an IPv6 single-stack uplink environment. This allows the router to not only support LAN / WAN auto-sensing function but also to identify IPv6 single-stack uplink environment.
[0005] The first aspect provides a router network port identification method, applied to a router, the method including:
[0006] Upon detecting a network cable connected to the target network port, the router sends multiple probe packets, including packets identifying an IPv6 single-stack uplink environment. The IPv6 single-stack uplink environment refers to the environment in which the router communicates with the server based on the IPv6 protocol, and the target network port can be any one of the router's multiple network ports. Upon receiving a response packet from any of the probe packets, the target network port is set as the WAN port. In this way, the probe packets sent by the router include relevant packets supporting the IPv6 single-stack uplink environment, enabling the detection of whether the other end of the network cable connected to the router is in an IPv6 single-stack uplink environment. This improves the compatibility of the router's port plug-and-play function, simplifies the router's internet access process, reduces the operational complexity for users using the router to access the internet, and enhances the user experience.
[0007] In one possible implementation, the messages used to identify an IPv6 single-stack uplink environment include: Router Solicitation messages and / or Dynamic Host Configuration Protocol version 6 (DHCPv6) Solicitation messages. Sending Router Solicitation messages and / or DHCPv6 Solicitation messages allows the router to determine whether the current uplink environment is an IPv6 single-stack uplink environment. In this way, in an IPv6 single-stack uplink environment, the router will not identify the other end of the network cable connected to the router as a device within the local area network, thereby improving the accuracy of the router's uplink environment identification, simplifying user operations related to internet access via the router, and ultimately improving the user experience.
[0008] In one possible implementation, upon receiving a response message from any of multiple probe messages, the target network interface is set to the WAN port. This includes setting the target network interface to the WAN port upon receiving a Router Advertisement message and / or a DHCPv6 Advertise message. The Router Advertisement message is a response message to a Router Solicitation message, and the DHCPv6 Advertisement message is a response message to a DHCPv6 Solicitation message. After receiving the Router Advertisement message and / or the DHCPv6 Advertisement message, the router can recognize that the current uplink environment is an IPv6 single-stack uplink environment. Thus, in an IPv6 single-stack uplink environment, the router can accurately identify the uplink environment. This allows the router to not only support LAN / WAN auto-sensing functionality but also to recognize IPv6 single-stack uplink environments.
[0009] In one possible implementation, upon receiving a response message from any of the multiple probe messages, the target network interface is set to the WAN port. This includes setting the target network interface to the WAN port when the number of probe messages sent is less than a preset number, and a Router Advertisement message and / or a DHCPv6 Advertisement message are received. Since there may be occasional situations where the router fails to receive a response message, if the preset number is too small, the randomness cannot be reduced, resulting in inaccurate judgment. If the preset number is too large, the router may spend too much time sending probe messages and waiting for response messages, leading to slow router response. Therefore, increasing the preset number of attempts allows the router to probe the uplink environment within an appropriate timeframe. While maintaining judgment accuracy, it prevents the router's probe time from becoming excessively long.
[0010] In one possible implementation, the IPv6 single-stack uplink environment includes a Stateless Address Autoconfiguration (SLAAC) environment and / or a Dynamic Host Configuration Protocol (DHCP) version 6 environment. The router detects whether the other end of the network cable connected to the router is in an IPv6 single-stack uplink environment by sending relevant messages supporting this environment. This allows the router to identify the IPv6 single-stack uplink environment and thus provide more comprehensive network configuration capabilities.
[0011] In one possible implementation, the multiple probe messages also include an Active Discovery Initial (PADI) message based on the Point-to-Point Ethernet protocol, and / or a Dynamic Host Configuration Protocol (DHCP) Discover message. If a PPPoE server is present in the uplink environment, the PPPoE server will return a PADO message to the router after receiving the PADI message. If a DHCP server is present in the uplink environment, the DHCP server will return a DHCP Offer message to the router after receiving the DHCP Discover message. In this way, after receiving the PADO message and / or the DHCP Offer message, the router can determine that the other end of the network cable connected to the router is in the uplink environment, thus achieving LAN / WAN auto-negotiation.
[0012] In one possible implementation, multiple probe packets are sent serially or in parallel. Sending multiple probe packets serially enables router port identification. This reduces the instantaneous CPU resource consumption in the router, improving its operating efficiency. Sending multiple probe packets in parallel reduces probing time, including the time spent sending probe packets and receiving response packets, thus quickly identifying whether the network cable connected to the router is an uplink cable, thereby improving the user experience.
[0013] One possible implementation further includes setting the target network port to a LAN port if no response message is received from any of the multiple probe messages. The router can automatically determine whether internet access is possible by identifying whether the other end of the network cable connected to the router is in an uplink environment. If the other end of the network cable is not in an uplink environment, the router can set the network port to a LAN port. Otherwise, the router can set the network port to a WAN port. In this way, the router can adaptively identify either the LAN or WAN port, improving the user experience.
[0014] The second aspect provides a router port identification device, which includes a port connection detection module and a port identification module. The port connection detection module is used to detect whether a network cable is connected to a target port of the router. The target port can be any one of multiple network ports on the router. The port identification module is used to send multiple probe packets, receive response packets for multiple probe packets, and set the target port as a WAN port or a LAN port.
[0015] A third aspect provides an apparatus comprising one or more processors and a memory for storing one or more programs, and one or more processors for invoking one or more programs to perform the methods described in the first aspect or any possible implementation thereof.
[0016] A fourth aspect provides a chip or chip system applied to a device, comprising one or more processors. The one or more processors are used to invoke instructions to execute the methods described in the first aspect or any possible implementation thereof. The communication interface in the chip can be an input / output interface, pins, or circuits, etc.
[0017] In one possible implementation, the chip or chip system described above in this application further includes at least one memory storing instructions. The memory can be an internal storage unit of the chip, such as a register or cache, or it can be a storage unit of the chip itself (e.g., read-only memory, random access memory, etc.).
[0018] The fifth aspect provides a readable storage medium (also referred to as a computer-readable storage medium) storing a program that, when run on a device, causes the device to perform the methods described in the first aspect or any possible implementation thereof.
[0019] The sixth aspect provides a program product (also referred to as a computer program product) comprising a program. When the program is run on a device, it causes the device to perform the methods described in the first aspect or any possible implementation thereof.
[0020] It should be understood that the second to sixth aspects of this application correspond to the technical solutions of the first aspect of this application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation are similar, and will not be repeated here. Attached Figure Description
[0021] Figure 1 A schematic diagram illustrating a router sending probe packets, provided as an embodiment of this application;
[0022] Figure 2A schematic diagram illustrating another router sending probe packets according to an embodiment of this application;
[0023] Figure 3 This is a schematic diagram of the architecture of the router port identification device provided in the embodiments of this application;
[0024] Figure 4 A flowchart corresponding to the first embodiment of the router port identification method provided in this application;
[0025] Figure 5 This is a flowchart illustrating the second embodiment of the router port identification method provided in this application.
[0026] Figure 6 A schematic diagram illustrating a router port identification method provided in an embodiment of this application;
[0027] Figure 7 This is a schematic diagram of the structure of a chip provided in an embodiment of this application. Detailed Implementation
[0028] To facilitate a clear description of the technical solutions in the embodiments of this application, some terms and technologies involved in the embodiments of this application will be briefly introduced below:
[0029] 1. Terminology
[0030] In the embodiments of this application, terms such as "first" and "second" are used to distinguish identical or similar items with substantially the same function and purpose. For example, "first chip" and "second chip" are used only to distinguish different chips and do not limit their order of execution. Those skilled in the art will understand that terms such as "first" and "second" do not limit the quantity or execution order, and that "first" and "second" do not necessarily imply that they are different.
[0031] It should be noted that, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design scheme described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.
[0032] In this application embodiment, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, and c can be single or multiple.
[0033] Currently, some routers support blind-plugging of network ports. In some scenarios, this function is also called local area network (LAN) or wide area network (WAN) auto-sensing, or simply LAN / WAN auto-sensing. Essentially, a router with blind-plugging capability can automatically identify whether the other end of the network cable connected to the router is in an uplink environment. That is, a router with blind-plugging capability can automatically determine whether it can connect to the internet to access it. If the other end of the network cable is in an uplink environment, the router can set the network port as a WAN port. Otherwise, the router can set the network port as a LAN port.
[0034] like Figure 1 As shown, for routers with blind-plug capability, after detecting a network cable connection, the router can send probe packets to check if there is a network to connect to. For example, probe packets can include PPPoE Active Discovery Initiation (PADI) packets and Dynamic Host Configuration Protocol (DHCP) discovery packets. PADI packets can also be called PADI broadcast packets, and DHCP discovery packets can be called DHCP discover broadcast packets or DHCP discover packets.
[0035] If a PPPoE server exists in the uplink environment, it will return a PPPoE active discovery offer (PADO) message to the router after receiving a PADI message. If a DHCP server exists in the uplink environment, it will return a DHCP offer message to the router after receiving a DHCP discover message. This DHCP offer message can also be called a DHCP offer message. Thus, after receiving the PADO message and / or the DHCP offer message, the router can determine that the other end of the network cable connected to the router is from the uplink environment.
[0036] It's understandable that both PPPoE and DHCP servers can assign IPv4 addresses to routers. However, in some scenarios, the uplink environment lacks PPPoE and DHCP servers and cannot assign IPv4 addresses to the router. In such cases, the uplink environment and the router need to communicate using the IPv6 protocol. This communication environment can also be understood as an IPv6 single-stack uplink environment. In an IPv6 single-stack uplink environment, the router cannot obtain the corresponding PADO message for the PADI message sent by the router; nor can it obtain the corresponding DHCP offer message for the DHCP discover message sent by the router. In other words, the router cannot identify the uplink environment through the aforementioned LAN / WAN auto-sensing function. Consequently, the router will identify the other end of the network cable connected to the router as a device within the local area network, such as a computer, printer, or switch, and will not proceed with the subsequent internet access process.
[0037] In this scenario, users need to log into the router's webpage and disable its LAN / WAN auto-sensing function. This forces the router to permanently configure a specific network port as the WAN port, requiring the user to plug the network cable into that port for the router to access the internet. This increases the difficulty of accessing the internet, making the process more complex and reducing the user experience.
[0038] In view of this, the router port identification method provided in this application allows the router to send probe packets that support IPv6 single-stack uplink environments, in order to detect whether the other end of the network cable connected to the router is in an IPv6 single-stack uplink environment. This enables the router to not only support LAN / WAN auto-sensing but also to identify IPv6 single-stack uplink environments. This improves the adaptability of the router's port blind-plugging function, simplifies the router's internet access process, reduces the operational complexity for users using the router to access the internet, and enhances the user experience.
[0039] For example, such as Figure 2 As shown, the router can send not only PADI messages and / or DHCP discover messages, but also messages used to probe the IPv6 single-stack uplink environment. It is understood that the IPv6 single-stack uplink environment can include stateless address autoconfiguration (SLAAC) environments and dynamic host configuration protocol for IPv6 (DHCPv6) environments, etc. Therefore, messages used to probe the IPv6 single-stack uplink environment can include: Router Solicitation messages of Internet Control Message Protocol for IPv6 (ICMPv6) and / or DHCPv6 Solicit messages. Router Solicitation messages can be used to probe SLAAC environments, and DHCPv6 Solicit messages can be used to probe DHCPv6 environments.
[0040] It is understood that if the IPv6 single-stack uplink environment includes other possible uplink environments, then the relevant packets used to probe the IPv6 single-stack uplink environment may include even more packets, and this application embodiment does not limit this. For ease of description, in the following description, this application embodiment uses four probe packets—PADI packet, DHCP discover packet, RouterSolicitation packet, and DHCPv6 Solicit packet—as examples.
[0041] In a single-stack IPv6 uplink environment, if a PPPoE server and a DHCP server are not present, the router cannot obtain the PADO message corresponding to the PADI message, nor the DHCP offer message corresponding to the DHCP discover message. Uplink devices supporting a single-stack IPv6 uplink environment can return a Router Advertisement message to the router after obtaining a Router Solicitation message; and similarly, uplink devices supporting a single-stack IPv6 uplink environment can return a DHCPv6 Advertise message to the router after obtaining a DHCPv6 Solicitation message.
[0042] Upon receiving Router Advertisement messages and / or DHCPv6 Advertisement messages, the router can identify the current uplink environment as an IPv6 single-stack uplink environment. In this IPv6 single-stack uplink environment, the router will not identify the other end of the network cable connected to the router as a device within the local area network, thereby improving the accuracy of the router's uplink environment identification, simplifying user operations related to internet access via the router, and ultimately enhancing the user experience.
[0043] The methods of this application will be described in detail below through specific embodiments. The following embodiments can be combined with each other or implemented independently, and the same or similar concepts or processes may not be described again in some embodiments.
[0044] Figure 3 A schematic diagram of the architecture of a router port identification device according to an embodiment of this application is shown.
[0045] A router port identification device may include a port connection detection module and a port identification module.
[0046] The Ethernet port connection detection module can be used to detect whether a network cable is connected to the router's Ethernet port. For example, when the Ethernet port connection detection module detects that a network cable is connected to the Ethernet port, it can notify the Ethernet port identification module.
[0047] The network port identification module may include a probe message construction submodule and a response message identification submodule.
[0048] The probe message construction submodule can be used to construct probe messages such as PADI messages, DHCP Discover messages, RouterSolicitation messages and / or DHCPv6 Solicit messages, and can also send these probe messages through the Ethernet port.
[0049] The response message identification submodule can be used to create raw socket interfaces to listen for messages received on the Ethernet port. It can also be used to identify whether a received message is a response message corresponding to a probe message.
[0050] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the device. In other embodiments of this application, the device may include more or fewer modules than illustrated, or combine some modules, or split some modules, or arrange different modules. The module names involved in the embodiments of this application can all be defined as other names, as long as they can achieve the function of each module, and no specific limitation is made on the module names. The illustrated modules may include hardware, software, or a combination of software and hardware.
[0051] The following will be combined with the appendix Figure 4 and Figure 5 Taking the first embodiment (1) and the second embodiment (2) as examples, the router port identification method provided in this application will be described in detail. Among them, the first embodiment (1) adopts the method of sending each probe packet serially to realize the router port identification method. The second embodiment adopts the method of sending each probe packet in parallel to realize the router port identification method.
[0052] It is understood that the following technical solutions are merely specific implementations of the embodiments of this application and are not intended to limit the protection scope of the embodiments of this application. Modifications, equivalent substitutions, improvements, etc., made based on the technical solutions of the embodiments of this application should all be included within the protection scope of the embodiments of this application.
[0053] (1) First embodiment
[0054] For example, such as Figure 4 The diagram shown is a flowchart of the router port identification method in the first embodiment.
[0055] S401 The network port connection detection module detected that a network cable was connected to the router's network port.
[0056] The network port connection detection module can detect whether a network cable is connected to the router's network port. In a possible implementation, the network port connection detection module can identify the network cable connection by detecting the electrical signals on the Ethernet port.
[0057] Optionally, the router's indicator light can illuminate when the network cable is successfully connected, allowing users to easily see that the network cable is connected.
[0058] After the network port connection detection module detects that a network cable is connected to the router's network port, it can notify the network port identification module. For example, the network port connection detection module can send a message to the network port identification module to indicate that a network cable is connected to the router's network port. Then, after the network port identification module receives this message, it can execute steps S402 and S403.
[0059] S402, Construct the probe message submodule to send PADI messages.
[0060] S403, The response message recognition submodule determines whether a PADO message has been received.
[0061] Understandably, after a network cable is connected to a router's network port, the probe message construction submodule within the network port identification module will send a PADI message. After this message is sent, the response message identification submodule within the network port identification module can listen for the received response message via a raw socket interface to determine if it matches the message received by that router's network port. If the router's network port matches, the response message identification submodule can parse the received response message and, based on the protocol type of the response message, determine whether it is a PADO message corresponding to the PADI message.
[0062] In some scenarios, the response message identification submodule may fail to receive the PADO message. This failure to receive the PADO message can be understood as a response message reception timeout. The failure to receive the PADO message can occur within a preset time period A after sending the PADO message. This preset time period A can be pre-set in the router; for example, the value of the preset time period A can include 200 milliseconds (ms), 500 ms, or 1 second (s). The specific value of the preset time period A is not limited in this embodiment.
[0063] If the response message identification submodule receives a PADO message, the network port identification module can determine that the router is connected to an uplink network cable, and then proceed to step S410.
[0064] If the response message identification submodule does not receive the PADO message, steps S404 and S405 can be executed.
[0065] S404, Construct the probe message submodule to send a DHCP discover message.
[0066] S405, The response message recognition submodule determines whether a DHCP offer message has been received.
[0067] Similar to steps S402 and S403, after the probe message submodule sends a DHCP discover message, the response message identification submodule can listen for response messages received on the Ethernet port via the raw socket interface. The response message identification submodule can also determine whether the response message is a DHCP offer message corresponding to the DHCP discover message based on its protocol type.
[0068] In some scenarios, the response message identification submodule may fail to receive the DHCP offer message, i.e., the response message reception times out. This failure to receive the DHCP offer message may occur within a preset time period B after sending the DHCP discover message. This preset time period B can be pre-set in the router; for example, its value may include 200ms, 500ms, or 1s. The values of preset time period B and preset time period A may be the same or different; the specific value of preset time period B is not limited in this embodiment.
[0069] If the response message identification submodule receives a DHCP offer message, the network port identification module can determine that the router is connected to an uplink network cable, and then proceed to step S410.
[0070] If the response message identification submodule does not receive the DHCP offer message, steps S406 and S407 can be executed.
[0071] S406. Construct the probe message submodule to send the Router Solicitation message.
[0072] S407, The response message recognition submodule determines whether a Router Advertisement message has been received.
[0073] Similar to steps S402 and S403, after the probe message submodule sends the Router Solicitation message, the response message identification submodule can listen for response messages received on the Ethernet port via the raw socket interface. The response message identification submodule can also determine whether the response message is a Router Advertisement message corresponding to a RouterSolicitation message based on its protocol type.
[0074] In some scenarios, the response message identification submodule may not receive the Router Advertisement message, resulting in a response message timeout. This failure to receive the Router Advertisement message may occur within a preset time period C after sending the Router Solicitation message. This preset time period C can be pre-set in the router; for example, its value may be 200ms, 500ms, or 1s. The values of preset time period C and preset time period A can be the same or different, as can the values of preset time period C and preset time period B. The specific value of preset time period C is not limited in this embodiment.
[0075] If the response message identification submodule receives a Router Advertisement message, the network port identification module can determine that the router is connected to an uplink network cable, and then proceed to step S410.
[0076] If the response message identification submodule does not receive the Router Advertisement message, steps S408 and S409 can be executed.
[0077] S408, Construct the probe message submodule to send a DHCPv6 Solicit message.
[0078] S409, The response message identification submodule determines whether a DHCPv6 Advertise message has been received.
[0079] Similar to steps S402 and S403, after the probe message submodule sends a DHCPv6 Solicit message, the response message identification submodule can listen for response messages received on the Ethernet port via the raw socket interface. The response message identification submodule can also determine whether the response message is a DHCPv6 Advertise message corresponding to a DHCPv6 Solicit message based on its protocol type.
[0080] In some scenarios, the response message identification submodule may not receive a DHCPv6 Advertise message, resulting in a response message timeout. This failure to receive the DHCPv6 Advertise message may occur within a preset time period D after sending the DHCPv6 Solicit message. This preset time period D can be pre-set in the router; for example, its value may be 200ms, 500ms, or 1s. The preset time period D may have the same or different values as preset time periods A, B, and C. The specific value of the preset time period D is not limited in this embodiment.
[0081] If the response message identification submodule receives a DHCPv6 Advertise message, the network port identification module can determine that the router is connected to an uplink network cable, and then proceed to step S410.
[0082] If the response message identification submodule does not receive the DHCPv6 Advertise message, then step S411 can be executed.
[0083] The S410 network port identification module determines that the router is connected to an uplink network cable.
[0084] Understandably, when the response message identification submodule receives any of the four response messages mentioned above, the network port identification module can determine that the network cable connected to the router is an uplink network cable. The network port identification module can then set the port where the network cable is inserted as the WAN port and perform IPv4 and / or IPv6 dialing.
[0085] In actual execution, the router may not have a specific "OK" step. The "OK" in this step can be understood as the router proceeding to the next step after receiving any of the four response messages mentioned above, such as performing IPv4 and IPv6 dialing procedures.
[0086] S411. Construct the probe message submodule to determine if the number of times the message is sent has reached the upper limit.
[0087] It is understandable that when the response message identification submodule does not receive any of the four response messages, since all four probe messages have been sent once, this can be considered as the probe message construction submodule sending one message. The number of messages sent can also be equal to the number of times the response message identification submodule fails to receive any of the four response messages. That is, each time from step S402 to step S411 (excluding step S410), the number of messages sent by the probe message construction submodule can be incremented by 1.
[0088] The upper limit value can be preset in the router. The specific value of the upper limit is not limited in this embodiment. For example, based on testing experience, the upper limit value can be 4 or a value close to that. It is understood that, since there may be occasional situations where the response message identification submodule fails to receive all four response messages, if the upper limit value is too small, the randomness cannot be reduced, thus hindering accurate judgment. If the upper limit value is too large, it may cause the router to spend too much time sending probe messages and waiting for response messages, resulting in a slow router response and a degraded user experience.
[0089] If the probe message submodule detects that the number of times the message has been sent has not reached the upper limit, which can be understood as the number of times the message has been sent being less than the upper limit, then step S402 can be executed again to resend the probe message.
[0090] If the probe message construction submodule detects that the number of times the message has been sent has reached the upper limit, it can be understood that the number of times the message has been sent is greater than or equal to the upper limit. This means that the probe message construction submodule has sent the above four probe messages multiple times, and the response message identification submodule still has not received any of the above four response messages. Then step S412 can be executed.
[0091] S412, The network port identification module determines that the router is not connected to an upstream network cable.
[0092] The network port identification module can determine that the network cable connected to the router is not an upstream cable, meaning that the other end of the cable is a device within the local area network (LAN), such as a computer, printer, or switch. In this way, the module can configure the port where the cable is plugged in as a LAN port and assign IP addresses to the connected devices within the LAN.
[0093] It is understandable that, similar to step S410, the router may not have a specific "determine" step in the actual execution process. The "determine" step in this case can be understood as follows: if the router has reached its maximum number of message sending attempts and has not yet received any of the four response messages mentioned above, the router can proceed to the next step, such as assigning an IP address.
[0094] Optionally, in the first embodiment, the order in which the four probe messages sent by the probe message construction submodule are not limited. The probe message construction submodule can send these four probe messages in any possible order. It can also be understood that the execution order of steps S402, S404, S406 and S408 is not limited in this embodiment.
[0095] The first embodiment of this application can implement a router port identification method by serially sending various probe messages. This reduces the instantaneous resource consumption of the router's central processing unit (CPU) and improves the router's operating efficiency.
[0096] (2) Second embodiment
[0097] For example, such as Figure 5 The diagram shown is a flowchart of the router port identification method according to the second embodiment.
[0098] S501 The network port connection detection module detected that a network cable was connected to the router's network port.
[0099] The network port connection detection module can detect whether a network cable is connected to the router's network port. For specific detection methods, please refer to the above text. Figure 4 The relevant descriptions in step S401 of the corresponding embodiment will not be repeated here.
[0100] After the network port connection detection module detects that a network cable is connected to the router's network port, it can notify the network port identification module. Then, the network port identification module can execute the following steps S502 to S505.
[0101] It is understood that the probe message construction submodule can execute steps S502 to S505 in parallel, meaning that the probe message construction submodule can send each message in steps S502 to S505 in parallel. Steps S502 to S505 do not represent the order in which the router interface identification method is executed. It can also be understood that the probe message construction submodule sends PADI messages, DHCP discover messages, Router Solicitation messages, and DHCPv6 Solicit messages without distinguishing the order in which they are sent. These messages can be sent simultaneously or separately with a short interval between them; this embodiment does not impose any limitations.
[0102] S502, Construct the probe message submodule to send PADI messages.
[0103] S503, Construct the probe message submodule to send a DHCP discover message.
[0104] S504. Construct the probe message submodule to send the Router Solicitation message.
[0105] S505, Construct the probe message submodule to send a DHCPv6 Solicit message.
[0106] S506, The response message recognition submodule determines whether a response message has been received.
[0107] In a possible implementation, the response message recognition submodule can listen for response messages received on the Ethernet port via a raw socket interface.
[0108] Each of the aforementioned probe messages has its corresponding response message: the PADI message corresponds to the PADO message, the DHCP discover message corresponds to the DHCP offer message, the Router Solicitation message corresponds to the RouterAdvertisement message, and the DHCPv6 Solicit message corresponds to the DHCPv6 Advertisement message. The response message identification submodule determines whether a response message has been received; this can be understood as whether the response message identification submodule has received at least one of the four response messages.
[0109] In some possible scenarios, the response message recognition submodule may not receive the four response messages mentioned above, which means there may be a response message reception timeout.
[0110] In one possible implementation, the failure to receive the above four response messages may include: within a preset time period A after sending the PADI message, the response message identification submodule does not receive the PADO message; within a preset time period B after sending the DHCP discover message, the response message identification submodule does not receive the DHCP offer message; within a preset time period C after sending the RouterSolicitation message, the response message identification submodule does not receive the RouterAdvertisement message; and within a preset time period D after sending the DHCPv6 Solicit message, the response message identification submodule does not receive the DHCPv6 Advertise message. The preset time periods A, B, C, and D can be defined by referring to... Figure 4 The relevant descriptions of steps S403 to S409 in the corresponding embodiments will not be repeated.
[0111] In another possible implementation, the failure to receive the four response messages may include: within a preset time period E after sending the first of the four probe messages, the response message identification submodule does not receive any response messages corresponding to the four probe messages. This preset time period E can be pre-set in the router; for example, the value of the preset time period E may include 200ms, 500ms, or 1s. The preset time period E may be the same as or different from the values of preset time periods A, B, C, and D, respectively. The specific value of the preset time period E is not limited in this embodiment.
[0112] In another possible implementation, the failure to receive the four response messages may include: within a preset time period F after sending the last of the four probe messages, the response message identification submodule does not receive any response messages corresponding to the four probe messages. This preset time period F can be pre-set in the router; for example, the value of the preset time period F may include 200ms, 500ms, or 1s. The preset time period F may be the same as or different from the values of preset time periods A, B, C, D, and E, respectively. The specific value of the preset time period F is not limited in this embodiment.
[0113] If the response message identification submodule receives at least one of the above four response messages, then step S507 can be executed.
[0114] If the response message identification submodule does not receive any of the above four response messages, then step S508 can be executed.
[0115] S507, the network port identification module determines that the router is connected to an uplink network cable.
[0116] Understandably, this step can be referred to Figure 4 The relevant descriptions in step S410 of the corresponding embodiment will not be repeated here.
[0117] S508. Check if the number of times the probe message submodule sends messages has reached the upper limit.
[0118] It is understandable that when the response message identification submodule does not receive any of the four response messages, since all four probe messages have been sent once, this can be considered as the probe message construction submodule sending one message. The number of messages sent can also be equal to the number of times the response message identification submodule fails to receive any of the four response messages. In other words, each time from step S502 to step S508 (excluding step S507), the number of messages sent by the probe message construction submodule can be incremented by 1.
[0119] The upper limit value can be referred to Figure 4 The relevant descriptions in step S411 of the corresponding embodiment will not be repeated here.
[0120] If the probe message construction submodule detects that the number of times the message has been sent has not reached the upper limit, it can continue to execute steps S502 to S505 to resend each probe message.
[0121] If the probe message construction submodule detects that the number of times the message has been sent has reached the upper limit, it means that the probe message construction submodule has sent the above four probe messages multiple times, and the response message identification submodule still has not received at least one of the above four response messages. Then step S509 can be executed.
[0122] S509, the network port identification module determines that the router is not connected to an upstream network cable.
[0123] Understandably, this step can be referred to Figure 4 The relevant descriptions in step S412 of the corresponding embodiment will not be repeated here.
[0124] The second embodiment of this application can implement a router port identification method by sending various probe packets in parallel. This parallel execution reduces probe time, including the time spent sending probe packets and receiving response packets, thereby enabling faster identification of whether the network cable connected to the router is an uplink cable, and ultimately improving the user experience.
[0125] It is understood that, for the router port identification method provided in this application embodiment, in an IPv6 single-stack uplink environment scenario, the Wireshark tool can be used to check whether the router sends Router Solicitation messages and / or DHCPv6 Solicit messages.
[0126] Figure 6 This application illustrates a router network port identification method according to an embodiment of the present application, applied to a router. The method includes:
[0127] S601. Upon detecting that a network cable is connected to the target network port, send multiple probe messages, including messages used to identify the IPv6 single-stack uplink environment; wherein, the IPv6 single-stack uplink environment is the environment in which the router communicates with the server based on the IPv6 protocol, and the target network port is any one of the multiple network ports of the router.
[0128] In this embodiment, the target network port is any one of the multiple network ports of the router, and the target network port may include the network port where the network cable is connected to the router. This target network port can be used as a WAN port or a LAN port. The router can set the target network port as a WAN port or a LAN port based on the identification of the connected network cable; alternatively, the user can configure the target network port as a WAN port or a LAN port, which is not limited in this embodiment.
[0129] Multiple probe messages can include the above. Figure 4 Corresponding embodiments or Figure 5 The various messages mentioned in the corresponding embodiments include PADI messages, DHCP discover messages, Router Solicitation messages, and DHCPv6 Solicit messages. Probe messages may also include other messages, which are not limited in this application embodiment.
[0130] Messages used to identify an IPv6 single-stack uplink environment may include the Router Solicitation message and the DHCPv6 Solicitation message mentioned above. Of course, other messages may also be included, and this application embodiment does not limit this.
[0131] S602. Upon receiving a response message from any one of the multiple probe messages, set the target network port as the WAN port.
[0132] Understandably, different probe messages can correspond to various different response messages. For example, a PADI message corresponds to a PADO message, a DHCP discover message corresponds to a DHCP offer message, a Router Solicitation message corresponds to a Router Advertisement message, and a DHCPv6 Solicit message corresponds to a DHCPv6 Advertisement message, and so on.
[0133] The response message to any one of the multiple probe messages can include any one of the following: PADO message, DHCP offer message, Router Advertisement message, and DHCPv6 Advertisement message. If the multiple probes include other messages, the response message received by the router can also include responses to those other messages. When the router receives any of the above response messages, it can determine that the network cable connected to the router is the upstream cable. Therefore, the router can designate the port where the network cable is plugged in, i.e., the target port, as the WAN port.
[0134] The router port identification method provided in this application allows the router to send probe packets that may include packets supporting IPv6 single-stack uplink environments, in order to detect whether the other end of the network cable connected to the router is in an IPv6 single-stack uplink environment. This enables the router to not only support LAN / WAN auto-sensing but also to identify IPv6 single-stack uplink environments. This improves the adaptability of the router's port blind-plugging function, simplifies the router's internet access process, reduces the operational complexity for users using the router to access the internet, and enhances the user experience.
[0135] Optional, in Figure 6 Based on the corresponding embodiments, the messages used to identify an IPv6 single-stack uplink environment include: Router Solicitation messages and / or Dynamic Host Configuration Protocol version 6 (DHCPv6) Solicit messages. The messages used to identify an IPv6 single-stack uplink environment can be referred to the relevant description in step S601 above. It is understood that the router sending Router Solicitation messages and / or DHCPv6 Solicit messages can be used to identify whether the current uplink environment is an IPv6 single-stack uplink environment. In this way, in an IPv6 single-stack uplink environment, the router will not identify the other end of the network cable connected to the router as a device within the local area network, thereby improving the accuracy of the router's uplink environment identification, simplifying the user's operation related to using the router to access the Internet, and thus improving the user experience.
[0136] Optional, in Figure 6 Based on the corresponding embodiments, when a response message of any one of the multiple probe messages is received, setting the target network port as the WAN port may include: when a Router Advertisement message and / or a DHCPv6 Advertise message are received, setting the target network port as the WAN port; wherein the Router Advertisement message is a response message of the Router Solicitation message, and the DHCPv6 Advertise message is a response message of the DHCPv6 Solicit message.
[0137] In this embodiment, after receiving a Router Advertisement message and / or a DHCPv6 Advertisement message, the router can identify that the current uplink environment is an IPv6 single-stack uplink environment. Thus, in an IPv6 single-stack uplink environment, the router can accurately identify the uplink environment. This allows the router to not only support LAN / WAN adaptive functionality but also to recognize IPv6 single-stack uplink environments.
[0138] Optional, in Figure 6 Based on the corresponding embodiments, when a response message is received from any one of the multiple probe messages, setting the target network port as a WAN port may include: when the number of times multiple probe messages are sent is less than a preset number, and a Router Advertisement message and / or a DHCPv6 Advertisement message are received, setting the target network port as a WAN port.
[0139] In this embodiment of the application, the preset number of times can be understood as... Figure 4 The upper limit value corresponds to the example. This preset number of times can be preset in the router. The specific value of the preset number of times is not limited in this embodiment. For example, the preset number of times can be 4 or a value close to that.
[0140] Understandably, since there might be occasional situations where the router fails to receive a response packet, if the preset number of attempts is too small, the randomness cannot be reduced, thus hindering accurate judgment. If the preset number of attempts is too large, the router may spend too much time sending probe packets and waiting for response packets, resulting in a slow response. Therefore, increasing the preset number of attempts allows the router to probe the uplink environment within an appropriate timeframe. While maintaining accuracy, it prevents the router's probe time from becoming excessively long. Optionally, in Figure 6 Based on the corresponding implementation, the IPv6 single-stack uplink environment includes a stateless address autoconfiguration (SLAAC) environment and / or a dynamic host configuration (DHCPv6) version 6 environment.
[0141] In this embodiment, the router detects whether the other end of the network cable connected to the router is in an IPv6 single-stack uplink environment by sending relevant messages supporting such an environment. This allows the router to identify the IPv6 single-stack uplink environment and provide more comprehensive network configuration capabilities.
[0142] Optional, in Figure 6 Based on the corresponding embodiments, multiple probe messages also include Active Discovery Initial PADI messages based on the Point-to-Point Ethernet protocol, and / or Dynamic Host Configuration Protocol (DHCP) discovery messages.
[0143] In this embodiment, when a PPPoE server is present in the uplink environment, the PPPoE server will return a PADO message to the router after receiving a PADI message. When a DHCP server is present in the uplink environment, the DHCP server will return a DHCP offer message to the router after receiving a DHCP discover message. Thus, after receiving the PADO message and / or the DHCP offer message, the router can determine that the other end of the network cable connected to the router is in the uplink environment, thereby achieving LAN / WAN adaptive functionality.
[0144] Optional, in Figure 6 Based on the corresponding implementation, multiple probe messages are sent serially or in parallel.
[0145] In this embodiment, the implementation of sending multiple probe messages serially can be referred to... Figure 4 The relevant descriptions in the corresponding embodiments; the implementation method of sending multiple probe messages in parallel can be referred to... Figure 5 The relevant descriptions in the corresponding embodiments will not be repeated here.
[0146] It's understandable that sending multiple probe packets serially is a good way to identify router ports. This reduces the router's instantaneous CPU resource consumption and improves its operating efficiency. Sending multiple probe packets in parallel is another option. This parallel execution reduces probing time, including the time spent sending probe packets and receiving response packets, allowing for faster identification of whether the network cable connected to the router is an uplink cable, thus improving the user experience.
[0147] Optional, in Figure 6 Based on the corresponding embodiments, the method may further include: setting the target network port as a LAN port if no response message is received from any of the multiple probe messages.
[0148] In this embodiment, if no response message is received from any of the multiple probe messages, the router can determine that the network cable connected to the router is not an upstream network cable, meaning that the other end of the network cable connected to the router is a device within the local area network, such as a computer, printer, or switch. In this way, the network port identification module can identify the port where the network cable is inserted as a LAN port and assign IP addresses to the connected devices within the local area network.
[0149] Routers can automatically determine internet access capability by identifying whether the other end of the network cable connected to the router is in an uplink environment. If the other end of the cable is not in an uplink environment, the router can configure the network port as a LAN port. Otherwise, the router can configure the network port as a WAN port. In this way, the router can adaptively identify whether to use the LAN or WAN port, improving the user experience.
[0150] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0151] The foregoing mainly describes the technical solutions provided by the embodiments of this application from a methodological perspective. To achieve the above functions, it includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that the method steps described in conjunction with the embodiments of this application can be implemented in hardware or a combination of hardware and software. Whether a function is executed in a hardware-driven or software-driven manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0152] This application provides a device that may include one or more processors and a memory. The memory may be used to store one or more programs. The one or more processors may invoke one or more programs to cause the device to execute the technical solutions described in the above embodiments. In some scenarios, the device may also be referred to as an electronic device; however, this application does not limit the specific name of the device.
[0153] This application provides a chip system. This chip system is applied to a device and may include one or more processors. The one or more processors can be used to invoke instructions to cause the device to execute the technical solutions described above.
[0154] Figure 7 This is a schematic diagram of a chip system provided in an embodiment of this application. The chip system 700 includes one or more processors 701, communication lines 702, communication interfaces 703, and memory 704.
[0155] In some implementations, memory 704 stores elements such as executable modules or data structures, or subsets thereof, or extended sets thereof.
[0156] The methods described in the embodiments of this application can be applied to, or implemented by, processor 701. Processor 701 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above methods can be completed by integrated logic circuits in the hardware of processor 701 or by instructions in software form. Processor 701 may be a general-purpose processor (e.g., a microprocessor or conventional processor), DSP, application-specific integrated circuit, off-the-shelf programmable gate array or other programmable logic device, discrete gate, transistor logic device, or discrete hardware component. Processor 701 can implement or execute the processing-related methods, steps, and logic block diagrams in the embodiments of this application.
[0157] The method described in this application can be implemented using a hardware decoding processor, or by a combination of hardware and software modules within the decoding processor. The software modules can be located in the memory 704, and the processor 701 can read information from the memory 704 and, in conjunction with its hardware, complete the steps of the above method. The processor 701, the memory 704, and the communication interface 703 can communicate via the communication line 702.
[0158] This application also provides a readable storage medium (also referred to as a computer-readable storage medium). The readable storage medium includes a program. When the program is run on the device, it causes the device to perform the technical solutions described in the above embodiments.
[0159] The methods described in the above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any combination thereof. If implemented in software, the functionality can be stored or transmitted on a readable medium as one or more instructions or programs. The readable medium can include storage media and communication media, and can also include any medium that can transfer a program from one place to another. The storage medium can be any accessible target medium.
[0160] In possible implementations, the readable medium may include random access memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, optical disc read-only memory, or other optical disc storage. The readable medium may also include disk storage or other disk storage devices, or be directed to any other medium or store the required program in the form of instructions or data structures, and be accessible.
[0161] This application also provides a program product (also referred to as a computer program product). The program product includes a program. When the program runs on a device, it causes the device to execute the technical solutions described in the above embodiments.
[0162] In the various embodiments of this application, unless otherwise specified or in case of logical conflict, the terminology and / or descriptions between the various embodiments are consistent and can be referenced by each other. Technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships.
[0163] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A router network port identification method, applied to a router, characterized in that, The method includes: Upon detecting a network cable connected to the target network port, multiple probe messages are sent, including messages used to identify an IPv6 single-stack uplink environment; wherein, the IPv6 single-stack uplink environment is the environment in which the router communicates with the server based on the IPv6 protocol, and the target network port is any one of the multiple network ports of the router. Upon receiving a response message from any one of the plurality of probe messages, the target network port is set as a WAN port.
2. The method as described in claim 1, characterized in that, The messages used to identify the IPv6 single-stack uplink environment include: Router Solicitation messages and / or Dynamic Host Configuration Protocol version 6 Solicit messages.
3. The method as described in claim 2, characterized in that, The step of setting the target network port as a WAN port upon receiving a response message from any one of the plurality of probe messages includes: Upon receiving a Router Advertisement message and / or a DHCPv6 Advertise message, the target network port is set as the WAN port; wherein the Router Advertisement message is a response message to the Router Solicitation message, and the DHCPv6 Advertise message is a response message to the DHCPv6 Solicitation message.
4. The method as described in claim 3, characterized in that, The step of setting the target network port as a WAN port upon receiving a response message from any one of the plurality of probe messages includes: If the number of times the plurality of probe messages are sent is less than a preset number, and the Router Advertisement message and / or the DHCPv6 Advertisement message are received, the target network port is set as the WAN port.
5. The method according to any one of claims 1-4, characterized in that, The IPv6 single-stack uplink environment includes a Stateless Address Autoconfiguration (SLAAC) environment and / or a Dynamic Host Configuration (DHCP) version 6 environment.
6. The method according to any one of claims 1-5, characterized in that, The multiple probe messages also include Active Discovery Initial PADI messages based on the Point-to-Point Ethernet protocol, and / or Dynamic Host Configuration Protocol (DHCP) discovery messages.
7. The method according to any one of claims 1-6, characterized in that, The multiple probe messages are sent serially or in parallel.
8. The method according to any one of claims 1-7, characterized in that, The method further includes setting the target network port as a LAN port if no response message is received from any of the plurality of probe messages.
9. A device, characterized in that, The device includes: one or more processors and memory; The memory is used to store one or more programs, which are invoked by the one or more processors to cause the device to perform the method as described in any one of claims 1-8.
10. A chip system, characterized in that, The chip system is applied to a device, the chip system including one or more processors, the one or more processors being configured to invoke instructions to cause the device to perform the method as described in any one of claims 1-8.
11. A readable storage medium, characterized in that, The readable storage medium includes a program that, when run on the device, causes the device to perform the method as described in any one of claims 1-8.
12. A program product, characterized in that, The program product includes a program that, when run on a device, causes the device to perform the method as described in any one of claims 1-8.