Router network port adaptive setting method and device, electronic equipment and medium

By sending and listening to probe packets at the application layer, the lag issue during router network port probing is resolved, the code structure is simplified, and the probing efficiency and smoothness are improved.

CN115622879BActive Publication Date: 2026-04-07SHENZHEN SKYWORTH DIGITAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-18
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

During the network port probing process, the existing router needs to send probe packets to four network ports, causing the kernel to forward unnecessary packets to the application layer, resulting in lag.

Method used

By sending probe packets to the network interface under test at the application layer and listening for reply packets, and setting the network interface to WAN or LAN, the kernel can be prevented from forwarding packets, simplifying the code structure and reducing resource consumption.

Benefits of technology

It improves the smoothness of the network port detection process, reduces the risk of router lag, and enhances network port detection efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115622879B_ABST
    Figure CN115622879B_ABST
Patent Text Reader

Abstract

The application discloses a router network port adaptive setting method and device, electronic equipment and medium. The router network port adaptive setting method comprises the following steps: adding a to-be-tested network port of a router to a LAN test bridge interface, and sending a detection packet to the to-be-tested network port through an application layer, wherein the source MAC address of the detection packet is the MAC address of the LAN test bridge interface; listening to the LAN test bridge interface; when a preset reply packet is received by the application layer, setting the to-be-tested network port as a WAN port; otherwise, setting the to-be-tested network port as a LAN port. The application solves the technical problem that the router is stuck during network port detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of communications, and in particular to a method, apparatus, electronic device, and medium for adaptive setting of router network ports. Background Technology

[0002] Most mainstream routers nowadays have LAN (local area network) / WAN (wide area network) auto-sensing capabilities. All ports on such routers can automatically determine whether the connection is to a PC or a gateway device and set the corresponding port as either WAN or LAN. This allows the network cable connecting to the optical modem to be connected to any port on the router, instead of being restricted to a specific port. However, this method requires sending probe packets to the LAN bridge interface, and the code structure for receiving reply packets through the kernel is complex and resource-intensive. Since probe packets need to be sent to all four ports, the kernel will send unnecessary packets to the application layer, causing the router to lag during port detection. Summary of the Invention

[0003] The main purpose of this application is to provide a router network port adaptive setting method, device, electronic device and medium, which aims to solve the technical problem of router lag during network port detection.

[0004] To achieve the above objectives, this application provides a router network port adaptive setting method, the router network port adaptive setting method comprising:

[0005] Add the router's network port to be tested to the LAN bridge interface, and send a probe packet to the network port to be tested through the application layer. The source MAC (Media Access Control Address) address of the probe packet is the MAC address of the LAN bridge interface.

[0006] Monitor the LAN bridge interface. When the application layer receives a preset reply message, set the network port under test as the WAN port; otherwise, set the network port under test as the LAN port.

[0007] Optionally, before the step of adding the router's network port under test to the LAN bridge interface and sending probe packets to the network port under test through the application layer, the method further includes:

[0008] When a network cable is detected connected to the network port under test, the kernel transmits the online message of the network port under test to the application layer.

[0009] Based on the online message, determine whether the WAN port already exists;

[0010] If it already exists, then set the network port to be tested as a LAN port;

[0011] If it does not exist, then adaptive settings will be applied to the network port under test.

[0012] Optionally, the probe message includes a DHCP (Dynamic Host Configuration Protocol) discovery message and a PADI (PPPoE (Point-to-Point Protocol Over Ethernet) activation discovery start message) message. The step of adding the router's network port to be tested to the LAN bridge interface and sending probe messages to the network port to be tested through the application layer includes:

[0013] Add the network port to be tested to the LAN bridge interface;

[0014] Configure the message parameters corresponding to the DHCP discovery message and the PADI message respectively, and create the probe message;

[0015] The probe message is sent to the network port under test through the application layer.

[0016] Optionally, the message parameters include the source MAC address, the destination sending interface, and the option field. The steps of configuring the message parameters corresponding to the DHCP discovery message and the PADI message, and creating the probe message, include:

[0017] Set the layer source MAC address corresponding to both the DHCP discovery message and the PADI message to the MAC address of the LAN bridge interface;

[0018] The transmission sets the destination sending interface corresponding to both the DHCP discovery message and the PADI message to the network port under test;

[0019] Set the option field of the DHCP discovery message to the first preset field (field identifier);

[0020] The probe message is created based on the message parameters, the DHCP discovery message, and the PADI message.

[0021] Optionally, the preset reply message includes at least one of a DHCP offer message and a PADO (PPPoE Activation Discovery Service) message. The step of monitoring the LAN bridge interface and, when the application layer receives the preset reply message, setting the network port under test as a WAN port; otherwise, setting the network port under test as a LAN port includes:

[0022] Monitor the LAN bridge interface, and when the application layer receives a reply message, determine whether the reply message belongs to the preset reply message;

[0023] If so, disconnect the network port to be tested from the LAN bridge interface and set the network port to be tested as a WAN port;

[0024] If not, then set the network port to be tested as a LAN port.

[0025] Optionally, after the step of setting the network port under test as a WAN port when the application layer receives a preset reply message while monitoring the LAN bridge interface, the method further includes:

[0026] Store the setting result of the network port to be tested as a WAN port to obtain the WAN port identifier corresponding to the network port to be tested;

[0027] When a network cable is detected connected to another physical network port of the router, the WAN port identifier is added to the online message.

[0028] Optionally, the router port adaptive setting method further includes:

[0029] When a DHCP discovery message is received, the option field of the DHCP discovery message is checked;

[0030] If the option field of the DHCP discovery message is the first preset field, then no reply will be given.

[0031] This application also provides a router port adaptive setting device, which is applied to a router port adaptive setting device, and the router port adaptive setting device includes:

[0032] The message sending module is used to add the network port under test of the router to the LAN bridge interface and send probe messages to the network port under test through the application layer, wherein the source MAC address of the probe message is the MAC address of the LAN bridge interface;

[0033] The network port setting module is used to monitor the LAN test bridge interface. When the application layer receives a preset reply message, it sets the network port under test as a WAN port; otherwise, it sets the network port under test as a LAN port.

[0034] Optionally, the message sending module is further configured to:

[0035] When a network cable is detected connected to the network port under test, the kernel transmits the online message of the network port under test to the application layer.

[0036] Based on the online message, determine whether the WAN port already exists;

[0037] If it already exists, then set the network port to be tested as a LAN port;

[0038] If it does not exist, then adaptive settings will be applied to the network port under test.

[0039] Optionally, the message sending module is further configured to:

[0040] Add the network port to be tested to the LAN bridge interface;

[0041] Configure the message parameters corresponding to the DHCP discovery message and the PADI message respectively, and create the probe message;

[0042] The probe message is sent to the network port under test through the application layer.

[0043] Optionally, the message sending module is further configured to:

[0044] Set the layer source MAC address corresponding to both the DHCP discovery message and the PADI message to the MAC address of the LAN bridge interface;

[0045] The transmission sets the destination sending interface corresponding to both the DHCP discovery message and the PADI message to the network port under test;

[0046] Set the option field of the DHCP discovery message to a first preset field, wherein the first preset field is used to characterize the identity of the sending device of the DHCP discovery message;

[0047] The probe message is created based on the message parameters, the DHCP discovery message, and the PADI message.

[0048] Optionally, the network port setting module is further used for:

[0049] Monitor the LAN bridge interface, and when the application layer receives a reply message, determine whether the reply message belongs to the preset reply message;

[0050] If so, disconnect the network port to be tested from the LAN bridge interface and set the network port to be tested as a WAN port;

[0051] If not, then set the network port to be tested as a LAN port.

[0052] Optionally, the network port setting module is further used for:

[0053] Store the setting result of the network port to be tested as a WAN port to obtain the WAN port identifier corresponding to the network port to be tested;

[0054] When a network cable is detected connected to another physical network port of the router, the WAN port identifier is added to the online message.

[0055] Optionally, the router port adaptive setting device is further used for:

[0056] When a DHCP discovery message is received, the option field of the DHCP discovery message is checked;

[0057] If the option field of the DHCP discovery message is the first preset field, then no reply will be given.

[0058] This application also provides an electronic device, which is a physical device, comprising: a memory, a processor, and a program for the router port adaptive setting method stored in the memory and executable on the processor. When the program for the router port adaptive setting method is executed by the processor, it can implement the steps of the router port adaptive setting method as described above.

[0059] This application also provides a computer-readable storage medium storing a program for implementing a router network port adaptive setting method. When the program for the router network port adaptive setting method is executed by a processor, it implements the steps of the router network port adaptive setting method as described above.

[0060] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the router port adaptive setting method described above.

[0061] This application provides a router port adaptive setting method, device, electronic device, and medium. First, the router's port to be tested is added to a LAN bridge interface. Then, a probe packet is sent to the port to be tested through the application layer. The source MAC address of the probe packet is the MAC address of the LAN bridge interface. Next, the LAN bridge interface is monitored. When the application layer receives a preset reply packet, the port to be tested is set as a WAN port; otherwise, it is set as a LAN port. This application, by sending probe packets to the port to be tested at the application layer and receiving reply packets at the application layer, eliminates the need for kernel packet forwarding, reducing code complexity, minimizing resource consumption, avoiding router lag during port detection, and improving the smoothness of the port detection process. Attached Figure Description

[0062] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0063] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0064] Figure 1 This is a flowchart illustrating the first embodiment of the router port adaptive setting method of this application;

[0065] Figure 2 This is a schematic diagram of the field setting code for the DHCP discovery message in the second embodiment of the router port adaptive setting method of this application;

[0066] Figure 3 This is a flowchart illustrating the second embodiment of the router port adaptive setting method of this application;

[0067] Figure 4 This is a schematic diagram of the router port adaptive setting device in this application;

[0068] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the router port adaptive setting method in this embodiment of the application.

[0069] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0070] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0071] Example 1

[0072] Most mainstream routers on the market now have LAN / WAN auto-sensing capabilities. Routers with this capability can automatically determine whether the connected device is a PC or a gateway device and set the corresponding port as either WAN or LAN. Therefore, users can connect the network cable to the optical modem to any port on the router instead of being restricted to a specific port. However, this method requires sending probe packets to the LAN bridge interface, and the kernel's packet reception method has a complex code structure and high resource consumption. It requires sending probe packets to all four ports, and the kernel will send unnecessary packets to the application layer, which can cause the router to lag during the port detection process.

[0073] This application provides a method for setting up a router's network port adaptively. In the first embodiment of this application's method for setting up a router's network port adaptively, refer to... Figure 1 The router port adaptive setting method includes:

[0074] Step S10: Add the network port under test of the router to the LAN bridge interface, and send a probe packet to the network port under test through the application layer, wherein the source MAC address of the probe packet is the MAC address of the LAN bridge interface.

[0075] Step S20: Monitor the LAN test bridge interface. When the application layer receives a preset reply message, set the network port under test to the WAN port; otherwise, set the network port under test to the LAN port.

[0076] In this embodiment, it should be noted that the purpose of setting the source MAC address of the probe packet to the MAC address of the LAN bridge interface is to forge the source MAC address of the probe packet, thereby sending the probe packet at the application layer and receiving the reply packet at the application layer, which improves the utilization of the application layer, eliminates the need to design a complex kernel code structure, and improves the efficiency of network interface detection.

[0077] As an example, steps S10 to S20 include: when a network cable is detected connected to the network port under test, the network port under test is added to the LAN bridge interface; a socket for the probe packet is created based on the PF_PACKET interface, a DHCP discovery packet and a PADI packet are created, and the probe packet is generated; the source MAC address of the probe packet is modified to the MAC address of the LAN bridge interface, and the probe packet is sent to the network port under test through the application layer; the network port under test in the LAN bridge interface is monitored, and when the network port under test sends a reply packet, the reply packet is received through the application layer; if the reply packet is the preset reply packet, the network port under test is set as a WAN port; if the reply packet is not the preset reply packet, the network port under test is set as a bridge port, i.e., a LAN port.

[0078] As an example, the LAN bridge interface is br0, and the router's physical network ports are eth0, eth1, eth2, and eth3, with the network port under test being eth0. If no WAN port exists on other physical network ports, eth0 is added to the br0 bridge. The source MAC address corresponding to both the DHCP discovery message and the PADI message MAC address is set to the MAC address of br0, and the destination sending interface is set to eth0. The DHCP discovery message and PADI message are sent to eth0 via the application layer. The br0 interface listens for reply messages; if a DHCP offer message or PADO message is received, the eth0 port is set as the WAN port; otherwise, the eth0 port is set as a port under the br0 bridge, i.e., the LAN port.

[0079] The method further includes, prior to the step of adding the router's network port under test to the LAN bridge interface and sending probe packets to the network port under test through the application layer:

[0080] Step A10: When a network cable is detected connected to the network port under test, the kernel transmits the online message of the network port under test to the application layer.

[0081] Step A20: Based on the online message, determine whether the WAN port already exists;

[0082] Step A30: If it already exists, set the network port to be tested as a LAN port;

[0083] Step A40: If it does not exist, then perform adaptive settings on the network port to be tested.

[0084] In this embodiment, it should be noted that the online message includes the corresponding identification information of other physical network ports in the router. The identification information is used to characterize the corresponding network port type. If other physical network ports have been set as WAN ports, the corresponding identification information is the WAN port identifier. The WAN port identifier is used as a reference in the adaptive settings of the network port to be tested. If the router already has a WAN port, then the network port to be tested is set as a LAN port.

[0085] As an example, steps A10 to A40 include: when the router's battery port is connected to a network cable, an online message is transmitted to the application layer through the kernel, wherein the online message includes identification information; based on the identification information, it is determined whether the router already has a WAN port; if the router already has a WAN port, the network port to be tested is set as a LAN port; if the router does not have a WAN port, the network port to be tested is adaptively configured.

[0086] The probe messages include DHCP discovery messages and PADI messages. The steps of adding the router's network port to be tested to the LAN bridge interface and sending probe messages to the network port to be tested through the application layer include:

[0087] Step S11: Add the network port to be tested to the LAN bridge interface;

[0088] Step S12: Configure the message parameters corresponding to the DHCP discovery message and the PADI message respectively, and create the probe message;

[0089] Step S13: Send the probe message to the network port under test through the application layer.

[0090] In this embodiment, it should be noted that the probe message includes DHCP discovery message and PADI message; the message parameters include the source MAC address, destination sending interface, and option field.

[0091] As an example, steps S11 to S13 include: adding the network port to be tested to the LAN bridge interface; creating a socket based on the PF_PACKET interface by configuring the source MAC address, destination sending interface, and option field corresponding to the DHCP discovery message and the PADI message respectively, setting the socket type to SOCK_RAW, and generating the probe message; and sending the DHCP discovery message and the PADI message to the network port to be tested through the application layer.

[0092] The steps of configuring the message parameters corresponding to the DHCP discovery message and the PADI message, and creating the probe message, include:

[0093] Step S121: Set the layer source MAC address corresponding to both the DHCP discovery message and the PADI message to the MAC address of the LAN bridge interface;

[0094] Step S122: The transmission sets the destination sending interface corresponding to both the DHCP discovery message and the PADI message to the network port under test;

[0095] Step S123: Set the option field of the DHCP discovery message to a first preset field, wherein the first preset field is used to characterize the identity of the sending device of the DHCP discovery message;

[0096] Step S124: Create the probe message based on the message parameters, the DHCP discovery message, and the PADI message.

[0097] In this embodiment, it should be noted that, referring to Figure 2 The option field is used to identify the router so that when the router is connected to a router of the same type as a sub-machine, it can send a DHCP discovery message with the SKDETECT option field so that the router of the same type can identify the sub-machine and avoid misidentifying the sub-machine as a gateway.

[0098] As an example, steps S121 to S124 include: setting the layer source MAC address of the DHCP discovery message to the MAC address of the LAN bridge interface; setting the layer source MAC address of the PADI message to the MAC address of the LAN bridge interface; setting the destination sending interface of the DHCP discovery message to the network port under test; setting the destination sending interface of the PADI message MAC address to the network port under test; setting the option field of the DHCP discovery message to a first preset field, wherein the first preset field is used to characterize the identity of the sending device of the DHCP discovery message; and generating the probe message based on the DHCP discovery message, the PADI message, and the message parameters.

[0099] As an example, the first preset field can be SKDETECT.

[0100] The step of monitoring the LAN bridge interface, and when the application layer receives a preset reply message, setting the network port under test as a WAN port; otherwise, setting the network port under test as a LAN port includes:

[0101] Step S21: Monitor the LAN bridge interface. When the application layer receives a reply message, determine whether the reply message belongs to the preset reply message.

[0102] Step S22: If yes, disconnect the network port to be tested from the LAN bridge interface and set the network port to be tested as a WAN port.

[0103] Step S23: If not, then set the network port to be tested as a LAN port.

[0104] In this embodiment, it should be noted that the preset reply message must include at least one of the DHCP offer message and the PADO message in order to determine that the interface type of the interface under test is a WAN port.

[0105] As an example, steps S21 to S23 include: monitoring the network port under test in the LAN bridge interface; when the network port under test sends a reply message, receiving the reply message through the application layer; detecting the reply message; if the reply message is the DHCP provide message or the PADO message, then disconnecting the network port under test from the LAN bridge interface and setting the network port under test as a WAN port; if the reply message is neither the DHCP provide message nor the PADO message, then setting the network port under test as a LAN port.

[0106] After the step of setting the network interface under test as a WAN port when the application layer receives a preset reply message while monitoring the LAN bridge interface, the method further includes:

[0107] Step S221: Store the setting result of the network port to be tested as a WAN port to obtain the WAN port identifier corresponding to the network port to be tested;

[0108] Step S222: When a network cable is detected connected to another physical network port of the router, the WAN port identifier is added to the online message.

[0109] In this embodiment, the WAN port identifier is used to identify the router so as to prevent it from being mistakenly identified as a gateway device when the router is used as a slave device of other routers of the same type.

[0110] As an example, steps S221 to S222 include: when the network port to be tested has been set as a WAN port, the setting result is stored to obtain the WAN port identifier, wherein the WAN port identifier is used to characterize the network port type of the network port to be tested; when it is detected that other physical network ports of the router have access cables, the WAN port identifier is added to the online message of the physical network port of the access cable to characterize that a WAN port already exists in the router, and the physical network port of the access cable is set as a LAN port.

[0111] This application provides a method for adaptively configuring a router's network port. First, the network port to be tested on the router is added to a LAN bridge interface. Then, a probe packet is sent to the network port to be tested through the application layer. The source MAC address of the probe packet is the MAC address of the LAN bridge interface. The application layer then listens to the LAN bridge interface. When the application layer receives a preset reply packet, the network port to be tested is set as a WAN port; otherwise, it is set as a LAN port. This application, by sending probe packets to the network port to be tested at the application layer and receiving reply packets at the application layer, eliminates the need for kernel packet forwarding, reducing code complexity, minimizing resource consumption, avoiding router lag during network port detection, and improving the smoothness of the network port detection process.

[0112] Example 2

[0113] Furthermore, based on the first embodiment of this application, in another embodiment of this application, the same or similar content as in Embodiment 1 can be referred to the above description, and will not be repeated hereafter. Based on this, refer to... Figure 3 The router port adaptive setting method further includes:

[0114] Step B10: When a DHCP discovery message is received, the option field of the DHCP discovery message is checked;

[0115] Step B20: If the option field of the DHCP discovery message is the first preset field, then no reply is given.

[0116] In this embodiment, the first preset field is option 60; the option field is used to identify whether the device connected to the interface under test is a sub-machine, that is, a sub-router in the mesh network, because the sub-router will send a discovery message with the option field SKDETECT, wherein the device receiving the discovery message is the DHCP server in the router.

[0117] As an example, steps B10 to B20 include: when the DHCP server receives a DHCP discovery message, it checks the option field of the DHCP discovery message; if the option field is SKDETECT, it determines that the connected device is a sub-router and does not reply.

[0118] This application provides a router port adaptive setting method. First, when a DHCP discovery message is received, the option field of the DHCP discovery message is checked. If the option field of the DHCP discovery message is a first preset field, no reply is given. This application overcomes the problem in the prior art that, in the network environment of mesh networking, the main router may identify the sub-router as the gateway, thus avoiding the failure situation where the host identifies the mesh sub-machine as the DHCP server, thereby forming a loop and causing all devices to be unable to access the Internet. This improves the identification accuracy of the main router.

[0119] Example 3

[0120] This application embodiment also provides a router port adaptive setting device, which is applied to a router port adaptive setting device, see reference. Figure 4 The router port adaptive setting device includes:

[0121] The message sending module is used to add the network port under test of the router to the LAN bridge interface and send probe messages to the network port under test through the application layer, wherein the source MAC address of the probe message is the MAC address of the LAN bridge interface;

[0122] The network port setting module is used to monitor the LAN test bridge interface. When the application layer receives a preset reply message, it sets the network port under test as a WAN port; otherwise, it sets the network port under test as a LAN port.

[0123] Optionally, the message sending module is further configured to:

[0124] When a network cable is detected connected to the network port under test, the kernel transmits the online message of the network port under test to the application layer.

[0125] Based on the online message, determine whether the WAN port already exists;

[0126] If it already exists, then set the network port to be tested as a LAN port;

[0127] If it does not exist, then adaptive settings will be applied to the network port under test.

[0128] Optionally, the message sending module is further configured to:

[0129] Add the network port to be tested to the LAN bridge interface;

[0130] Configure the message parameters corresponding to the DHCP discovery message and the PADI message respectively, and create the probe message;

[0131] The probe message is sent to the network port under test through the application layer.

[0132] Optionally, the message sending module is further configured to:

[0133] Set the layer source MAC address corresponding to both the DHCP discovery message and the PADI message to the MAC address of the LAN bridge interface;

[0134] The transmission sets the destination sending interface corresponding to both the DHCP discovery message and the PADI message to the network port under test;

[0135] Set the option field of the DHCP discovery message to a first preset field, wherein the first preset field is used to characterize the identity of the sending device of the DHCP discovery message;

[0136] The probe message is created based on the message parameters, the DHCP discovery message, and the PADI message.

[0137] Optionally, the network port setting module is further used for:

[0138] Monitor the LAN bridge interface, and when the application layer receives a reply message, determine whether the reply message belongs to the preset reply message;

[0139] If so, disconnect the network port to be tested from the LAN bridge interface and set the network port to be tested as a WAN port;

[0140] If not, then set the network port to be tested as a LAN port.

[0141] Optionally, the network port setting module is further used for:

[0142] Store the setting result of the network port to be tested as a WAN port to obtain the WAN port identifier corresponding to the network port to be tested;

[0143] When a network cable is detected connected to another physical network port of the router, the WAN port identifier is added to the online message.

[0144] Optionally, the router port adaptive setting device is further used for:

[0145] When a DHCP discovery message is received, the option field of the DHCP discovery message is checked;

[0146] If the option field of the DHCP discovery message is the first preset field, then no reply will be given.

[0147] The router port adaptive setting device provided in this application adopts the router port adaptive setting method in the above embodiments, which solves the technical problem of router lag during port detection. Compared with the prior art, the beneficial effects of the router port adaptive setting device provided in this application are the same as those of the router port adaptive setting method provided in the above embodiments, and other technical features in this router port adaptive setting device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0148] Example 4

[0149] This application provides an electronic device, which includes: at least one processor; and a memory communicatively linked to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the router port adaptive setting method in the first embodiment described above.

[0150] The following is for reference. Figure 5 The diagram illustrates a structural schematic of an electronic device suitable for implementing embodiments of the present disclosure. The electronic devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0151] like Figure 5 As shown, an electronic device may include a processing unit (such as a central processing unit, graphics processing unit, etc.) that can perform various appropriate actions and processes based on a program stored in read-only memory (ROM) or a program loaded from a storage device into random access memory (RAM). The RAM also stores various programs and data required for the operation of the electronic device. The processing unit, ROM, and RAM are interconnected via a bus. Input / output (I / O) interfaces are also linked to the bus.

[0152] Typically, the following systems can be linked to the I / O interface: input devices such as touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices such as liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices such as magnetic tapes, hard disks, etc.; and communication devices. Communication devices allow electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although electronic devices with various systems are shown in the figures, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems may be implemented alternatively.

[0153] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from a storage device, or installed from a ROM. When the computer program is executed by a processing device, it performs the functions defined above in the methods of embodiments of this disclosure.

[0154] The electronic device provided in this application employs the router port adaptive setting method in the above embodiments, solving the technical problem of router lag during port detection. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the router port adaptive setting method provided in Embodiment 1 above, and other technical features of this electronic device are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0155] It should be understood that various parts of this disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics may be combined in any suitable manner in one or more embodiments or examples.

[0156] 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.

[0157] Example 5

[0158] This embodiment provides a computer-readable storage medium having computer-readable program instructions stored thereon, which are used to execute the router port adaptive setting method in the first embodiment described above.

[0159] The computer-readable storage medium provided in this application embodiment may be, for example, a USB flash drive, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, system, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical link having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.

[0160] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.

[0161] The aforementioned computer-readable storage medium carries one or more programs that, when executed by an electronic device, cause the electronic device to: acquire images captured in a mixed color temperature scene;

[0162] Based on the white balance gray area drawn under the mixed color temperature scene, the captured image is subjected to high color temperature white balance correction and low color temperature white balance correction respectively to obtain a high color temperature corrected image and a low color temperature corrected image; the low color temperature corrected image is converted to the LAB color space to obtain a first converted image, and the high color temperature corrected image is converted to the LAB color space to obtain a second converted image; according to a preset weighted smoothing mapping function, the pixel values ​​of the first converted image or the second converted image are mapped to obtain a fusion weight matrix, wherein the preset weighted smoothing mapping function represents the smooth mapping relationship between pixel values ​​and weights; according to the fusion weight matrix, the first converted image and the second converted image are weighted and fused to obtain a target white balance image.

[0163] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be linked to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be linked to an external computer (e.g., via the Internet using an Internet service provider).

[0164] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0165] The modules described in the embodiments of this disclosure can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0166] The computer-readable storage medium provided in this application stores computer-readable program instructions for executing the above-described router port adaptive setting method, thus solving the technical problem of router lag during port detection. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the router port adaptive setting method provided in the above-described embodiments, and will not be repeated here.

[0167] Example 6

[0168] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the router port adaptive setting method described above.

[0169] The computer program product provided in this application solves the technical problem of router lag during network port detection. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the router network port adaptive setting method provided in the above embodiments, and will not be repeated here.

[0170] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent scope of this application.

Claims

1. A method for adaptive setting of a router's network port, characterized in that, The router port adaptive setting method includes: Add the router's network port to be tested to the LAN bridge interface, and send probe packets to the network port to be tested through the application layer. The source MAC address of the probe packets is the MAC address of the LAN bridge interface. Monitor the LAN test bridge interface. When the application layer receives a preset reply message, set the network port under test as the WAN port; otherwise, set the network port under test as the LAN port. The method further includes, prior to the step of adding the router's network port under test to the LAN bridge interface and sending probe packets to the network port under test through the application layer: When a network cable is detected connected to the network port under test, the kernel transmits the online message of the network port under test to the application layer. The online message includes the corresponding identification information of other physical network ports in the router. The identification information is used to characterize the corresponding network port type. If other physical network ports have been set as WAN ports, the corresponding identification information is the WAN port identifier. Based on the online message, determine whether the WAN port already exists; If it already exists, then set the network port to be tested as a LAN port; If it does not exist, then adaptive settings will be applied to the network port under test.

2. The router port adaptive setting method as described in claim 1, characterized in that, The probe messages include DHCP discovery messages and PADI messages. The steps of adding the router's network port to be tested to the LAN bridge interface and sending probe messages to the network port to be tested through the application layer include: Add the network port to be tested to the LAN bridge interface; Configure the message parameters corresponding to the DHCP discovery message and the PADI message respectively, and create the probe message; The probe message is sent to the network port under test through the application layer.

3. The router port adaptive setting method as described in claim 2, characterized in that, The message parameters include the source MAC address, destination sending interface, and option field. The steps of configuring the message parameters corresponding to the DHCP discovery message and the PADI message, and creating the probe message, include: Set the layer source MAC address corresponding to both the DHCP discovery message and the PADI message to the MAC address of the LAN bridge interface; The transmission sets the destination sending interface corresponding to both the DHCP discovery message and the PADI message to the network port under test; Set the option field of the DHCP discovery message to a first preset field, wherein the first preset field is used to characterize the identity of the sending device of the DHCP discovery message; The probe message is created based on the message parameters, the DHCP discovery message, and the PADI message.

4. The router port adaptive setting method as described in claim 1, characterized in that, in, The preset reply message includes at least one of a DHCP offer message and a PADO message. The step of monitoring the LAN bridge interface and, when the application layer receives the preset reply message, setting the network port under test as a WAN port; otherwise, setting the network port under test as a LAN port includes: Monitor the LAN bridge interface, and when the application layer receives a reply message, determine whether the reply message belongs to the preset reply message; If so, disconnect the network port to be tested from the LAN bridge interface and set the network port to be tested as a WAN port; If not, then set the network port to be tested as a LAN port.

5. The router port adaptive setting method as described in claim 1, characterized in that, After the step of setting the network interface under test as a WAN port when the application layer receives a preset reply message while monitoring the LAN bridge interface, the method further includes: Store the setting result of the network port to be tested as a WAN port to obtain the WAN port identifier corresponding to the network port to be tested; When a network cable is detected connected to another physical network port of the router, the WAN port identifier is added to the online message.

6. The router port adaptive setting method as described in claim 1, characterized in that, The router port adaptive setting method also includes: When a DHCP discovery message is received, the option field of the DHCP discovery message is checked; If the option field of the DHCP discovery message is the first preset field, then no reply will be given.

7. A router port adaptive setting device, characterized in that, The router port adaptive setting device includes: The message sending module is used to add the network port under test of the router to the LAN bridge interface and send probe messages to the network port under test through the application layer, wherein the source MAC address of the probe message is the MAC address of the LAN bridge interface; The network port setting module is used to monitor the LAN test bridge interface. When the application layer receives a preset reply message, it sets the network port under test as a WAN port; otherwise, it sets the network port under test as a LAN port. The network port setting module is further configured to: when a network cable is detected connected to the network port under test, transmit an online message of the network port under test to the application layer through the kernel, wherein the online message includes the corresponding identification information of other physical network ports in the router, the identification information is used to characterize the corresponding network port type, and if other physical network ports have been set as WAN ports, the corresponding identification information is the WAN port identifier; based on the online message, determine whether the WAN port already exists; if it already exists, set the network port under test as a LAN port; if it does not exist, perform adaptive settings for the network port under test.

8. An electronic device, characterized in that, The electronic device includes: At least one processor; and, A memory communicatively linked to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the steps of the router port adaptive setting method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a program for implementing a router port adaptive setting method, which is executed by a processor to implement the steps of the router port adaptive setting method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Method and device for identifying Ethernet ports and router

    CN106713039A

  • Automatic adaption method for LAN interface and WAN interface and router

    CN108667672A