Equipment communication method and electronic equipment
By establishing a WLAN connection at the same time as establishing a P2P connection and transmitting data via WLAN after the WLAN connection is successful, the problem of long P2P connection time is solved, and fast data transmission and high-quality user experience are achieved.
Patent Information
- Application Number
- CN202410389511.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-30
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-03-30
AI Technical Summary
In wireless local area networks, the process of establishing a point-to-point (P2P) connection takes a long time, causing users to wait for a long time and affecting the user experience.
When establishing a P2P connection, first establish a wireless local area network (WLAN) connection, and transmit data through the WLAN connection after the WLAN connection is successful. After the P2P connection is successful, switch to the P2P connection to transmit data, and give priority to using the P2P connection to transmit data.
It reduces user waiting time, improves user experience, and quickly switches to WLAN connection when P2P connection fails to avoid data transmission jams or interruptions, ensuring data transmission service quality.
Smart Images

Figure CN120769366A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a device communication method and electronic equipment. Background Art
[0002] When two devices in a wireless local area network (WLAN) communicate, they can use a WLAN connection or a peer-to-peer (P2P) connection for data transmission. In some scenarios, such as multi-screen collaboration between a phone and a tablet, multi-screen collaboration between a phone and a personal computer, wireless screen projection between a phone and a smart screen, or keyboard and mouse sharing services between multiple terminal devices, there are high requirements for the transmission quality of the wireless link. Even if the devices are in the same LAN, P2P connections are often required to ensure the quality of service and experience.
[0003] Since establishing a P2P connection involves many steps and is time-consuming, which is longer than establishing a WLAN connection, users experience significant waiting time when using a P2P connection, resulting in a poor user experience. Summary of the Invention
[0004] The embodiments of the present invention provide a device communication method and an electronic device to solve the problem of long waiting time when users use P2P connection.
[0005] In a first aspect, an embodiment of the present application provides a device communication method, applied to a first electronic device, the method comprising:
[0006] The first electronic device initiates, in response to a received user operation for sending first data to the second electronic device, establishing a wireless local area network (WLAN) connection with the second electronic device and establishing a point-to-point (P2P) connection with the second electronic device, wherein the first electronic device and the second electronic device are respectively connected to the same wireless access point via the WLAN;
[0007] After the first electronic device successfully establishes a WLAN connection with the second electronic device and before the first electronic device successfully establishes a P2P connection with the second electronic device, the first electronic device sends the first data to the second electronic device through the WLAN connection;
[0008] After successfully establishing a P2P connection with the second electronic device, the first electronic device sends first data to the second electronic device through the P2P connection.
[0009] In the above method, when the first electronic device initiates the sending of first data to the second electronic device, it simultaneously initiates the establishment of a WLAN connection and a P2P connection. After the WLAN connection is successfully established and before the P2P connection is successfully established, the data is first transmitted by establishing a fast WLAN connection. After the P2P connection is successfully established, the data is transmitted through the P2P connection to reduce the user's waiting time and improve user experience.
[0010] It should be noted that the first electronic device is also referred to as the first device or client, and the second electronic device is also referred to as the second device or server. When the first electronic device initiates a data transmission request to the second electronic device, it simultaneously establishes a WLAN connection and a P2P connection. Here, "simultaneously" can mean triggering or starting to establish a WLAN connection and a P2P connection at the same time, or triggering or starting to establish a WLAN connection and a P2P connection at two very short intervals. For example, the first electronic device triggers or starts to establish a WLAN connection at the first time, and triggers or starts to establish a P2P connection at the second time. The difference between the first time and the second time is less than 1S seconds, 0.5 seconds or less.
[0011] In one possible implementation, the method further includes: after the WLAN connection is successfully established, the first electronic device adds WLAN data path information to the first data path list, where the WLAN data path information includes the WLAN IP address and a first port of the second electronic device, where the first port is the port of the WLAN IP address of the second electronic device;
[0012] After the P2P connection is successfully established, the first electronic device adds P2P data path information to the first data path list. The P2P data path information includes the P2P IP of the second electronic device and the second port. The second port is the port of the P2P IP of the second electronic device.
[0013] It should be noted that, in the following specific implementations, the WLAN IP of the second electronic device is also represented as WLAN_IP2, and the first port is also port S1. The P2P IP of the second electronic device is also represented as P2P_IP2, and the second port is also port S2.
[0014] The above method sets a data path list to record the WLAN data path and P2P data path for the user to transmit the first data, and selects the data path for transmitting the first data based on the data paths already in the first data path list, thereby achieving switching between different data paths for the same service.
[0015] In one possible implementation, the priority of the P2P data path is higher than that of the WLAN data path, and the priority is used to determine the data path for sending the first data.
[0016] The above method gives priority to using the P2P data path, so that after the P2P data path is successfully established and added to the first data path list, the first data can be automatically switched to the P2P data path for transmission.
[0017] In one possible implementation, the method further includes: when the P2P connection fails, the first electronic device deletes the P2P data path information in the first data path list, sends the first data to the second electronic device via the WLAN connection, and triggers re-establishment of the P2P connection with the second electronic device.
[0018] The above method can quickly switch the first data to the WLAN data path when the P2P connection fails, thereby avoiding data transmission delays or interruptions caused by the P2P connection failure. Furthermore, by continuing to use the newly established P2P data path after reconnection, the quality of data transmission service is guaranteed.
[0019] In one possible implementation, establishing a WLAN connection between a first electronic device and a second electronic device includes:
[0020] The first electronic device establishes a WLAN control path with the second electronic device;
[0021] The first electronic device establishes a WLAN data path with the second electronic device through the WLAN control path.
[0022] In one possible implementation, before the first electronic device establishes a WLAN control path with the second electronic device, the method further includes:
[0023] The first electronic device creates a first service session, where the first service session is used to transmit first data;
[0024] The first electronic device sets the available flag of the first service session to invalid, and sets the identifier of the first protocol session corresponding to the first service session to an invalid value.
[0025] The above method provides a specific implementation of establishing a WLAN connection between a first electronic device and a second electronic device.
[0026] In one possible implementation, the first electronic device establishes a WLAN data path with the second electronic device through the WLAN control path, including:
[0027] When the identifier of the first protocol session is an invalid value, the first electronic device creates the first protocol session and updates the identifier of the first protocol session to a valid value;
[0028] The first electronic device applies for a third port on the WLAN IP of the first electronic device;
[0029] The first electronic device sends a first message to the second electronic device, where the first message carries an identifier of the first service session, a third port, and a first link type;
[0030] The first electronic device receives a first response message from the second electronic device, where the first response message carries an identifier of the first service session, an identifier of the second service session, a first port, and a first link type; the second service session is a service session created by the second electronic device corresponding to the first service session.
[0031] The above method can avoid repeated creation of the first protocol session by identifying whether the identifier of the first protocol session is valid and creating the first protocol session only when it is invalid.
[0032] In one possible implementation, after the first electronic device adds information about the WLAN data path to the first data path list or the first electronic device adds information about the P2P data path to the first data path list, the method further includes: when the available flag of the first service session is set to invalid, updating the available flag to a valid value.
[0033] The above method records whether the business data (i.e., the first data) of the first business session can be transmitted by setting the available flag of the first business session, and records whether the protocol session has been created by setting whether the identifier of the protocol session is valid, thereby avoiding repeated creation of the protocol session when the WLAN data path and the P2P data path for transmitting the first data are created, thereby speeding up the data path creation process.
[0034] In one possible implementation, establishing a P2P connection between a first electronic device and a second electronic device includes:
[0035] The first electronic device establishes a P2P physical connection with the second electronic device;
[0036] After the P2P physical connection is successful, the first electronic device establishes a P2P control path with the second electronic device;
[0037] The first electronic device establishes a P2P data path with the second electronic device through the P2P control path.
[0038] In one possible implementation, when the first electronic device establishes a P2P data path with the second electronic device through the P2P control path, one implementation manner may be:
[0039] The first electronic device applies for a fourth port on the P2P IP of the first electronic device;
[0040] The first electronic device sends a third message to the second electronic device, where the third message carries the identifier of the first service session, the fourth port, and the second link type;
[0041] The first electronic device receives a third response message from the second electronic device, where the third response message carries the identifier of the first service session, the identifier of the second service session, the second port, and the second link type.
[0042] In one possible implementation, the method further includes: the first electronic device checking whether the identifier of the first protocol session is valid;
[0043] One implementation manner of the first electronic device applying for the fourth port on the P2P IP of the first electronic device may be: when the identifier of the first protocol session is valid, the first electronic device applies for the fourth port on the P2P IP of the first electronic device.
[0044] The above method avoids repeated creation of the first protocol session by identifying whether the identifier of the first protocol session is valid, thereby speeding up the creation of the P2P data path.
[0045] In one possible implementation, the first electronic device includes an application, a service session management system, and a control path establishment system;
[0046] The first electronic device creates the first service session, and one implementation manner may be: in response to receiving the first session creation request, the service session management system creates the first service session and generates an identifier of the first service session;
[0047] Setting the available flag of the first service session to invalid and setting the identifier of the first protocol session corresponding to the first service session to an invalid value may be implemented as follows: the service session management system sets the available flag of the first service session to invalid and sets the identifier of the first protocol session corresponding to the first service session to an invalid value. The available flag of the first service session is used to indicate whether the application has been notified to transmit the first data. Before the WLAN connection is successfully established, the available flag of the first service session is invalid; the identifier of the first protocol session is set to an invalid value to indicate that the first protocol session has not been established.
[0048] The above method records whether the business data (i.e., the first data) of the first business session can be transmitted by setting the available flag of the first business session, and records whether the protocol session has been created by setting whether the identifier of the protocol session is valid, thereby avoiding repeated creation of the protocol session when the WLAN data path and the P2P data path for transmitting the first data are created, thereby speeding up the data path creation process.
[0049] In one possible implementation, the first electronic device includes a service session management system and a control path establishment system, and the method further includes:
[0050] The service session management system sends a connection request to the control path establishment system. The connection request carries the WLAN IP address of the first electronic device, the WLAN IP address of the second electronic device, the MAC address of the first electronic device, and the MAC address of the second electronic device. The connection request is used to request to establish a WLAN connection and a P2P connection with the second electronic device.
[0051] One implementation method of initiating a wireless local area network (WLAN) connection with a second electronic device and establishing a point-to-point (P2P) connection with the second electronic device may be: the control path establishment system responds to a connection request, initiates establishment of a WLAN control path with the second electronic device based on the WLAN IP of the first electronic device and the WLAN IP of the second electronic device, and establishes a P2P physical connection with the second electronic device based on the MAC of the first electronic device and the MAC of the second electronic device.
[0052] In the above method, the service session management system sends a connection request to the control path establishment system, simultaneously initiates the establishment of a WLAN control path with the second electronic device, and establishes a P2P physical connection with the second electronic device, so as to first use the WLAN connection and then use the P2P connection to transmit the first data, thereby reducing the user's waiting time and improving the user experience.
[0053] In one possible implementation, the first electronic device includes a control path establishment system, a data path establishment system, and a protocol session management system;
[0054] When the identifier of the first protocol session is an invalid value, the first electronic device establishes the first protocol session, and before updating the identifier of the first protocol session to a valid value, the method further includes: after the WLAN control path is established, the control path establishment system sends a first data path establishment request to the data path establishment system, the first data path establishment request carrying the WLAN IP address of the first electronic device, the WLAN IP address of the second electronic device, and the identifier of the first service session, the first data path establishment request being used to request establishment of the WLAN data path;
[0055] When the identifier of the first protocol session is an invalid value, the first electronic device creates the first protocol session. One implementation method may be: the data path establishment system, in response to the first data path creation request, sends a second session creation request to the protocol session management system when the identifier of the first protocol session is invalid. The second session creation request carries the WLAN IP address of the first electronic device, and the second session creation request is used to request the creation of the first protocol session. The protocol session management system, in response to the second session creation request, creates the first protocol session and generates the identifier of the first protocol session. The first protocol session is used to encapsulate and send the first data in accordance with the requirements of the protocol.
[0056] In one possible implementation, the first electronic device further includes a service session management system, and the protocol session management system is configured to apply for the third port on the WLAN IP address of the first electronic device. After the first electronic device applies for the third port on the WLAN IP address of the first electronic device, the method further includes: the protocol session management system sending an identifier of the first protocol session and a port number of the third port to the data path establishment system;
[0057] One implementation method of the first electronic device updating the identifier of the first protocol session to a valid value may be: the data path establishment system sends the identifier of the first protocol session to the business session management system; in response to receiving the identifier of the first protocol session, the business session management system updates the identifier of the first protocol session to a valid value.
[0058] The above method avoids repeated creation of the first protocol session by identifying whether the identifier of the first protocol session is valid, thereby speeding up the creation of the WLAN data path.
[0059] In one possible implementation, the first electronic device includes a service session management system, a data path establishment system, and a protocol session management system; and updating the available flag to a valid value may be implemented as follows:
[0060] The protocol session management system sends the identifier of the first protocol session to the service session management system through the data path establishment system;
[0061] In response to receiving the identifier of the first service session, the service session management system sends a first notification to the application when the available flag of the first service session is invalid, the first notification carrying the identifier of the first service session, and the first notification being used to instruct transmission of the first data;
[0062] After sending the first notification, the service session management system sets the available flag of the first service session to be valid.
[0063] In the above method, after adding the information of the WLAN data path or the information of the P2P data path to the first data path list, the available flag is updated to a valid value to record whether there is a data path available for the first data transmission, thereby avoiding the service session management system from repeatedly notifying the application.
[0064] In one possible implementation, the first electronic device includes a control path establishment system, a data path establishment system, and a protocol session management system;
[0065] The method further includes: after the P2P control path is established, the control path establishment system sends a second data path establishment request to the data path establishment system, the second data path establishment request carrying the P2P IP address of the first electronic device, the P2P IP address of the second electronic device, and an identifier of the first service session, the second data path establishment request being used to request establishment of the P2P data path;
[0066] The first electronic device checks whether the identifier of the first protocol session is valid. One implementation manner may be: the data path establishment system checks whether the identifier of the first protocol session corresponding to the first service session is valid in response to the second data path creation request;
[0067] When the identifier of the first protocol session is valid, the first electronic device applies for the fourth port on the P2P IP of the first electronic device. One implementation method may be: when the identifier of the first protocol session is valid, the data path establishment system sends a first port application instruction to the protocol session management system, where the first port application instruction carries the P2P IP of the second electronic device;
[0068] The protocol session management system applies for a fourth port on the P2P IP of the first electronic device in response to the first port application instruction.
[0069] The above method avoids repeated creation of the first protocol session by identifying whether the identifier of the first protocol session is valid, thereby speeding up the creation of the P2P data path.
[0070] In one possible implementation, the first electronic device includes a protocol session management system and a sending and receiving system;
[0071] Before sending the first data to the second electronic device via the WLAN connection and / or sending the first data to the second electronic device via the P2P connection, the method further includes: the protocol session management system determining a data path with the highest priority from the first data path list;
[0072] One implementation of sending the first data to the second electronic device via the WLAN connection may be: when the protocol session management system determines that the data path with the highest priority is the WLAN data path, the protocol session management system sends a first sending request to the sending and receiving system, the first sending request carrying information about the first data and the WLAN data path; in response to receiving the first sending request, the sending and receiving system sends the first data to the second electronic device via the WLAN data path;
[0073] One implementation method of sending the first data to the second electronic device through the P2P connection may be: when the protocol session management system determines that the data path with the highest priority is the P2P data path, the protocol session management system sends a second sending request to the sending and receiving system, where the second sending request carries information about the first data and the P2P data path; in response to receiving the second sending request, the sending and receiving system sends the first data to the second electronic device through the P2P data path.
[0074] In the above method, when sending the first data, the protocol session management system selects a data path with a high priority based on the existing data paths in the first data path list, thereby implementing switching between different data paths for the same service and giving priority to the P2P data path. Therefore, after the P2P data path is successfully established and added to the first data path list, the first data can be automatically switched to the P2P data path for transmission.
[0075] In a second aspect, an embodiment of the present application further provides a device communication method, applied to a second electronic device, the method comprising:
[0076] The second electronic device receives an initiation from the first electronic device to establish a wireless local area network (WLAN) connection and a point-to-point (P2P) connection, and the first electronic device and the second electronic device are connected to the same wireless access point via WLAN;
[0077] After the second electronic device successfully connects to the first electronic device via WLAN and before successfully connecting to the first electronic device via P2P, the second electronic device receives the first data sent by the first electronic device via WLAN.
[0078] After the second electronic device successfully establishes a P2P connection with the first electronic device, the second electronic device receives the first data sent by the first electronic device through the P2P connection.
[0079] In one possible implementation, the method further includes: after the WLAN connection is successfully established, the second electronic device adds WLAN data path information to the second data path list, the WLAN data path information includes the WLAN IP of the first electronic device and a third port, and the first port is the port of the WLAN IP of the first electronic device; after the P2P connection is successfully established, the second electronic device adds P2P data path information to the second data path list, the P2P data path information includes the P2P IP of the first electronic device and a fourth port, and the second port is the port of the second electronic device on the P2P IP of the second electronic device.
[0080] It should be noted that, in the following specific implementations, the WLAN IP of the first electronic device is also represented as WLAN_IP1, the third port is also port C1, the P2P IP of the first electronic device is also represented as P2P_IP1, and the fourth port is also port C2.
[0081] In a possible implementation, the priority of the P2P data path is higher than that of the WLAN data path, and the priority is used to determine the data path for sending the second data.
[0082] In one possible implementation, the method further includes:
[0083] When the P2P connection fails, the second electronic device deletes the information of the P2P data path in the second data path list, and receives the first data from the first electronic device through the WLAN connection.
[0084] In one possible implementation, establishing a WLAN connection with the first electronic device includes:
[0085] The second electronic device establishes a WLAN control path with the first electronic device;
[0086] The second electronic device establishes a WLAN data path with the first electronic device through the WLAN control path.
[0087] In one possible implementation, the second electronic device establishes a WLAN data path with the first electronic device through the WLAN control path. One implementation manner may be:
[0088] The second electronic device receives a first message from the first electronic device, where the first message carries an identifier of the first service session, a third port, and a first link type;
[0089] When the second electronic device does not include the service session corresponding to the first protocol session, the second electronic device creates a second service session, sets the available flag of the second service to invalid, and sets the identifier of the second protocol session corresponding to the second service session to invalid;
[0090] When the identifier of the protocol session corresponding to the second service session is invalid, the second electronic device creates a second protocol session and updates the identifier of the second protocol session to a valid value;
[0091] The second electronic device applies for the first port on the WLAN IP of the first electronic device;
[0092] The second electronic device sends a first response message to the first electronic device, where the first response message carries the identifier of the first service session, the identifier of the second service session, the first port, and the first link type.
[0093] In one possible implementation, after the second electronic device adds information about the WLAN data path to the second data path list or after the second electronic device adds information about the P2P data path to the second data path list, the method further includes: when the available flag bit of the second service session is set to invalid, updating the available flag bit to a valid value.
[0094] In one possible implementation, establishing a P2P connection with a second electronic device includes:
[0095] The second electronic device establishes a P2P physical connection with the first electronic device;
[0096] After the P2P physical connection is successful, the second electronic device establishes a P2P control path with the first electronic device;
[0097] The second electronic device establishes a P2P data path with the first electronic device through the P2P control path.
[0098] In a possible implementation, when the second electronic device establishes a P2P data path with the first electronic device through the P2P control path, one implementation manner may be:
[0099] The second electronic device receives a third message from the first electronic device, where the third message carries the identifier of the first service session, the fourth port, and the second link type;
[0100] The second electronic device applies for a second port on the P2P IP of the second electronic device;
[0101] The second electronic device sends a third response message to the first electronic device, where the third response message carries the identifier of the first service session, the identifier of the second service session, the second port, and the second link type.
[0102] In one possible implementation, the method further includes:
[0103] The second electronic device checks whether a second service session corresponding to the first service session is included;
[0104] The second electronic device checks whether the identifier of the second protocol session is valid when the second service session is included;
[0105] One implementation manner of the second electronic device applying for the second port on the P2P IP of the second electronic device may be: when the identifier of the second protocol session is valid, the second electronic device applies for the second port on the P2P IP of the second electronic device.
[0106] In one possible implementation, the second electronic device includes a data path establishment system and a service session management system;
[0107] The method further includes: the data path establishment system sending a third session creation request to the service session management system in response to the received first message, the third session creation request carrying an identifier of the first service session, the third session creation request being used to request creation of a service session corresponding to the first service session;
[0108] When the second electronic device does not include a service session corresponding to the first protocol session, one implementation manner may be: in response to the received third session creation request, the service session management system creates the second service session when the service session corresponding to the first service session is not included, and sets the identifier of the second protocol session corresponding to the second service session to an invalid value;
[0109] The method further includes: the service session management system sending a second message to the data path establishment system, the second message including an identifier of the second service session, and the second message is used to indicate that the second service session has been created.
[0110] In one possible implementation, the second electronic device includes a business session management system, a data path establishment system, and a protocol session management system; one implementation method for updating the available flag to a valid value may be: the protocol session management system sends an identifier of the second protocol session to the business session management system through the data path establishment system; when the business session management system receives the identifier of the second business session, if the available flag of the second business session is invalid, the second notification is sent to the application, the second notification carries the identifier of the second business session, and the second notification is used to indicate that the second data can be transmitted; after sending the second notification, the business session management system sets the available flag of the second business session to be valid.
[0111] In one possible implementation, the second electronic device includes a data path establishment system, a protocol session management system, and a service session management system;
[0112] The method further includes: the data path establishment system sending a fifth session creation request to the service session management system, the fifth session creation request carrying an identifier of the first service session, the fifth session creation request being used to request creation of a second service session;
[0113] One implementation of the second electronic device checking whether the second service session corresponding to the first service session is included may be: the service session management system checks whether the second service session corresponding to the first service session is included in response to the fifth session creation request;
[0114] The method further includes: when the second service session is included, the service session management system sends fourth information to the data path establishment system, the fourth information including an identifier of the second service session, and the fourth information is used to indicate that the second service session has been established;
[0115] One implementation of the second electronic device checking whether the identifier of the second protocol session is valid when the second service session is included may be: in response to receiving the fourth information, the data path establishment system checks whether the identifier of the second protocol session is valid;
[0116] When the identifier of the second protocol session is valid, the second electronic device applies for the second port on the P2P IP of the second electronic device. One implementation method may be: when the identifier of the first protocol session is valid, the data path establishment system sends a second port application instruction to the protocol session management system, where the second port application instruction carries the P2P IP of the second electronic device;
[0117] The protocol session management system applies for a second port on the P2P IP of the second electronic device in response to the second port application instruction.
[0118] In one possible implementation, the second electronic device includes a sending and receiving system, a protocol session management system, a data path establishment system, and a business session management system; one implementation method for receiving the first data from the first electronic device through a WLAN connection may be: when the sending and receiving system receives the first data, it sends the port for receiving the first data to the protocol session management system, and the port for receiving the first data is the first port; the protocol session management system determines the identifier of the second protocol session based on the first port, and sends the first data and the identifier of the second protocol session to the data path establishment system; the data path establishment system sends the identifier of the second business session corresponding to the first data and the second protocol session to the business session management system; the business session management system sends the identifier of the first data and the second business session to the application.
[0119] In one possible implementation, the second electronic device includes a sending and receiving system, a protocol session management system, a data path establishment system, and a business session management system; one implementation method for receiving the first data from the first electronic device through a P2P connection may be: when the sending and receiving system receives the first data, it sends the port for receiving the first data to the protocol session management system, and the port for receiving the first data is the second port; the protocol session management system determines the identifier of the second protocol session based on the second port, and sends the first data and the identifier of the second protocol session to the data path establishment system; the data path establishment system sends the identifier of the second business session corresponding to the first data and the second protocol session to the business session management system; the business session management system sends the identifier of the first data and the second business session to the application.
[0120] In a third aspect, an embodiment of the present application further provides an electronic device comprising a memory and one or more processors; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method described in the first aspect or any possible implementation of the first aspect.
[0121] In a fourth aspect, an embodiment of the present application further provides an electronic device comprising a memory and one or more processors; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code comprises computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method described in the second aspect or any possible implementation of the second aspect.
[0122] In a fifth aspect, an embodiment of the present application further provides a computer-readable storage medium comprising instructions, characterized in that when the instructions are run on an electronic device, the electronic device executes the method described in the first aspect or any possible implementation of the first aspect.
[0123] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium comprising instructions, characterized in that when the instructions are run on an electronic device, the electronic device executes the method described in the second aspect or any possible implementation of the second aspect.
[0124] In a seventh aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the first aspect or any possible implementation of the first aspect.
[0125] In an eighth aspect, an embodiment of the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the second aspect or any possible implementation of the second aspect.
[0126] In a ninth aspect, an embodiment of the present application provides a chip system comprising at least one processor for implementing the method described in the first aspect or any possible implementation of the first aspect.
[0127] In a tenth aspect, an embodiment of the present application provides a chip system, which includes at least one processor for implementing the method described in the second aspect or any possible implementation of the second aspect.
[0128] It should be understood that the second to tenth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding possible implementations are similar and will not be repeated. BRIEF DESCRIPTION OF THE DRAWINGS
[0129] Figure 1 A schematic diagram of the structure of a communication system provided in an embodiment of the present application;
[0130] Figures 2A to 2C A user interface involved in a process of initiating screen projection from a first device to a second device provided in an embodiment of the present application is a schematic diagram;
[0131] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0132] Figure 4 A schematic diagram of the software and hardware structure of an electronic device provided in an embodiment of the present application;
[0133] Figures 5A to 5E A schematic diagram of a device communication method provided in an embodiment of the present application;
[0134] Figures 6A to 6B Another user interface involved in the process of initiating screen projection from a first device to a second device provided in an embodiment of the present application is a schematic diagram;
[0135] Figure 7 A flowchart of a method for device communication when a P2P link is abnormal provided in an embodiment of the present application;
[0136] Figure 8 A flowchart of another device communication method provided in an embodiment of the present application;
[0137] Figure 9A A flowchart of a method for establishing a WLAN data path through negotiation between a first device and a second device provided in an embodiment of the present application;
[0138] Figure 9B A flowchart of a method for establishing a P2P data path through negotiation between a first device and a second device provided in an embodiment of the present application;
[0139] Figure 10 A flowchart of another method for device communication when a P2P link is abnormal is provided in an embodiment of the present application. DETAILED DESCRIPTION
[0140] The following is a clear and detailed description of the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship between related objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0141] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.
[0142] The device communication method provided in the embodiments of the present application can be applied to scenarios that are sensitive to or have high requirements for latency, such as call sharing, notification sharing, keyboard and mouse sharing, multi-screen collaboration, screen mirroring / extension, video on demand / live broadcast, etc. between multiple devices in a wireless local area network.
[0143] Figure 1 As shown in FIG. 1 , a schematic diagram of the structure of a communication system provided in an embodiment of the present application may include a wireless access point (AP) 10, such as a router, and multiple devices connected to the AP 10, such as a first device 20 and a second device 30. The first device 20 may initiate data transmission services to the second device 30, such as multi-screen collaboration services, screen projection services, call sharing services, keyboard and mouse sharing services, and other services that are sensitive to or have high latency requirements.
[0144] In order to overcome the problem that when the first device 20 establishes a P2P connection to the second device 30, the P2P connection takes a long time and the user has a long waiting time. In an embodiment of the present application, when the first device 20 initiates a first service session to the second device 30, the first device 20 can trigger the establishment of a WLAN connection and a P2P connection with the second device 30 at the same time. Since the first device and the second device have completed the WLAN physical connection, at this time, the WLAN connection between the first device and the second device needs to establish a WLAN control channel and a WLAN data channel, while the P2P connection between the first device and the second device needs to first establish a P2P physical connection and then establish a P2P control channel and a P2P data channel. Therefore, the WLAN connection will be completed faster. The first device 20 can send the service data of the first service session to the second device through the WLAN connection after the WLAN connection is successful and before the P2P connection is successful. After the P2P connection is successful, the service data of the first service session is sent to the second device through the P2P connection to reduce the user's waiting time, and give priority to using P2P to transmit service data to improve the service quality of the service.
[0145] In the embodiment of the present application, the first device 20 or the second device 30 may not be limited to Figure 1 The mobile phone and laptop computer shown in the figure can also be a desktop computer, a laptop computer, a handheld computer, a tablet computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, an in-vehicle device, a smart home device and / or a smart city device. The embodiments of the present application do not impose any special restrictions on the specific type of the terminal.
[0146] The following example illustrates the process of device communication using an application scenario in which a first device (such as a mobile phone) initiates screen projection to a second device (such as a laptop).
[0147] Figures 2A to 2C This example shows the user interface of a first device initiating screen projection to a second electronic device. In this scenario, the device communication process includes the following steps:
[0148] like Figure 2AAs shown, the mobile phone may display a user interface 201, and the personal computer may display a user interface 202. The user interface 201 may include a "connect" control and a "cancel" control. The user may click the "connect" control, and the mobile phone may initiate the establishment of a WLAN connection and a P2P connection simultaneously in response to the click operation on the "connect" control.
[0149] The establishment speed of WLAN connection is faster than that of P2P connection.
[0150] like Figure 2B As shown, when the WLAN connection is successful, the P2P connection has not yet been successfully established. The mobile phone can use the WLAN connection to transmit the screen projection data. At this time, the user interface 204 displayed on the personal computer may include the user interface 203 of the mobile phone.
[0151] like Figure 2C As shown, when the P2P connection is successful, the mobile phone switches the projection data from the WLAN connection to the P2Pe connection, and then uses the P2P connection to transmit the projection data. At this time, the user interface 206 displayed on the personal computer may include the user interface 205 of the mobile phone.
[0152] In another implementation, when the P2P connection is successful, the mobile phone can use the P2P connection to transmit the projection data, and can also use the WLAN connection to transmit the projection data at the same time, or not use the WLAN connection to transmit the projection data.
[0153] The following describes the device involved in the embodiments of the present application.
[0154] like Figure 3 As shown, the electronic device 100 provided in the embodiment of the present application can be the above-mentioned Figure 1 、 Figure 2A-2C The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a camera 191, a display 192, and a subscriber identification module (SIM) card interface 193. The sensor module 180 may include one or more of a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.
[0155] It can be understood that the structural schematic of the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different arrangement of components. The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0156] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices, or can be integrated in one or more processors. The processor is used to implement the implementation logic of multi-device cooperative management, such as service association logic, service disconnection logic, and service mode switching logic, etc.
[0157] The memory in the processor 110 can also be provided for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory.
[0158] In some embodiments, the processor 110 can include one or more interfaces. It can be understood that the interface connection relationship between the modules shown in the embodiments of the present application is only illustrative, and does not constitute a structural limitation on the electronic device 100.
[0159] The wireless communication function of the electronic device 100 can be realized through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, etc.
[0160] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antenna. For example: the antenna 1 can be multiplexed as a diversity antenna of a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0161] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0162] The modulation and demodulation processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal.
[0163] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0164] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with a network and other devices through wireless communication technologies. The wireless communication technologies may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0165] The electronic device 100 implements a display function through a GPU, a display screen 192 , and an application processor, etc. The display screen 192 is used to display images, videos, etc.
[0166] The electronic device 100 can implement a shooting function through an image signal processor (ISP), a camera 191, a video codec, a GPU, a display screen 192, and an application processor. The camera 191 is used to capture still images or videos.
[0167] The internal memory 121 may be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor.
[0168] The electronic device 100 can implement an audio function through an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, and an application processor, etc. For example, music play, recording, etc.
[0169] The SIM card interface 193 is used to connect a SIM card. The SIM card can be connected and disconnected with the electronic device 100 by being inserted into or pulled out of the SIM card interface 193.
[0170] Figure 4 A software and hardware structure schematic diagram of an electronic device provided by an embodiment of the present application.
[0171] As shown in Figure 4 , the software and hardware architecture of the electronic device can adopt a layered architecture, which divides the system into several layers, each layer having a clear role and division of labor. Layers communicate with each other through software interfaces.
[0172] As shown in Figure 4 , the software and hardware structure framework of the electronic device involved in the present application can include an application layer, an application framework layer (framework, FWK), a system library and an Android runtime, a hardware abstraction layer (hardware abstract layer, HAL) (not shown), a kernel layer and a hardware layer.
[0173] The application layer (application) can include a series of applications, for example, the application package can include WLAN applications, Bluetooth applications, application connections, call sharing, notification sharing, keyboard and mouse sharing, file sharing, screen projection, video and gallery applications, and other applications not shown, such as music, camera, browser, etc. Application programs.
[0174] Among them, the WLAN application is mainly used to realize the opening, connection and setting of WLAN, etc., and the Bluetooth application is used to realize the opening, connection and setting of Bluetooth, etc. The application continuation application is used to realize the content and usage status of the application between this electronic device and nearby devices. The call sharing application is used to realize that nearby devices answer and continue calls from this electronic device. For example, the smart screen can answer calls from this electronic device, and tablets and computers also support making calls. Notification sharing is used to realize that nearby devices receive notifications from this electronic device and support processing on these devices. Keyboard and mouse sharing is used to share input devices with this electronic device and nearby computers, or the mouse, keyboard and touchpad of the computer or tablet are shared with this electronic device. It can also realize cross-device file transfer and cross-device window display and use. The file sharing application is used to realize wireless sharing of files with other electronic devices in the same network, and realize extremely fast sharing or printing of files. The screen projection application is used to realize the linking of this end device with the large-screen device to realize the display of videos and other content displayed on this electronic device through the large-screen device, or to realize the linking of the display of this electronic device with the small-screen device to realize the display of videos and other content displayed on the small-screen device through the large screen of this electronic device. Here, "large screen" and "small screen" refer to the relative sizes of the display screens of electronic devices.
[0175] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions. The application framework layer can also include a window manager, content provider, view system, and resource manager (not shown in the figure).
[0176] The application framework layer also includes a business session management system, a control path establishment system, a data path establishment system, a protocol session management system, and a sending and receiving system. The specific functional implementation of the business session management system, the control path establishment system, the data path establishment system, the protocol session management system, and the sending system can also be found in the following Figures 5A-5E and Figure 7 The method shown will not be described here in detail.
[0177] The runtime is responsible for system scheduling and management. It consists of a core library and a virtual machine. The core library consists of two parts: one containing the functions that a programming language (e.g., Java) needs to call, and the other the system's core library.
[0178] The application layer and application framework layer run in a virtual machine. The virtual machine executes application layer and application framework layer programming files (for example, Java files) as binary files. The virtual machine performs functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0179] The system library can include multiple functional modules, such as the surface manager, media libraries, 3D image processing library (such as OpenGL ES), and 2D graphics engine (such as SGL).
[0180] The surface manager is used to manage the display subsystem and provide the fusion of two-dimensional (2D) and three-dimensional (3D) layers for multiple applications.
[0181] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0182] The 3D image processing library is used to implement 3D graphics drawing, image rendering, compositing and layer processing.
[0183] A 2D graphics engine is a drawing engine for 2D drawings.
[0184] The Hardware Abstraction Layer (HAL) is an interface layer between the operating system kernel and upper-level software. Its purpose is to abstract the hardware. The HAL is an abstract interface for device kernel drivers, providing application programming interfaces (APIs) that access the underlying devices to higher-level Java API frameworks. The HAL consists of multiple library modules, each of which implements an interface for a specific type of hardware component.
[0185] The kernel layer is the foundation of the Android operating system. Ultimately, all Android operating system functions are performed through the kernel layer. The kernel layer includes drivers such as the Wi-Fi driver, Bluetooth driver, display driver, camera driver, and audio driver. The Bluetooth driver drives the Bluetooth module. The Wi-Fi driver drives the Wi-Fi module.
[0186] The hardware layer may include WiFi modules, Bluetooth modules, etc., and may also include displays, microphones, cameras, storage, audio encoders, video encoders, etc.
[0187] It should be noted that the application provides Figure 4 The software structure diagram of the electronic device shown is only an example.
[0188] The specific module division in different layers of the Android operating system is not limited. For details, please refer to the introduction of the Android operating system software structure in conventional technology. In addition, the device communication method provided in this application can also be implemented based on other operating systems, and this application will not give examples one by one.
[0189] The following describes the device communication method provided by the embodiment of the present application. This method can be applied to the above Figure 1 The communication system shown, Figure 2A-2C The scene and interface shown in the figure, the first device and the second device in the method can be the above Figure 3 The electronic equipment shown can be used Figure 4 The hardware and software architecture of the electronic device shown.
[0190] Example 1
[0191] Example 1 Combination Figures 5A-5E A flow chart of a device communication method is provided, wherein: Figure 5A-5B It shows the process of initiating a data transmission service, simultaneously creating a WLAN control channel and a P2P control channel, creating and initializing resources used by a service session, and creating a WLAN data channel. Figure 5C It shows the process of sending screen projection data after the WLAN data path is successfully established and before the P2P data path is successfully established. Figure 5D It shows the process of establishing the P2P control channel successfully and the P2P data channel. Figure 5E It shows the process of sending screen projection data after the P2P data channel is successfully established.
[0192] The device communication method may include but is not limited to some or all of the following steps:
[0193] S01, a screen projection application of a first device receives a screen projection operation, where the screen projection operation is used to instruct to project the screen to a second device.
[0194] Specifically, the screen projection application of the first device can determine the currently available device in response to receiving the user operation of the screen projection. Among them, one implementation of the first device determining the currently available device can be: Figure 6AAs shown, the first device can display the interface of the screen projection application. When the wireless screen projection function is turned on, the screen projection application can send a request to the networking module to request to obtain the device identification list under the current network; the networking module responds to the request, and sends the device identification list under the current network to the screen projection application. The first device displays the device identification list on the interface of the screen projection application. The device identification list includes the identifications of available devices under the same WiFi network. The first device displays the device identification list. Furthermore, the user can click on the identification of the second device in the device identification list. At this time, the screen projection application of the first device receives the user operation to project the screen to the second device.
[0195] For example, Figure 2A As shown, the first device (mobile phone) can display a user interface for connecting to the second device (laptop). Furthermore, the first device responds to a user operation input to the "connect" control on the user interface, such as a click operation, and the first device receives the screen projection operation to the second device.
[0196] The above-mentioned screen projection operation is also called a user operation for instructing to send the first data to the second device, and the screen projection data is also the first data.
[0197] It should be understood that before the first device initiates a data transmission service, such as a screen projection service, the first device and the second device are connected to the same AP via WLAN and are in the same wireless local area network.
[0198] S02, the screen projection application of the first device responds to the user operation and sends a first session creation request to the service session management system. The first session creation request carries the identifier of the second device and is used to request the creation of a screen projection service session.
[0199] S03: The service session management system of the first device obtains address information of the second device according to the identifier of the second device.
[0200] Specifically, the service session management system may send a request to the networking module, which carries the identifier of the second device, requesting to obtain the WLAN IP address of the second device (also represented in this application as WLAN_IP2) and the MAC address of the second device (also represented in this application as MAC2). In response to the request, the networking module sends the IP address of the second device to the service session management system.
[0201] The first device may also obtain its own WLAN IP address (expressed as WLAN_IP1) and its own MAC address (expressed as MAC1).
[0202] Among them, WLAN_IP1 and WLAN_IP2 are used to establish a WLAN control path, and MAC1 and MAC2 are used to establish a P2P physical connection between the first device and the second device.
[0203] S04. The service session management system of the first device creates a first service session in response to the first session creation request, generates an identity document (ID) for the first service session, sets the available flag of the first service session to invalid, and initializes the identifier of the protocol session corresponding to the first service session to an invalid value (False).
[0204] The first service session is used for data exchange between the first device and the application, and for sending and receiving data for the application. The attributes of the first service session may include a flag indicating whether the first service session is available (also called an available flag). When the first service session is created, the available flag of the first service session is set to invalid (false).
[0205] Among them, the available flag of the first business session is used to indicate whether the screen projection application has been notified that the business data of the first business session, that is, the screen projection data, can be transmitted. Before the data path (such as the WLAN data path) for transmitting the business data of the first business session is successfully established, the available flag of the first business session is invalid; and after the data path (such as the WLAN data path) for transmitting the business data of the first business session is successfully established, the business session management system will send a first notification to the screen projection application to notify the screen projection application that the business data of the first business session can be transmitted. After the first notification is sent, the business session management system will modify the available flag of the first business session to be valid to record that the screen projection application has been notified that the business data of the first business session can be transmitted.
[0206] It should be understood that at this point, the protocol session corresponding to the first service session (i.e., the first protocol session) has not yet been created. When creating the first service session, the service session management system initializes the ID of the first protocol session to an invalid value. The service session management system of the first device can determine whether the protocol session has been created based on whether the ID of the first protocol session is valid. After the first protocol session is created, the service session management system updates the ID of the first protocol session to a valid value.
[0207] S05: The service session management system of the first device sends a connection request to the control path establishment system. The connection request is used to request to establish a WLAN connection and a P2P connection with the second device. The connection request carries the WLAN IP address of the first device (i.e., WLAN_IP1), the WLAN IP address of the second device (i.e., WLAN_IP2), the MAC address of the first device (i.e., MAC1), the MAC address of the second device (i.e., MAC2), and the ID of the first service session (denoted as A1_ID).
[0208] WLAN_IP1 and WLAN_IP2 are used for the first device and the second device to establish a WLAN control path, and MAC1 and MAC2 are used for the first device and the second device to establish a P2P physical connection.
[0209] In response to the creation request, the first device can simultaneously establish a WLAN connection and a P2P connection, that is, can simultaneously start executing S06 and S07. Since the first device and the second device are both connected to the AP (and have completed the WLAN physical connection), the process of establishing a WLAN connection between the first device and the second device is a socket establishment process, including establishing a WLAN control path between the first device and the second device, and further establishing a WLAN data path between the first device and the second device through the WLAN control path.
[0210] When a first device establishes a P2P connection with a second device, it first establishes a physical P2P connection. This is followed by a socket establishment, which establishes a P2P control channel between the first device and the second device. Furthermore, a P2P data channel is established between the first device and the second device through the P2P control channel. Therefore, a successful WLAN connection typically precedes a successful P2P connection.
[0211] Optionally, the control path establishment system of the first device records a relationship table between the ID of the first service session and the establishment action.
[0212] The following S06 describes the process of establishing the WLAN control channel, and S08-S33 describes the process of creating the WLAN data channel. S34-S47 describes the process of the first device and the second device recording the WLAN channel in their respective data channel lists and notifying the screen projection application that business data can be transmitted after the WLAN data channel is successfully established. S48-S59 describes the process of the first device sending screen projection data through the WLAN data channel after the WLAN data channel is successfully established and before the P2P data channel is successfully established. The following S07 describes the process of the first device and the second device P2P physical connection, S60-S61 describes the process of establishing the P2P control channel, S62-S78 describes the process of establishing the P2P data channel, and S79-S88 describes the process of the first device and the second device recording the P2P channel in their respective data channel lists after the P2P data channel is successfully established. S89-S100 describes the process of the first device sending screen projection data through the WLAN data channel before the P2P data channel is successfully established.
[0213] S06: The control path establishment system of the first device and the control path establishment system of the second device perform a three-way handshake on the TCP protocol via WLAN to establish a WLAN control path.
[0214] Since the first and second devices are already connected to a wireless local area network, the WLAN connection between the first and second devices is established as a socket. Specifically, a three-way handshake of the TCP protocol is performed on the WLAN link to establish the WLAN control path. The three-way handshake requires the WLAN IP addresses (i.e., WLAN_IP1 and WLAN_IP2) of the local (first device) and remote (second device) devices. If the handshake is successful, the first device determines that the WLAN control path has been successfully established.
[0215] S07 , the control path establishing system of the first device establishes a P2P physical connection with the control path establishing system of the second device.
[0216] In response to the connection request, the first device and the second device establish a P2P physical connection. After the P2P physical connection is successful, a Socket is established, that is, S60-S78 are executed.
[0217] The P2P physical connection between the first device and the second device needs to use the MAC addresses of the local end and the opposite end (ie, MAC1 and MAC2).
[0218] S08. After the WLAN control path is successfully established (i.e., the three-way handshake is successful), the control path establishment system of the first device sends a first data path establishment request to the data path establishment system. The first data path establishment request carries the WLAN IP address of the first device (i.e., WLAN_IP1), the WLAN IP address of the second device (i.e., WLAN_IP2), and the ID of the first service session (i.e., A1_ID), requesting to establish the WLAN data path.
[0219] S09 , the data path establishing system of the first device checks whether the ID of the first protocol session corresponding to the ID of the first service session is valid in response to the first data path creation request.
[0220] At this time, the first protocol session has not been created, and the ID of the first protocol session is an invalid value. S10 can be executed. Otherwise, if it is valid, it means that the first protocol session has been created. At this time, a request for applying for a port can be sent to the protocol session management system of the first device, and further, S12 can be executed.
[0221] S10. When the ID of the first protocol session is invalid, the data path establishment system of the first device sends a second session creation request to the protocol session management system. The second session creation request carries the WLAN IP of the first device (i.e., WLAN_IP1) and is used to request the creation of a protocol session corresponding to the first service session (i.e., the first protocol session).
[0222] S11 , the protocol session management system of the first device creates a protocol session corresponding to the first service session, ie, a first protocol session, in response to the second session creation request, to generate an ID (ie, B1_ID) for identifying the first protocol session.
[0223] S12 , the protocol session management system of the first device applies for a User Datagram Protocol (UDP) port on the local WLAN IP (ie, WLAN_IP1 ), exemplarily represented as port C1 .
[0224] Specifically, the protocol session management system performs port binding on WLAN_IP1 and randomly obtains a UDP protocol port, such as port C1.
[0225] S13, the protocol session management system of the first device sends the ID of the first protocol session (ie B1_ID) and port C1 to the data path establishment system. The first protocol session is used by the first device to encapsulate and send service data from the first service session according to protocol requirements.
[0226] S14 , the data path establishing system of the first device sends the ID of the first protocol session (ie, B1_ID) to the service session management system.
[0227] S15: The service session management system of the first device refreshes the ID of the first protocol session corresponding to the first service session.
[0228] At this time, the ID of the first protocol session changes from an invalid value to a valid value, that is, B1_ID.
[0229] S16, the service session management system of the first device sends first information to the data path establishment system. The first information may carry the ID of the first service session (ie, A1_ID), indicating that the ID of the first protocol session has been refreshed.
[0230] S17, after receiving the first information, the data path establishment system of the first device can send a first message to the data path establishment system of the second device through the WLAN control path. The first message carries the port C1 of the first device, the ID of the first service session (i.e., A1_ID) and the link type WLAN, which is used to negotiate the establishment of the WLAN data path.
[0231] S18, after receiving the first message, the data path establishment system of the second device parses the first message to obtain the UDP port C1, A1_ID, link type WLAN and WLAN IPs of both ends (ie, WLAN_IP1 and WLAN_IP2) of the first device.
[0232] Specifically, the data path establishment system of the second device may parse the first message to obtain the port C1 of the first device, the ID of the first service session (ie, A1_ID), and the link type WLAN carried in the first message.
[0233] The data path establishment system of the second device can also obtain the source address of the first message (ie, WLAN_IP1) and the destination address of the first message (ie, WLAN_IP2) when the link type is WLAN.
[0234] S19 , the data path establishment system of the second device sends a third session creation request to the service session management system. The third session creation request carries the ID of the first service session (ie, A1_ID).
[0235] S20: The service session management system of the second device checks whether the local end includes a service session corresponding to the ID of the first service session in response to the third session creation request.
[0236] Since the service session management system of the second device has not yet created a service session corresponding to the second service session, it does not include the service session corresponding to the first service session. In this case, S21 can be executed. Otherwise, when the service session corresponding to the service session system has been established, the service session management system of the second device sends information carrying the ID of the service session corresponding to the ID of the first service session (i.e., the second service session) to the data path establishment system to indicate that the second service session has been created.
[0237] S21. When the service session management system of the second device does not have a service session corresponding to the ID of the first service session on the local end, it creates a second service session to generate the second service session ID (i.e., A2_ID), sets the available flag of the second service session to invalid, and initializes the ID of the protocol session corresponding to the second service session (i.e., the second protocol session) to an invalid value (False).
[0238] The second service session is used to interact with the data of the application of the second device (such as the screen projection application) and send and receive data for the application.
[0239] It should be understood that at this point, the protocol session corresponding to the second service session (the second protocol session) has not yet been created. When creating the second service session, the service session management system initializes the corresponding second protocol session ID to an invalid value. The service session management system of the first device can determine whether the second protocol session has been created based on whether the second protocol session ID is valid. After the second protocol session is created, the service session management system updates the second protocol session ID to a valid value.
[0240] Like the first service session, the second service session may also include a flag indicating whether the second service session is available (also called an available flag). When the second service session is created, the available flag is set to invalid (false).
[0241] S22: The service session management system of the second device sends second information to the data path establishment system. The second information may carry an identifier of the second service session (ie, A2_ID) to indicate that the second service session has been created.
[0242] S23: After receiving the second information, the data path establishing system of the second device may check whether the ID of the second protocol session corresponding to the second service session is valid.
[0243] At this time, the second protocol session has not been created, and the ID of the second protocol session is an invalid value.
[0244] If the ID of the second protocol session is valid, it indicates that the second protocol session has been created. At this time, a request for applying for a port may be sent to the protocol session management system of the second device. Further, S26 is executed.
[0245] S24 , when the ID of the second protocol session is invalid, the data path establishment system of the second device sends a fourth session creation request to the protocol session management system. The fourth session creation request carries WLAN_IP2 and is used to request creation of a protocol session corresponding to the second service session.
[0246] S25 , the protocol session management system of the second device creates a protocol session corresponding to the second service session, ie, a second protocol session, in response to the fourth session creation request, to generate an ID of the second protocol session (ie, B2_ID).
[0247] The second protocol session is used by the second device to receive and parse received data according to protocol requirements to obtain service data of the first service session.
[0248] S26 , the protocol session management system of the second device applies for a UDP port on the local WLAN IP (WLAN_IP2), exemplarily represented as port S1.
[0249] S27, the protocol session management system of the second device sends the ID of the second protocol session (ie, B2_ID) and the port S1 to the data path establishment system.
[0250] S28: The data path establishing system of the second device sends the ID of the second protocol session (ie, B2_ID) to the service session management system.
[0251] S29: The service session management system of the second device refreshes the ID of the second protocol session.
[0252] At this time, the ID of the second protocol session changes from an invalid value to a valid value, namely B2_ID.
[0253] S30, the service session management system of the second device sends third information to the data path establishment system. The third information may carry the ID of the second service session (ie, A2_ID) to indicate that the ID of the second protocol session has been updated.
[0254] S31, the data path establishment system of the second device sends a first response message to the data path establishment system of the first device through the WLAN control path. The first response message is a response message of the first message, carrying the ID of the first service session (i.e., A1_ID), the ID of the second service session (i.e., A2_ID), the link type WLAN and the port S1.
[0255] S32. After receiving the first response message, the data path establishment system of the first device sends a first protocol connection instruction to the protocol session management system. The first protocol connection instruction carries the WLAN IP (i.e., WLAN_IP2) of the other end (i.e., the second device), port S1, and the ID of the first protocol session (i.e., B1_ID).
[0256] It should be understood that after receiving the first response message, the data path establishment system of the first device can determine the ID of the first protocol session corresponding to the ID of the first service session (ie, B1_ID).
[0257] S33 , the protocol session management system of the first device performs a protocol handshake with the protocol session management system of the second device in response to the first protocol connection instruction to exchange respective protocol session IDs.
[0258] Specifically, the protocol session management system of the first device sends a second message carrying the ID of the first protocol session (i.e., B1_ID) to the protocol session management system of the second device. After receiving the second message, the protocol session management system of the second device sends a second response message carrying the ID of the second protocol session (i.e., B2_ID) to the protocol session management system of the second device. At this point, the protocol session management system of the first device and the protocol session management system of the second device both determine that the handshake is complete.
[0259] S34 , after completing the protocol handshake, the protocol session management system of the first device adds the WLAN data path to the first data path list.
[0260] Specifically, in the protocol session management system, each protocol session can correspond to a data path list. The data path list corresponding to the ID of the first protocol session is also referred to as the first data path list. The protocol session management system can also set priorities for the data paths in this data path list. For example, the P2P data path has a higher priority than the WLAN data path. When a session has multiple available data paths, the protocol session management system will prioritize the data path with the higher priority for sending service data.
[0261] Specifically, the protocol session management system of the first device maintains a first data path list corresponding to the ID (B1_ID) of the first protocol session. The first data path list may include information of one or more data paths. The recorded WLAN data path information includes the WLAN IP and port of the other end, that is, WLAN_IP2 and port S1, etc.
[0262] S35 , the protocol session management system of the first device sends the ID of the first protocol session (ie, B1_ID) and the link type WLAN to the data path establishment system.
[0263] S36 , the data path establishing system of the first device sends the ID of the first service session (ie A1_ID) and the link type WLAN to the service session management system.
[0264] S37: The service session management system of the first device adds the WLAN data path to the third data path list corresponding to the ID of the first service session.
[0265] Specifically, the service session management system of the first device maintains a data path list (i.e., a third data path list) corresponding to the ID (A1_ID) of the first service session. The information of the WLAN data path included in the third data path list may include the link type WLAN, so that the service session management system of the first device knows the number of data paths currently available for the first service session and the link type to which they belong.
[0266] S38: The service session management system of the first device checks whether the available flag of the first service session is valid.
[0267] Among them, the available flag is used to indicate whether the business session can transmit business data or whether to send a notification indicating that data can be transmitted. When the available flag of the first business session is invalid, the business session management system does not send a notification to the screen projection application to indicate that the first business session is successfully opened or that the business data of the first business session can be transmitted, and the screen projection application will not send the business data of the first business session. Conversely, when the available flag of the first business session is valid, the business session management system has sent a notification to the screen projection application to indicate that the first business session is successfully opened or that the business data of the first business session can be transmitted, and the screen projection application has already sent the business data of the first business session.
[0268] At this time, the available flag of the first service session is invalid (false).
[0269] S39. When the available flag of the first business session is invalid, the business session management system of the first device sends a first notification to the screen projection application. The first notification can carry the ID of the first business session (i.e., A1_ID), which is used to indicate that the first business session is successfully opened or the business data of the first business session can be transmitted. At this time, the business data (i.e., screen projection data) can be transmitted.
[0270] S40: After S39, the service session management system of the first device sets the available flag of the first service session to be valid (true). At this point, the screen projection application has been notified that service data can be sent.
[0271] Correspondingly, after S33, the second device may also perform the same operations as above S34-S40, for details, see the following steps S41-S47.
[0272] S41 , after completing the protocol handshake, the protocol session management system of the second device adds the WLAN data path to the second data path list.
[0273] Specifically, the protocol session management system of the second device maintains a data path list corresponding to the ID of the second protocol session, i.e., the second data path list. This second data path list may include information about one or more data paths. The recorded WLAN data path information includes the WLAN IP address and port of the peer end, i.e., WLAN_IP1 and port C1. S42: The protocol session management system of the second device sends the ID of the second protocol session (i.e., B2_ID) and the link type WLAN to the data path establishment system.
[0274] S43: The data path establishing system of the second device sends the ID of the second service session (ie, A2_ID) and the link type WLAN to the service session management system.
[0275] S44: The service session management system of the second device adds the WLAN data path to the fourth data path list.
[0276] Specifically, the service session management system of the second device maintains a data path list (i.e., a fourth data path list) corresponding to the ID of the second service session. The information of the WLAN data path included in the fourth data path list may include the link type WLAN, so that the service session management system of the second device knows the number of data paths currently available for the second service session and the link type to which they belong.
[0277] S45: The service session management system of the second device checks whether the available flag of the second service session is valid.
[0278] When the available flag of the second service session is invalid, the service session management system has not sent a notification to the screen casting application indicating that the second service session has been successfully opened or that service data of the second service session can be transmitted, and the screen casting application will not send the service data of the second service session. Conversely, when the available flag of the second service session is valid, the service session management system has sent a notification to the screen casting application indicating that the second service session has been successfully opened or that service data of the second service session can be transmitted, and the screen casting application has already sent the service data of the second service session.
[0279] At this time, the available flag of the second service session is invalid (false).
[0280] S46. When the available flag of the second business session is invalid, the business session management system of the second device sends a second notification to the screen projection application. The second notification can carry the ID of the second business session (i.e., A2_ID), which is used to indicate that the second business session is successfully opened or the business data of the second business session can be transmitted. At this time, the business data can be transmitted.
[0281] Among them, the available flag is used to indicate whether the business session can transmit business data. When the available flag of a business session is invalid, the screen projection application does not receive the notification indicating that the second business session is successfully opened, and the business data of the second business session will not be sent, such as the data used to control the screen projection on the second device side.
[0282] S47, after S46, the service session management system of the second device sets the available flag of the second service session to be valid (true). At this time, the screen projection application has been notified that the service data can be sent.
[0283] It should be understood that the above steps S37 and S44 are not necessary steps. In some embodiments, the service session management system of the device may not include a data path list corresponding to the service session.
[0284] It should be understood that after S39, the screen projection application of the first device can send the service data of the first service session to the screen projection application of the second device. Figure 5C As shown in the flowchart, the process of sending service data may include but is not limited to some or all of the following steps S48-S59:
[0285] S48, after receiving the first notification, the screen projection application of the first device can send the business data of the first business session (ie, screen projection data) and the ID of the first business session (ie, A1_ID) to the business session management system.
[0286] S49, after receiving the screen projection data and the ID of the first service session, the service session management system of the first device sends the screen projection data and the ID of the first service session (ie, A1_ID) to the data path establishment system.
[0287] S50, the data path establishment system of the first device sends the screen projection data and the ID of the first protocol session (ie, B1_ID) to the protocol session management system.
[0288] Among them, the data path establishment system of the first device stores the correspondence between the ID of the first business session (i.e., A1_ID) and the ID of the first protocol session (i.e., B1_ID). Therefore, after the data path establishment system receives the projection data and A1_ID, it can determine the B1_ID corresponding to A1_ID, and then send the projection data and B1_ID to the protocol session management system.
[0289] S51: After receiving the projection data and B1_ID, the protocol session management system of the first device determines the data path with the highest priority from the first data path list. In this case, the first data path list only contains the WLAN data path, and the determined data path is the WLAN data path, which is used to send the projection data.
[0290] S52, the protocol session management system of the first device sends a first sending request to the sending and receiving system. The first sending request carries the screen projection data and the information of the WLAN data path recorded in the first data path list (ie, WLAN_IP2 and port S1).
[0291] S53, the sending system of the first device sends the projection data to the sending and receiving system of the second device through the WLAN data path in response to the first sending request.
[0292] Specifically, the sending and receiving system of the first device will fragment, encrypt, encapsulate the protocol header and other operations on the data packets to be sent in the projection data, further obtain the first data path list, select the data path with the highest priority, which is the WLAN data path in this case, mount the data packet to the selected path, and send it to the second device.
[0293] S54, after receiving the projection data, the sending and receiving system of the second device sends the projection data and port S1 to the protocol session management system.
[0294] It should be understood that the sending and receiving system can obtain the UDP port for receiving the projection data, namely port S1.
[0295] S55, the protocol session management system of the second device determines the ID of the second protocol session (ie, B2_ID) according to the port S1 that receives the screen projection data.
[0296] When creating a protocol session, the protocol session management system may store the ID of the protocol session and the port corresponding to the ID, and further determine the ID of the second protocol session corresponding to the port S1 according to the port S1 receiving the service data.
[0297] S56, the protocol session management system of the second device sends the screen projection data and B2_ID to the data path establishment system.
[0298] S57, the data path establishment system of the second device sends the projection data and A2_ID to the service session management system.
[0299] Among them, the data path establishment system of the second device stores the correspondence between the ID of the second business session (i.e., A2_ID) and the ID of the second protocol session (i.e., B2_ID). Therefore, after the data path establishment system receives the projection data and A2_ID, it can determine the B2_ID corresponding to A2_ID, and then send the projection data and B2_ID to the protocol session management system.
[0300] S58, the service session management system of the second device sends the screen projection data and the ID of the second service session (ie, A2_ID) to the screen projection application.
[0301] S59, the screen projection application of the second device displays the screen projection data.
[0302] Similarly, after S46, the screen projection application of the second device can send the business data of the second business session to the screen projection application of the first device. The specific implementation is the same as the above-mentioned screen projection application of the first device sending the business data of the first business session to the screen projection application of the second device, which will not be repeated here.
[0303] S60: After the P2P physical connection is successfully established, the control path establishment system of the first device obtains the P2P IP address of the first device (denoted as P2P_IP1) and the P2P IP address of the second device (denoted as P2P_IP2) through the DHCP protocol.
[0304] S60 is executed after S07 is executed so that the P2P physical connection is successfully established.
[0305] S61: The control path establishment system of the first device performs a three-way handshake of the TCP protocol with the control path establishment system of the second device through P2P to establish a P2P control path.
[0306] The three-way handshake requires knowing the P2P IP addresses of the local end (first device) and the peer end (second device) (ie, P2P_IP1 and P2P_IP2). If the handshake succeeds, the first device determines that the P2P control path is successfully established.
[0307] S62: After the P2P control path is successfully established (i.e., the three-way handshake is successful), the control path establishment system of the first device sends a second data path establishment request to the data path establishment system. The second data path establishment request carries the P2P IP of the first device (i.e., P2P_IP1), the P2P IP of the second device (i.e., P2P_IP2), and the ID of the first service session (i.e., A1_ID).
[0308] S63: The data path establishment system of the first device responds to the second data path establishment request and checks whether the ID of the first protocol session (ie, B1_ID) corresponding to the ID of the first service session is valid. In this case, B1_ID is valid.
[0309] Since the first protocol session has been created during the process of establishing the WLAN data path, and the ID of the first protocol session (i.e., B1_ID) is a valid value, S64 can be executed. Otherwise, if it is invalid, it is necessary to create a protocol session corresponding to the first service session (i.e., the first protocol session), and then create the first protocol session. At this time, a session creation request can be sent to the protocol session management system of the first device to establish the first protocol session.
[0310] S64 , when the first protocol session ID is valid, the data path establishment system of the first device sends a first port application instruction to the protocol session management system. The first port application instruction carries P2P_IP1 for indicating the port to be applied for.
[0311] S65 , the protocol session management system of the first device responds to the first port application instruction and applies for a UDP port on the local P2P IP (ie, P2P_IP1 ), exemplarily represented as port C2 .
[0312] S66: The protocol session management system of the first device sends the ID of the first protocol session (ie, B1-ID) and port C2 to the data path establishment system.
[0313] S67, the data path establishment system of the first device sends a third message to the data path establishment system of the second device. The third message carries port C2, the ID of the first service session (ie, A1_ID), and the link type P2P, for negotiating the establishment of a P2P data path.
[0314] S68 , after receiving the third message, the data path establishment system of the second device parses the third message to obtain port C2 , A1_ID, link type P2P, and P2P IP addresses of the first device and the second device (ie, P2P_IP1 and P2P_IP2 ).
[0315] Specifically, the data path establishment system of the second device can parse the third message to obtain the port C2, A1_ID, and link type P2P carried in the third message. If the link type is P2P, the data path establishment system of the second device can obtain the source address of the third message (i.e., P2P_IP1) and the destination address of the first message (i.e., P2P_IP2).
[0316] S69: The data path establishment system of the second device sends a fifth session creation request to the service session management system. The fifth session creation request carries the ID of the first service session and is used to request creation of a protocol session corresponding to the first service session.
[0317] S70 : The service session management system of the second device checks whether the local end includes a service session corresponding to the ID of the first service session (ie, A1_ID) in response to the fifth session creation request.
[0318] In the process of establishing the WLAN data path, the service session management system of the second device has already established a second service session corresponding to the ID of the first service session (i.e., A1_ID). At this time, there is no need to create a second service session, and S71 can be executed. It should be understood that when it is not included, the service management system of the second device needs to create a second service session.
[0319] S71: The service session management system of the second device returns fourth information to the data path establishment system. The fourth information includes the ID of the second service session (ie, A2_ID), indicating that the second service session has been created.
[0320] S72: After receiving the fourth information, the data path establishing system of the second device may check whether the ID of the second protocol session corresponding to the corresponding second service session is valid.
[0321] The second protocol session is also created when the WLAN data path is established. At this time, the ID of the second protocol session is valid. It should be understood that when the ID of the second protocol session is invalid, the second protocol session needs to be created.
[0322] S73, when the ID of the second protocol session is valid, the data path establishment system of the second device sends a second port application instruction to the protocol session management system. The second port application instruction carries the P2P IP of the second device (ie, P2P_IP2) and is used to request to apply for a UDP port on P2P_IP2.
[0323] S74, the protocol session management system of the second device applies for a UDP port on the local P2P IP (ie, P2P_IP2), exemplarily represented as port S2.
[0324] S75 , the protocol session management system of the second device sends the port S2 and the ID of the second protocol session (ie, B2_ID) to the data path establishment system.
[0325] S76, the data path establishment system of the second device sends a third response message to the data path establishment system of the first device. The third response message is a response message of the third message, carrying the ID of the first service session (i.e., A1_ID), the ID of the second service session (i.e., A2_ID), the link type P2P and the port S2.
[0326] The data path establishment system of the second device can determine the ID of the corresponding second service session (ie, A2_ID) based on the ID of the second protocol session (ie, B2_ID), and then determine the ID of the first service session (ie, A1_ID) corresponding to the A2_ID.
[0327] S77. After receiving the third response message, the data path establishment system of the first device sends a second protocol connection instruction to the protocol session management system. The second protocol connection instruction carries the P2P IP of the second device (i.e., P2P_IP2), port S2, and the ID of the first protocol session (i.e., B1_ID).
[0328] The data path establishment system of the first device can parse the third response message to obtain A1_ID, A2_ID and port S2 carried therein, and further obtain the ID of the first protocol session, namely A1_ID, based on the ID of the first service session (ie A1_ID).
[0329] S78 , the protocol session management system of the first device performs a protocol handshake with the protocol session management system of the second device in response to the second protocol connection instruction to exchange respective protocol session IDs.
[0330] Specifically, the protocol session management system of the first device sends a fourth message carrying the ID of the first protocol session to the protocol session management system of the second device. After receiving the fourth message, the protocol session management system of the second device sends a fourth response message carrying the ID of the second protocol session to the protocol session management system of the second device. At this point, the handshake is completed.
[0331] S79: The protocol session management system of the first device adds the P2P data path to the first data path list.
[0332] Specifically, the P2P data path is added to the first data path list, that is, the information of the P2P data path corresponding to B1_ID is added. The recorded P2P data path information may include the P2P IP address and port of the peer end, such as P2P_IP2 and port S2. In this case, the first data path list includes both the P2P data path and the WLAN data path, with the P2P data path having a higher priority than the WLAN data path.
[0333] S80: The protocol session management system of the first device sends the ID of the first protocol session (ie, B1_ID) and the link type P2P to the data path establishment system.
[0334] S81: The data path establishing system of the first device sends the ID of the first service session (ie, A1_ID) and the link type P2P to the service session management system.
[0335] S82: The service session management system of the first device adds a P2P data path to the third data path list corresponding to the ID of the first service session.
[0336] The information of the P2P data path included in the third data path list may include a link type P2P.
[0337] S83: The service session management system of the first device checks whether the available flag of the first service session is valid. If valid, the first notification is not sent.
[0338] At this time, the available flag is valid (true), and there is no need to send the first notification again to notify the screen projection application that the first business session is successfully opened or that the business data of the first business session can be transmitted.
[0339] Correspondingly, after S78, the second device may also perform the same operations as above S79-S83, for details, please refer to the following steps S84-S88.
[0340] S84: The protocol session management system of the second device adds the P2P data path to the second data path list.
[0341] Specifically, the P2P data path is added to the second data path list, that is, the information of the P2P data path corresponding to B2_ID is added. The recorded P2P data path information may include the P2P IP address and port of the peer end, such as P2P_IP1 and port C2. In this case, the second data path list includes both the P2P data path and the WLAN data path, with the P2P data path having a higher priority than the WLAN data path.
[0342] S85: The protocol session management system of the second device sends the ID of the second protocol session (ie, B1_ID) and the link type P2P to the data path establishment system.
[0343] S86: The data path establishing system of the second device sends the ID of the second service session (ie, A1_ID) and the link type P2P to the service session management system.
[0344] S87: The service session management system of the second device adds the P2P data path to the fourth data path list corresponding to the ID of the second service session.
[0345] The information of the P2P data paths included in the fourth data path list may include a link type of P2P.
[0346] S88: The service session management system of the second device checks whether the available flag of the second service session is valid. If valid, the second notification is not sent.
[0347] At this time, the available flag is valid (true), and there is no need to send a second notification to notify the projection application that the second business session is successfully opened or that the business data of the second business session can be transmitted.
[0348] It should be understood that the above steps S80-S82 and S85-S87 are not necessary steps. In some embodiments, the service session management system of the device may not include a data path list corresponding to the service session, and may not need to check whether the available flag bit of the service session is valid.
[0349] After S79, the specific implementation of the screen projection data that the screen projection application of the first device can send to the screen projection application of the second device can be as follows: Figure 5E As shown, including but not limited to some or all of the following steps:
[0350] S89, after receiving the first notification, the screen projection application of the first device can send the business data of the first business session (ie, screen projection data) and the ID of the first business session (ie, A1_ID) to the business session management system.
[0351] S90, after receiving the projection data and the ID of the first service session, the service session management system of the first device sends the projection data and the ID of the first service session (ie, A1_ID) to the data path establishment system.
[0352] S91, the data path establishment system of the first device sends the screen projection data and the ID of the first protocol session (ie, B1_ID) to the protocol session management system.
[0353] Among them, the data path establishment system of the first device stores the correspondence between the ID of the first business session (i.e., A1_ID) and the ID of the first protocol session (i.e., B1_ID). Therefore, after the data path establishment system receives the projection data and A1_ID, it can determine the B1_ID corresponding to A1_ID, and then send the projection data and B1_ID to the protocol session management system.
[0354] S92: After receiving the projection data and B1_ID, the protocol session management system of the first device determines the data path with the highest priority from the first data path list. In this case, the first data path list includes both the WLAN data path and the P2P data path. The determined data path is the P2P data path, and the projection data is sent using the P2P data path.
[0355] S93, the protocol session management system of the first device sends a second sending request to the sending and receiving system, and the second sending request carries the screen projection data and the information of the P2P data path recorded in the first data path list (ie, P2P_IP2 and port S2).
[0356] S94, the sending system of the first device responds to the second sending request and sends the projection data to the sending and receiving system of the second device through the P2P data path.
[0357] Specifically, the sending and receiving system of the first device will fragment, encrypt, encapsulate the protocol header and other operations on the data packets to be sent in the projection data, further obtain the first data path list, select the data path with the highest priority, which is the P2P data path in this case, mount the data packet to the selected path, and send it to the second device.
[0358] S95, after receiving the projection data, the sending and receiving system of the second device sends the projection data and port S1 to the protocol session management system.
[0359] It should be understood that the sending and receiving system can obtain the UDP port for receiving the projection data, namely port S2.
[0360] S96, the protocol session management system of the second device determines the ID of the second protocol session (ie, B2_ID) according to the port S2 that receives the screen projection data.
[0361] When creating a protocol session, the protocol session management system may store the ID of the protocol session and the port corresponding to the ID, and further determine the ID of the second protocol session corresponding to the port S2 according to the port S2 receiving the service data.
[0362] S97, the protocol session management system of the second device sends the screen projection data and B2_ID to the data path establishment system.
[0363] S98, the data path establishment system of the second device sends the projection data and A2_ID to the service session management system.
[0364] Among them, the data path establishment system of the second device stores the correspondence between the ID of the second business session (i.e., A2_ID) and the ID of the second protocol session (i.e., B2_ID). Therefore, after the data path establishment system receives the projection data and A2_ID, it can determine the B2_ID corresponding to A2_ID, and then send the projection data and B2_ID to the protocol session management system.
[0365] S99, the service session management system of the second device sends the screen projection data and the ID of the second service session (ie, A2_ID) to the screen projection application.
[0366] S100, the screen projection application of the second device displays the screen projection data.
[0367] like Figure 6B As shown, the display interface 62 of the second device includes the interface 61 currently displayed by the first device.
[0368] Similarly, after S84, the screen projection application of the second device can send the business data of the second business session to the screen projection application of the first device. The specific implementation is the same as the above-mentioned screen projection application of the first device sending the business data of the first business session to the screen projection application of the second device, which will not be repeated here.
[0369] In the above method, when the first device initiates a service session for data transmission to the second device, it simultaneously triggers the WLAN connection and the P2P connection, so that before the P2P connection is successfully established, the service data of the service session is first transmitted through the WLAN data path. After the P2P connection is successfully established, the service data is switched to the P2P data path to reduce the user's waiting time.
[0370] Example 2
[0371] Example 2 provides a method for device communication when a P2P link is abnormally disconnected. When the P2P link is abnormally disconnected, service data can be dynamically switched to the WLAN link and P2P connection reconnection and recovery are initiated. Before the P2P link is restored, service data is transmitted via WLAN. After the P2P reconnection is successful, service data is switched back to the P2P link. This ensures that service data transmission is not interrupted when the P2P link is abnormally disconnected.
[0372] like Figure 7 As shown, the device communication method when the P2P link is abnormal may include but is not limited to some or all of the following steps:
[0373] S101: The control path establishment system of the first device detects whether the P2P physical connection with the second device is faulty. If so, S102-S106 can be executed to switch the screen projection data to the WLAN data path, or S107-S114 can be executed to trigger the P2P connection to be reestablished, so that the screen projection data can be transmitted through the newly created P2P data channel after the reestablishment.
[0374] S102: When the control path establishment system of the first device detects the P2P physical connection failure, it sends a third notification to the protocol session management system. The third notification carries the ID of the first protocol session and is used to indicate that the P2P data path corresponding to the ID of the first protocol session has failed.
[0375] S103, the protocol session management system of the first device deletes the P2P data path from the first data path list to use the WLAN data channel for subsequent screen projection data transmission.
[0376] Specifically, the protocol session management system of the first device may first determine a data path list corresponding to the ID of the first protocol session (ie, a first data path list), and further delete the P2P data path from the first data path list, ie, delete P2P_IP2 and port S2.
[0377] S104, when the protocol session management system of the first device receives the projection data and the ID (B1_ID) of the first service session from the data path establishment system after S103, it determines that the WLAN data path is the data path with the highest priority from the first data path list.
[0378] After S103 , the first data path list includes the WLAN data path but does not include the P2P data path. The protocol session management system of the first device determines the WLAN data path as the data path with the highest priority from the first data path list.
[0379] S105, the protocol session management system of the first device sends a third sending request to the sending and receiving system, and the third sending request carries the screen projection data and the information of the WLAN data path recorded in the first data path list (ie, WLAN_IP2 and port S1).
[0380] S106, the sending system of the first device sends the projection data to the sending and receiving system of the second device through the WLAN data path in response to the third sending request.
[0381] The specific implementation of the above S104-S106 can refer to the above S51-S53. The second device can execute the steps of S54-S59, which will not be repeated here.
[0382] S107 , when detecting the P2P physical connection failure, the control path establishment system of the first device sends an indication message to the service session management system. The indication message carries the ID of the first service session and is used to indicate the P2P data link failure corresponding to the first service session.
[0383] S108: After receiving the indication information, the service session management system of the first device may determine whether to perform P2P reconnection. If so, execute S109; otherwise, do nothing and use the WLAN data path to transmit the projection data, or close the first service session.
[0384] Among them, the service session management system of the first device can decide whether to reconnect. It can determine the cause of the failure. For example, if the cause of the failure is that the user triggered the closure of the P2P connection, then there is no need to reconnect P2P. For example, if the cause of the failure is insufficient memory of the first device or the current communication quality is poor, then S109 can be executed to trigger P2P reconnection.
[0385] Optionally, the service session management system of the first device may further delete the P2P data path from the third data path list.
[0386] S109 , the service session management system of the first device sends a P2P reconnection request to the control path establishment system. The request carries MAC1 and MAC2 for requesting a P2P connection.
[0387] S110 , the control path establishment system of the first device and the control path establishment system of the second device perform P2P connection reconstruction to establish a P2P physical connection, a P2P control path, and a P2P data path.
[0388] It should be understood that the process of P2P connection reconstruction includes the P2P physical connection between the first device and the second device, the creation of a P2P control path, the creation of a P2P data path, etc. The specific implementation of the reconstruction S107 can be found in the above S07, S60-S78, which will not be repeated here.
[0389] It should be noted that, during the reconstruction process, when S60 is executed, the P2P IP of the first device obtained is different from the P2P_IP1 of the first device. Similarly, the P2P IP of the second device obtained is also different from the P2P_IP2 of the second device. Exemplarily, the P2P IP of the first device and the P2P IP of the second device obtained during the reconstruction process are expressed as P2P_IP3 and P2P_IP4, respectively.
[0390] Similarly, during the reconstruction process, when S65 is executed, the UDP port number applied for at P2P_IP3 will also change, indicating port C3; when S74 is executed, the UDP port number applied for at P2P_IP4 will also change, indicating port S3.
[0391] S111 , after the P2P reconnection is successful, the protocol session management system of the first device adds the newly created P2P data path to the first data path list, that is, adds P2P_IP4 and port S3.
[0392] S112, when the protocol session management system of the first device receives the projection data and the ID (B1_ID) of the first business session from the data path establishment system after S112, it determines that the recreated P2P data path is the data path with the highest priority from the first data path list.
[0393] After S112 , the first data path list includes the WLAN data path and the re-created P2P data path, and the protocol session management system of the first device determines the re-created P2P data path as the data path with the highest priority from the first data path list.
[0394] S113, the protocol session management system of the first device sends a fourth sending request to the sending and receiving system, and the fourth sending request carries the projection data and the information of the re-created P2P data path recorded in the first data path list (ie, P2P_IP4 and port S3).
[0395] S114, the sending system of the first device sends the projection data to the sending and receiving system of the second device through the re-created P2P data path in response to the fourth sending request.
[0396] Among them, after S103, before the P2P connection is successfully reconnected, the process of the first device sending the projection data to the second device is the same as the above S48-S59. After the P2P connection is successfully reconnected, the process of the first device sending the projection data to the second device is the same as the above S89-S100 in principle, but the re-created P2P data path is used. It should be understood that during the P2P reconnection process, the second device will also add the re-created P2P data path to the second data path list, that is, add P2P_IP3 and port C3, so as to use the re-created P2P data path to transmit the business data of the second business session. The process of the second device sending the business data of the second business session to the first device is the same as the process of the first device sending the projection data to the second device in principle, and will not be repeated here.
[0397] Example 3
[0398] Embodiment 3 provides a method for device communication, which can also enable the first device to simultaneously trigger a WLAN connection and a P2P connection when initiating a first service session for data transmission to a second device, so that before the P2P connection is successful, the service data of the first service session is first sent to the second device via WLAN, and after the P2P connection is successful, the service data is sent to the second device via P2P, so that the service data is switched to the P2P link, thereby reducing the user's waiting time.
[0399] like Figure 8 The device communication method provided by the third embodiment is described as follows. Figure 1 The system implementation shown in FIG. 1 may include, but is not limited to, some or all of the following steps:
[0400] S201: An application program of a first device receives a user operation of sending first data to a second device.
[0401] During S201, the first device and the second device are connected to the same AP via WLAN. The user operation can be an operation of projecting the screen to the second device. In this case, the projected screen data is the first data. For specific implementation, please refer to the above Figure 5AThe user operation can also be a user operation of sharing a call with the second device, in which case the call data collected by the first device is the first data. The user operation can also be a user operation of sharing a keyboard and mouse with the second device, in which case the service data of the first service session is control data received by the first device through a keyboard or a mouse, etc.
[0402] S202, the first device creates a first service session.
[0403] The first service session is used to transmit the first data. The service data of the first service session is the first data.
[0404] Specifically, the first device creates the first service session, generates an ID of the first service session, and initializes an ID of a protocol session corresponding to the first service session (i.e., the first protocol session) to an invalid value. For specific implementation, refer to S04 in the above Figure 5A .
[0405] Optionally, the first device can also set a usable flag of the first service session to be invalid.
[0406] Optionally, the first device can obtain a WLAN IP and a MAC (i.e., WLAN_IP2 and MAC2) of the second device between S202 and S203.
[0407] S203, the first device performs a three-way handshake of a TCP protocol with the second device through a WLAN to establish a WLAN control channel. For specific implementation, refer to S06 in the above Figure 5A , which will not be repeated here.
[0408] S204, the first device performs a P2P physical connection with the second device. For specific implementation, refer to S07 in the above Figure 5A , which will not be repeated here.
[0409] The first device can trigger S203 and S204 at the same time.
[0410] S205, after the WLAN control channel is established, the first device negotiates with the second device to establish a WLAN data channel through the WLAN control channel.
[0411] As shown in Figure 9A , one specific implementation of S205 can include but is not limited to the following steps:
[0412] S205a, the first device creates a first protocol session corresponding to the first service session.
[0413] S205b, the first device applies for a UPD port C1 on a local WLAN IP.
[0414] S205c, the first device sends a first message to the second device, the first message carrying the port C1, the ID of the first service session, and the link type WLAN, for negotiating a WLAN data path for the first service session.
[0415] S205d, the second device parses the first message to obtain the port C1, the ID of the first service session, the link type WLAN, and the WLAN IP of the first device and the second device.
[0416] S205e, the second device creates a second service session without including the service session corresponding to the first service session, and creates a second protocol session without the ID of the protocol session corresponding to the second service session being valid.
[0417] In one specific implementation of S205e, the second device can first check whether the local end includes the service session corresponding to the first protocol session. If not, the service session corresponding to the first service session is created (i.e., the second service session is created), and if yes, the second service session does not need to be created. Further, the second device can check whether the ID of the protocol session corresponding to the second service session is valid. If not, the protocol session corresponding to the second service session is created (i.e., the second protocol session is created), and if yes, the second protocol session does not need to be created. The specific implementation can be referred to S20-S25 in the above Figure 5B .
[0418] S205f, the second device applies for a UPD port S1 on the WLAN IP of the local end. The specific implementation can be referred to S26 in the above Figure 5B .
[0419] S205g, the second device sends a first response message to the first device, the first response message carrying the port S1, the ID of the first service session, the ID of the second service session, and the link type WLAN.
[0420] After receiving the first response message, the second device parses the first response message to obtain the port S1, the ID of the first service session, the ID of the second service session, and the link type WLAN, and performs S205h.
[0421] S205h, the first device and the second device perform protocol handshake to exchange the respective protocol session IDs. The specific implementation can be referred to S33 in the above Figure 5B .
[0422] S206, the first device adds the WLAN data path in the first data path list corresponding to the first protocol session. The specific implementation can be referred to S34 in the above Figure 5B .
[0423] S207, the second device adds the WLAN data path in the second data path list corresponding to the second protocol session. The specific implementation can be referred to S41 in the above Figure 5B , which will not be described here. Optionally, after S206, the first device can also check whether the available flag of the first service session is valid. If valid, it is determined that the service data of the first service session can be sent out. If invalid, the valid flag of the first service session is modified to be valid. The specific implementation can be referred to steps S38-S40 in the above Figure 5B . Similarly, after S207, the second device can also check whether the available flag of the second service session is valid. If valid, it is determined that the service data of the second service session can be sent out. If invalid, the valid flag of the second service session is modified to be valid. The specific implementation can be referred to steps S45-S47 in the above Figure 5B .
[0424] S208, the first device determines that the data path with the highest priority in the first data path list is the WLAN data path when the service data of the first service session is received.
[0425] wherein, before the P2P connection is successful, the first data path list contains the WLAN data path and does not contain the P2P data path, and at this time, the data path with the highest priority is the WLAN data path.
[0426] S209, the first device sends the service data of the first service session to the second device through the link with the highest priority (WLAN link).
[0427] The specific implementation of S208-S209 can be referred to the above Figure 5C , which will not be described here.
[0428] It should be understood that, after S207, the specific implementation of the second device sending the service data of the second service session to the first device is the same as the above first device sending the service data of the first service session to the second device. Specifically, the second device determines that the data path with the highest priority in the second data path list is the WLAN data path when the service data of the second service session is received, and sends the service data of the second service session to the first device through the WLAN data path.
[0429] S210, the first device determines that the P2P physical connection is successful.
[0430] Optionally, after the P2P physical connection is successfully established, the first device can also obtain the IP of the P2P of the first device and the IP of the P2P of the second device through the DHCP protocol. The specific implementation can be referred to S60 in the above Figure 5D , which will not be described here.
[0431] S211, the first device performs a three-way handshake of the TCP protocol with the second device via P2P to establish a P2P control path. Figure 5D The S61 in the series will not be described in detail here.
[0432] S212: The first device negotiates with the second device to establish a P2P data path through the P2P control path.
[0433] Among them Figure 9B As shown, a specific implementation of S212 may include some or all of the following steps S212a-S212f:
[0434] S212a: The first device applies for UPD port C2 on the local P2P IP.
[0435] Since the first service session and the first protocol session have been created at this time, the first device can execute S212a to avoid duplicate creation. Optionally, before executing S212a, the first device can also check whether the ID of the first protocol session is valid. If it is valid, execute S212a. Otherwise, if it is invalid, it is necessary to create the first protocol session and then execute S212a. For specific implementation, please refer to the above Figure 5D S62-S66 in the specification will not be described here.
[0436] S212b, the first device sends a second message to the second device, the message carrying port C2, the first service session ID and the link type P2P, for negotiating a P2P data path for the first service session. Figure 5D The S67 in the series will not be described in detail here.
[0437] S212c, the second device parses the second message to obtain port C2, the ID of the first service session and the link type P2P, and obtains the P2P IP of the first device and the P2P IP of the second device. For specific implementation, please refer to the above Figure 5D The S68 in the series will not be described in detail here.
[0438] S212d: The second device applies for UPD port S2 on the local P2P IP.
[0439] Since the second business session and the second protocol session have been created at this time, the second device can execute S212d to avoid duplicate creation. Optionally, after S212c and before S212d, the second device can also check whether the local end contains the business session corresponding to the first business session. If so, there is no need to create the second protocol session. Otherwise, it is necessary to create the second protocol session. Furthermore, the second device can also check whether the ID of the second protocol session corresponding to the second business session is valid. If it is valid, execute S212d. Otherwise, if it is invalid, it is necessary to create a second protocol session and execute S212d after creation. For specific implementation, please refer to the above Figure 5D S69-S75 in the specification will not be described here.
[0440] S212e, the second device sends a second response message to the first device, the first response message carries the port S2, the first service session ID, the second service session ID and the link type P2P. For specific implementation, please refer to the above Figure 5D The S76 in the series will not be described in detail here.
[0441] S212f, the first device and the second device perform a protocol handshake to exchange their respective protocol session IDs. For specific implementation, please refer to the above Figure 5D S77-S78 in the text will not be described here.
[0442] S213, the first device adds the P2P data path to the first data path list. For specific implementation, please refer to the above Figure 5D The S79 in the article will not be described in detail here.
[0443] S214: The second device adds the P2P data path to the second data path list. Figure 5D The S84 in the series will not be described in detail here.
[0444] Optionally, after S213, the first device may further check whether the available flag of the first service session is valid. If valid, it is determined that the service data of the first service session can be delivered. If invalid, the valid flag of the first service session is modified to be valid. For specific implementation, see the above Figure 5D Similarly, after S214, the second device can also check whether the available flag of the second service session is valid. If it is valid, it is determined that the service data of the second service session can be sent. If it is invalid, the valid flag of the second service session is modified to be valid. For specific implementation, please refer to the above Figure 5D Steps S86-S88.
[0445] S215 : When receiving the service data of the first service session, the first device determines that the data path with the highest priority is the P2P data path from the first data path list.
[0446] After the P2P connection is successful, the first data path list includes the WLAN data path and the P2P data path. At this time, the data path with the highest priority is the P2P data path.
[0447] S216: The first device sends the service data of the first service session to the second device through the P2P data path.
[0448] The specific implementation of S215-S216 can be found in the above Figure 5E , I will not go into details here.
[0449] It should be understood that after S214, the specific implementation of the second device sending the business data of the second business session to the first device is the same as the above-mentioned first device sending the business data of the first business session to the second device. Specifically, when the second device receives the business data of the second business session, it determines that the data path with the highest priority from the second data path list is the P2P data path, and sends the business data of the second business session to the first device through the P2P data path.
[0450] A specific implementation of the above S201-S216 can be found in the above Figures 5A-5E , I will not go into details here.
[0451] Example 4
[0452] Embodiment 4 provides a method for device communication when a P2P physical connection is abnormally disconnected. This method also allows for the dynamic switching of service data to the WLAN data path when a P2P link is abnormally disconnected, and for the initiation of P2P connection reconnection and recovery. Before the P2P connection is restored, service data is transmitted via the WLAN. After the P2P reconnection is successful, service data is again switched to the P2P data path. This ensures that service data transmission is not interrupted when a P2P physical connection is abnormally disconnected.
[0453] like Figure 10 As shown, the device communication method when the P2P link is abnormal may include but is not limited to some or all of the following steps:
[0454] S301: The first device detects whether the P2P physical connection is faulty. For details, see the above. Figure 7 S101, no further details will be given here.
[0455] S302: The first device deletes the P2P data path from the first data path list. For specific implementation, please refer to the above Figure 7S102-S103 will not be repeated here.
[0456] S303: Before the P2P connection is successful, the first device sends the service data of the first service session to the second device through the WLAN data path. For specific implementation, please refer to the above Figure 7 S104-S106 will not be repeated here.
[0457] S304: The first device establishes a P2P physical connection with the second device.
[0458] S305: The first device determines that the P2P physical connection is successful.
[0459] S306: The first device performs a three-way handshake of the TCP protocol with the second device through P2P to establish a P2P control path.
[0460] S307: The first device negotiates with the second device to establish a P2P data channel through the P2P control channel.
[0461] It should be noted that the specific implementation of the above S304-S307 is the same as the above Figure 5D The difference between S60-S78 is that the P2P IPs of both ends used by the re-created P2P control channel and the P2P IPs and port numbers of both ends involved in the re-created P2P data channel will change. Figure 7 S110, no further details are given here.
[0462] S308: The first device adds the newly created P2P data path to the first data path list. For specific implementation, please refer to the above Figure 7 S111, no further details will be given here.
[0463] S309: When the first device receives the service data of the first service session, it determines the data path with the highest priority from the first data path list as the newly created P2P data path. For specific implementation, please refer to the above Figure 7 S112, no further details will be given here.
[0464] S310: After the P2P connection is successful, the first device sends the service data of the first service session to the second device through the P2P data path. For specific implementation, please refer to the above Figure 7 S113-S114 will not be repeated here.
[0465] A specific implementation of the above S301-S310 can be found in the above Figure 7 , I will not go into details here.
[0466] It should be understood that each step in the above method embodiments provided herein can be implemented by hardware integrated logic circuits in a processor or by software instructions. The method steps disclosed in the embodiments of this application can be directly implemented as being executed by a hardware processor, or by a combination of hardware and software modules in a processor.
[0467] The present application also provides an electronic device, which may include a memory and a processor, wherein the memory may be used to store a computer program, and the processor may be used to call the computer program in the memory so that the electronic device executes the method in any one of the above embodiments.
[0468] The present application also provides a chip system, which includes at least one processor for implementing the functions involved in the method executed by the electronic device in any of the above embodiments.
[0469] In one possible design, the chip system also includes a memory, which is used to store program instructions and data. The memory is located inside or outside the processor.
[0470] The chip system can be composed of chips, or can include chips and other discrete devices.
[0471] Optionally, there may be one or more processors in the chip system. The processor may be implemented in hardware or software. When implemented in hardware, the processor may be a logic circuit, an integrated circuit, etc. When implemented in software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.
[0472] Optionally, the memory in the chip system may be one or more. The memory may be integrated with the processor or may be provided separately from the processor, which is not limited in the embodiments of the present application. For example, the memory may be a non-transient processor, such as a read-only memory (ROM), which may be integrated with the processor on the same chip or provided on different chips. The embodiments of the present application do not specifically limit the type of memory or the configuration of the memory and the processor.
[0473] Exemplarily, the chip system can be a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system on chip (SoC), a central processor unit (CPU), a network processor (NP), a digital signal processor (DSP), a microcontroller unit (MCU), a programmable logic device (PLD) or other integrated chips.
[0474] The present application also provides a computer program product, which includes: a computer program (also referred to as code, or instruction), which enables a computer to execute the method executed by the electronic device in any of the above embodiments when the computer program is executed.
[0475] The present application also provides a computer-readable storage medium storing a computer program (also referred to as code or instruction). When the computer program is executed, the computer executes the method executed by the electronic device in any of the above embodiments.
[0476] The various implementation modes of this application can be combined arbitrarily to achieve different technical effects.
[0477] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive).
[0478] Those skilled in the art will appreciate that all or part of the process steps in the above-described method embodiments can be implemented by a computer program instructing the relevant hardware. The program can be stored in a computer-readable storage medium, and when executed, the program can include the process steps in the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
[0479] In short, the above are only embodiments of the technical solution of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made based on the disclosure of the present invention should be included in the scope of protection of the present invention.
Claims
1. A device communication method, characterized in that: Applied to a first electronic device, the method includes: The first electronic device initiates, in response to a received user operation for sending first data to a second electronic device, establishing a wireless local area network (WLAN) connection with the second electronic device and establishing a point-to-point (P2P) connection with the second electronic device, wherein the first electronic device and the second electronic device are respectively connected to the same wireless access point via the WLAN; After the first electronic device successfully establishes the WLAN connection with the second electronic device and before the first electronic device successfully establishes the P2P connection with the second electronic device, the first electronic device sends the first data to the second electronic device through the WLAN connection; After the first electronic device successfully establishes the P2P connection with the second electronic device, the first electronic device sends the first data to the second electronic device through the P2P connection.
2. The method according to claim 1, characterized in that The method further comprises: After the WLAN connection is successfully established, the first electronic device adds WLAN data path information to the first data path list, where the WLAN data path information includes the WLAN IP address and a first port of the second electronic device, where the first port is the port of the WLAN IP address of the second electronic device; After the P2P connection is successfully established, the first electronic device adds P2P data path information to the first data path list, where the P2P data path information includes the P2P IP of the second electronic device and a second port, where the second port is the port of the P2P IP of the second electronic device.
3. The method according to claim 2, characterized in that The priority of the P2P data path is greater than that of the WLAN data path, and the priority is used to determine the data path for sending the first data.
4. The method according to claim 2 or 3, characterized in that The method further comprises: When the P2P connection fails, the first electronic device deletes the information of the P2P data path in the first data path list, sends the first data to the second electronic device through the WLAN connection, and triggers re-establishment of the P2P connection with the second electronic device.
5. The method according to any one of claims 2 to 4, characterized in that: The establishing a WLAN connection with the second electronic device includes: The first electronic device establishes a WLAN control path with the second electronic device; The first electronic device establishes a WLAN data path with the second electronic device through the WLAN control path.
6. The method according to claim 5, characterized in that Before the first electronic device and the second electronic device establish a WLAN control path, the method further includes: The first electronic device establishes a first service session, where the first service session is used to transmit the first data; The first electronic device sets the available flag of the first service session to invalid, and sets the identifier of the first protocol session corresponding to the first service session to an invalid value.
7. The method according to claim 6, characterized in that The first electronic device establishes a WLAN data path with the second electronic device through the WLAN control path, including: When the identifier of the first protocol session is an invalid value, the first electronic device creates the first protocol session and updates the identifier of the first protocol session to a valid value; The first electronic device applies for a third port on the WLAN IP of the first electronic device; The first electronic device sends a first message to the second electronic device, where the first message carries the identifier of the first service session, the third port, and the first link type; The first electronic device receives a first response message from the second electronic device, where the first response message carries an identifier of the first service session, an identifier of the second service session, the first port, and the first link type; the second service session is a service session created by the second electronic device corresponding to the first service session.
8. The method according to claim 6 or 7, characterized in that After the first electronic device adds information about the WLAN data path to the first data path list or the first electronic device adds information about the P2P data path to the first data path list, the method further includes: when the available flag bit of the first service session is set to invalid, updating the available flag bit to a valid value.
9. The method according to any one of claims 2 to 8, characterized in that: The establishing a P2P connection with the second electronic device includes: The first electronic device establishes a P2P physical connection with the second electronic device; After the P2P physical connection is successful, the first electronic device establishes a P2P control path with the second electronic device; The first electronic device establishes a P2P data path with the second electronic device through the P2P control path.
10. The method according to claim 9, characterized in that The first electronic device establishes a P2P data path with the second electronic device through the P2P control path, specifically including: The first electronic device applies for a fourth port on the P2P IP of the first electronic device; The first electronic device sends a third message to the second electronic device, where the third message carries the identifier of the first service session, the fourth port, and the second link type; The first electronic device receives a third response message from the second electronic device, where the third response message carries the identifier of the first service session, the identifier of the second service session, the second port, and the second link type.
11. The method according to claim 10, characterized in that The method further includes: the first electronic device checking whether the identifier of the first protocol session is valid; The first electronic device applies for the fourth port on the P2P IP of the first electronic device, specifically including: the first electronic device applies for the fourth port on the P2P IP of the first electronic device when the identifier of the first protocol session is valid.
12. The method according to any one of claims 6 to 8, characterized in that: The first electronic device includes an application, a service session management system, and a control path establishment system; The creating of the first service session specifically includes: in response to receiving the first session creation request, the service session management system creating the first service session and generating an identifier of the first service session; Setting the available flag of the first service session to invalid and setting the identifier of the first protocol session corresponding to the first service session to an invalid value specifically includes: the service session management system setting the available flag of the first service session to invalid and setting the identifier of the first protocol session corresponding to the first service session to an invalid value; the available flag of the first service session is used to indicate whether the application has been notified to transmit the first data; before the WLAN connection is successfully established, the available flag of the first service session is invalid; and setting the identifier of the first protocol session to an invalid value indicates that the first protocol session has not been established.
13. The method according to any one of claims 6 to 8 or 12, characterized in that: The first electronic device includes a service session management system and a control path establishment system, and the method further includes: The service session management system sends a connection request to the control path establishment system, where the connection request carries the WLAN IP address of the first electronic device, the WLAN IP address of the second electronic device, the MAC address of the first electronic device, and the MAC address of the second electronic device, and is used to request establishment of a WLAN connection and a P2P connection with the second electronic device; The initiating establishment of a wireless local area network (WLAN) connection with the second electronic device and establishing a point-to-point (P2P) connection with the second electronic device specifically includes: the control path establishment system responding to the connection request, initiating establishment of a WLAN control path with the second electronic device based on the WLAN IP of the first electronic device and the WLAN IP of the second electronic device, and establishing a P2P physical connection with the second electronic device based on the MAC of the first electronic device and the MAC of the second electronic device.
14. The method according to claim 7, wherein: The first electronic device includes a control path establishment system, a data path establishment system and a protocol session management system; When the identifier of the first protocol session is an invalid value, the first electronic device establishes the first protocol session, and before updating the identifier of the first protocol session to a valid value, the method further includes: after the WLAN control path is established, the control path establishment system sends a first data path establishment request to the data path establishment system, the first data path establishment request carrying the WLAN IP address of the first electronic device, the WLAN IP address of the second electronic device, and the identifier of the first service session, the first data path establishment request being used to request establishment of the WLAN data path; When the identifier of the first protocol session is an invalid value, the first electronic device creates the first protocol session, specifically including: the data path establishment system, in response to the first data path creation request, sends a second session creation request to the protocol session management system when the identifier of the first protocol session is invalid, the second session creation request carrying the WLAN IP address of the first electronic device, the second session creation request being used to request creation of the first protocol session; and the protocol session management system creating the first protocol session in response to the second session creation request, generating the identifier of the first protocol session, the first protocol session being used to encapsulate and send the first data in accordance with protocol requirements.
15. The method according to claim 14, characterized in that The first electronic device further includes a service session management system, and the application for the third port on the WLAN IP of the first electronic device is performed by the protocol session management system. After the first electronic device applies for the third port on the WLAN IP of the first electronic device, the method further includes: the protocol session management system sending an identifier of the first protocol session and a port number of the third port to the data path establishment system; Updating the identifier of the first protocol session to a valid value specifically includes: The data path establishment system sends an identifier of the first protocol session to the service session management system; In response to receiving the identifier of the first protocol session, the service session management system updates the identifier of the first protocol session to a valid value.
16. The method according to claim 8, characterized in that The first electronic device includes a service session management system, a data path establishment system, and a protocol session management system; and updating the available flag to a valid value specifically includes: The protocol session management system sends an identifier of the first protocol session to the service session management system through the data path establishment system; In response to receiving the identifier of the first service session, the service session management system sends a first notification to the application when the available flag of the first service session is invalid, the first notification carrying the identifier of the first service session, and the first notification being used to instruct transmission of the first data; After sending the first notification, the service session management system sets the available flag of the first service session to be valid.
17. The method according to claim 11, characterized in that The first electronic device includes a control path establishment system, a data path establishment system and a protocol session management system; The method further includes: after the P2P control path is established, the control path establishment system sends a second data path establishment request to the data path establishment system, the second data path establishment request carrying the P2P IP address of the first electronic device, the P2P IP address of the second electronic device, and an identifier of the first service session, the second data path establishment request being used to request establishment of the P2P data path; The first electronic device checks whether the identifier of the first protocol session is valid, specifically comprising: the data path establishment system checks whether the identifier of the first protocol session corresponding to the first service session is valid in response to the second data path creation request; When the identifier of the first protocol session is valid, the first electronic device applies for a fourth port on the P2P IP of the first electronic device, specifically comprising: when the identifier of the first protocol session is valid, the data path establishment system sends a first port application instruction to the protocol session management system, where the first port application instruction carries the P2P IP of the second electronic device; The protocol session management system applies for a fourth port on the P2P IP of the first electronic device in response to the first port application instruction.
18. The method according to any one of claims 2 to 17, characterized in that: The first electronic device includes a protocol session management system and a sending and receiving system; Before sending the first data to the second electronic device via the WLAN connection and / or sending the first data to the second electronic device via the P2P connection, the method further includes: determining, by the protocol session management system, a data path with the highest priority from the first data path list; The sending of the first data to the second electronic device through the WLAN connection specifically includes: when the protocol session management system determines that the data path with the highest priority is the WLAN data path, sending a first sending request to the sending and receiving system, the first sending request carrying information about the first data and the WLAN data path; and in response to receiving the first sending request, the sending and receiving system sending the first data to the second electronic device through the WLAN data path; The sending of the first data to the second electronic device through the P2P connection specifically includes: when the protocol session management system determines that the data path with the highest priority is the P2P data path, sending a second sending request to the sending and receiving system, the second sending request carrying information of the first data and the P2P data path; in response to receiving the second sending request, the sending and receiving system sending the first data to the second electronic device through the P2P data path.
19. A device communication method, characterized in that: Applied to a second electronic device, the method includes: The second electronic device receives an initiation from the first electronic device to establish a wireless local area network (WLAN) connection and a point-to-point (P2P) connection, and the first electronic device and the second electronic device are connected to the same wireless access point via WLAN; After the second electronic device successfully connects to the WLAN of the first electronic device and before the second electronic device successfully connects to the P2P of the first electronic device, the second electronic device receives the first data sent by the first electronic device through the WLAN connection; After the second electronic device successfully establishes the P2P connection with the first electronic device, the second electronic device receives the first data sent by the first electronic device through the P2P connection.
20. The method according to claim 19, characterized in that The method further comprises: After the WLAN connection is successfully established, the second electronic device adds WLAN data path information to the second data path list, where the WLAN data path information includes the WLAN IP address and a third port of the first electronic device, where the first port is the port of the WLAN IP address of the first electronic device; After the P2P connection is successfully established, the second electronic device adds P2P data path information to the second data path list, where the P2P data path information includes the P2P IP of the first electronic device and a fourth port, where the second port is the port of the second electronic device at the P2P IP of the second electronic device.
21. The method according to claim 20, characterized in that The priority of the P2P data path is greater than that of the WLAN data path, and the priority is used to determine the data path for sending the second data.
22. The method according to claim 20 or 21, characterized in that The method further comprises: When the P2P connection fails, the second electronic device deletes the information of the P2P data path in the second data path list, and receives the first data from the first electronic device through the WLAN connection.
23. The method according to any one of claims 19 to 22, characterized in that: The establishing a WLAN connection with the first electronic device includes: The second electronic device establishes a WLAN control path with the first electronic device; The second electronic device establishes a WLAN data path with the first electronic device through the WLAN control path.
24. The method according to claim 23, wherein The second electronic device establishes a WLAN data path with the first electronic device through the WLAN control path, specifically including: The second electronic device receives a first message from the first electronic device, where the first message carries the identifier of the first service session, the third port, and the first link type; When the second electronic device does not include a service session corresponding to the first protocol session, creating a second service session, setting the available flag of the second service to invalid, and setting the identifier of the second protocol session corresponding to the second service session to invalid; When the identifier of the protocol session corresponding to the second service session is invalid, the second electronic device creates the second protocol session and updates the identifier of the second protocol session to a valid value; The second electronic device applies for a first port on the WLAN IP of the first electronic device; The second electronic device sends a first response message to the first electronic device, where the first response message carries the identifier of the first service session, the identifier of the second service session, the first port, and the first link type.
25. The method according to claim 24, characterized in that After the second electronic device adds information about the WLAN data path in the second data path list or after the second electronic device adds information about the P2P data path in the second data path list, the method further includes: when the available flag bit of the second service session is set to invalid, updating the available flag bit to a valid value.
26. The method according to any one of claims 19 to 25, characterized in that The establishing a P2P connection with the second electronic device includes: The second electronic device establishes a P2P physical connection with the first electronic device; After the P2P physical connection is successful, the second electronic device establishes a P2P control path with the first electronic device; The second electronic device establishes a P2P data path with the first electronic device through the P2P control path.
27. The method according to claim 26, characterized in that The second electronic device establishes a P2P data path with the first electronic device through the P2P control path, specifically including: The second electronic device receives a third message from the first electronic device, where the third message carries the identifier of the first service session, the fourth port, and the second link type; The second electronic device applies for a second port on the P2P IP of the second electronic device; The second electronic device sends a third response message to the first electronic device, where the third response message carries the identifier of the first service session, the identifier of the second service session, the second port, and the second link type.
28. The method according to claim 27, characterized in that The method further comprises: The second electronic device checks whether a second service session corresponding to the first service session is included; When the second service session is included, the second electronic device checks whether the identifier of the second protocol session is valid; The second electronic device applies for the second port on the P2P IP of the second electronic device, specifically including: the second electronic device applies for the second port on the P2P IP of the second electronic device when the identifier of the second protocol session is valid.
29. The method according to claim 24 or 25, characterized in that The second electronic device includes a data path establishment system and a service session management system; The method further includes: the data path establishment system sending, in response to the received first message, a third session creation request to the service session management system, wherein the third session creation request carries an identifier of the first service session, and the third session creation request is used to request creation of a service session corresponding to the first service session; The second electronic device creating a second service session when the service session corresponding to the first protocol session is not included, specifically comprising: in response to the received third session creation request, the service session management system creating the second service session when the service session corresponding to the first service session is not included, and setting the identifier of the second protocol session corresponding to the second service session to an invalid value; The method further includes: the service session management system sending a second message to the data path establishment system, where the second message includes an identifier of the second service session, and the second message is used to indicate that the second service session has been created.
30. The method according to claim 25, wherein The second electronic device includes a service session management system, a data path establishment system, and a protocol session management system; and updating the available flag to a valid value specifically includes: The protocol session management system sends the identifier of the second protocol session to the service session management system through the data path establishment system; Upon receiving the identifier of the second service session, the service session management system sends a second notification to the application when the available flag of the second service session is invalid, where the second notification carries the identifier of the second service session and indicates that the second data can be transmitted; After sending the second notification, the service session management system sets the available flag of the second service session to be valid.
31. The method according to claim 28, wherein The second electronic device includes a data path establishment system, a protocol session management system and a service session management system; The method further includes: the data path establishment system sending a fifth session creation request to the service session management system, the fifth session creation request carrying the identifier of the first service session, the fifth session creation request being used to request creation of the second service session; The second electronic device checks whether the second service session corresponding to the first service session is included, specifically comprising: the service session management system checks whether the second service session corresponding to the first service session is included in response to the fifth session creation request; The method further includes: when the second service session is included, the service session management system sends fourth information to the data path establishment system, the fourth information including an identifier of the second service session, the fourth information being used to indicate that the second service session has been established; The second electronic device checks whether the identifier of the second protocol session is valid when the second service session is included, specifically comprising: in response to receiving the fourth information, the data path establishment system checks whether the identifier of the second protocol session is valid; When the identifier of the second protocol session is valid, the second electronic device applies for the second port on the P2P IP of the second electronic device, specifically comprising: when the identifier of the first protocol session is valid, the data path establishment system sends a second port application instruction to the protocol session management system, where the second port application instruction carries the P2P IP of the second electronic device; The protocol session management system applies for the second port on the P2P IP of the second electronic device in response to the second port application instruction.
32. The method according to any one of claims 20 to 31, characterized in that The second electronic device includes a sending and receiving system, a protocol session management system, a data path establishment system, and a service session management system; and receiving the first data from the first electronic device through the WLAN connection specifically includes: When receiving the first data, the sending and receiving system sends a port for receiving the first data to the protocol session management system, where the port for receiving the first data is the first port; The protocol session management system determines an identifier of the second protocol session according to the first port, and sends the first data and the identifier of the second protocol session to the data path establishment system; The data path establishment system sends the first data and the identifier of the second service session corresponding to the second protocol session to the service session management system; The service session management system sends the first data and the identifier of the second service session to the application.
33. The method according to any one of claims 20 to 31, characterized in that The second electronic device includes a sending and receiving system, a protocol session management system, a data path establishment system, and a service session management system; and receiving the first data from the first electronic device through the P2P connection specifically includes: When receiving the first data, the sending and receiving system sends the port for receiving the first data to the protocol session management system, where the port for receiving the first data is the second port; The protocol session management system determines an identifier of the second protocol session according to the second port, and sends the first data and the identifier of the second protocol session to the data path establishment system; The data path establishment system sends the first data and the identifier of the second service session corresponding to the second protocol session to the service session management system; The service session management system sends the first data and the identifier of the second service session to the application.
34. An electronic device, characterized in that: It includes a memory and one or more processors; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method as described in any one of claims 1-18 or 19-33.
35. A computer-readable storage medium comprising instructions, characterized in that: When the instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1-18 or 19-33.
Citation Information
Patent Citations
WiFi data transmission method and terminal
CN103249085A
Data transmission control method and related product
CN109640310A
System and method for providing wireless internet access and electronic device
CN113676902A
Method, device and system for transmitting data in near field
CN114697934A
Display device and screen projection processing method
CN115883625A