WiFi direct method and apparatus, communication device

By setting a virtual IP address different from the proxy IP address for WiFi Direct Connect terminals, the address conflict problem in scenarios with weak wireless network coverage is solved, and successful data transmission in multi-hop routing communication is achieved.

CN116708376BActive Publication Date: 2025-11-07CHINA TELECOM CORP LTD TECHNOLOGY INNOVATION CENTER +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310826257.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-06
Publication Date
2025-11-07
Estimated Expiration
2043-07-06

AI Technical Summary

Technical Problem

In scenarios with weak or no wireless network coverage, WiFi Direct connected terminals may fail to send data to the Internet due to default virtual IP address conflicts.

Method used

By determining the virtual IP address of the upstream terminal and setting different first and second virtual IP addresses for the VPN service to avoid address conflicts, a direct connection group is established using the proxy address of the VPN service, and a WiFi direct connection service frame carrying the second virtual address is broadcast to establish a multi-hop route.

Benefits of technology

It effectively avoids virtual IP address conflicts, ensures that data packets can be successfully forwarded to the Internet, and realizes multi-hop routing communication in scenarios with weak or no wireless network coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116708376B_ABST
    Figure CN116708376B_ABST
Patent Text Reader

Abstract

The application relates to a WiFi direct connection method and device, communication equipment, a storage medium and a computer program product. The method comprises the following steps: after a first networkless terminal establishes WiFi direct connection with a superior terminal, determining a first virtual IP address set by a VPN service of the superior terminal; starting the VPN service, setting the first virtual IP address as a proxy address of the VPN service, and setting a second virtual IP address of the VPN service. The first virtual IP address is different from the second virtual IP address. A direct connection group is established as a direct connection group owner, and a WiFi direct connection service frame carrying the second virtual address is broadcasted, so that a second networkless terminal establishes WiFi direct connection with the first networkless terminal, and the second virtual IP address is set as a proxy address of a VPN service of the second networkless terminal. The method can avoid IP conflict and successfully transmits and receives data messages.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of wireless communication, and in particular to a WiFi direct method and device, a communication device, a storage medium and a computer program product. BACKGROUND

[0002] In a weak or non-coverage wireless network scenario, using Bluetooth or WiFi direct technology to build a self-organizing network can solve the communication problem of a mobile phone in a non-infrastructure environment.

[0003] In the related art, a multi-hop routing communication method in a weak or non-coverage wireless network scenario is implemented by using VPN and WiFi direct. Specifically, after a network terminal and a non-network terminal establish a connection through WiFi direct, the non-network terminal sends data to the Internet through the network terminal. After the non-network terminal and other non-network terminals establish a connection through WiFi direct, the non-network terminal can send data sent by the other non-network terminals to the Internet through the network terminal. And so on. When each terminal proxies data sent by other terminals, a virtual IP address needs to be set so that other terminals use the virtual IP address as a proxy address.

[0004] However, in the current data transmission process, since the virtual IP addresses set by each terminal are all default, the virtual IP addresses set by interconnected terminals may cause address conflicts, resulting in a situation where data cannot be successfully sent to the Internet. SUMMARY

[0005] Therefore, it is necessary to provide a WiFi direct method, device, communication device, computer readable storage medium and computer program product capable of avoiding address conflicts to solve the above technical problems.

[0006] In a first aspect, the present application provides a WiFi direct method. The method is applied to a first non-network terminal, and the method comprises:

[0007] After establishing a WiFi direct connection with a superior terminal, determining a first virtual IP address set by a virtual private network (VPN) service of the superior terminal; the superior terminal is a direct connection group owner in a direct connection group established for the first non-network terminal;

[0008] Starting the VPN service, and setting the first virtual IP address as a proxy address of the VPN service;

[0009] Setting a second virtual IP address of the VPN service; the first virtual IP address and the second virtual IP address are different;

[0010] establishing a direct connection group as a direct connection group owner, and broadcasting a WiFi direct connection service frame carrying the second virtual address, so as to enable the second networkless terminal to establish a WiFi direct connection with the first networkless terminal and use the second virtual IP address as a proxy address of the VPN service of the second networkless terminal.

[0011] In one embodiment, the second virtual IP address of the VPN service is set by:

[0012] determining the connection level of the superior terminal, and determining the connection level of the first networkless terminal based on the connection level of the superior terminal; the connection level of the superior terminal is the number of terminals passed through when a networked terminal communicates with the superior terminal;

[0013] setting the second virtual IP address of the VPN service based on the connection level of the first networkless terminal.

[0014] In one embodiment, the broadcasting of the WiFi direct connection service frame carrying the second virtual address comprises:

[0015] broadcasting a WiFi direct connection service frame carrying the second virtual address and the connection level of the first networkless terminal.

[0016] In one embodiment, the method further comprises:

[0017] forwarding a data packet to a TUN virtual network device through the proxy address of the VPN service to implement data packet takeover;

[0018] forwarding the data packet taken over by the TUN virtual network device to the superior terminal after processing, so that the superior terminal forwards the data packet to the Internet.

[0019] In one embodiment, the forwarding of the data packet taken over by the TUN virtual network device to the superior terminal after processing comprises:

[0020] unpacking the taken-over data packet to obtain unpacked data, wherein the unpacked data comprises a data transmission type;

[0021] packaging the unpacked data according to the data transmission type and forwarding the packaged data to the superior terminal.

[0022] In one embodiment, the method further comprises:

[0023] receiving a data packet forwarded by the second networkless terminal through a TUN virtual network device;

[0024] Forward the data packet sent by the second networkless terminal to the superior terminal through the TUN virtual network device.

[0025] In a second aspect, the present application provides a WiFi direct device. The device is applied to a first networkless terminal, and the device comprises:

[0026] A determining module, configured to determine a first virtual Internet Protocol (IP) address of a virtual private network (VPN) service set by a superior terminal after establishing a WiFi direct connection with the superior terminal; the superior terminal is a direct connection group owner in a direct connection group established for the first networkless terminal;

[0027] A starting module, configured to start the VPN service and set the first virtual IP address as a proxy address of the VPN service;

[0028] A setting module, configured to set a second virtual IP address of the VPN service; the first virtual IP address is different from the second virtual IP address;

[0029] A broadcasting module, configured to establish a direct connection group as a direct connection group owner, and broadcast a WiFi direct service frame carrying the second virtual address, so that a second networkless terminal establishes a WiFi direct connection with the first networkless terminal and takes the second virtual IP address as a proxy address of a VPN service of the second networkless terminal.

[0030] In one embodiment, the setting module specifically comprises:

[0031] A determining unit, configured to determine a connection level of the superior terminal, and determine a connection level of the first networkless terminal based on the connection level of the superior terminal; the connection level of the superior terminal is a number of terminals passed through when a networked terminal communicates with the superior terminal;

[0032] A setting unit, configured to set the second virtual IP address of the VPN service based on the connection level of the first networkless terminal.

[0033] In one embodiment, the broadcasting module is specifically configured to:

[0034] Broadcast a WiFi direct service frame carrying the second virtual address and the connection level of the first networkless terminal.

[0035] In one embodiment, the device further comprises:

[0036] A takeover module, configured to forward a data packet to a TUN virtual network device through the proxy address of the VPN service, so as to implement data packet takeover;

[0037] The first forwarding module is configured to forward the data packet taken over by the TUN virtual network device to the upper terminal after processing, so that the upper terminal forwards the data packet to the Internet.

[0038] In one embodiment, the first forwarding module specifically includes:

[0039] The unpacking unit is configured to unpack the taken-over data packet to obtain unpacked data, wherein the unpacked data includes a data transmission type.

[0040] The forwarding unit is configured to encapsulate the unpacked data and forward the encapsulated data to the upper terminal according to the data transmission type.

[0041] In one embodiment, the device further includes:

[0042] The receiving module is configured to receive a data packet forwarded by the second networkless terminal through a TUN virtual network device.

[0043] The second forwarding module is configured to forward a data packet sent by the second networkless terminal to the upper terminal through the TUN virtual network device.

[0044] In a third aspect, the present application also provides a communication device. The communication device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the following steps when executing the computer program:

[0045] After establishing a wireless fidelity (WiFi) direct connection with an upper terminal, a first virtual Internet Protocol (IP) address of a virtual private network (VPN) service of the upper terminal is determined; the upper terminal is a direct connection group owner in a direct connection group established for the first networkless terminal;

[0046] The VPN service is started, and the first virtual IP address is set as a proxy address of the VPN service.

[0047] A second virtual IP address of the VPN service is set; the first virtual IP address and the second virtual IP address are different.

[0048] The direct connection group is established as a direct connection group owner, and a WiFi direct connection service frame carrying the second virtual address is broadcasted, so that a second networkless terminal establishes a WiFi direct connection with the first networkless terminal and sets the second virtual IP address as a proxy address of a VPN service of the second networkless terminal.

[0049] In a fourth aspect, the present application also provides a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the following steps:

[0050] determining a first virtual Internet Protocol (IP) address of a virtual private network (VPN) service of the superior terminal after establishing a wireless fidelity (WiFi) direct connection with the superior terminal, wherein the superior terminal is a direct connection group owner in a direct connection group for the first networkless terminal;

[0051] starting the VPN service and setting the first virtual IP address as a proxy address of the VPN service;

[0052] setting a second virtual IP address of the VPN service, wherein the first virtual IP address is different from the second virtual IP address;

[0053] establishing the direct connection group as the direct connection group owner and broadcasting a WiFi direct service frame carrying the second virtual address, so that a second networkless terminal establishes a WiFi direct connection with the first networkless terminal and takes the second virtual IP address as a proxy address of a VPN service of the second networkless terminal.

[0054] In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the following steps:

[0055] determining a first virtual Internet Protocol (IP) address of a virtual private network (VPN) service of the superior terminal after establishing a wireless fidelity (WiFi) direct connection with the superior terminal, wherein the superior terminal is a direct connection group owner in a direct connection group for the first networkless terminal;

[0056] starting the VPN service and setting the first virtual IP address as a proxy address of the VPN service;

[0057] setting a second virtual IP address of the VPN service, wherein the first virtual IP address is different from the second virtual IP address;

[0058] establishing the direct connection group as the direct connection group owner and broadcasting a WiFi direct service frame carrying the second virtual address, so that a second networkless terminal establishes a WiFi direct connection with the first networkless terminal and takes the second virtual IP address as a proxy address of a VPN service of the second networkless terminal.

[0059] The WiFi direct method, device, communication device, storage medium and computer program product, wherein the WiFi direct method, device, communication device, storage medium and computer program product use an address allocated in a WiFi direct connection for communication between the networkless terminal and the superior terminal, and set a virtual IP address of a VPN service as a virtual IP address different from a proxy IP address, thereby avoiding a problem of data transmission failure due to a conflict between the proxy address and the set virtual IP address. Attached Figure Description

[0060] Figure 1 This is a diagram illustrating the application environment of the WiFi Direct connection method in one embodiment;

[0061] Figure 2 This is a flowchart illustrating a WiFi Direct connection method in one embodiment;

[0062] Figure 3 A schematic diagram illustrating the process of establishing WiFi routing for multiple terminals in one embodiment;

[0063] Figure 4 This is a schematic diagram illustrating the process of sending and receiving data packets after establishing a WiFi route in one embodiment;

[0064] Figure 5 This is a structural block diagram of a WiFi Direct connection device in one embodiment;

[0065] Figure 6 This is an internal structural diagram of a communication device in one embodiment. Detailed Implementation

[0066] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0067] In scenarios with weak or no wireless network coverage, devices without a network cannot communicate with the internet. To address this, a method is proposed that uses WiFi direct connection to achieve multi-hop routing and enable communication between devices without a network and the internet.

[0068] Wi-Fi Direct is a point-to-point connection technology that allows two devices to establish a direct TCP / IP connection without the need for a wireless access point (AP). One device acts as a traditional AP, called the Group Owner (GO), while the other device, called the Group Client (GC) or Legacy Client (LC), connects to the GO just like connecting to an AP. The relationship between the GO and GC / LC can be one-to-one or one-to-many. Wi-Fi Direct and traditional Wi-Fi technologies are not mutually exclusive: a GO can provide services to several GCs / LCs like an AP; it can also connect to an AP like a traditional station; and it can also be an AP itself.

[0069] Specifically, the WIFI direct protocol is designed for group communication, but in actual scenarios, inter-group communication or multi-hop mechanism is often needed to expand the communication range. However, due to the protocol stipulation, the default IP address of the GO in the WIFI direct communication is 192.168.49.1. If inter-group communication or multi-hop communication is needed, IP conflict will occur among multiple GOs, resulting in failure of multi-hop communication.

[0070] Therefore, in the related art, multi-hop routing is achieved through a virtual private network (VPN) and WIFI direct, so that a networkless terminal can communicate with the Internet in a weak or non-covered wireless network scenario.

[0071] Specifically, after the secondary networkless terminal establishes WIFI direct with the primary networked terminal, the virtual IP address set by the primary networked terminal for the VPN is used as the proxy address of the secondary networkless terminal, so that the data packets between the secondary networkless terminal and the Internet are forwarded by the primary networked terminal; after the tertiary networkless terminal establishes WIFI direct with the secondary networkless terminal, the virtual IP address set by the secondary networkless terminal for the VPN is used as the proxy address of the tertiary networkless terminal, so that the data packets between the tertiary networkless terminal and the Internet are forwarded by the primary networked terminal and the secondary networkless terminal, and so on.

[0072] However, when different level terminals set the same virtual IP address for their respective VPNs, IP address conflict will occur. The inventors have found in practice that, for different level terminals, if the virtual IP address set for the VPN is the same, such as the proxy address of the secondary networkless terminal being the same as the virtual IP address set for the VPN service, IP conflict will occur, making it difficult to send data packets to the correct terminal; however, for terminals of the same level, if the virtual IP address set for the VPN is the same, such as the two secondary networkless terminals each setting the same virtual IP address for the VPN service, no IP conflict will occur.

[0073] Based on this, the present application proposes a WIFI direct method, which is applied to a first networkless terminal. After the first networkless terminal establishes WIFI direct with a superior terminal, the first networkless terminal determines a first virtual IP address set by the superior terminal for a VPN service. The VPN service is started, the first virtual IP address is set as the proxy address of the VPN service, and a second virtual IP address of the VPN service is set. The first virtual IP address and the second virtual IP address are different. The first networkless terminal establishes a direct group as a direct group owner and broadcasts a WIFI direct service frame carrying the second virtual address, so that a second networkless terminal establishes WIFI direct with the first networkless terminal and sets the second virtual IP address as the proxy address of the VPN service of the second networkless terminal.

[0074] By the WiFi direct method of the present application, the address allocated in the WiFi direct is used when the terminal without network communicates with the superior terminal, and the terminal without network sets the virtual IP address of the VPN service as a virtual IP address different from the proxy IP address, thereby avoiding the problem of data sending failure due to the conflict between the proxy address and the set virtual IP address.

[0075] The WiFi direct method provided by the embodiments of the present application can be applied to the application environment as shown in Figure 1 The terminal with network can communicate with the Internet through the basic network infrastructure environment, such as through a wired network, a wireless router, a base station, etc., to realize the communication with the Internet. The terminal without network cannot directly communicate with the Internet, and the wireless terminal can establish a connection with other terminals close in distance through WiFi direct.

[0076] In one embodiment, as shown in Figure 2 A WiFi direct method is provided, which is applied to a first terminal without network, and the first terminal without network is taken as an example of the terminal without network in Figure 1 The method comprises the following steps:

[0077] Step 201: After establishing a WiFi direct connection with a superior terminal, a first virtual IP address set by the superior terminal for a virtual private network (VPN) service is determined.

[0078] The superior terminal is the owner of the direct connection group established by the first terminal without network, that is, the superior terminal is GO and the first terminal without network is GC / LC in the one-to-one WiFi direct connection established by the first terminal without network and other terminals. The superior terminal can be a terminal with network or a terminal without network.

[0079] Specifically, after the superior terminal enables the VPN service, the superior terminal sets a first virtual address for the VPN service, the superior terminal establishes a first direct connection group as a direct connection group owner, generates an SSID (Service Set Identifier) and a password. The superior terminal and the first non-network terminal complete the WiFi direct connection service discovery, and the first non-network terminal initiates a WiFi direct connection service request to the superior terminal. The superior terminal broadcasts response information carrying the SSID, the password, and the first virtual IP address in response to the instruction service request of the first non-network terminal. The first non-network terminal receives the response information broadcast by the superior terminal, and establishes a WiFi direct connection with the superior terminal through the SSID and the password carried in the response information. After establishing the WiFi direct connection with the superior terminal, the first non-network terminal determines the first virtual IP address carried by the superior terminal when broadcasting, and sets the first virtual IP address as the first virtual IP address set by the superior terminal for the VPN service.

[0080] Step 203, starting the VPN service, and setting the first virtual IP address as the proxy address of the VPN service.

[0081] Specifically, the first non-network terminal starts the VPN service, sets the first virtual IP address as the proxy address of the VPN service, and the first non-network terminal can transmit and receive data packets through the first virtual IP address by the superior terminal.

[0082] Step 205, setting a second virtual IP address of the VPN service.

[0083] The first virtual IP address and the second virtual IP address are different.

[0084] Specifically, each terminal (including a network terminal and a non-network terminal) needs to set a virtual IP address for the VPN service as a data forwarding proxy address used when a subordinate terminal accesses. The first non-network terminal needs to set a virtual address of the VPN service as a terminal for proxy forwarding data packets of other non-network terminals. In order to ensure that the first virtual IP address of the superior terminal obtained during service discovery (i.e., the proxy address of the first non-network terminal) is not in conflict with the second virtual IP address set by the first network terminal for the VPN service, the second virtual IP address set by the first non-network terminal for the VPN service needs to be different from the first virtual IP address.

[0085] Step 207, establishing a direct connection group as a direct connection group owner, and broadcasting a WiFi direct connection service frame carrying the second virtual address, so that the second non-network terminal establishes a WiFi direct connection with the first non-network terminal, and sets the second virtual IP address as a proxy address of the VPN service of the second non-network terminal.

[0086] Specifically, after the first networkless terminal enables the VPN service, a second virtual address is set for the VPN service, the first networkless terminal acts as a direct connection group owner, a second direct connection group is established, and an SSID and a password are generated. The first networkless terminal and the second networkless terminal complete WiFi direct connection service discovery, and the second networkless terminal initiates a WiFi direct connection service request to the upper terminal. The first networkless terminal broadcasts response information carrying an SSID, a password, and a first virtual IP address in response to the instruction service request of the second networkless terminal. The second networkless terminal receives the response information broadcast by the first networkless terminal, and establishes a WiFi direct connection with the first networkless terminal through the SSID and the password carried in the response information. After establishing the WiFi direct connection with the first networkless terminal, the second networkless terminal determines the second virtual IP address carried by the upper terminal during broadcasting, which is the second virtual IP address set for the VPN service of the upper terminal, and takes the second virtual IP address as the proxy address of the VPN service of the second networkless terminal.

[0087] In this embodiment, the address allocated in the WiFi direct connection is used when the networkless terminal communicates with the upper terminal. The networkless terminal sets the virtual IP address as a virtual IP address different from the proxy IP address when setting the virtual IP address of the VPN service, thereby avoiding the problem of data sending failure due to the conflict between the proxy address and the set virtual IP address of the networkless terminal.

[0088] In one of the embodiments, the step 205 specifically includes:

[0089] Step 205A, determining the connection level of the upper terminal, and determining the connection level of the first networkless terminal based on the connection level of the upper terminal.

[0090] The connection level of the upper terminal is the number of terminals passed through when the networked terminal communicates with the upper terminal, and the passed terminals include the networked terminal and the upper terminal. For example, the networked terminal is a terminal capable of communicating with the Internet through the basic network construction, and is a first-level terminal in the WiFi multi-hop routing scenario of the present application, and the corresponding connection level is 1. The terminal establishing a WiFi direct connection with the first-level terminal is a second-level terminal, and the corresponding connection level is 2. The terminal establishing a WiFi direct connection with the second-level terminal is a third-level terminal, and the corresponding connection level is 3, and so on.

[0091] Specifically, the superior terminal broadcasts response information in response to the instruction service request of the first networkless terminal, the response information can carry the SSID, the password, the first virtual IP address, and the connection level of the superior terminal, the connection level of the superior terminal is determined according to the connection level carried in the response information, and then the connection level of the first networkless terminal is obtained by adding one to the connection level of the superior terminal based on the connection level of the superior terminal. Alternatively, after the superior terminal establishes WiFi direct connection with the first networkless terminal, the superior terminal requests the connection level of the superior terminal, the superior terminal returns the connection level of the superior terminal in response to the request of the first networkless terminal, and then the connection level of the first networkless terminal is obtained by adding one to the connection level of the superior terminal based on the connection level of the superior terminal.

[0092] Step 205B, setting the second virtual IP address of the VPN service based on the connection level of the first networkless terminal.

[0093] Specifically, after the first networkless terminal obtains the connection level of the first networkless terminal, the second virtual IP address of the VPN service is set based on the connection level of the first networkless terminal, for example, the last four bits of the second virtual address are set as a number representing the connection level, or are set as a number related to the connection level. For example, the second virtual address can be set as 10.1.1.x, and x is the connection level of the first networkless terminal.

[0094] In this embodiment, the virtual IP set by each level of terminal for the VPN service is extended in a ladder manner, so that the virtual IP set by each level of terminal for the VPN service does not conflict with the virtual IP set by the superior terminal for the VPN service, thereby ensuring normal data forwarding.

[0095] In one embodiment, the above step 207 specifically includes:

[0096] As the owner of the direct connection group, the direct connection group is established, and a WiFi direct connection service frame carrying the second virtual address and the connection level of the networkless terminal is broadcasted.

[0097] Specifically, if each terminal sets the virtual IP address of the respective VPN service based on the respective connection level, the connection level of the upper terminal needs to be known to determine the connection level of the current terminal. Therefore, the first networkless terminal broadcasts response information in response to the instruction service request of the second networkless terminal, wherein the response information carries the SSID, password, first virtual IP address, and connection level. The networkless terminal establishes a direct connection group by broadcasting a WiFi direct service frame carrying the second virtual IP address and the connection level of the networkless terminal, so that the second networkless terminal establishes a WiFi direct connection with the first networkless terminal, and sets the second virtual IP address as the proxy address of the VPN service of the second networkless terminal. The connection level of the second networkless terminal is determined according to the connection level carried in the broadcast, and the virtual IP address of the VPN server is further set according to the connection level of the second networkless terminal.

[0098] As shown in Table 1, the table shows the fields according to an embodiment:

[0099] Table 1

[0100] Field Type Description Stage Number Int Stage number in the multi-hop network VPN String Set virtual IP address SSID ID String SSID name to be turned on after becoming GO Password String SSID password to be turned on after becoming GO

[0101] In this embodiment, the "connection level" field is added in the response information, so that the next terminal can determine the connection level of the current terminal based on the "connection level" field in the response information, and further set the virtual IP address of the VPN service based on the connection level of the current terminal, to ensure that the virtual IP addresses of the upper and lower terminals are inconsistent, and to avoid address conflict.

[0102] In one embodiment, the above method further comprises:

[0103] Step 209: forwarding the data packet to the TUN virtual network device through the proxy address of the VPN service to implement data packet takeover.

[0104] Step 211: forwarding the data packet taken over by the TUN virtual network device to the upper terminal after processing, so that the upper terminal forwards the data packet to the Internet.

[0105] Specifically, the first networkless terminal initiates a request to a server in the Internet to generate a request data packet. The first networkless terminal forwards the data packet to the TUN virtual network device through the proxy address of the VPN service. The TUN virtual network device unpacks and repackages the data packet, sends the data packet to the VPN service client, and sends the request data packet to the upper terminal through the proxy address of the VPN service client.

[0106] In this embodiment, since the first virtual IP address set by the first networkless terminal for the VPN service is different from the proxy address second virtual IP address, no address conflict occurs, and the data packet of the local terminal can be successfully sent to the upper terminal, and then sent to the upper terminal or the Internet by the upper terminal, thereby realizing the communication between the first networkless terminal and the Internet.

[0107] In one embodiment, the step 211 specifically includes:

[0108] Step 211A, unpacking the taken-over data packet to obtain unpacked data, wherein the unpacked data includes a data transmission type.

[0109] Step 211B, encapsulating the unpacked data according to the data transmission type and forwarding the encapsulated data to the upper terminal.

[0110] The transmission type can be UDP or TCP.

[0111] Specifically, the TUN virtual network device of the first networkless terminal parses the intercepted data packet header to obtain transmission-related parameters, including the data transmission type; and encapsulates the data according to the data transmission type and sends the encapsulated data to the upper terminal node. After the first networkless terminal determines the transmission type of the data packet, the unpacked data is encapsulated and forwarded to the upper terminal according to the data transmission type.

[0112] In this embodiment, the TUN virtual network device is used to take over the data packet, so that the first networkless terminal can communicate with the upper terminal through the VPN service.

[0113] In one embodiment, the method further includes:

[0114] Step 213, receiving the data packet forwarded by the second networkless terminal through the TUN virtual network device.

[0115] Step 215, forwarding the data packet sent by the second networkless terminal to the upper terminal through the TUN virtual network device.

[0116] Specifically, the first networkless terminal acts as a terminal for receiving and transmitting data packets of the second networkless terminal, receives the data packet forwarded by the second networkless terminal through the TUN virtual network device, unpacks and re-encapsulates the data packet, and forwards the data packet sent by the second networkless terminal to the upper terminal through the TUN virtual network device, and the upper terminal forwards the data packet of the second networkless terminal to the upper terminal or the Internet, thereby realizing the communication between the second networkless terminal and the Internet.

[0117] In this embodiment, the second virtual IP address set by the first non-network terminal is different from the first virtual IP address set by the upper terminal and the virtual IP address set by the second non-network terminal, so that the first non-network terminal does not occur address conflict when transmitting and receiving data packets, thereby causing the failure of transmitting and receiving data packets.

[0118] Next, a detailed embodiment provided by the present application is described in detail.

[0119] As shown in Figure 3 Fig. 1 is a flow diagram of a WiFi multi-hop routing construction process according to an embodiment of the present application.

[0120] The WiFi direct connection process between the first non-network terminal and the second non-network terminal:

[0121] The first non-network terminal enables the VPN service and sets a first virtual address for the VPN service. The first virtual address is set based on the level of the first non-network terminal, and the level of the first non-network terminal is 1.

[0122] The first non-network terminal establishes a first direct connection group as a direct connection group owner and generates an SSID and a password.

[0123] The first non-network terminal and the second non-network terminal complete WiFi direct connection service discovery.

[0124] The second non-network terminal initiates a WiFi direct connection service request to the first non-network terminal.

[0125] The first non-network terminal broadcasts response information carrying an SSID, a password, a first virtual address, and a level in response to the direct connection service request of the second non-network terminal.

[0126] The second non-network terminal receives the response information broadcast by the first non-network terminal and establishes a WiFi direct connection with the first non-network terminal through the SSID and the password carried in the response information.

[0127] The WiFi direct connection process between the second non-network terminal and the third non-network terminal:

[0128] The second non-network terminal enables the VPN service, sets a first virtual address as a proxy address, and sets a second virtual address for the VPN service. The second virtual address is set based on the level of the second non-network terminal, and the level of the second non-network terminal is 2, which is one more than the level of the upper terminal.

[0129] The second non-network terminal establishes a second direct connection group as a direct connection group owner and generates an SSID and a password.

[0130] The second non-network terminal and the third non-network terminal complete WiFi direct connection service discovery.

[0131] The third networkless terminal initiates a WiFi direct connection service request to the second networkless terminal.

[0132] The second networkless terminal broadcasts response information carrying an SSID, a password, a second virtual address, and a level number in response to the direct connection service request from the third networkless terminal. The level number of the second networkless terminal is 2.

[0133] The third networkless terminal receives the response information broadcast by the second networkless terminal and establishes a WiFi direct connection with the second networkless terminal through the SSID and the password carried in the response information.

[0134] The same applies.

[0135] As shown in FIG. 1, a flowchart of data transmission after WiFi multi-hop routing is established according to an embodiment of the present application is shown. Figure 4

[0136] The third networkless terminal sends a request data packet to the second networkless terminal through a proxy address.

[0137] The second networkless terminal sends the request data packet sent by the third networkless terminal to the first networked terminal through the proxy address.

[0138] The first networked terminal receives a response data packet. If the response data packet is from the first networked terminal, the first networked terminal sends the response data packet to a corresponding application service. If the response data packet is not from the first networked terminal, the first networked terminal sends the response data packet to the second networkless terminal.

[0139] The second networkless terminal receives a response data packet. If the response data packet is from the second networkless terminal, the second networkless terminal sends the response data packet to a corresponding application service. If the response data packet is not from the second networkless terminal, the second networkless terminal sends the response data packet to the third networkless terminal.

[0140] The third networkless terminal receives a response data packet. If the response data packet is from the third networkless terminal, the third networkless terminal sends the response data packet to a corresponding application service. If the response data packet is not from the third networkless terminal, the third networkless terminal sends the response data packet to the fourth networkless terminal.

[0141] The same applies.

[0142] Next, a more specific embodiment of the present application is described in detail. In this embodiment, the IP addresses are as follows:

[0143] The server IP is 8.8.8.8.

[0144] The first networked terminal has a public network IP of 121.33.232.104, a GO IP of 192.168.49.1, and a VPN IP of 10.1.1.1.​

[0145] Secondary networkless terminal: LC IP: 192.168.49.3, VPN IP: 10.1.1.2, GO IP: 192.168.49.1, proxy IP: 10.1.1.1.

[0146] Tertiary networkless terminal: LC IP: 192.168.49.2, VPN IP: 10.1.1.3, GO IP: 192.168.49.1, proxy IP: 10.1.1.2.

[0147] Quaternary networkless terminal: LC IP: 192.168.49.2, VPN IP: 10.1.1.4, GO IP: 192.168.49.1, proxy IP: 10.1.1.3.

[0148] Quinary networkless terminal: ……

[0149] It should be noted that the first terminal can establish a WiFi direct connection with multiple secondary networkless terminals, the secondary networkless terminal can establish a WiFi direct connection with multiple tertiary networkless terminals, and the tertiary networkless terminal can establish a WiFi direct connection with multiple quaternary networkless terminals, and so on.

[0150] The virtual IP address set for the VPN service of a terminal at a certain level needs to be different from the virtual IP address of the VPN service of the superior terminal (the GC in the direct connection group established by the superior terminal for the terminal at this level) and the subordinate terminal (the LC in the direct connection group established by the superior terminal for the terminal at this level), otherwise an IP address conflict will occur; the virtual IP addresses set for the VPN service of terminals at the same level can be the same, for example, two secondary networkless terminals establish a WiFi direct connection with a first networked terminal respectively, and the two secondary networkless terminals each establish a WiFi direct connection with other tertiary networkless terminals, the virtual IP addresses set for the VPN service can be the same.

[0151] Taking the communication of the tertiary networkless terminal with the server through the WiFi multi-hop routing mode as an example, the communication process is as follows:

[0152] The application service of the tertiary networkless terminal initiates a request to the server, generates a request data packet with a target IP: 8.8.8.8 and a source IP: 192.168.49.2, and the tertiary networkless terminal first forwards the data packet to the TUN virtual network device through the proxy address of the VPN service, the TUN virtual network device sends the data packet to the VPN service client, and sends the request data packet to the secondary networkless terminal through the proxy IP: 10.1.1.2 of the VPN service client.

[0153] The secondary networkless terminal receives the request data packet sent by the tertiary networkless terminal through the VPN service, restores the data packet to a request data packet with a target IP: 8.8.8.8 and a source IP: 192.168.49.2, modifies the source IP: 192.168.49.2 in the request data packet to an LC IP: 192.168.49.3 for communication with the primary networked terminal, and then forwards the data packet to the TUN virtual network device through the proxy address of the VPN service. The TUN virtual network device sends the request data packet to the VPN service client, and sends the request data packet to the primary networked terminal through the proxy IP: 10.1.1.1 of the VPN service client.

[0154] The primary networked terminal receives the request data packet sent by the secondary networkless terminal through the VPN service, restores the request data packet to a request data packet with a target IP: 8.8.8.8 and a source IP: 192.168.49.2, modifies the source IP: 192.168.49.2 in the request data packet to a public network IP: 121.33.232.104 for communication with the public network, and then sends the request data packet to the server through the Internet.

[0155] The server receives the data packet, generates a response data packet with a source IP: 8.8.8.8 and a destination IP: 121.33.232.104, and sends the response data packet to the primary networked terminal.

[0156] The primary networked terminal receives the response data packet, and in a case where the response data packet is determined to be a response data packet of a proxy terminal (a secondary networkless terminal establishing WiFi direct connection with the primary networked terminal), modifies the destination of the response data packet to an LC IP: 192.168.49.3 for communication between the secondary networkless terminal and the primary networked terminal, and sends the response data packet to the secondary networkless terminal.

[0157] The secondary networkless terminal receives the response data packet, and in a case where the response data packet is determined to be a response data packet of a proxy terminal (a tertiary networkless terminal establishing WiFi direct connection with the secondary networked terminal), modifies the destination of the response data packet to an LC IP: 192.168.49.2 for communication between the tertiary networkless terminal and the secondary networked terminal, and sends the response data packet to the secondary networkless terminal.

[0158] The tertiary networkless terminal receives the response data packet, and returns the response data packet to an application service corresponding to the request data packet.

[0159] It should be understood that although the steps in the flowcharts involved in the embodiments described above are shown in sequence according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of the steps is not strictly limited in sequence, and the steps can be executed in other sequences. Moreover, at least some of the steps in the flowcharts involved in the embodiments described above can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution sequence of the steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least part of other steps or steps or stages in other steps.

[0160] Based on the same inventive concept, the embodiments of the present application also provide a WiFi direct device for implementing the above-mentioned WiFi direct method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more WiFi direct device embodiments provided below can refer to the limitations of the WiFi direct method in the above text, which will not be repeated here.

[0161] In one embodiment, as shown in Figure 5 A WiFi direct device is provided, which is applied to a first networkless terminal, and the device comprises:

[0162] The determining module 501 is configured to determine a first virtual Internet Protocol (IP) address of a Virtual Private Network (VPN) service set by a superior terminal after establishing a WiFi direct connection with the superior terminal, wherein the superior terminal is a direct connection group owner in a direct connection group established for the first networkless terminal.

[0163] The starting module 503 is configured to start the VPN service and set the first virtual IP address as a proxy address of the VPN service.

[0164] The setting module 505 is configured to set a second virtual IP address of the VPN service, wherein the first virtual IP address and the second virtual IP address are different.

[0165] The broadcasting module 507 is configured to establish a direct connection group as a direct connection group owner, and broadcast a WiFi direct service frame carrying the second virtual address, so as to establish a WiFi direct connection between a second networkless terminal and the first networkless terminal, and set the second virtual IP address as a proxy address of a VPN service of the second networkless terminal.

[0166] In one embodiment, the setting module 505 specifically comprises:

[0167] The determining unit is configured to determine the connection level of the upper terminal, and determine the connection level of the first networkless terminal based on the connection level of the upper terminal; the connection level of the upper terminal is the number of terminals passed through when a networked terminal communicates with the upper terminal;

[0168] The setting unit is configured to set a second virtual IP address of the VPN service based on the connection level of the first networkless terminal.

[0169] In one of the embodiments, the broadcasting module 507 is further configured to:

[0170] Broadcast a WiFi direct service frame carrying the second virtual address and the connection level of the first networkless terminal.

[0171] In one of the embodiments, the apparatus further includes:

[0172] The takeover module is configured to forward the data packet to a TUN virtual network device through the proxy address of the VPN service, and implement data packet takeover.

[0173] The first forwarding module is configured to forward the data packet taken over by the TUN virtual network device after processing to the upper terminal, so that the upper terminal forwards the data packet to the Internet.

[0174] In one of the embodiments, the first forwarding module specifically includes:

[0175] The unpacking unit is configured to unpack the taken-over data packet to obtain unpacked data, the unpacked data including a data transmission type.

[0176] The forwarding unit is configured to encapsulate the unpacked data according to the data transmission type and forward the encapsulated data to the upper terminal.

[0177] In one of the embodiments, the apparatus further includes:

[0178] The receiving module is configured to receive the data packet forwarded by the second networkless terminal through the TUN virtual network device.

[0179] The second forwarding module is configured to forward the data packet sent by the second networkless terminal to the upper terminal through the TUN virtual network device.

[0180] The modules in the WiFi direct apparatus can be all or partially implemented by software, hardware, and combinations thereof. The modules can be embedded in or independent of a processor in a communication device in hardware form, or stored in a memory in a communication device in software form, so as to be called and executed by a processor to perform operations corresponding to the modules.

[0181] In one embodiment, a communication device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown, the communication device includes a processor, memory, and a communication interface connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a Wi-Fi Direct connection method.

[0182] Those skilled in the art will understand that Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the communication device to which the present application is applied. Specific communication devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0183] In one embodiment, a communication device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.

[0184] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.

[0185] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.

[0186] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when the computer program is executed, the processes of the above-mentioned embodiments of the methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (Read-Only Memory, ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive memory (ReRAM), magnetoresistive random access memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric memory (Ferroelectric Random Access Memory, FRAM), phase change memory (Phase Change Memory, PCM), graphene memory, etc. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.

[0187] Any combination of the technical features of the above embodiments can be made. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combination of the technical features does not exist contradictory, it should be considered as the scope of the present application.

[0188] The above embodiments only express several implementation manners of the present application, and the description is more specific and detailed, but it should not be understood as a limitation on the scope of the patent of the present application. It should be noted that for ordinary skilled in the art, without departing from the concept of the present application, a number of modifications and improvements can be made, which are within the scope of protection of the present application. Therefore, the scope of protection of the present application should be subject to the appended claims.

Claims

1. A WiFi direct method, characterized in that, The method is applied to a first networkless terminal, and the method comprises: After establishing a wireless fidelity (WiFi) direct connection with a superior terminal, determining a first virtual internet protocol (IP) address of a virtual private network (VPN) service of the superior terminal; the superior terminal is a direct connection group owner in a direct connection group established for the first networkless terminal; Starting the VPN service and setting the first virtual IP address as a proxy address of the VPN service; Setting a second virtual IP address of the VPN service; the first virtual IP address is different from the second virtual IP address; Establishing a direct connection group as the direct connection group owner and broadcasting a WiFi direct connection service frame carrying the second virtual IP address, so that a second networkless terminal establishes a WiFi direct connection with the first networkless terminal and takes the second virtual IP address as a proxy address of a VPN service of the second networkless terminal; The setting of the second virtual IP address of the VPN service comprises: Determining a connection level of the superior terminal and determining a connection level of the first networkless terminal based on the connection level of the superior terminal; the connection level of the superior terminal is a number of terminals passed through when a networked terminal communicates with the superior terminal; Setting the last four bits of the second virtual address as a number representing the connection level; The determining of the connection level of the superior terminal and the determining of the connection level of the first networkless terminal based on the connection level of the superior terminal comprise: Receiving response information broadcast by the superior terminal, wherein the response information carries the connection level of the superior terminal; Adding one to the connection level of the superior terminal to obtain the connection level of the first networkless terminal.

2. The method of claim 1, wherein, The broadcasting of the WiFi direct connection service frame carrying the second virtual address comprises: Broadcasting a WiFi direct connection service frame carrying the second virtual address and the connection level of the first networkless terminal.

3. The method of claim 2, wherein, The connection level broadcast by the first networkless terminal is used for enabling the second networkless terminal to determine a connection level of the second networkless terminal and set a virtual IP address of a VPN server according to the connection level of the second networkless terminal.

4. The method of claim 1, wherein, The method further comprises: Forwarding a data packet to a TUN virtual network device through the proxy address of the VPN service to implement data packet takeover; Forwarding the data packet taken over by the TUN virtual network device to the superior terminal after processing, so that the superior terminal forwards the data packet to the Internet.

5. The method of claim 4, wherein, The forwarding of the data packet taken over by the TUN virtual network device to the superior terminal after processing comprises: Unpacking the taken-over data packet to obtain unpacked data, wherein the unpacked data comprises a data transmission type; Packing the unpacked data according to the data transmission type and forwarding the packed data to the superior terminal.

6. The method of claim 4, wherein, The method further comprises: Receiving a data packet forwarded by the second networkless terminal through a TUN virtual network device; Forwarding the data packet sent by the second networkless terminal to the superior terminal through the TUN virtual network device.

7. A WiFi Direct device, characterized in that, The device is applied to a first networkless terminal, and the device comprises: The determining module is configured to determine a first virtual Internet Protocol (IP) address of a virtual private network (VPN) service of the superior terminal after a WiFi direct connection is established with the superior terminal; the superior terminal is a direct connection group owner in a direct connection group established for the first networkless terminal; The starting module is configured to start the VPN service and set the first virtual IP address as a proxy address of the VPN service; The setting module is configured to set a second virtual IP address of the VPN service; the first virtual IP address is different from the second virtual IP address; The broadcasting module is configured to establish a direct connection group as a direct connection group owner, broadcast a WiFi direct service frame carrying the second virtual IP address, so that a second networkless terminal establishes a WiFi direct connection with the first networkless terminal and sets the second virtual IP address as a proxy address of a VPN service of the second networkless terminal; The setting module comprises: The determining unit is configured to determine a connection number of the superior terminal and determine a connection number of the first networkless terminal based on the connection number of the superior terminal; the connection number of the superior terminal is a number of terminals passed through when a networked terminal communicates with the superior terminal; The setting unit is configured to set the last four bits of the second virtual address as a number representing the connection number; The determining unit is specifically configured to receive response information broadcast by the superior terminal, the response information carrying the connection number of the superior terminal; and add one to the connection number of the superior terminal to obtain the connection number of the first networkless terminal.

8. A communication device comprising a memory and a processor, the memory storing a computer program, characterized in that, The processor executes the computer program to implement the steps of the method in any one of claims 1 to 6.

9. A computer readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.

10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Multi-hop routing implementation method and device, equipment and storage medium

    CN114867077A