Communication connection establishment method, electronic device, and storage medium
By obtaining the association mapping table of the interface address of the sending end and its Internet protocol address, the problem of instability of communication between devices is solved and a more stable communication connection is achieved.
Patent Information
- Application Number
- PCT/CN2024/126440
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-01-19
- Filing Date
- 2024-10-22
- Publication Date
- 2025-07-24
AI Technical Summary
In the prior art, when communicating between devices, the P2P Interface Address and P2P Device Address are inconsistent, resulting in the failure of communication between devices, especially the unstable screen projection connection under the Miracast protocol.
By obtaining the interface address of the sending end and its corresponding Internet protocol address, the Internet protocol address of the sending end is directly obtained and a communication connection is established.
It avoids communication failure caused by address inconsistency between devices and improves the stability of communication between devices.
Smart Images

Figure CN2024126440_24072025_PF_FP_ABST
Abstract
Description
Communication connection establishment method, electronic device and storage medium
[0001] This application claims priority to Chinese patent application filed on January 19, 2024, with application number 202410080997.X, and application name “Method, device, electronic device and storage medium for establishing communication connection”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of communication technology, and in particular to a method, device, electronic device and storage medium for establishing a communication connection. Background Art
[0003] Current Wi-Fi Direct inter-device communication and Miracast protocol implementations on platforms like Android typically rely on obtaining the peer device's P2P Device Address (P2P Device Address), performing a RARP reverse query to obtain the peer device's IP address, and ultimately achieving socket-based communication between P2P devices within a P2P group. However, the principles of Wi-Fi Direct ad hoc networking indicate that inter-device communication within a P2P group should use the P2P Interface Address for more reliable communication. However, the P2P Interface Address may not necessarily match the P2P Device Address, especially when the random MAC address feature is enabled on the P2P device. Technical issues
[0004] This major flaw in the general implementation of using P2P Device Address for P2P Group device communication prevents the receiver from performing a RARP reverse query based on the sender's P2P Device Address to obtain the corresponding sender's IP address, resulting in the inability to complete the connection between devices based on WiFi Direct, including the Miracast protocol. The Miracast protocol will also experience stability issues such as failure to connect to the screen projection between devices. Technical Solutions
[0005] This application aims to solve at least one of the technical problems existing in the related art. To this end, the embodiments of the present application provide a method, device, electronic device and storage medium for establishing a communication connection, which can avoid abnormal communication between devices and improve the stability of the communication connection between devices.
[0006] In a first aspect, an embodiment of the present application provides a method for establishing a communication connection, comprising:
[0007] In response to a networking request sent by a sending end to a receiving end, obtaining an interface address of the sending end and an address protocol resolution table of the receiving end; the address protocol resolution table is a mapping table of associations between interface addresses and their corresponding Internet Protocol addresses;
[0008] Acquire the Internet Protocol address of the sending end based on the interface address and the address protocol resolution table;
[0009] A connection request is initiated to the sending end based on the Internet Protocol address, so that the sending end establishes a communication connection with the receiving end based on the connection request.
[0010] In a second aspect, an embodiment of the present application provides a device for establishing a communication connection, comprising:
[0011] a first acquisition module, configured to, in response to a networking request sent by a sending end to a receiving end, acquire an interface address of the sending end and an address protocol resolution table of the receiving end; the address protocol resolution table being a mapping table of associations between interface addresses and their corresponding Internet Protocol addresses;
[0012] A second acquisition module, configured to acquire the Internet Protocol address of the sending end based on the interface address and the address protocol resolution table;
[0013] The communication connection establishing module is used to initiate a connection request to the sending end based on the Internet Protocol address, so that the sending end can establish a communication connection with the receiving end based on the connection request.
[0014] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory storing multiple computer programs; a processor loading the computer programs from the memory to execute any one of the communication connection establishment methods provided in the embodiment of the present application.
[0015] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores multiple computer programs, and the computer programs are suitable for loading by a processor to execute any one of the communication connection establishment methods provided in the embodiments of the present application.
[0016] In a fifth aspect, an embodiment of the present application further provides a computer program product, comprising a computer program, which, when executed by a processor, implements any one of the communication connection establishment methods provided in the embodiments of the present application. Beneficial effects
[0017] The embodiment of the present application directly obtains the Internet Protocol address through the interface address, avoiding the problem that the Internet Protocol address cannot be obtained through the device address when the interface address and the device address are inconsistent, avoiding the inability to communicate normally between devices, and improving the stability of the communication connection between devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0019] FIG1 is a flow chart of a method for establishing a communication connection provided in an embodiment of the present application;
[0020] FIG2 is a schematic diagram of a timing flow of establishing a communication connection provided in an embodiment of the present application;
[0021] FIG3 is a schematic diagram of the overall solution flow chart provided in an embodiment of the present application;
[0022] FIG4 is a schematic diagram of the structure of a communication connection establishment device provided in an embodiment of the present application;
[0023] FIG5 is a schematic structural diagram of an electronic device provided in an embodiment of the present application. Modes for Carrying Out the Invention
[0024] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of this application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0025] The embodiments of the present application provide a method, device, electronic device and storage medium for establishing a communication connection. Specifically, the embodiments of the present application will be described from the perspective of a communication connection establishing device, which can be specifically integrated into an electronic device, that is, the communication connection establishing method of the embodiment of the present application can be executed by an electronic device. Optionally, the electronic device includes a terminal device. The terminal device can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a game console, or a personal computer (PC) and other devices. Optionally, the electronic device includes a server, which can be an independent server or a server network or server cluster composed of servers, including but not limited to computers, network hosts, single network servers, network server sets or cloud servers composed of servers. Among them, the cloud server is composed of a large number of computers or network servers based on cloud computing (Cloud Computing).
[0026] It should be noted that the order in which the following embodiments are described is not intended to limit the preferred order of the embodiments. Although a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than that shown in the drawings.
[0027] Screen projection protocol: transfers content on one device to another device via the network for display. Standard screen projection protocols in the field of multi-screen interaction include DLNA, AirPlay, Miracast, etc.
[0028] Miracast: A screen projection protocol proposed by the Wi-Fi Alliance, also known as WiFi Display, or WFD for short. It is based on WiFi Direct point-to-point connection and supports screen mirroring content projection. It is currently widely used on Android and Windows devices.
[0029] WiFi Direct: WiFi direct connection, the same as WiFi P2P, allows devices to directly connect to each other through WLAN without an intermediate access point.
[0030] P2P Group: This refers to a P2P (Peer-to-Peer) group. When two devices connect directly to a Wi-Fi network, they form a P2P group and automatically assign Internet Protocol addresses (IP addresses) within the group via DHCP.
[0031] GO (Group Owner): After two devices establish a Wi-Fi direct connection, a P2P group is formed. The group owner is the GO and acts as a DHCP server.
[0032] GC (Group Client): After two devices establish a WiFi direct connection, a P2P group is formed. The group user is the GC role and acts as a DHCP client.
[0033] DHCP (Dynamic Host Configuration Protocol) is used to centrally manage and dynamically configure user IP addresses. DHCP networking uses a client / server communication model, where a server controls a range of IP addresses. When a client logs in to the server, it automatically obtains an IP address and subnet mask assigned by the server.
[0034] The MAC (Media Access Control Address) is written into the hardware by the network equipment manufacturer during production and serves as a unique identifier for the device on the network. A MAC address is 48 bits (6 bytes) and is typically represented as 12 hexadecimal numbers, with colons separating each two hexadecimal numbers, such as 08:00:20:0A:8C:6D. The first three bytes represent the OUI (Organizationally Unique Identifier), a code assigned to each manufacturer by the IEEE registration authority. The last three bytes are the extended identifier assigned by the manufacturer.
[0035] RARP (Reverse Address Resolution Protocol) allows the IP address of a physical machine in the LAN to be obtained from the ARP table or cache of the gateway server based on the MAC address of the physical machine in the LAN.
[0036] Miracast protocol screen casting connection principle: The Miracast protocol generally divides devices into two roles: sender and receiver. The protocol implements device / service discovery by appending WFD IEs (which contain WFD device information) to Wi-Fi Beacon, Probe Request, and Probe Response frames. When a sender selects a receiver for screen casting, the devices first complete ad hoc network negotiation and establish a P2P group via Wi-Fi Direct. Devices within the P2P group are then assigned IP addresses for inter-device communication. After the P2P group is successfully established, the sender listens for RTSP (over TCP) connections and communicates the port information to the receivers within the same P2P group using the WFD IE. The receiver then identifies the sender by parsing the P2P group information and obtains its RTSP listening port and IP address. The receiver then initiates a connection to the sender, and the devices complete subsequent protocol interaction over this RTSP connection to achieve screen casting.
[0037] WiFi Direct ad hoc network connection principle: After completing ad hoc network negotiation, WiFi Direct establishes a P2P group. Devices within the P2P group are assigned IP addresses for inter-device communication. A P2P group is generally divided into two roles: the GO (Group Owner) and the GC (Group Client). During the ad hoc networking phase, the two parties negotiate the role by exchanging the values of the Group Owner Intent attribute. There is only one GO in a P2P group, while there may be multiple GCs. When allocating IP addresses, the GO acts like a LAN gateway. P2P devices in a P2P group can generally easily obtain the GO's IP address, while the GC's IP address typically requires a RARP reverse lookup using the P2P device's MAC address. WiFi Direct defines two types of MAC addresses for P2P devices: the P2P Device Address, which uniquely identifies a P2P device; and the P2P Interface Address, which uniquely identifies a P2P device within a P2P group. Although Wi-Fi Direct doesn't specify how P2P devices use the two types of MAC addresses, the P2P Device Address is generally used for Device Discovery before establishing or joining a P2P group, while the P2P Interface Address is generally used for communication between P2P devices within a P2P group. The P2P Interface Address doesn't necessarily match the P2P Device Address, especially when the random MAC address feature is enabled on a P2P device. However, the P2P Interface Address is generally generated using an algorithm based on the P2P Device Address and may differ between Wi-Fi module manufacturers.
[0038] P2P devices:
[0039] P2P devices with WiFi Direct connection capability: Add the P2P interface address information of the peer P2P device and obtain the IP address of the peer P2P device through RARP.
[0040] P2P devices without Wi-Fi Direct connectivity: A matching similarity algorithm is performed based on the OUI vendor information in the peer device's Device Address information. The device searches the ARP list of the local P2P device for the most similar MAC address, marks it as the peer device's P2P Interface Address information, and obtains the peer device's IP address through RARP.
[0041] Cloud: Maintain and update the similarity algorithm list corresponding to the OUI manufacturer and send it to P2P devices.
[0042] The following is a detailed description of the method for establishing a communication connection provided in the embodiment of the present application, which is described in detail with reference to the accompanying drawings. The embodiment of the present application is described by taking the communication connection establishment device as the execution subject as an example, and the embodiment of the present application is described by taking the P2P receiving end as an example. Referring to FIG. 1 , FIG. 1 is a flow chart of the method for establishing a communication connection provided in the embodiment of the present application. The specific flow of the method for establishing a communication connection provided in the embodiment of the present application may be as follows: Steps 10 to 30, including:
[0043] Step 10: In response to the networking request sent by the sending end to the receiving end, the interface address of the sending end and the address protocol resolution table of the receiving end are obtained.
[0044] Optionally, when a P2P sender needs to establish a socket connection for communication with a P2P receiver, the P2P sender needs to send a networking request to the P2P receiver. Simultaneously, the P2P sender listens for subsequent socket communication connection requests from the P2P receiver. Therefore, the P2P receiver responds to the P2P sender's networking request and completes the negotiation and establishment of a P2P Group between the P2P sender and the P2P receiver. At this point, the P2P receiver needs to obtain the interface address of the P2P sender. The specific process is as follows: Steps 101 to 102. Simultaneously, the P2P receiver needs to obtain an address protocol resolution table on the P2P receiver's local machine. The address protocol resolution table is a mapping table of associations between interface addresses and their corresponding Internet Protocol addresses. In one embodiment, the address protocol resolution table is shown in Table 1.
[0045] Table 1 Address protocol resolution table
[0046] Step 20, based on the interface address and the address protocol resolution table, obtain the Internet Protocol address of the sender. Optionally, the P2P receiving end matches the interface address in the address protocol resolution table, determines the Internet Protocol address of the interface address in the address protocol resolution table, and determines the Internet Protocol address as the Internet Protocol address of the P2P sender. Specifically: using the interface address of the P2P sender as the address index, traverse the address protocol resolution table to obtain the Internet Protocol address of the P2P sender. In one embodiment, using the interface address of the P2P sender as the MAC address index, traverse the HW Address (device MAC address) column of the address protocol resolution table to find an entry that matches the interface address of the P2P sender, and mark the "IP Address" column data corresponding to the row where the entry is located as the Internet Protocol IP address of the P2P sender.
[0047] Step 30: Initiate a connection request to the sending end based on the Internet Protocol address, so that the sending end establishes a communication connection with the receiving end based on the connection request.
[0048] Optionally, the P2P receiving end initiates a Socket connection request to the P2P sending end through the Internet Protocol address of the P2P sending end. After receiving the Socket connection request sent by the P2P receiving end, the P2P sending end establishes a Socket communication connection with the P2P receiving end according to the Socket connection request.
[0049] The embodiment of the present application directly obtains the Internet Protocol address through the interface address, avoiding the problem that the Internet Protocol address cannot be obtained through the device address when the interface address and the device address are inconsistent, avoiding the inability to communicate normally between devices, and improving the stability of the communication connection between devices.
[0050] In an optional embodiment, the description of steps 101 to 102 is as follows:
[0051] Step 101, in response to a networking request sent by a sending end to a receiving end, obtaining device information of the sending end and a device connection mode of the receiving end;
[0052] Step 102: Acquire the interface address of the sending end based on the device connection mode and the device information.
[0053] Optionally, the P2P receiving end obtains the device information of the P2P sending end in response to the networking request of the P2P sending end, wherein the device information is used to obtain the interface address or device address of the P2P sending end. Therefore, the device information includes a device address field and an interface address field. The device address of the P2P sending end can be obtained according to the device address field, and the interface address of the P2P sending end can be obtained according to the interface address field.
[0054] It should be noted that in systems that follow the AOSP native specification on Android platform devices, the WiFi Direct framework only supports obtaining partial information about the P2P sender, such as the P2P Device Address, between devices that have completed P2P Group formation. However, the P2P Interface Address, which is generally used for inter-device communication in a P2P Group, cannot be directly obtained. Therefore, it is necessary to distinguish whether the P2P receiver has WiFi Direct connection capabilities. In other words, the P2P receiver needs to obtain the device connection mode of the P2P receiver itself.
[0055] The device connection mode indicates whether the P2P receiving end has a point-to-point direct connection capability. Therefore, the device connection mode may be that the P2P receiving end has a point-to-point direct connection capability or that the P2P receiving end does not have a point-to-point direct connection capability.
[0056] Furthermore, the P2P receiving end obtains the interface address of the P2P sending end according to whether the P2P receiving end has point-to-point direct connection capability or not, combined with the device connection mode and the device information of the P2P sending end. The specific process is as shown in steps 1021 to 1022.
[0057] The embodiment of the present application directly obtains the interface address of the sending end, so that the Internet Protocol address can be obtained directly through the interface address, avoiding the problem that the Internet Protocol address cannot be obtained through the device address when the interface address and the device address are inconsistent, avoiding the inability to communicate normally between devices, and improving the stability of the communication connection between devices.
[0058] Optionally, referring to FIG2 , FIG2 is a schematic diagram of a timing flow of establishing a communication connection provided in an embodiment of the present application. In an optional embodiment, steps 1021 to 1022 are described as follows:
[0059] Step 1021: If the device connection mode is point-to-point direct connection capability, obtain the interface address field in the device information, and obtain the interface address of the sender based on the interface address field;
[0060] Step 1022: If the device connection mode does not have a point-to-point direct connection capability, obtain the device address field in the device information, and obtain the interface address of the sending end based on the device address field.
[0061] Optionally, if the device connection mode is P2P and the receiving end has direct point-to-point connection capabilities, the P2P receiving end can be added to provide the P2P interface address (P2P Interface Address) information of the P2P sending end. For example, on Android platform devices that follow the AOSP native specification, the WiFi Direct framework can add an Interface Address field to the WifiP2pDevice class corresponding to the P2P end device information when completing the P2P Group formation between devices. The P2P end device's P2P Interface Address information can be obtained from the wpa_supplicant module in the HAL layer of the WiFi Direct framework and passed to the Wifi Direct framework.
[0062] Therefore, if the device connection mode is P2P and the receiving end has point-to-point direct connection capability, the P2P receiving end obtains the interface address field in the device information and parses the interface address field to obtain the interface address of the P2P sending end.
[0063] In the embodiment of the present application, the P2P Interface Address information of the P2P sending end is added to the P2P receiving end with WiFi Direct connection capability, which is used to perform RARP reverse query to obtain the IP address of the P2P sending end, and finally realize the Socket connection communication between P2P devices in the P2P Group, thereby avoiding the problem that the Internet Protocol address cannot be obtained through the device address when the interface address and the device address are inconsistent, avoiding the inability to communicate normally between devices, and improving the stability of the communication connection between devices. Optionally, if the device connection mode is that the P2P receiving end does not have point-to-point direct connection capability, the P2P device address (P2P Device Address) information of the P2P sending end can be added to the P2P receiving end. For example, in a system that follows the AOSP native specification on an Android platform device, the WiFi Direct framework can obtain the P2P Device Address of the P2P device in the Device Address field in the WifiP2pDevice class corresponding to the P2P device information between devices that have completed the formation of the P2P Group.
[0064] Therefore, if the device connection mode is P2P and the receiving end does not have point-to-point direct connection capability, the P2P receiving end obtains the device address field in the device information, parses the device address field, and obtains the device address. Further, the P2P receiving end obtains the interface address of the P2P sending end based on the device address, and the specific process is as shown in steps 10221 to 10224.
[0065] In the embodiment of the present application, if only the P2P device address (P2P Device Address) information can be obtained at a P2P receiving end that does not have WiFi Direct connection capability, the interface address of the P2P sending end is first obtained based on the device address, and then the Internet Protocol address is matched based on the interface address, rather than directly matching the Internet Protocol address based on the device address. This avoids the problem of being unable to obtain the Internet Protocol address through the device address when the interface address and the device address are inconsistent, avoids the problem of normal communication failure between devices, and improves the stability of the communication connection between devices.
[0066] In an optional embodiment, steps 10221 to 10224 are described as follows:
[0067] Step 10221: Acquire the device address of the sender based on the device address field, and acquire a device vendor identifier based on the device address.
[0068] Step 10222: If no similarity calculation strategy corresponding to the device vendor identifier is found, fuzzy matching is performed on the device address based on the address protocol resolution table of the receiving end to obtain the interface address of the sending end.
[0069] Step 10223: If the similarity calculation strategy corresponding to the device manufacturer identifier is traversed based on the device manufacturer identifier, then obtain the target calculation strategy corresponding to the device manufacturer identifier;
[0070] Step 10224: perform address operation on the device address based on the target operation strategy to obtain the interface address of the sending end.
[0071] Optionally, the P2P receiving end parses the device address field to obtain the device address of the P2P sending end, and determines the first three bytes of the device address of the P2P sending end as the device vendor OUI identifier. In one embodiment, the device address of the P2P sending end is 72:f7:54:87:0f:42, and the first three bytes of the device address are 72:f7:54. Therefore, the device vendor OUI identifier is 72:f7:54.
[0072] Furthermore, the P2P receiver obtains a similarity algorithm list from the cloud and traverses the similarity algorithm list based on the device manufacturer's OUI identifier to determine whether it has found a similarity calculation strategy corresponding to the device manufacturer's OUI identifier. The similarity algorithm list is a mapping table of associations between device manufacturer OUI identifiers and their corresponding similarity calculation strategies. The similarity algorithm list is stored in the cloud. Cloud-based configuration and distribution facilitate dynamic maintenance and updates of the similarity algorithm list. Alternatively, the similarity algorithm list can be stored locally through pre-configuration. The specific similarity calculation strategy of an OUI manufacturer can generally be obtained from the corresponding WiFi module driver. In one embodiment, the similarity algorithm list is shown in Table 2.
[0073] Table 2 Similarity algorithm list
[0074] Furthermore, if the device vendor OUI identifier is not found in the similarity algorithm list, the P2P receiver performs a fuzzy match on the device address based on the P2P receiver's address protocol resolution table to obtain the interface address of the P2P sender. The specific process is as follows: Steps a to b. In one embodiment, the device vendor OUI identifier is 68:f5:92. When traversing the similarity algorithm list based on the device vendor OUI identifier, no similarity calculation strategy is found.
[0075] Furthermore, if the device manufacturer's OUI identifier is found in the similarity algorithm list and the corresponding similarity calculation strategy is found, the P2P receiving end retrieves the target calculation strategy from the similarity algorithm list based on the device manufacturer's OUI identifier. In one embodiment, the device manufacturer's OUI identifier is 72:f7:54. The specific similarity calculation strategy retrieved from the similarity algorithm list based on the device manufacturer's OUI identifier 72:f7:54 is determined as the target calculation strategy for the device manufacturer's OUI identifier 72:f7:54.
[0076] Furthermore, the P2P receiving end performs address operation on the device address according to the target operation strategy to obtain the interface address of the P2P sending end. The specific process is as follows: step c to step e.
[0077] In an embodiment of the present application, if only P2P Device Address information can be obtained at a P2P receiving end that does not have WiFi Direct connection capability, a similarity calculation strategy is executed based on the device manufacturer's OUI identifier by utilizing the similarity between the P2P Device Address and the P2P Interface Address. Then, an address calculation is performed based on the result of the similarity calculation strategy to obtain the interface address of the P2P sending end. The Internet Protocol address is then matched based on the interface address, rather than directly matching the Internet Protocol address based on the device address. This avoids the problem of being unable to obtain the Internet Protocol address through the device address when the interface address and the device address are inconsistent, avoids the problem of normal communication failure between devices, and improves the stability of the communication connection between devices.
[0078] In an optional embodiment, steps a to b are described as follows:
[0079] Step a, comparing the bytes in the device address with the bytes of each interface address in the address protocol resolution table in byte position order from front to back, to obtain the number of bytes that differ between the device address and each interface address in the address protocol resolution table;
[0080] Step b: determining the interface address of the sending end based on the number of byte differences.
[0081] Optionally, the P2P receiving end compares the bytes in the device address with the bytes of each interface address in the address protocol resolution table in order of byte position from front to back to obtain the number of byte differences between the device address and each interface address in the address protocol resolution table.
[0082] In one embodiment, the address protocol resolution table is as shown in Table 1. Therefore, the interface addresses in the address protocol resolution table are the device MAC addresses 9e:b2:77:94:12:f2 and 72:f7:54:87:8f:42 in the HW Address column, and the device address is 72:f5:54:83:8f:42. Therefore, byte 72 is compared with byte 9e, byte f5 with byte b2, byte 54 with byte 77, byte 83 with byte 94, byte 8f with byte 12, and byte 42 with byte f2 in order of byte position from front to back, and the number of byte differences between the device address 72:f5:54:83:8f:42 and the device MAC address 9e:b2:77:94:12:f2 is 6. Compare byte 72 with byte 72, byte f5 with byte f7, byte 54 with byte 54, byte 83 with byte 87, byte 8f with byte 8f, and byte 42 with byte 42 in byte position order from front to back. The result is that the number of byte differences between device address 72:f5:54:83:8f:42 and device MAC address 2:f7:54:87:8f:42 is 2.
[0083] Furthermore, the P2P receiving end determines the device MAC address in the address protocol resolution table, whose byte difference with the device address is less than or equal to a preset number, as the interface address of the P2P sending end.
[0084] In one embodiment, it can be understood that the interface address of the P2P sender is determined based on the priority of the number of byte differences, with the smaller the number of byte differences, the higher the priority. For example, if the preset number is 2, and the address protocol resolution table includes device MAC address 1 and device MAC address 2, the number of byte differences between the device address and device MAC address 1 is 2, and the number of byte differences between the backup address and device MAC address 2 is 1. Therefore, the priority of the byte difference of 1 is higher than the priority of the byte difference of 2. Therefore, device MAC address 2 in the address protocol resolution table is determined as the interface address of the P2P sender.
[0085] In the embodiment of the present application, on a P2P receiving end that does not have WiFi Direct connection capability, a fuzzy match is performed on the device address according to the address protocol resolution table of the P2P receiving end to obtain an interface address, and then an Internet Protocol address is matched according to the interface address, rather than directly matching the Internet Protocol address according to the device address. This avoids the problem of being unable to obtain the Internet Protocol address through the device address when the interface address and the device address are inconsistent, avoids the inability to communicate normally between devices, and improves the stability of the communication connection between devices.
[0086] In an optional embodiment, steps c to e are described as follows:
[0087] Step c, performing an operation on the original byte at the preset position in the device address based on the target operation strategy to obtain the operated byte at the preset position;
[0088] Step d, replacing the original byte at the preset position in the device address with the calculated byte to obtain the calculated address of the sending end;
[0089] Step e: verifying the device address and the calculated address based on the address protocol resolution table to obtain the interface address of the sending end.
[0090] It should be noted that the target operation strategy indicates the preset position in the device address that requires address operation and the address operation method. Therefore, the P2P receiving end determines the preset position in the device address that requires address operation and the address operation method based on the target operation strategy.
[0091] Furthermore, the P2P receiving end operates on the original byte at the preset position according to the operation method to obtain the operated byte at the preset position, and replaces the original byte at the preset position in the device address with the operated byte to obtain the operated address of the P2P sending end.
[0092] Furthermore, the P2P receiving end uses the calculated address as the priority address and the device address as the auxiliary address to perform address verification in the address protocol resolution table to determine whether there is a device MAC address that is the same as the calculated address or the device address in the address protocol resolution table.
[0093] Furthermore, if it is determined that a device MAC address identical to the calculated address exists in the address protocol resolution table, the calculated address is determined as the interface address of the P2P sender. If it is determined that a device MAC address identical to the calculated address does not exist in the address protocol resolution table, but a device MAC address identical to the device address exists, the device address is determined as the interface address of the P2P sender.
[0094] In one embodiment, the similarity algorithm list is shown in Table 2. The device address is 72:f7:54:87:0f:42, so the device vendor OUI identifier is 72:f7:54. Therefore, according to the similarity algorithm list, the target operation strategy corresponding to the device vendor OUI identifier is mac_addr[0]|=0x02 and mac_addr[4]^=0x80. Among them, mac_addr[0]|=0x02 indicates that the position requiring address operation in the device address is the first byte position, and the operation method is an OR operation. mac_addr[4]^=0x80 indicates that the position requiring address operation in the device address is the fifth byte position, and the operation method is an XOR operation. Therefore, the first byte of the device address 72:f7:54:87:0f:42 is ORed with 0x02, and the fifth byte is XORed with 0x80, resulting in an address of 72:f7:54:87:8f:42 after the operation.
[0095] In the embodiment of the present application, the P2P receiving end that does not have the WiFi Direct connection capability calculates the device address according to the target operation strategy, determines the interface address, and then matches the Internet Protocol address based on the interface address, rather than directly matching the Internet Protocol address based on the device address. This avoids the problem of not being able to obtain the Internet Protocol address through the device address when the interface address and the device address are inconsistent, avoids the inability to communicate normally between devices, and improves the stability of the communication connection between devices. Optionally, the method for establishing a communication connection in the embodiment of the present application is explained using the screen projection scenario as an example, with reference to Figure 3, which is a schematic diagram of the overall solution flow provided in the embodiment of the present application, specifically:
[0096] S1: P2P device A (P2P sender) requests to establish a P2P ad hoc network with P2P device B (P2P receiver) and listens for subsequent Socket communication connection requests from P2P device B. That is, the P2P sender in the Miracast protocol initiates a screen projection request to the P2P receiver.
[0097] S2: P2P device B receives the P2P self-organizing network request from P2P device A, and both parties complete the negotiation and establishment of the P2P Group. That is, the P2P receiver in the Miracast protocol receives the screen projection request from the P2P sender.
[0098] S3: Determine whether P2P device B has Wi-Fi Direct connection capabilities. For example, on Android devices that follow the AOSP native specification, the Wi-Fi Direct framework only supports obtaining partial information about the peer P2P device, such as the P2P Device Address, between devices that have established a P2P group. However, the P2P Interface Address, which is generally used for inter-device communication within the P2P group, cannot be directly obtained.
[0099] S4: If P2P device B has WiFi Direct connection capabilities, P2P device B can add the P2P interface address information of P2P device A, recorded as MAC address MAC1. For example, on Android platform devices that follow the AOSP native specification, the WiFi Direct framework can add an Interface Address field to the WifiP2pDevice class corresponding to the P2P device information when forming a P2P Group between devices. This field corresponds to the P2P Interface Address of the P2P device. The P2P Interface Address information of the P2P device can be obtained from the wpa_supplicant module in the HAL layer of the WiFi Direct framework and passed to the device.
[0100] S5: P2P device B obtains its ARP list, which contains the MAC information and IP address of the peer device. For example, the ARP address cache list L1 on Linux-like platforms such as Android is typically located in the / proc / net / arp node, as shown in Table 1.
[0101] S6: P2P device B uses the MAC1 address obtained in S4 as an index to perform an RARP traversal search in the ARP list L1 on the local device to obtain the IP address of the peer P2P device A. That is, it traverses the "HW address" column of the ARP list L1 to find an entry that matches the MAC address, and marks the "IP address" column data corresponding to the row where the entry is located as the IP address of the peer P2P device A.
[0102] S7: P2P device B uses the IP address of P2P device A to establish a TCP / UDP-based socket connection for communication. Similar to the Miracast protocol, after the receiver learns the sender's IP address and RTSP connection listening port in the P2P group, it initiates an RTSP connection request to the sender, completing the screen casting connection process and responding to the protocol's service communication phase. S1 to S7 describe the technical solution when P2P device B has Wi-Fi Direct connectivity.
[0103] The following steps describe the technical solution when P2P device B does not have Wi-Fi Direct connection capabilities, specifically:
[0104] S8: P2P device B obtains the P2P device address information of P2P device A, recorded as MAC address MAC2. For example, on an Android platform device that follows the AOSP native specification, the Wi-Fi Direct framework can obtain the P2P device address of the P2P device from the device Address field in the WifiP2pDevice class corresponding to the P2P device information after the devices have formed a P2PGroup.
[0105] S9: P2P device B obtains the ARP list L1 on its local device, which contains the MAC information and IP address of the peer device, the same as S5.
[0106] S10: P2P device B obtains from the cloud a list L2 of similarity algorithms for P2P device addresses and P2P interface addresses corresponding to the P2P device MAC address OUI vendor, as shown in Table 2. Dynamic maintenance and updates of list L2 can be more conveniently performed through cloud-based configuration and distribution. However, local preconfiguration can also be used to store similarity algorithm list L2. The specific similarity rules for the OUI vendor can generally be obtained from the corresponding WiFi module driver.
[0107] S11: P2P device B uses the MAC address MAC2 obtained in S8 and executes the similarity algorithm matched in list L2 based on the OUI vendor information of this MAC address to obtain the possible P2P interface address of P2P device A, recorded as MAC address MAC3. Using MAC address MAC3 as a priority and MAC address MAC2 as a secondary, it searches through the local ARP list L1 obtained in S9 for verification. Finally, it obtains the MAC address used by P2P device A for communication between P2P group devices, recorded as MAC address MAC4.
[0108] For example, if the P2P device address of P2P device A is 72:f7:54:87:0f:42, then the OUI identifier is 72:f7:54. The similarity algorithm list L2 configured on the cloud is searched based on the OUI identifier. After matching, it is found that the module manufacturer corresponding to the OUI identifier is rockchip. The manufacturer-specific similarity rule corresponding to the OUI identifier is: perform an OR operation on the first byte of the MAC address with 0x02, and perform an XOR operation on the fifth byte with 0x80. After calculating the P2P Device Address according to the similarity rule, the possible P2P interface address of P2P device A is 72:f7:54:87:8f:42. Using 72:f7:54:87:8f:42 as the priority and 72:f7:54:87:0f:42 as the auxiliary, it is searched in the local ARP list L1 obtained from S9 for verification, and finally confirms that P2P device A is in the P2P The MAC address used in inter-group communication is the P2P interface address 72:f7:54:87:8f:42, obtained through the similarity algorithm. To reduce the complexity of the traversal algorithm and improve search efficiency, when searching the local ARP list L1 obtained from S9, you can use the "P2P" keyword to filter out rows containing matching entries in the "Device" column for priority.
[0109] When the OUI identifier is not configured with a corresponding vendor-specific similarity algorithm or the vendor-specific similarity rule is not effective, a general similarity rule can also be used for fuzzy matching. Specifically, P2P device B uses the MAC address MAC2 obtained in S8 to traverse the local ARP list L1 obtained in S9, performs a binary bit-wise exclusive OR operation on the MAC address MAC2 and the "HW address" column data, counts the number of differences in each row, and takes the best match within a certain number (for example, when the number of differences is only 2 bits) to determine that the two are similar. In this way, the MAC address used by P2P device A for communication between P2P Group devices is obtained, and thus the P2P interface address of P2P device A is obtained.
[0110] Further, by repeating S5 to S7, Socket connection communication can be achieved between P2P device B and peer P2P device A. The communication connection establishment apparatus provided in the embodiment of the present application is described below, and the communication connection establishment apparatus described below and the communication connection establishment method described above can be referred to in correspondence with each other.
[0111] 4 is a schematic diagram of the structure of a communication connection establishment device provided in an embodiment of the present application. The communication connection establishment device may include:
[0112] A first acquisition module 401 is configured to, in response to a networking request sent by a sending end to a receiving end, acquire an interface address of the sending end and an address protocol resolution table of the receiving end; the address protocol resolution table is a mapping table of associations between interface addresses and their corresponding Internet Protocol addresses;
[0113] A second acquisition module 402 is configured to acquire the Internet Protocol address of the sending end based on the interface address and the address protocol resolution table;
[0114] The communication connection establishing module 403 is configured to initiate a connection request to the sending end based on the Internet Protocol address, so that the sending end establishes a communication connection with the receiving end based on the connection request.
[0115] In an optional embodiment, the first obtaining module 401 is further configured to:
[0116] In response to a networking request sent by a sending end to a receiving end, obtaining device information of the sending end and a device connection mode of the receiving end; the device connection mode indicates whether the device has a point-to-point direct connection capability;
[0117] Based on the device connection mode and the device information, an interface address of the sending end is acquired.
[0118] In an optional embodiment, the first obtaining module 401 is further configured to:
[0119] If the device connection mode is a point-to-point direct connection capability, obtaining the interface address field in the device information, and obtaining the interface address of the sending end based on the interface address field; or
[0120] If the device connection mode is that the device does not have a point-to-point direct connection capability, the device address field in the device information is obtained, and the interface address of the sending end is obtained based on the device address field.
[0121] In an optional embodiment, the first obtaining module 401 is further configured to:
[0122] Acquire a device address of the sender based on the device address field, and acquire a device vendor identifier based on the device address;
[0123] If the similarity calculation strategy corresponding to the device manufacturer identifier is not traversed, fuzzy matching is performed on the device address based on the address protocol resolution table of the receiving end to obtain the interface address of the sending end; or
[0124] If the similarity calculation strategy corresponding to the device manufacturer identifier is traversed based on the device manufacturer identifier, then the target calculation strategy corresponding to the device manufacturer identifier is obtained;
[0125] An address operation is performed on the device address based on the target operation strategy to obtain the interface address of the sending end.
[0126] In an optional embodiment, the first obtaining module 401 is further configured to:
[0127] Comparing the bytes in the device address with the bytes of each interface address in the address protocol resolution table in byte order from front to back, to obtain the number of bytes that differ between the device address and each interface address in the address protocol resolution table;
[0128] An interface address of the sending end is determined based on the number of byte differences.
[0129] In an optional embodiment, the first obtaining module 401 is further configured to:
[0130] Performing an operation on the original byte at the preset position in the device address based on the target operation strategy to obtain the operated byte at the preset position;
[0131] Replacing the original byte at the preset position in the device address with the calculated byte to obtain the calculated address of the sending end;
[0132] The device address and the calculated address are verified based on the address protocol resolution table to obtain the interface address of the sending end; the interface address of the sending end is the device address or the calculated address.
[0133] In an optional embodiment, the second obtaining module 402 is further configured to:
[0134] The interface address of the sending end is used as an address index, and the address protocol resolution table is traversed to obtain the Internet Protocol address of the sending end.
[0135] The embodiment of the present application directly obtains the Internet Protocol address through the interface address, avoiding the problem that the Internet Protocol address cannot be obtained through the device address when the interface address and the device address are inconsistent, avoiding the inability to communicate normally between devices, and improving the stability of the communication connection between devices.
[0136] The specific embodiments of the communication connection establishment device provided in this application are basically the same as the embodiments of the communication connection establishment method, and will not be described in detail here.
[0137] Optionally, as shown in Figure 5, Figure 5 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device may include: a processor (processor) 510, a communication interface (Communication Interface) 520, a memory (memory) 530 and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call the computer program in the memory 530 to execute the steps of the communication connection establishment method, for example, including:
[0138] In response to a networking request sent by a sending end to a receiving end, obtaining an interface address of the sending end and an address protocol resolution table of the receiving end; the address protocol resolution table is a mapping table of associations between interface addresses and their corresponding Internet Protocol addresses;
[0139] Acquire the Internet Protocol address of the sending end based on the interface address and the address protocol resolution table;
[0140] A connection request is initiated to the sending end based on the Internet Protocol address, so that the sending end establishes a communication connection with the receiving end based on the connection request.
[0141] On the other hand, embodiments of the present application further provide a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium includes a computer program. The computer program may be stored on the non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the steps of the communication connection establishment method provided in each of the above embodiments, for example, including:
[0142] In response to a networking request sent by a sending end to a receiving end, obtaining an interface address of the sending end and an address protocol resolution table of the receiving end; the address protocol resolution table is a mapping table of associations between interface addresses and their corresponding Internet Protocol addresses;
[0143] Acquire the Internet Protocol address of the sending end based on the interface address and the address protocol resolution table;
[0144] A connection request is initiated to the sending end based on the Internet Protocol address, so that the sending end establishes a communication connection with the receiving end based on the connection request.
[0145] In another aspect, embodiments of the present application further provide a computer product, which includes a computer program. The computer program may be stored on the computer product. When the computer program is executed by a processor, the computer can perform the steps of the communication connection establishment method provided in the above embodiments, for example, including:
[0146] In response to a networking request sent by a sending end to a receiving end, obtaining an interface address of the sending end and an address protocol resolution table of the receiving end; the address protocol resolution table is a mapping table of associations between interface addresses and their corresponding Internet Protocol addresses;
[0147] Acquire the Internet Protocol address of the sending end based on the interface address and the address protocol resolution table;
[0148] A connection request is initiated to the sending end based on the Internet Protocol address, so that the sending end establishes a communication connection with the receiving end based on the connection request.
[0149] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0150] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the above technical solution, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several computer programs for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
[0151] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A communication connection establishment method, wherein, Including: In response to a networking request sent from a sender to a receiver, obtain the interface address of the sender and the address protocol parsing table of the receiver; The address protocol parsing table is an association relationship mapping table between interface addresses and their corresponding Internet protocol addresses; Based on the interface address and the address protocol parsing table, obtain the Internet protocol address of the sender; Initiate a connection request to the sender based on the Internet protocol address, so that the sender can establish a communication connection with the receiver based on the connection request.
2. The communication connection establishment method according to claim 1, wherein The obtaining the interface address of the sender in response to a networking request sent from a sender to a receiver includes: In response to a networking request sent from a sender to a receiver, obtain the device information of the sender and the device connection mode of the receiver; the device connection mode indicates whether it has the ability of point-to-point direct connection; Based on the device connection mode and the device information, obtain the interface address of the sender.
3. The communication connection establishment method according to claim 2, wherein, The obtaining the interface address of the sender based on the device connection mode and the device information includes: If the device connection mode has the ability of point-to-point direct connection, obtain the interface address field in the device information, and obtain the interface address of the sender based on the interface address field; or If the device connection mode does not have the ability of point-to-point direct connection, obtain the device address field in the device information, and obtain the interface address of the sender based on the device address field.
4. The communication connection establishment method according to claim 3, wherein, The obtaining the interface address of the sender based on the interface address field includes: Parse the interface address field to obtain the interface address of the sender.
5. The communication connection establishment method according to claim 3, wherein, The obtaining the interface address of the sender based on the device address field includes: Parse the device address field to obtain the device address; According to the device address, obtain the interface address of the sender.
6. The communication connection establishment method according to claim 3, wherein, The obtaining the interface address of the sender based on the device address field includes: Obtain the device address of the sender based on the device address field, and obtain the device manufacturer identifier based on the device address; If the corresponding similarity operation strategy is not traversed based on the device manufacturer identifier, perform fuzzy matching on the device address based on the address protocol parsing table of the receiver to obtain the interface address of the sender; or, If the corresponding similarity operation strategy is traversed based on the device manufacturer identifier, obtain the target operation strategy corresponding to the device manufacturer identifier; Perform address operation on the device address based on the target operation strategy to obtain the interface address of the sender.
7. The communication connection establishment method according to claim 6, wherein, The obtaining the device manufacturer identifier based on the device address includes: Determine the first 3 bytes in the device address of the sender as the device manufacturer OUI identifier.
8. The communication connection establishment method according to claim 7, wherein, After obtaining the device manufacturer identifier based on the device address, the method further includes: Obtain a list of similarity algorithms from the cloud; Traverse in the list of similarity algorithms according to the device manufacturer OUI identifier to determine whether the corresponding similarity operation strategy to the device manufacturer OUI identifier is traversed.
9. The communication connection establishment method according to claim 8, wherein, The similarity algorithm list is an association relationship mapping table of the OUI identifier of the device manufacturer and the similarity operation strategy; The similarity algorithm list is stored in the cloud or stored in a locally pre-configured manner.
10. The communication connection establishment method according to claim 6, wherein, The fuzzy matching of the device address based on the address protocol parsing table at the receiving end to obtain the interface address of the sending end includes: Sequentially comparing the bytes in the device address with the bytes of each interface address in the address protocol parsing table from the front to the back by byte position to obtain the number of byte differences between the device address and each interface address in the address protocol parsing table; Determining the interface address of the sending end based on the number of byte differences.
11. The communication connection establishment method according to claim 10, wherein, The determining the interface address of the sending end based on the number of byte differences includes: Determining the device MAC address with the number of byte differences less than or equal to the preset number as the interface address of the sending end.
12. The communication connection establishment method according to claim 10, wherein, The determining the interface address of the sending end based on the number of byte differences includes: Determining the interface address of the sending end according to the priority of the number of byte differences.
13. The communication connection establishment method according to claim 6, wherein, The address operation on the device address based on the target operation strategy to obtain the interface address of the sending end includes: Performing an operation on the original bytes at a preset position in the device address based on the target operation strategy to obtain the operation result bytes at the preset position; Replacing the original bytes at the preset position in the device address with the operation result bytes to obtain the operation result address of the sending end; Verifying the device address and the operation result address based on the address protocol parsing table to obtain the interface address of the sending end; the interface address of the sending end is the device address or the operation result address.
14. The communication connection establishment method according to claim 13, wherein, Before performing the operation on the original bytes at a preset position in the device address based on the target operation strategy to obtain the operation result bytes at the preset position, the method further includes: Determining the preset position in the device address that requires address operation and the operation method of the address operation according to the target operation strategy.
15. The communication connection establishment method according to claim 13, wherein, The verifying the device address and the operation result address based on the address protocol parsing table to obtain the interface address of the sending end includes: Using the operation result address as the priority address and the device address as the auxiliary address to perform address verification in the address protocol parsing table to obtain the interface address of the sending end.
16. The communication connection establishment method according to claim 15, wherein, The using the operation result address as the priority address and the device address as the auxiliary address to perform address verification in the address protocol parsing table to obtain the interface address of the sending end includes: Determining whether there is a device MAC address in the address protocol parsing table that is the same as the operation result address or the device address; When there is a device MAC address in the address protocol parsing table that is the same as the operation result address, determining the operation result address as the interface address of the sending end; When there is no device MAC address in the address protocol parsing table that is the same as the operation result address but there is a device MAC address that is the same as the device address, determining the device address as the interface address of the sending end.
17. The communication connection establishment method according to claim 1, wherein, Obtaining the Internet protocol address of the sending end based on the interface address and the address protocol parsing table includes: Taking the interface address of the sending end as an address index, traversing in the address protocol parsing table to obtain the Internet protocol address of the sending end.
18. The communication connection establishment method according to claim 17, wherein, The taking the interface address of the sending end as an address index and traversing in the address protocol parsing table to obtain the Internet protocol address of the sending end includes: Taking the interface address of the sending end as a MAC address index, traversing and searching in the device MAC address column of the address protocol parsing table for an entry that matches the interface address of the sending end; marking the data in the Internet protocol address column corresponding to the row where the matching entry is located as the Internet protocol address of the sending end.
19. An electronic device, wherein, Including a processor and a memory, the memory storing multiple computer programs; the processor loading the computer programs from the memory to execute the communication connection establishment method according to any one of claims 1 to 18.
20. A computer-readable storage medium, wherein, The computer-readable storage medium stores multiple computer programs, and the computer programs are suitable for being loaded by a processor to execute the communication connection establishment method according to any one of claims 1 to 18.
Citation Information
Patent Citations
Communication connection establishment method and device, electronic equipment and storage medium
CN117939697A
Processing method and apparatus for address resolution protocol ARP information
CN102857588A
Routing method based on MAC address and network interface
CN110224936A
Method, device and system for determining network topology structure and electronic equipment
CN115834396A
Display device, mobile terminal and method for adjusting resolution according to signal intensity
CN116233506A