Equipment distinguishing method and equipment
By combining the actual MAC address and IP address of the device, the mapping relationship is established, and the identification problem of relay routers and access devices is solved, and the accurate distinction and effective management of the devices are achieved.
Patent Information
- Application Number
- CN202311242956.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-03-25
AI Technical Summary
During network communication, the relay router will replace its own MAC address and the MAC address of the access device with a unified MAC address, causing the main router to be unable to distinguish between the relay router and the access device. In addition, dynamic allocation and lease term issues of IP addresses also cause the main router to be unable to accurately distinguish different devices.
By combining the actual MAC address and IP address of the device, a mapping relationship between the actual MAC address and IP address of the device is established to distinguish different devices. The specific methods include receiving messages, obtaining the MAC address and IP address carried, determining the identity of the device, and updating the IP address and mapping relationship if necessary.
Accurate identification and distinction between relay equipment and access equipment is achieved, confusion in equipment management is avoided, and effective management of equipment and reasonable allocation of network resources is ensured.
Smart Images

Figure CN119697108A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of communication technology, and in particular, to a method and device for distinguishing devices. Background Art
[0002] By using relays, the network coverage can be improved, so that devices that are far away from the main router can also access the network provided by the main router. For example, after a router that acts as a relay (referred to as a relay router) is connected to the main router, other devices can access the network provided by the main router by accessing the relay router.
[0003] Generally, the main router distinguishes different devices through the media access control (MAC) address or Internet protocol (IP) address of the device connected to the network to realize the functions of monitoring, statistics, and display of data streams of different devices. However, during the network communication process, some relay routers will replace their own MAC address and the MAC address of the device connected to the relay router with a unified MAC address, resulting in the main router being unable to distinguish between the relay router and the device connected to the relay router. The configuration of IP addresses includes dynamic allocation and static configuration, which may result in different devices using the same IP address. In addition, the dynamically allocated IP address has a lease period, and failure to renew the lease after the expiration may also cause the IP address to be allocated to other devices, resulting in different devices using the same IP address. In this way, the main router cannot distinguish different devices through IP addresses. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides a method and device for distinguishing devices. The technical solution provided by the present application distinguishes different devices by combining the actual MAC address and IP address of the device, thereby facilitating device management.
[0005] In order to achieve the above technical objectives, this application provides the following technical solutions:
[0006] In a first aspect, a method for distinguishing devices is provided, which is applied to a first device. The method includes: receiving a first message, the first message carrying a first media access control MAC address and a first Internet Protocol IP address. Receiving a second message, the second message carrying a second MAC address and a second IP address. When the first MAC address is the same as the second MAC address, and the first IP address is different from the second IP address, obtaining a third MAC address corresponding to the first IP address and a fourth MAC address corresponding to the second IP address. If the first MAC address is the same as the third MAC address, determining that the second device corresponding to the first message is a relay device of the first device. If the second MAC address is different from the fourth MAC address, determining that the third device corresponding to the second message is an access device of the second device.
[0007] In some examples, the first message or the second message includes but is not limited to various types of messages such as data streams and control streams sent by the lower-layer device to the upper-layer device.
[0008] In some examples, the first MAC address and the second MAC address are used MAC addresses, and the third MAC address and the fourth MAC address are actual MAC addresses. In some scenarios, after receiving the message, the relay device replaces the actual MAC address carried in the message with a unified MAC address and forwards it to the first device.
[0009] In this way, the first device distinguishes different devices by establishing a mapping relationship between the actual MAC address and the IP address of the device. Compared with the prior art, the first device cannot distinguish between the relay device and the access device of the relay device. The device distinguishing method provided in the embodiment of the present application can accurately identify different devices based on the actual MAC address, IP address, and used MAC address. Avoid confusing different devices during the device management process and achieve effective management of the device.
[0010] According to the first aspect, before receiving the first message, the method further includes: receiving a third message sent by the second device, the third message carrying a third MAC address of the second device, allocating the first IP address to the second device, and saving a mapping relationship between the first IP address and the third MAC address.
[0011] According to the first aspect, or any implementation of the first aspect above, obtaining a third MAC address corresponding to the first IP address includes: determining the third MAC address corresponding to the first IP address according to a mapping relationship.
[0012] In this way, when other devices access the first device, the first device establishes and saves the mapping relationship between the IP address assigned to the device and the actual MAC address of the device. In the subsequent communication process, the first device can determine the actual MAC address corresponding to the IP address carried in the received message based on the mapping relationship.
[0013] According to the first aspect, or any implementation of the first aspect above, the method further includes: receiving a fourth message sent by the second device, the fourth message carrying a third MAC address of the second device. Allocating a third IP address to the second device. Determining a mapping relationship between the third MAC address and the first IP address that has been saved. Updating the first IP address corresponding to the third MAC address to the third IP address.
[0014] In this way, after the device IP address changes, the first device can also determine whether the new and old IP addresses correspond to the same device, and by updating the unique identifier of the device, always determine the unique corresponding device to meet the device management requirements.
[0015] According to the first aspect, or any implementation of the first aspect above, the method also includes: generating device information, the device information including one or more of the second device identifier, the first MAC address, the third MAC address, the first IP address, the device tag, and the device characteristics.
[0016] According to the first aspect, or any implementation of the first aspect above, the method further includes: generating an identifier of the second device according to the first MAC address and the first IP address of the second device.
[0017] In this way, the first device generates unique identifiers for other devices to index the corresponding unique devices, thereby avoiding confusion between different devices during the device management process and achieving effective management of the devices.
[0018] According to the first aspect, or any implementation of the first aspect above, the method further includes: receiving a fifth message, the fifth message carrying a fifth MAC address and a fourth IP address. When the fifth MAC address is different from both the first MAC address and the second MAC address, determining that the fourth device corresponding to the fifth message is an access device of the first device.
[0019] In this way, the first device can determine whether the original source device of the message is the access device of the first device, the relay device of the first device, or the access device of the relay device according to whether the MAC address carried in the received message is the same as other MAC addresses, thereby facilitating the first device to manage different devices.
[0020] According to the first aspect, or any implementation of the first aspect above, the method further includes: receiving a sixth message, the sixth message carrying a sixth MAC address and a fifth IP address. When the sixth MAC address is the same as the second MAC address, and the fifth IP address is different from the second IP address, obtaining a seventh MAC address corresponding to the fifth IP address. If the sixth MAC address is different from the seventh MAC address, determining that the fifth device corresponding to the sixth message is an access device of the second device, and distinguishing the third device from the fifth device by the second IP address and the fifth IP address.
[0021] In this way, the first device can distinguish different access devices of the same relay router through the IP address, thereby facilitating the first device to manage different devices.
[0022] In a second aspect, a first device is provided. The first device includes: one or more processors and a memory, the memory is coupled to the one or more processors, and the memory is used to store one or more programs. When the one or more processors read the one or more programs from the memory, the first device executes: receiving a first message, the first message carries a first media access control MAC address and a first Internet Protocol IP address. Receive a second message, the second message carries a second MAC address and a second IP address. When the first MAC address is the same as the second MAC address, and the first IP address is different from the second IP address, obtain a third MAC address corresponding to the first IP address and a fourth MAC address corresponding to the second IP address. If the first MAC address is the same as the third MAC address, determine that the second device corresponding to the first message is a relay device of the first device. If the second MAC address is different from the fourth MAC address, determine that the third device corresponding to the second message is an access device of the second device.
[0023] According to the second aspect, when one or more processors read one or more programs from the memory, the first device is also caused to execute: receiving a third message sent by the second device, the third message carrying a third MAC address of the second device, assigning a first IP address to the second device, and saving a mapping relationship between the first IP address and the third MAC address.
[0024] According to the second aspect, or any implementation of the second aspect above, obtaining a third MAC address corresponding to the first IP address includes: determining the third MAC address corresponding to the first IP address according to a mapping relationship.
[0025] According to the second aspect, or any implementation of the second aspect above, when one or more processors read one or more programs from the memory, the first device is also caused to execute: receiving a fourth message sent by the second device, the fourth message carrying the third MAC address of the second device. Allocating a third IP address to the second device. Determining a mapping relationship between the third MAC address and the first IP address that has been saved. Updating the first IP address corresponding to the third MAC address to the third IP address.
[0026] According to the second aspect, or any implementation of the second aspect above, when one or more processors read one or more programs from the memory, the first device is also caused to execute: generate device information, the device information including one or more of the second device's identifier, first MAC address, third MAC address, first IP address, device tag, and device features.
[0027] According to the second aspect, or any implementation of the second aspect above, when one or more processors read one or more programs from the memory, the first device is also enabled to execute: generating an identifier of the second device based on the first MAC address and the first IP address of the second device.
[0028] According to the second aspect, or any implementation of the second aspect above, when one or more processors read one or more programs from the memory, the first device is also caused to execute: receiving a fifth message, the fifth message carrying a fifth MAC address and a fourth IP address. When the fifth MAC address is different from both the first MAC address and the second MAC address, determining that the fourth device corresponding to the fifth message is the access device of the first device.
[0029] According to the second aspect, or any implementation of the second aspect above, when one or more processors read one or more programs from the memory, the first device is also caused to execute: receiving a sixth message, the sixth message carrying a sixth MAC address and a fifth IP address. When the sixth MAC address is the same as the second MAC address, and the fifth IP address is different from the second IP address, obtain the seventh MAC address corresponding to the fifth IP address. If the sixth MAC address is different from the seventh MAC address, determine that the fifth device corresponding to the sixth message is the access device of the second device, and distinguish the third device from the fifth device by the second IP address and the fifth IP address.
[0030] In a third aspect, a device is provided, which has the function of implementing the method for distinguishing devices as described in the first aspect and any possible implementation thereof. The function can be implemented by hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above functions.
[0031] In a fourth aspect, a readable storage medium is provided, wherein the readable storage medium stores a program, and when the program is executed by a device, the device executes the method of the first aspect or any one of the implementations of the first aspect.
[0032] According to a fifth aspect, a program product is provided. When the program product is run on a device, the device executes the method according to the first aspect or any one of the implementations of the first aspect.
[0033] According to a sixth aspect, a circuit system is provided, the circuit system comprising a processing circuit, wherein the processing circuit is configured to execute the method according to the first aspect or any one of the embodiments of the first aspect.
[0034] In the seventh aspect, a chip system is provided, comprising at least one processor and at least one interface circuit, wherein the at least one interface circuit is used to perform transceiver functions and send instructions to the at least one processor, and when the at least one processor executes the instructions, the at least one processor executes the method of the first aspect or any one of the embodiments of the first aspect.
[0035] The technical effects of the aforementioned aspects can be referenced to each other and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 Schematic diagram of the device networking scenario provided in the embodiment of the present application Figure 1 ;
[0037] Figure 2 A schematic diagram of a communication system for applying the method for distinguishing devices provided in an embodiment of the present application;
[0038] Figure 3 A schematic diagram of the hardware structure of the first device provided in an embodiment of the present application;
[0039] Figure 4 Schematic diagram of the device differentiation method provided in the embodiment of the present application Figure 1 ;
[0040] Figure 5 Schematic diagram of the device networking scenario provided in the embodiment of the present application Figure 2 ;
[0041] Figure 6 A schematic diagram of the message structure provided for an embodiment of the present application;
[0042] Figure 7 A schematic diagram of a MAC address replacement scenario provided in an embodiment of the present application;
[0043] Figure 8 Schematic diagram of the device networking scenario provided in the embodiment of the present application Figure 3 ;
[0044] Fig. 9 Schematic diagram of the device differentiation method provided in the embodiment of the present application Figure 2 ;
[0045] Fig.10 A schematic diagram of the structure of the first device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0046] The technical solutions in the embodiments of the present application are described below in conjunction with the accompanying drawings in the embodiments of the present application. Wherein, in the description of the embodiments of the present application, the terms used in the following embodiments are only for the purpose of describing specific embodiments, and are not intended to be used as limitations on the present application. As used in the specification and the appended claims of the present application, the singular expressions "one", "a kind of", "said", "above", "the" and "this" are intended to include expressions such as "one or more", unless there is a clear indication to the contrary in the context. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" refer to one or more (including two).
[0047] References to "one embodiment" or "some embodiments" etc. described in this specification mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Thus, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways. The term "connection" includes direct connection and indirect connection, unless otherwise specified. "First" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0048] In the embodiments of the present application, the words "exemplarily" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a specific way.
[0049] In some embodiments, the effective communication distance of the wireless router is limited, such as about 50 to 100 meters, and devices beyond the effective communication distance cannot access the network provided by the wireless router. Therefore, generally, a relay router (referred to as a relay router) is connected to the main router through a relay method to expand the network coverage of the main router.
[0050] For example, Figure 1 As shown, the relay router is connected to the Wi-Fi network provided by the main router by means of wireless fidelity (Wi-Fi) relay. In this way, mobile phones and laptops that are far away from the main router can also access the Wi-Fi network provided by the main router by establishing a communication connection with the relay router. Optionally, a device connected to the relay router is called an access device of the relay router, and the access device can be connected to the relay router by wire or wirelessly. For example, a mobile phone is connected to the relay router through a 5G network, and a laptop is connected to the relay router through a wired connection. It should be understood that the number of access devices of the relay router is one or more. For the access device, the relay router acts as an access point (AP), and for the main router, the relay router acts as a station (STA). The access device acts as a STA.
[0051] Generally, the main router distinguishes different devices through the media access control (MAC) addresses or Internet protocol (IP) addresses of the devices connected to the network, so as to realize functions such as monitoring, statistics, and display of data streams of different devices.
[0052] For example, different devices are distinguished by MAC addresses. During network communication, some relay routers will replace the MAC address of the device connected to the relay router and the MAC address of the device connected to the relay router with a unified MAC address, resulting in the main router being unable to distinguish between the relay router and the device connected to the relay router. Optionally, the unified MAC address is, for example, the MAC address of the relay router, a pre-configured MAC address, etc.
[0053] For example, Figure 1As shown in Table 1, the mobile phone and the laptop are connected to the relay router, so the access devices of the relay router include the laptop and the mobile phone. Among them, as shown in Table 1 below, the actual MAC address of the relay router is 2a:cf:24:f1:bc:94, the actual MAC address of the laptop is 00:68:eb:c8:6d:37, and the actual MAC address of the mobile phone is 62:b7:8e:c7:27:3e. When the mobile phone and the laptop send messages to the relay router, the mobile phone and the laptop will use their actual MAC addresses as the source MAC addresses in the message header of the sent message (that is, the actual MAC address of the device) and carry them in the message to facilitate the relay router to identify the device. However, after the relay router receives the message sent by the access device, it will replace the source MAC address in the message header of the message with a unified MAC address. For example, as shown in Table 2 below, the relay router replaces all the source MAC addresses in the messages sent by the mobile phone and the laptop with the MAC address of the relay router, and then the relay router forwards the message to the main router. Then, after receiving the message, the main router cannot distinguish the original source of the message and will identify the relay router, mobile phone and laptop as the same device, causing problems in device management.
[0054] For example, on the device management interface of the main router, the main router manages the relay router, mobile phone and laptop as one device; or the three devices switch from time to time and the device identity cannot be accurately identified. Then, for the access device of the relay router, functions such as child Internet protection, route speed limit, traffic statistics, and firewall cannot be realized.
[0055] Table 1
[0056] Actual MAC address IP address Relay Router 2a:cf:24:f1:bc:94 192.168.3.3 Laptop 00:68:eb:c8:6d:37 192.168.3.4 cell phone 62:b7:8e:c7:27:3e 192.168.3.5
[0057] Table 2
[0058] MAC address used by the message IP address Relay Router 2a:cf:24:f1:bc:94 192.168.3.3 Laptop 2a:cf:24:f1:bc:94 192.168.3.4 cell phone 2a:cf:24:f1:bc:94 192.168.3.5
[0059] For another example, different devices are distinguished by IP addresses. As shown in Table 1 above, different devices have different IP addresses. However, IP address configuration includes dynamic allocation and static configuration, which may result in different devices using the same IP address. Moreover, dynamically allocated IP addresses have a lease period. If the lease period expires and is not renewed, the IP address may be allocated to other devices, resulting in different devices using the same IP address. In this way, the main router cannot distinguish different devices by IP addresses.
[0060] Therefore, the embodiment of the present application provides a method for distinguishing devices, which distinguishes different devices by combining the actual MAC address and IP address of the device, thereby facilitating device management.
[0061] Figure 2 A schematic diagram of a communication system for applying the device differentiation method provided in an embodiment of the present application. Figure 2 As shown, the communication system includes a first device 100 , a second device 200 and a third device 300 .
[0062] Optionally, the first device 100 may be, for example, a router (as a main router), customer premise equipment (CPE), a host, a gateway, or other device used for device management. The present application does not limit the specific type of the first device 100.
[0063] Optionally, the second device 200 may be, for example, a router (as a relay router, also referred to as a slave router), and the second device 200 serves as a relay device of the first device 100. The present application does not limit the specific type of the second device 200.
[0064] Optionally, the third device 300 may be, for example, a mobile phone, a tablet computer, a laptop computer, a smart screen, a wearable device, a vehicle terminal, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), an artificial intelligence (AI) device, or other terminal device. The operating system installed on the third device 300 includes but is not limited to: Or other operating systems. This application does not limit the specific type of the third device 300 and the installed operating system.
[0065] In some embodiments, during access to a network provided by the first device 100 , the first device 100 dynamically allocates an IP address of the second device 200 or the third device 300 according to a request of the second device 200 or the third device 300 .
[0066] In some embodiments, the third device 300 is an access device of the second device 200. Alternatively, the third device 300 is an access device of the first device 100, that is, the third device 300 can also directly establish a communication connection with the first device 100.
[0067] In some embodiments, the communication system further includes a fourth device. In response to a user operation, the fourth device may log in to the device management interface of the first device 100. On the device management interface, the fourth device may display the network usage of the second device 200 and the third device 300 managed by the first device 100, and receive the user's management operation on the second device 200 and the third device 300. Alternatively, the first device 100 is configured with a display screen, which may directly display the device management interface.
[0068] Optionally, the first device 100, the second device 200, and the third device 300 in the embodiment of the present application may be implemented by different devices, and the different devices may have the same, similar, or somewhat different hardware structures, such as Figure 3 The hardware structure shown.
[0069] For example, the first device 100 has Figure 3 Take the hardware structure shown in the figure as an example. Figure 3 The hardware structure shown is described.
[0070] Figure 3 A schematic structural diagram of the first device 100 is shown.
[0071] The first device 100 includes at least one processor 301 , a communication line 302 , a memory 303 and at least one communication interface 304 . The memory 303 may also be included in the processor 301 .
[0072] The processor 301 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the present application.
[0073] The communication link 302 may include a pathway to transmit information between the above-mentioned components.
[0074] The communication interface 304 is used to communicate with other devices. In the embodiment of the present application, the communication interface can be a module, a circuit, a bus, an interface, a transceiver or other device capable of realizing a communication function, and is used to communicate with other devices. Optionally, when the communication interface is a transceiver, the transceiver can be an independently arranged transmitter, which can be used to send information to other devices, and the transceiver can also be an independently arranged receiver, which is used to receive information from other devices. The transceiver can also be a component that integrates the functions of sending and receiving information, and the embodiment of the present application does not limit the specific implementation of the transceiver.
[0075] The memory 303 may be a read-only memory or other types of static storage devices capable of storing static information and instructions, a random access memory or other types of dynamic storage devices capable of storing information and instructions, or an electrically erasable programmable read-only memory, a read-only optical disk or other optical disk storage, a compact disk storage, a magnetic disk storage medium or other magnetic storage device, or any other medium capable of carrying or storing a desired program in the form of an instruction or data structure and capable of being accessed by a device or computer, but not limited thereto. The memory may be independent and connected to the processor via a communication line 302. The memory may also be integrated with the processor.
[0076] The memory 303 is used to store programs for implementing the solution of the present application, and is controlled to be executed by the processor 301. The processor 301 is used to execute the programs stored in the memory 303, thereby implementing the device distinguishing method provided in the following embodiments of the present application.
[0077] Optionally, the program in the embodiment of the present application may also be referred to as an application, an instruction, a program or other names, and the embodiment of the present application does not specifically limit this.
[0078] In a specific implementation, as an embodiment, the processor 301 may include one or more CPUs, such as Figure 3 CPU0 and CPU1 in.
[0079] In a specific implementation, as an embodiment, the first device 100 may include multiple processors, such as Figure 3 301 and processor 305 in FIG. Each of these processors may be a single-CPU processor or a multi-CPU processor. The processor here may refer to one or more devices, circuits, and / or processing cores for processing data (e.g., programs).
[0080] In some embodiments, the first device 100 further includes a display screen 306, and the first device 100 implements a display function through the display screen 306. For example, the first device 100 displays a device management interface through the display screen 306. In some examples, the first device 100 includes one or more display screens.
[0081] It is understandable that the embodiments of the present application are as follows Figure 3 The structure does not constitute the only limitation on the implementation of the structure of the first device 100. In other embodiments of the present application, the first device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0082] In some embodiments, the third device 300 may include Figure 3 The structure shown may have more or fewer components. For example, the third device 300 may also include a camera, a sensor module, etc.
[0083] The following describes in detail the method for distinguishing devices provided in the embodiment of the present application by taking the first device 100 as a main router, the second device 300 as a relay router, and the third device 300 as an access device as an example.
[0084] It should be understood that the third device 300 may be an access device of at least one of the first device 100 or the third device 300, and the second device 200 is a relay device of the first device 100, used to expand the network coverage of the first device 100. In some examples, the second device 200 may also relay other second devices 200 to further expand the network coverage of the first device 100.
[0085] Figure 4 This is a flow chart of a method for distinguishing devices provided in an embodiment of the present application. It should be noted that this method does not Figure 4 The specific order described below is a limitation, and it should be understood that in other embodiments, the order of some steps in the method can be interchanged according to actual needs, or some steps can be omitted or deleted. The method includes the following steps:
[0086] S401. The main router obtains the actual MAC address of the device and establishes a mapping relationship between the actual MAC address and the IP address.
[0087] In some embodiments, during the access to the main router, the IP address of the device requesting access to the network provided by the main router is dynamically allocated by the main router. Then, during the IP address allocation process, the main router can obtain the actual MAC address of each device.
[0088] In some examples, the main router sends a broadcast message, which is used to notify the current main router that there is an accessible network. After receiving the broadcast message, other devices send a message (such as a DHCP discover message) to the main router based on the dynamic host configuration protocol (DHCP), which is used to request access to the network. Optionally, the message carries the actual MAC address of the device. Accordingly, after receiving the message, the main router can configure the parameters of the device that sent the message, which are necessary parameters for the device to access the network, such as the assigned IP address. And in this process, the main router can obtain the actual MAC address of the device. It should be understood that different devices have different actual MAC addresses and different assigned IP addresses.
[0089] For example, Figure 5 In the networking scenario shown, the main router receives messages from the relay router, device 1 (access device 1 of the relay router), device 2 (access device 2 of the relay router), and device 3 (access device 3 of the main router) for requesting access to the network. Afterwards, the main router allocates IP addresses to the four devices through the configuration module and sends the IP addresses to the device management module. In addition, the device management module can obtain the actual MAC addresses of the four devices. Then, the device management module can establish a mapping relationship between the actual MAC addresses and IP addresses of different devices as shown in Table 3 below.
[0090] Table 3
[0091] Actual MAC address IP address Relay Router 2a:cf:24:f1:bc:94 192.168.3.3 Access device 1 of relay router 00:68:eb:c8:6d:37 192.168.3.4 Access device 2 of relay router 62:b7:8e:c7:27:3e 192.168.3.5 Access device 3 of the main router 68:05:ca:ba:d0:09 192.168.3.2
[0092] S402: The primary router obtains the MAC address used by the device.
[0093] In some embodiments, the access device of the relay router responds to the user operation and sends a message to the relay router, and the message includes, for example, a data message, a control message, etc. For example, the message is used to request to obtain the network data provided by the main router. After receiving the message, the relay router replaces the MAC address carried in the message with a unified MAC address and forwards it to the main router. In this way, the main router responds to the message and can send network data to the relay router, and the relay router sends the network data to the access device of the corresponding relay router, thereby meeting the network access requirements of the access device of the relay router.
[0094] Optionally, the unified MAC address is, for example, an actual MAC address of the relay router, a pre-configured MAC address, etc.
[0095] In some examples, after receiving a message sent by a device, the relay router will replace the actual MAC address in the message with a unified MAC address. The unified MAC address is then used by the device in the subsequent messages forwarded by the relay router to the main router. In some examples, when the relay router sends a message generated by itself to the main router, it can also carry a unified MAC address in the message. Alternatively, the actual MAC address of the relay router can be carried in the message.
[0096] Correspondingly, after receiving and parsing the message, the main router can obtain the MAC address used by the device carried therein (such as the relay router, the access device of the relay router, and the access device of the main router). It should be understood that the MAC address used by the device carried in the message received by the main router may be the actual MAC address of the device, or it may be a unified MAC address after replacement.
[0097] The following describes in detail the device differentiation process by taking the example of a relay router replacing the MAC address carried in a received message with the actual MAC address of the relay router (that is, the unified MAC address is the actual MAC address of the relay router).
[0098] In some examples, a device sends a message to an upper layer device based on the address resolution protocol (ARP). For example, an access device of a relay router sends an ARP message to the relay router, and the actual MAC address and IP address are carried in the message header of the ARP message.
[0099] For example, Figure 6 In step ① shown, access device 1 of the relay router sends a message to the relay router, the message including an Ethernet link (ETH) message header for indicating the actual MAC address of access device 1 of the relay router, and an IP message header for indicating the IP address of access device 1 of the relay router. Access device 2 of the relay router sends a message to the relay router, the message including an ETH message header for indicating the actual MAC address of access device 2 of the relay router, and an IP message header for indicating the IP address of access device 2 of the relay router.
[0100] Afterwards, if Figure 6 In step ② shown in the figure, when the relay router needs to forward a message, it replaces the actual MAC address indicated in the ETH message header of the message of the access device of the relay router with a unified MAC address (such as the actual MAC address of the relay router), and then forwards the message to the upper layer device (such as the main router), wherein the IP address in the forwarded message is the same as the IP address in the original message. Figure 5 As shown, after receiving the message, the main router parses the message through the address resolution module, obtains the MAC address and IP address used by the device carried in the message, and sends the resolution result to the device management module. For example, as shown in Table 4 below, in the message received by the main router, the message initiated by the relay router and the message initiated by the access device of the relay router indicate the same MAC address used, while the message sent by the access device 3 of the main router that directly communicates with the main router indicates the same MAC address used as the actual MAC address of the access device 3 of the main router. That is, the communication of the access device 3 of the main router does not pass through the relay router, so the MAC address in the message will not be replaced.
[0101] It should be understood that the address resolution module can count the correspondence between the IP address and the used MAC address without further distinguishing the devices using the same MAC address. The following Table 4 is only used to illustrate the correspondence between the IP address and the used MAC address.
[0102] Table 4
[0103] MAC address used IP address Relay Router 2a:cf:24:f1:bc:94 192.168.3.3 Access device 1 of relay router 2a:cf:24:f1:bc:94 192.168.3.4 Access device 2 of relay router 2a:cf:24:f1:bc:94 192.168.3.5 Access device 3 of the main router 68:05:ca:ba:d0:09 192.168.3.2
[0104] S403. The main router distinguishes different devices according to the actual MAC address, the used MAC address, and the IP address of the device.
[0105] In some embodiments, after obtaining the actual MAC address, used MAC address, and IP address of the device, the main router can distinguish different devices by combining the actual MAC address, used MAC address, and IP address of the device.
[0106] In some examples, the main router determines that multiple devices with different IP addresses use the same MAC address, and can determine that these devices include relay routers and access devices of relay routers. Then, the main router can determine the actual identity of the device based on whether the used MAC address is the same as the actual MAC address corresponding to the IP address. For example, if the used MAC address is the same as the actual MAC address corresponding to the IP address, the device corresponding to the IP address is a relay router; if the used MAC address is different from the actual MAC address corresponding to the IP address, the device corresponding to the IP address is an access device of the relay router.
[0107] It should be understood that when the relay router replaces the MAC address carried in the received message with a unified MAC address, which is not the actual MAC address of the relay router, and the message generated by the relay router itself carries the actual MAC address of the relay router, the main router determines that the MAC addresses used by multiple devices with different IP addresses are the same. Then, these devices with different IP addresses are relay router access devices.
[0108] For example, Figure 5 In the networking scenario shown, based on the above steps S401 and S402, the device management module can obtain the IP address, actual MAC address, and used MAC address of the device. Figure 7As shown, the IP addresses and actual MAC addresses counted by the configuration module are relied on, such as the IP address of the relay router is ip1 and the actual MAC address is mac1, the IP address of the access device 1 of the relay router is ip2 and the actual MAC address is mac2, the IP address of the access device 2 of the relay router is ip3 and the actual MAC address is mac3, and the IP address of the access device 3 of the main router is ip4 and the actual MAC address is mac4. And the IP addresses and used MAC addresses counted by the address resolution module are relied on, such as the IP address of the relay router is ip1 and the used MAC address is mac1, the IP address of the access device 1 of the relay router is ip2 and the used MAC address is mac1, the IP address of the access device 2 of the relay router is ip3 and the used MAC address is mac1, and the IP address of the access device 3 of the main router is ip4 and the used MAC address is mac4.
[0109] Afterwards, as shown in Table 5 below, the device management module determines the device that uniquely corresponds to the IP address and MAC address as the access device of the main router, such as device 3. The device management module obtains a list of IP addresses corresponding to the same MAC address, such as (ip1, ip2, ip3) corresponding to mac1. Afterwards, the device management module obtains the actual MAC address corresponding to each IP address in the IP address list, and determines the actual identity of the device based on whether the actual MAC address is the same as the used MAC address. As shown in Table 5 below, the main router determines through the device management module that mac1 corresponding to ip1 is the same as mac1, and the device corresponding to ip1 is a relay router; determines that mac2 corresponding to ip2 is different from mac1, and the device corresponding to ip2 is an access device of the relay router, and according to ip2, the device can be determined to be access device 1 of the relay router; determines that mac3 corresponding to ip3 is different from mac1, and the device corresponding to ip3 is an access device of the relay router, and according to ip3, the device can be determined to be access device 2 of the relay router.
[0110] Table 5
[0111]
[0112]
[0113] It should be understood that the above table 5 is only an exemplary description, and may include more or less information. For example, in the IP address allocation process, the main router may also obtain field information such as option 12 and option 60 in the DHCP discover message according to the DHCP discover message of the device. Then, the above table 5 may also include a device feature column for indicating these field information.
[0114] In some embodiments, in the process of determining whether devices with different IP addresses use the same MAC address, the primary router determines devices with different IP addresses as different devices. However, a device can be configured with both an IPv4 address and an IPv6 address. Then, when the IPv4 address and the IPv6 address are different, it is not considered that multiple different IP addresses are identified. That is, when a device has both an IPv4 address and an IPv6 address, it is not considered that there are multiple IP addresses.
[0115] In some embodiments, as shown in Table 5 above, after the main router recognizes the actual identity of the device, it identifies the devices with different identities through the device tags. For example, the device tag of the relay router is FLAG_THIRD_PARTY_ROUTER, the device tag of the access device of the relay router is FLAG_THIRD_PARTY_STA, and the device tag of the access device of the main router is FLAG_STA.
[0116] In some embodiments, during the device management process, the primary router identifies different devices through the unique identifier of the device. For example, after determining the actual identity of the device, the primary router uses a hash algorithm to calculate the hash value corresponding to the device based on the MAC address and IP address used by the device, and uses the hash value as the unique identifier of the device to index different devices.
[0117] For example, as shown in Table 5 above, after the main router receives the message sent or forwarded by the lower-layer device for the first time, it can obtain the MAC address used by the device, and then generate the hash value corresponding to the device based on the IP address previously assigned to the device during the access process. Subsequently, during the communication process, the main router can determine that the data includes the corresponding hash value based on the MAC address and IP address used in the received message, and then use the hash value as the basis for distinguishing the actual device, and perform traffic statistics, blocking, speed limiting, display and other functions on each device.
[0118] In this way, the main router distinguishes different devices by establishing a mapping relationship between the actual MAC address and the IP address of the device. Compared with the prior art, the main router cannot distinguish between the relay router and the access device of the relay router. The device distinguishing method provided in the embodiment of the present application can accurately identify different devices by combining the actual MAC address, IP address, and the used MAC address, avoid confusing different devices during the device management process, and achieve effective management of the device.
[0119] Exemplarily, in response to the user's operation of logging into the main router device management interface, the management device (such as a mobile phone, tablet, etc.) can display the device management interface. On the device management interface, the management device can respectively display the device usage of the access device of the main router, the relay router, and the access device of the relay router, such as traffic statistics, real-time network speed, network speed limit, etc. In addition, the user can intuitively see the network usage of each device connected to the main router through the device management interface, so as to operate a specific device, such as disconnecting a device from the Internet, accelerating games, blocking specific application flows, etc.
[0120] In some embodiments, the device differentiation method provided in the embodiments of the present application can be applied to different networking scenarios. Figure 8 In the networking scenario shown, the relay routers of the main router include relay router 1 and relay router 2. Among them, the access devices of relay router 1 include device 1, device 2 and relay router 3. The relay router 3 is a relay device of relay router 1, thereby further expanding the network coverage of the main router. The access devices of relay router 3 include device 6. The access devices of relay router 2 include device 4 and device 5. Then, during the communication process, the main router recognizes that the MAC addresses used by relay router 1, device 1, device 2, relay router 3 and device 6 are the same, such as mac1; the main router recognizes that the MAC addresses used by relay router 2, device 4 and device 5 are the same, such as mac5; the main router recognizes that the MAC address used by the access device 3 of the main router is mac4. Then, based on the MAC addresses, actual MAC addresses, and IP addresses used by each device, the main router can distinguish different devices and identify different devices through hash values.
[0121] In some embodiments, the IP address assigned to a device may change. When the device applies for an IP address, the main router determines that the actual MAC address of the device has been recorded, and can refresh the unique identification of the device according to the newly assigned IP address. This achieves adaptive unique identification of the changing device and avoids the problem of device unrecognition.
[0122] In some examples, after a device exits the network, the main router will reclaim the device's IP address. Subsequently, the IP address can be assigned to other devices that request to access the network. Optionally, after the device exits the network and requests to access the network again, the main router will give priority to assigning the device's previously used IP address.
[0123] In some examples, there are lease issues with dynamically allocated IP addresses. If the lease is not renewed after a timeout, the main router will reclaim the IP address allocated to the device. For example, the IP address allocated to the device by the main router is ip3, and the lease period is 24 hours. During the communication process, if the communication time exceeds 24 hours and the device still does not request a renewal, the main router can reclaim the IP address of the device.
[0124] Exemplarily, after the main router receives a message (such as a DHCP discover message) sent by the access device 2 of the relay router for requesting access to the network, it obtains the actual MAC address carried therein, such as mac3. The main router determines that the actual MAC address of the device is consistent with the actual MAC address of the known device by querying the device information list shown in Table 5 above. Then, as shown in Table 6 below, the main router assigns an IP address to the device, such as ip5. Afterwards, the main router refreshes the known information based on the newly assigned IP address of the device and the known information corresponding to the device in Table 5. As shown in Table 6, the IP address of the access device 2 of the relay router is refreshed to ip5 and the unique identifier is hash (mac1, ip5), and the actual MAC address is mac3, the used MAC address is mac1, and the device label is FLAG_THIRD_PARTY_STA unchanged. And, as shown in Table 7, the information of the access device 2 of the refreshed relay router is added to the maintained device information list, and the historical information of the access device 2 of the relay router in the device information list is deleted.
[0125] In this way, after the device IP address changes, the main router can also determine whether the new and old IP addresses correspond to the same device, and by updating the unique identifier of the device, always determine the unique corresponding device to meet the device management needs.
[0126] Table 6
[0127]
[0128] Table 7
[0129]
[0130] Fig. 9 This is a flow chart of another method for distinguishing devices provided in an embodiment of the present application. It should be noted that this method does not Fig. 9The specific order described below is a limitation, and it should be understood that in other embodiments, the order of some steps in the method can be interchanged according to actual needs, or some steps can be omitted or deleted. The method includes the following steps:
[0131] S901. A first device receives a first message, where the first message carries a first MAC address and a first IP address.
[0132] S902: The first device receives a second message, where the second message carries a second MAC address and a second IP address.
[0133] The first message or the second message includes but is not limited to data streams, control streams and other types of messages sent by the lower layer device to the upper layer device. For example, the first message is a message sent by the second device to the first device for requesting network data.
[0134] In some embodiments, after receiving the message, the first device parses the message and can obtain the MAC address and IP address used by the device carried in the message.
[0135] In some examples, the first message or the second message received by the first device may be a message sent by a device connected to the first device, and the device connected to the first device may be, for example, a device directly connected to the first device or a relay device of the first device. The first message or the second message received by the first device may also be a message forwarded by a device connected to the first device, and the original sending device of the message may be, for example, an access device of a device connected to the first device.
[0136] For example, Figure 5 In the networking scenario shown, the first device is, for example, a main router, and the first device receives a message sent by a relay router. Alternatively, device 1 sends a message to a relay router, and after receiving the message, the relay router forwards the message to the main router.
[0137] It should be understood that the embodiments of the present application do not limit the execution order of step S901 and step S902. The first device may first receive the first message, and then receive the second message (i.e., first execute step S901, and then execute step S902). Alternatively, the first device may first receive the second message, and then receive the first message (i.e., first execute step S902, and then execute step S901). Alternatively, the first device may receive the first message and the second message at the same time (i.e., execute step S901 and step S902 at the same time).
[0138] S903: When the first MAC address is the same as the second MAC address and the first IP address is different from the second IP address, the first device obtains a third MAC address corresponding to the first IP address and a fourth MAC address corresponding to the second IP address.
[0139] In some embodiments, after receiving the message, the relay device of the first device replaces the MAC address carried in the message with a unified MAC address. Then, after the first device receives the message forwarded by the relay device, it parses the message to obtain the first MAC address or the second MAC address as the MAC address used by the device. The MAC addresses used by the messages received by the first device may be the same.
[0140] For example, Figure 5 In the networking scenario shown, the first device is, for example, a main router. Device 1 sends message 1 to the relay router, and message 1 carries the actual MAC address and IP address of device 1; device 2 sends message 2 to the relay router, and message 2 carries the actual MAC address and IP address of device 2. After receiving message 1 and message 2, the relay router replaces the MAC addresses carried therein with a unified MAC address and forwards them to the main router. Then, after receiving message 1 and message 2, the main router can determine that the MAC addresses carried in these two messages are the same, but the IP addresses are different. Therefore, in a relay scenario with a relay router, after receiving messages carrying the same MAC address but different IP addresses, the first device can further determine the true identity of the original source device of these messages.
[0141] In some embodiments, during the device networking process, the first device receives a third message sent by the second device, and the third message carries the third MAC address of the second device. The first device assigns a first IP address to the second device. Afterwards, the first device saves the mapping relationship between the first IP address and the third MAC address. Then, when the first device receives the first message and parses out the second message containing the second MAC address identical to the first MAC address carried in the first message, the first device can determine the third MAC address corresponding to the first IP address based on the first IP address carried in the first message and the saved mapping relationship.
[0142] It should be understood that during the networking process, the first device also obtains the fourth MAC address of the third device, and therefore can also save the mapping relationship between the fourth MAC address and the second IP address assigned by the first device to the third device. In this way, the first device can subsequently determine the fourth MAC address corresponding to the second IP address based on the second IP address carried in the second message and the mapping relationship.
[0143] For example, Figure 5In the networking scenario shown, the main router receives messages from the relay router, device 1 (access device 1 of the relay router), device 2 (access device 2 of the relay router), and device 3 for requesting access to the network. Afterwards, the main router allocates IP addresses to the four devices through the configuration module and sends the IP addresses to the device management module. In addition, the device management module can obtain the actual MAC addresses of the four devices. Then, the device management module can establish a mapping relationship between the actual MAC addresses and IP addresses of different devices as shown in Table 3 above. In this way, after receiving the message, the main router can determine the actual MAC address of the device based on the IP address carried in the message and the saved mapping relationship.
[0144] S904: If the first MAC address is the same as the third MAC address, the first device determines that the second device corresponding to the first message is a relay device of the first device.
[0145] S905: If the second MAC address is different from the fourth MAC address, the first device determines that the third device corresponding to the second message is an access device of the second device.
[0146] In some embodiments, the first device generates device information, wherein the device information includes one or more of the identification of the second device, the first MAC address, the third MAC address, the first IP address, the device tag, and the device characteristics.
[0147] In some examples, the first device generates an identifier of the second device based on the first MAC address and the first IP address of the second device.
[0148] In this way, the first device generates unique identifiers for other devices to index the corresponding unique devices, thereby avoiding confusion between different devices during the device management process and achieving effective management of the devices.
[0149] For example, Figure 5In the networking scenario shown, during the network configuration process, the main router can obtain the actual MAC address of the relay router as mac1, and the assigned IP address as ip1; the actual MAC address of device 1 is mac2, and the assigned IP address is ip2; the actual MAC address of device 2 is mac3, and the assigned IP address is ip3; the actual MAC address of device 3 is mac4, and the assigned IP address is ip4. And in the communication process, the first device can obtain the MAC addresses used by the relay router, device 1 and device 2 are all mac1, and the MAC address used by device 3 is mac4 according to the obtained message. Then, the first device can generate a device information list, and record the device information of multiple devices in the device information list, such as the MAC addresses used, actual MAC addresses, and IP addresses of the relay router, device 1, device 2, and device 3. For example, the device information list shown in Table 5 above.
[0150] In some embodiments, the first device obtains the actual MAC address of the device based on the IP address. Afterwards, if the actual MAC address corresponding to the IP address is the same as the used MAC address, the first device can determine that the original source device of the message is the relay device of the first device. For example, the first device is a main router, and the original source device is a relay router. If the actual MAC address corresponding to the IP address is not the same as the used MAC address, the first device can determine that the original source device of the message is not the relay device of the first device, but an access device of the relay device. For example, the first device is a main router, and the original source device is an access device of the relay router.
[0151] For example, Figure 5In the networking scenario shown, the main router (such as the first device) receives the first message sent by the relay router, and the first message carries the first MAC address and the first IP address of the relay router. In addition, device 1 sends a second message to the main router through the relay router, and the second message carries the second MAC address and the second IP address. The second MAC address is a unified MAC address after the relay router is replaced, such as the unified MAC address is the actual MAC address of the relay router. Afterwards, the first device determines that the first MAC address is the same as the second MAC address, and the first IP address is different from the second IP address, and it can be determined that the first message and the second message come from different devices. The first device determines the third MAC address corresponding to the first IP address and the fourth MAC address corresponding to the second IP address based on the stored device information list. Then, if the main router determines that the first MAC address is the same as the third MAC address (that is, the MAC address used by the device is the same as the actual MAC address), it can be determined that the original source device that sent the first message is the relay router, that is, the relay device of the main router. If the main router determines that the second MAC address is different from the fourth MAC address (ie, the MAC address used by the device is different from the actual MAC address), it can be determined that the original source device sending the second message is the relay router access device, that is, the access device of the relay router.
[0152] In this way, the first device distinguishes different devices by establishing a correspondence between the actual MAC address, IP address, and used MAC address of the device. Compared with the prior art, the first device cannot distinguish between a relay device and an access device of the relay device. The device distinguishing method provided in the embodiment of the present application can accurately identify different devices based on the actual MAC address, IP address, and used MAC address, avoid confusing different devices during the device management process, and achieve effective management of the device.
[0153] In some embodiments, the first device receives a fifth message carrying a fifth MAC address and a fourth IP address. When the fifth MAC address is different from both the first MAC address and the second MAC address, the first device determines that the fourth device corresponding to the fifth message is the access device of the first device.
[0154] For example, Figure 5 In the networking scenario shown, the main router (such as the first device) receives the fifth message sent by device 3, and determines that the fifth MAC address carried in the fifth message is different from the MAC addresses carried in other received messages. It can be determined that the fifth message is a message sent by the access device of the main router.
[0155] In this way, the first device can determine whether the original source device of the message is the access device of the first device, the relay device of the first device, or the access device of the relay device according to whether the MAC address carried in the received message is the same as other MAC addresses, thereby facilitating the first device to manage different devices.
[0156] In some embodiments, the first device receives a sixth message, which carries a sixth MAC address and a fifth IP address. When the sixth MAC address is the same as the second MAC address, and the fifth IP address is different from the second IP address, the first device obtains the seventh MAC address corresponding to the fifth IP address. If the sixth MAC address is different from the seventh MAC address, the first device determines that the fifth device corresponding to the sixth message is the access device of the second device, and distinguishes the third device from the fifth device by the second IP address and the fifth IP address.
[0157] For example, Figure 5 In the networking scenario shown, device 1 sends the second message to the main router through the relay router, and device 2 sends the sixth message to the main router through the relay router. That is, the original source device of the second message is device 1, and the original source device of the sixth message is device 2. Then, the MAC address used by the device carried in the second message and the sixth message is the same, and the MAC address used is the unified MAC address after the relay router is replaced. When the first device determines that the MAC addresses carried by the second message and the sixth message are the same, it determines whether the IP addresses carried are the same. If they are the same, the first device can determine that the second message and the sixth message are messages sent by the same device. If they are not the same, the first device can determine that the second message and the sixth message are messages sent by different devices. Furthermore, the first device can obtain the fourth MAC address corresponding to the second IP address carried in the second message and the seventh MAC address corresponding to the fifth IP address carried in the sixth message according to the saved mapping relationship, and then determine that the device 1 corresponding to the second message and the device 2 corresponding to the sixth message are both relay router access devices according to the difference between the second MAC address and the fourth MAC address carried in the second message, and the difference between the sixth MAC address and the seventh MAC address carried in the sixth message. Then, the first device needs to distinguish the two relay router access devices through the IP addresses of device 1 and device 2.
[0158] In this way, the first device can distinguish different access devices of the same relay router through the IP address, thereby facilitating the first device to manage different devices.
[0159] In some embodiments, the first device receives a fourth message sent by the second device, the fourth message carrying the third MAC address of the second device. The first device assigns a third IP address to the second device. The first device determines that a mapping relationship between the third MAC address and the first IP address has been saved. Then, the first device updates the first IP address corresponding to the third MAC address to the third IP address.
[0160] In some examples, the IP address assigned to the first device may change. In this case, when the first device applies for an IP address, it determines that the actual MAC address of the device has been recorded, and can refresh the information of the device in the device information list according to the newly assigned IP address. For example, the unique identification of the device, IP address, etc. are refreshed. This achieves adaptive unique identification of the changing device and avoids the problem of device unrecognition.
[0161] In this way, after the device IP address changes, the first device can also determine whether the new and old IP addresses correspond to the same device, and by updating the unique identifier of the device, always determine the unique corresponding device to meet the device management requirements.
[0162] In some examples, the first device may also execute the steps and functions executed by the first device 100 (such as a main router) in the above embodiment, the second device may also execute the steps and functions executed by the second device 200 (such as a relay router) in the above embodiment, and the third device may also execute the steps and functions executed by the third device 300 (such as a relay router access device) in the above embodiment, thereby implementing the method for distinguishing devices provided in the above embodiment.
[0163] Combination of the above Figure 4-Figure 9 The method for distinguishing devices provided in the embodiment of the present application is described in detail. Fig.10 The first device provided in the embodiment of the present application is described in detail.
[0164] In one possible design, Fig.10 This is a schematic diagram of the structure of the first device provided in the embodiment of the present application. Fig.10 As shown, the first device 1000 may include: a transceiver unit 1001 and a processing unit 1002. The first device 1000 may be used to implement the functions of the first device 100 (eg, a master router) involved in the above method embodiment.
[0165] Optionally, the transceiver unit 1001 is used to support the first device 1000 to execute Figure 4 S401 and S402 in; and / or, for supporting the first device 1000 to execute Fig. 9 S901 and S902 in.
[0166] Optionally, the processing unit 1002 is used to support the first device 1000 to execute Figure 4 S401 and S403 in; and / or, for supporting the first device 1000 to execute Fig. 9 S903, S904 and S905 in.
[0167] The transceiver unit 1001 may include a receiving unit and a sending unit, and may be implemented by a transceiver or a transceiver-related circuit component, and may be a transceiver or a transceiver module. Figure 3 The processing unit 1002 may be implemented by a processor-related circuit component, which may be a processor or a processing module. For example, the processing unit 1002 may be Figure 3 The processor 301 is shown. The operations and / or functions of each unit in the first device 1000 are respectively to implement the corresponding processes of the device distinguishing method described in the above method embodiment. All relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional unit, and will not be repeated here for the sake of brevity.
[0168] Optionally, Fig.10 The first device 1000 shown may also include a storage unit ( Fig.10 (not shown), the storage unit stores a program or instruction. When the transceiver unit 1001 and the processing unit 1002 execute the program or instruction, Fig.10 The first device 1000 shown can execute the device distinguishing method described in the above method embodiment.
[0169] Fig.10 The technical effects of the first device 1000 shown can refer to the technical effects of the device distinguishing method described in the above method embodiment, and will not be repeated here.
[0170] In addition to being in the form of the first device 1000, the technical solution provided in the present application may also be a functional unit or chip in the first device, or a device used in conjunction with the first device.
[0171] An embodiment of the present application also provides a chip system, including: a processor, the processor is coupled to a memory, the memory is used to store programs or instructions, when the program or instructions are executed by the processor, the chip system implements the method in any of the above method embodiments.
[0172] Optionally, the processor in the chip system may be one or more. The processor may be implemented by hardware or by software. When implemented by hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented by software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.
[0173] Optionally, the memory in the chip system may also be one or more. The memory may be integrated with the processor or may be separately arranged with the processor, which is not limited in the embodiments of the present application. Exemplarily, the memory may be a non-transient processor, such as a read-only memory ROM, which may be integrated with the processor on the same chip or may be arranged on different chips respectively. The embodiments of the present application do not specifically limit the type of memory and the arrangement of the memory and the processor.
[0174] Exemplarily, the chip system can be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD) or other integrated chips.
[0175] It should be understood that each step in the above method embodiment can be completed by an integrated logic circuit of hardware in a processor or by instructions in the form of software. The method steps disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware processor, or by a combination of hardware and software modules in a processor.
[0176] An embodiment of the present application further provides a readable storage medium, in which a program is stored. When the program is executed on a device, the device executes the above-mentioned related steps to implement the method for distinguishing devices in the above-mentioned embodiment.
[0177] The embodiment of the present application also provides a program product. When the program product is run on a device, the device executes the above-mentioned related steps to implement the method for distinguishing devices in the above-mentioned embodiment.
[0178] In addition, an embodiment of the present application further provides a device. The device may be a component or a module, and the device may include one or more processors and a memory connected to each other. The memory is used to store a program. When the program is executed by one or more processors, the device performs the device distinguishing method in the above-mentioned method embodiments.
[0179] Among them, the device, readable storage medium, program product or chip provided in the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0180] The steps of the method or algorithm described in conjunction with the disclosure of the embodiments of the present application can be implemented in a hardware manner, or can be implemented by a processor executing software instructions. The software instructions can be composed of corresponding software modules, and the software modules can be stored in a random access memory, a flash memory, a read-only memory, an erasable programmable read-only memory, an electrically erasable programmable read-only memory, a register, a hard disk, a mobile hard disk, a read-only optical disk, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application-specific integrated circuit.
[0181] Through the description of the above implementation methods, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed; that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, device and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0182] In the several embodiments provided in the present application, it should be understood that the disclosed method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation; for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of modules or units, which can be electrical, mechanical or other forms.
[0183] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0184] The readable storage medium includes but is not limited to any of the following: a USB flash drive, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk, and other media that can store programs.
[0185] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for distinguishing devices, characterized in that: Applied to a first device, the method includes: Receive a first message, wherein the first message carries a first media access control MAC address and a first Internet Protocol IP address; Receive a second message, wherein the second message carries a second MAC address and a second IP address; When the first MAC address is the same as the second MAC address and the first IP address is different from the second IP address, obtain a third MAC address corresponding to the first IP address and a fourth MAC address corresponding to the second IP address; If the first MAC address is the same as the third MAC address, determining that the second device corresponding to the first message is a relay device of the first device; If the second MAC address is different from the fourth MAC address, it is determined that the third device corresponding to the second message is an access device of the second device.
2. The method according to claim 1, characterized in that Before receiving the first message, the method further includes: Receive a third message sent by the second device, where the third message carries the third MAC address of the second device; Allocating the first IP address to the second device; A mapping relationship between the first IP address and the third MAC address is saved.
3. The method according to claim 2, characterized in that The obtaining a third MAC address corresponding to the first IP address includes: According to the mapping relationship, the third MAC address corresponding to the first IP address is determined.
4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: receiving a fourth message sent by the second device, wherein the fourth message carries the third MAC address of the second device; assigning a third IP address to the second device; Determining that a mapping relationship between the third MAC address and the first IP address has been saved; The first IP address corresponding to the third MAC address is updated to the third IP address.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Generate device information, wherein the device information includes one or more of the identifier of the second device, the first MAC address, the third MAC address, the first IP address, a device tag, and a device feature.
6. The method according to claim 5, characterized in that The method further comprises: An identifier of the second device is generated according to the first MAC address and the first IP address of the second device.
7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Receiving a fifth message, wherein the fifth message carries a fifth MAC address and a fourth IP address; When the fifth MAC address is different from both the first MAC address and the second MAC address, it is determined that the fourth device corresponding to the fifth message is an access device of the first device.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: Receiving a sixth message, wherein the sixth message carries a sixth MAC address and a fifth IP address; When the sixth MAC address is the same as the second MAC address and the fifth IP address is different from the second IP address, acquiring a seventh MAC address corresponding to the fifth IP address; If the sixth MAC address is different from the seventh MAC address, it is determined that the fifth device corresponding to the sixth message is the access device of the second device, and the third device and the fifth device are distinguished by the second IP address and the fifth IP address.
9. A first device, characterized in that: include: One or more processors and a memory, wherein the memory is coupled to the one or more processors, and the memory is used to store one or more programs. When the one or more processors read the one or more programs from the memory, the first device executes the method as described in any one of claims 1 to 8.
10. A readable storage medium, characterized in that: The readable storage medium includes a program, and when the program is executed on a device, the device is caused to execute the method according to any one of claims 1 to 8.