Data transmission method and device and storage medium
By adapting multiple protocol stacks in the RTOS platform and selecting the appropriate protocol stack according to the data type for data transmission, the network application limitation caused by the RTOS platform only supports a single protocol stack, achieving more efficient and flexible data transmission.
Patent Information
- Application Number
- CN202510535544.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2025-07-18
AI Technical Summary
The RTOS platform only supports a single protocol stack, which is unable to meet the needs of complex network applications, limiting network communication capabilities and system flexibility and scalability.
Adapt multiple protocol stacks in the RTOS platform, and data transmission is transmitted by selecting the appropriate target protocol stack among multiple protocol stacks, including the TCP/IP protocol stack and the LwIP protocol stack, and different protocol stacks are selected according to the data type.
It improves the adaptability and functional diversity of electronic devices in diverse network application scenarios, improves the efficiency and reliability of data transmission, and simplifies development and maintenance work.
Smart Images

Figure CN120343014A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of communication technologies, and particularly relates to a data transmission method, apparatus, and storage medium. Background Art
[0002] A real-time operating system (RTOS) is an operating system designed specifically for real-time applications. It can efficiently manage processor resources to ensure that the system can meet operation requirements within specific time constraints. The RTOS platform provides a foundation for developing and running real-time applications and is widely used in fields such as embedded devices and industrial control systems.
[0003] The Transmission Control Protocol / Internet Protocol (TCP / IP) protocol stack is a set of standard protocols for communication, which can ensure reliable transmission of data between different network devices and operating systems. The lightweight (LwIP) TCP / IP protocol stack is a lightweight implementation of the TCP / IP protocol stack, which is optimized specifically for resource-constrained embedded systems to ensure that network tasks can be instantaneously responded to and processed.
[0004] Currently, RTOS platforms deployed with the TCP / IP protocol stack or the LwIP protocol stack can only transmit limited types of data, thus unable to meet the requirements of complex network applications. Summary of the Invention
[0005] This application relates to a data transmission method, apparatus, and storage medium, which are used to solve the technical problem in the prior art that the RTOS platform can only transmit limited types of data, resulting in the inability to meet the requirements of complex network applications.
[0006] In a first aspect, an embodiment of this application provides a data transmission method, which is applied to an electronic device supporting multiple protocol stacks. The method includes:
[0007] Obtain at least one data to be transmitted;
[0008] For any one of the at least one data to be transmitted, determine a target protocol stack for transmitting the data to be transmitted among the multiple protocol stacks;
[0009] Transmit the data to be transmitted through the target protocol stack.
[0010] In a possible implementation, determining the target protocol stack for transmitting the data to be transmitted among the multiple protocol stacks includes:
[0011] Determine the type of the data to be transmitted;
[0012] Determine the target protocol stack among the multiple protocol stacks according to the type of the data to be transmitted.
[0013] In a possible implementation manner, the determining the target protocol stack among the multiple protocol stacks according to the type of the data to be transmitted includes:
[0014] Obtain indication information according to the type of the data to be transmitted;
[0015] Determine the target protocol stack among the multiple protocol stacks according to the indication information.
[0016] In a possible implementation manner, the obtaining the indication information according to the type of the data to be transmitted includes:
[0017] If the type of the data to be transmitted is internal data, obtain the indication information through the API;
[0018] If the type of the data to be transmitted is external data, obtain the indication information by triggering an event.
[0019] In a possible implementation manner, the multiple protocol stacks include a TCP / IP protocol stack and an LwIP protocol stack;
[0020] The determining the target protocol stack among the multiple protocol stacks according to the indication information includes:
[0021] If the indication information indicates the LwIP protocol stack, determine the LwIP protocol stack as the target protocol stack; or,
[0022] If the indication information indicates the TCP / IP protocol stack, determine the TCP / IP protocol stack as the target protocol stack.
[0023] In a possible implementation manner, the multiple protocol stacks include a TCP / IP protocol stack and an LwIP protocol stack;
[0024] The determining the target protocol stack among the multiple protocol stacks according to the type of the data to be transmitted includes:
[0025] If the type of the data to be transmitted is internal data, determine the LwIP protocol stack as the target protocol stack; or,
[0026] If the type of the data to be transmitted is external data, determine the TCP / IP protocol stack as the target protocol stack.
[0027] In a possible implementation, the internal data is the data generated by the applications deployed in the electronic device; or,
[0028] the external data is the USB data or Wi-Fi data received by the electronic device.
[0029] In a second aspect, an embodiment of the present application provides a data transmission device, which is applied to an electronic device supporting multiple protocol stacks. The device includes:
[0030] An acquisition module, configured to acquire at least one data to be transmitted;
[0031] A determination module, configured to determine, for any one of the at least one data to be transmitted, a target protocol stack for transmitting the data to be transmitted among the multiple protocol stacks;
[0032] A transmission module, configured to transmit the data to be transmitted through the target protocol stack.
[0033] In a third aspect, an embodiment of the present application provides a data transmission device, which is applied to an electronic device supporting multiple protocol stacks. The device includes: a processor and a memory;
[0034] The memory stores computer-executable instructions;
[0035] The processor executes the computer-executable instructions stored in the memory to implement the method described in the first aspect.
[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, the method described in the first aspect is implemented.
[0037] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0038] In a sixth aspect, an embodiment of the present application provides a chip, on which a computer program is stored. When the computer program is executed by the chip, the method described in the first aspect is implemented.
[0039] In a possible implementation, the chip is a chip in a chip module.
[0040] An embodiment of the present application provides a data transmission method, apparatus, and storage medium. The method is applied to an electronic device supporting multiple protocol stacks. The method obtains at least one data to be transmitted, and for any one of the at least one data to be transmitted, determines a target protocol stack for transmitting the data to be transmitted among the multiple protocol stacks. It is possible to select a suitable protocol stack for data transmission according to different network application scenarios, effectively solving the problem of data transmission type limitations brought by a single protocol stack, so that the device can meet the requirements of complex network applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is an application scenario diagram of the data transmission method provided by the present application;
[0042] Figure 2 is the flow of the data transmission method provided by the embodiment of the present application Figure 1 ;
[0043] Figure 3 is the flow of the data transmission method provided by the embodiment of the present application Figure 2 ;
[0044] Figure 4 is the flow of the data transmission method provided by the embodiment of the present application Figure 3 ;
[0045] Figure 5 is the schematic diagram of determining the protocol stack provided by the embodiment of the present application Figure 1 ;
[0046] Figure 6 is the schematic diagram of determining the protocol stack provided by the embodiment of the present application Figure 2 ;
[0047] Figure 7 is the flow of the data transmission method provided by the embodiment of the present application Figure 4 ;
[0048] Figure 8 is the schematic diagram of adapting multiple protocol stacks for the RTOS platform in the present application;
[0049] Figure 9 is the schematic diagram of determining the protocol stack provided by the embodiment of the present application Figure 3 ;
[0050] Figure 10 is the schematic structural diagram of the data transmission apparatus 10 provided by the embodiment of the present application;
[0051] Figure 11 is the schematic structural diagram of the data transmission apparatus 20 provided by the embodiment of the present application.
[0052] Through the above-mentioned accompanying drawings, specific embodiments of the present application have been shown, and will be described in more detail hereinafter. These drawings and written descriptions are not intended to limit the scope of the concept of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. Detailed Description of the Embodiments
[0053] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the scope of protection of the present application.
[0054] In the present application, "at least one" means one or more. "Multiple" means two or more.
[0055] In the present application, "exemplarily", "in this embodiment" and the like are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" in the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of the word "exemplary" is intended to present concepts in a specific manner.
[0056] To clearly understand the technical solution of the present application, the solutions of the prior art will be introduced in detail first.
[0057] The RTOS platform ensures the efficient and reliable operation of the embedded system in a resource-constrained environment by providing real-time task scheduling, efficient resource management, and reliable communication mechanisms. The protocol stack, as a set of communication protocols, is used for network communication between different devices. Therefore, the RTOS platform usually integrates the protocol stack to provide network communication functions, enabling the RTOS platform to support network connections and data transmission, and meeting the application requirements of the embedded system in a network environment.
[0058] However, when the RTOS platform only supports a single protocol stack, due to the limited types of data transmitted, it is difficult for the RTOS platform to meet the requirements of complex network applications, and its network communication capabilities may be limited. In addition, if the RTOS platform only supports the TCP / IP protocol stack, especially when the TCP / IP protocol stack is a closed-source version, it will be difficult for developers to perform customized development according to new business requirements, which will limit the flexibility and scalability of the system. Similarly, if the RTOS platform only supports the open-source LwIP protocol stack, since the functions of LwIP are relatively basic, it may not be able to fully meet the requirements of complex network applications, thereby further limiting the applicable scenarios of the RTOS platform.
[0059] To solve the above technical problems, the present application provides a data transmission method, which can be applied to an electronic device supporting multiple protocol stacks. By adapting multiple protocol stacks in the RTOS platform, the functional combination of different protocol stacks is realized, and the limitation of the data transmission type that may be brought by a single protocol stack is solved. Thus, in the face of diverse network application scenarios, the appropriate protocol stack can be flexibly selected according to actual needs to execute the corresponding data transmission tasks, thereby improving the functional diversity and scalability of the platform.
[0060] Figure 1 FIG. is an application scenario diagram for implementing the data transmission method provided by the present application. As Figure 1 shown, the application in the application layer can pass data to the network protocol stack in the transport layer or network layer through the socket application programming interface (API). Since the data transmission method provided by the present application is applicable to an electronic device supporting multiple protocol stacks, the application program can select the appropriate protocol stack according to the specific network environment and requirements to complete data transmission. In the data link layer, the universal serial bus (USB) and the general packet radio service (GPRS) can be used as the data transmission paths. Among them, USB can perform data interaction by connecting to Ethernet (ETHER) and selecting the appropriate protocol stack according to needs; GPRS can also select the appropriate protocol stack for data interaction.
[0061] It should be noted that the above application scenario is only an example. Optionally, Figure 1 the TCP / IP protocol stack and the LwIP protocol stack in can also be other types of protocol stacks, and the scenario can also include other numbers of protocol stacks. The embodiments of the present application do not limit this.
[0062] Next, the technical solution shown in the present application will be described in detail through specific embodiments. It should be noted that the following several embodiments can exist independently or be combined with each other. For the same or similar content, it will not be repeated in different embodiments.
[0063] Figure 2 FIG. is a schematic flowchart of a data transmission method provided by an embodiment of the present application. As Figure 2 shown, this method is applied to an electronic device supporting multiple protocol stacks and includes:
[0064] S201. Obtain at least one data to be transmitted.
[0065] Among them, the data to be transmitted refers to the data that needs to complete the interaction through the protocol stack. In this embodiment, the data to be transmitted can be application data, USB data, wireless fidelity (Wi-Fi) data, etc. Application data is the data generated or processed by an application program or a system process; USB data is the data obtained by the USB interface into the electronic device; Wi-Fi data is the data obtained through a wireless network.
[0066] S202. For any one of at least one data to be transmitted, determine a target protocol stack for transmitting the data to be transmitted among multiple protocol stacks.
[0067] In this embodiment, according to the specific network environment and corresponding requirements required by each data to be transmitted, the most suitable protocol stack can be selected from multiple protocol stacks supported by the electronic device as the target protocol stack for performing this data transmission task subsequently. Exemplarily, for some data to be transmitted with high requirements for the network environment, the TCP / IP protocol stack can be selected to ensure reliable data transmission and provide high-quality services; while for a large amount of low-priority data, the LwIP protocol stack can be selected to provide efficient data transmission, thereby reducing resource consumption and improving the overall performance of the system.
[0068] It should be noted that this embodiment does not limit the manner of determining the target protocol stack for any one data to be transmitted.
[0069] S203. Transmit the data to be transmitted through the target protocol stack.
[0070] Specifically, for each different data to be transmitted, after determining the appropriate target protocol stack, the data will be routed to the target protocol stack. Subsequently, the target protocol stack will perform necessary processing on the data, including but not limited to operations such as encapsulation, address resolution, error detection and correction, etc., to ensure that the data format meets the transmission requirements. After the processing is completed, the data to be transmitted will be sent to the modulator-demodulator (Modem) side to complete the data transmission process.
[0071] The data transmission method provided in this embodiment is applied to an electronic device supporting multiple protocol stacks. The method first obtains at least one data to be transmitted. Then, for any one of the at least one data to be transmitted, a target protocol stack for transmitting the data to be transmitted is determined among the multiple protocol stacks, and then the data to be transmitted is transmitted through the target protocol stack. By adapting multiple protocol stacks in the electronic device, each data to be transmitted can select a suitable target protocol stack for transmission, thereby solving the problem of limited data transmission types and facilitating improving the adaptability of the electronic device to various network application scenarios and the diversity of functions. In addition, by matching the data transmission requirements with the characteristics of the protocol stack, the efficiency and reliability of data transmission can be effectively improved.
[0072] Figure 3 It is a flowchart illustration of a data transmission method provided by an embodiment of the present application Figure 2 As Figure 3 shown, as an optional implementation manner, on the basis of the above embodiment, the method includes:
[0073] S301. Obtain at least one data to be transmitted.
[0074] It should be noted that the execution process of S301 can refer to the execution process of S201, which will not be elaborated here.
[0075] S302. For any one of the at least one data to be transmitted, determine the type of the data to be transmitted.
[0076] In this embodiment, the type of the data to be transmitted can be determined according to the source of the data to be transmitted. Exemplarily, the source of the data to be transmitted can include inside and outside the electronic device. As an optional implementation manner, the internal data can be data generated by applications deployed in the electronic device, and the external data can be USB data or Wi-Fi data received by the electronic device.
[0077] S303. According to the type of the data to be transmitted, determine a target protocol stack among the multiple protocol stacks.
[0078] Since different types of data to be transmitted have different requirements for the functions of the protocol stack, therefore, for each type of data to be transmitted, a set of protocol stacks suitable for this type of data to be transmitted can be selected from the multiple protocol stacks for subsequent data transmission. It should be noted that different types of data to be transmitted can be transmitted simultaneously using different protocol stacks.
[0079] The data transmission method provided in this embodiment determines a target protocol stack for transmitting data to be transmitted among multiple protocol stacks, including: determining the type of the data to be transmitted; and determining the target protocol stack among multiple protocol stacks according to the type of the data to be transmitted. By supporting multiple protocol stacks in an electronic device and selecting the most suitable protocol stack according to different types of data to be transmitted, the electronic device can more flexibly adapt to various data types and network environments, thereby better meeting the transmission requirements of different types of data and improving the reliability and efficiency of data transmission.
[0080] Figure 4 Flow schematic of a data transmission method provided in an embodiment of the present application Figure 3 As Figure 4 shown, the method includes:
[0081] S401. Obtain at least one piece of data to be transmitted.
[0082] It should be noted that the execution process of S401 can refer to the execution process of S201 and will not be elaborated here.
[0083] S402. For any one of the at least one piece of data to be transmitted, determine the type of the data to be transmitted.
[0084] It should be noted that the execution process of S402 can refer to the execution process of S302 and will not be elaborated here.
[0085] S403. Obtain indication information according to the type of the data to be transmitted.
[0086] Among them, the indication information can be used to indicate the protocol stack used by the data to be transmitted.
[0087] As an optional implementation manner, when the type of the data to be transmitted is internal data, the indication information can be obtained through the API. In this embodiment, when the type of the data to be transmitted is internal data (such as application data), since data can be transmitted between the application data and the protocol stack through the socket API, the socket API can be used to obtain the indication information, and then the corresponding protocol stack can be selected from multiple protocol stacks for data transmission according to the obtained indication information.
[0088] As an optional implementation manner, when the type of the data to be transmitted is external data, the indication information can be obtained by triggering an event. In this embodiment, when the type of the data to be transmitted is external data (such as USB data), since the USB network sharing process can be triggered by the USB share start (usbshare_start) event, the indication information can be obtained through this trigger event, and then the corresponding protocol stack can be selected from multiple protocol stacks for subsequent data transmission according to the obtained indication information.
[0089] S404. If the indication information indicates the LwIP protocol stack, then the LwIP protocol stack is determined as the target protocol stack.
[0090] Specifically, in this embodiment, an RTOS platform can be deployed in an electronic device that supports multiple protocol stacks. Figure 5 Schematic diagram of determining a protocol stack provided by an embodiment of the present application Figure 1 . As Figure 5 shown, in the previous embodiment, taking application data as an example, it has been illustrated that internal data can obtain indication information through the socket API. For example, when the indication information indicates the LwIP protocol stack, the LwIP protocol stack can be determined as the target protocol stack. After the target protocol stack is determined, the data to be transmitted can use the LwIP protocol stack to reach the Modem through the WAN port to complete the uplink transmission of the data. Correspondingly, the Modem will also use the LwIP protocol stack and complete the downlink transmission of the data through the WAN port.
[0091] Figure 6 Schematic diagram of determining a protocol stack provided by an embodiment of the present application Figure 2 . In this embodiment, an RTOS platform can be deployed in an electronic device that supports multiple protocol stacks. The RTOS platform can include a remote network driver interface specification (RNDIS) module, and external data can be obtained through the RNDIS module.
[0092] In this embodiment, the indication information can be derived from flag information. As Figure 6 shown, in the previous embodiment, taking USB data as an example, it has been illustrated that external data can obtain indication information through a USB sharing startup event. For example, flag information can be predefined in the RTOS platform. When the USB sharing startup event indicates that the USB sharing function is started, this event can obtain the predefined flag information, and this flag information is used to indicate the protocol stack to be used for this data transmission.
[0093] It should be noted that after the Modem completes the activation of the packet data protocol (PDP), it will obtain an IP address assigned by the operator and establish a GPRS-based data channel. Subsequently, the Modem will register a WAN port (virtual network card) with the protocol stack and mount a transmit (TX) interface function. During data transmission, when the protocol stack needs to send data to the Modem side, the data can be directly sent to the Modem side by calling TX.
[0094] Exemplarily, for the uplink transmission of data, if the indication information indicates to select the LwIP protocol stack, the data to be transmitted will reach the LwIP protocol stack through the data receive (receive) interface (LwIP RX) of the LwIP protocol stack. After that, the data to be transmitted will be sent to the Modem side through the corresponding LwIP TX. Correspondingly, for the downlink transmission of data, the Modem side will send the data to the data receive interface of the LwIP protocol stack, and then the data will enter the corresponding LwIP protocol stack. After that, the LwIP protocol stack will send the data to RNDIS through the LwIP TX of the downlink.
[0095] S405. When the indication information indicates the TCP / IP protocol stack, determine the TCP / IP protocol stack as the target protocol stack.
[0096] As Figure 5 shown, in this embodiment, when the indication information indicates the TCP / IP protocol stack, the TCP / IP protocol stack can be determined as the target protocol stack. After determining the target protocol stack, the data to be transmitted can use this TCP / IP protocol stack and reach the Modem through the WAN port to complete the uplink transmission of data. Correspondingly, the Modem will also use this TCP / IP protocol stack and complete the downlink transmission of data through the WAN port.
[0097] As Figure 6 shown, in this embodiment, for the uplink transmission of data, if the indication information indicates to select the TCP / IP protocol stack, the data to be transmitted will reach the TCP / IP protocol stack through the data receive interface (TCP / IP RX) of the TCP / IP protocol stack. After that, the data to be transmitted will be sent to the Modem side through the corresponding TCP / IP TX. Correspondingly, for the downlink transmission of data, the Modem side will send the data to the data receive interface of the TCP / IP protocol stack, and then the data will enter the corresponding TCP / IP protocol stack. After that, the TCP / IP protocol stack will send the data to RNDIS through the TCP / IP TX of the downlink.
[0098] It should be noted that in the Figure 6 scenario shown, the data is transmitted in a transparent transmission mode. Among them, the transparent transmission mode means that the data does not go through intermediate processing or conversion, remains unchanged during the transmission process, and is not modified or interpreted. This method can ensure the integrity and consistency of the data, which is beneficial to simplifying the transmission process and improving the transmission efficiency.
[0099] The data transmission method provided in this embodiment, where multiple protocol stacks include the TCP / IP protocol stack and the LwIP protocol stack; determining a target protocol stack among multiple protocol stacks according to indication information includes: if the indication information indicates the LwIP protocol stack, then determining the LwIP protocol stack as the target protocol stack; or, if the indication information indicates the TCP / IP protocol stack, then determining the TCP / IP protocol stack as the target protocol stack. Controlling the selection of the protocol stack through indication information can improve the flexibility of data transmission, simplify the development and maintenance of the protocol stack selection process, overcome the problem of data transmission type limitations brought by a single protocol stack, and thus meet the requirements of complex network applications.
[0100] Figure 7 Schematic flow of a data transmission method provided in an embodiment of the present application Figure 4 As Figure 7 shown, as an optional implementation, the method includes:
[0101] S701. Obtain at least one data to be transmitted.
[0102] It should be noted that the execution process of S701 can refer to the execution process of S201, which will not be elaborated here.
[0103] S702. For any one of the at least one data to be transmitted, determine the type of the data to be transmitted.
[0104] It should be noted that the execution process of S702 can refer to the execution process of S302, which will not be elaborated here.
[0105] If the type of the data to be transmitted is internal data, then determine the LwIP protocol stack as the target protocol stack.
[0106] It should be noted that the execution process of S703 can refer to the execution process of S404, which will not be elaborated here.
[0107] If the type of the data to be transmitted is external data, then determine the TCP / IP protocol stack as the target protocol stack.
[0108] It should be noted that the execution process of S704 can refer to the execution process of S405, which will not be elaborated here.
[0109] The data transmission method provided in this embodiment, the multiple protocol stacks include the TCP / IP protocol stack and the LwIP protocol stack; determining a target protocol stack among the multiple protocol stacks according to the type of data to be transmitted includes: if the type of data to be transmitted is internal data, determining the LwIP protocol stack as the target protocol stack; or, if the type of data to be transmitted is external data, determining the TCP / IP protocol stack as the target protocol stack. Through the mutual cooperation between the protocol stacks, each protocol stack can give full play to its respective advantages. The LwIP protocol stack provides efficient resource utilization in internal data transmission, while the TCP / IP protocol stack provides comprehensive network support in external data transmission. This division of labor not only improves the overall performance of the system, but also simplifies the development and maintenance work, and enhances the flexibility and adaptability of the system.
[0110] It should be noted that before implementing the data transmission method of this application, an RTOS platform can be deployed in the electronic device, and then multiple protocol stacks can be adapted for the RTOS platform. Taking the LwIP protocol stack as an example below, the process of adapting the protocol stack for the RTOS platform will be specifically described.
[0111] Figure 8 It is a schematic diagram of adapting multiple protocol stacks for the RTOS platform of this application. As Figure 8 shown, taking the adaptation of the LwIP protocol stack for the RTOS platform as an example, since the protocol stack plays a connecting role in network applications, connecting the application layer applications upward and the link layer downward, first, a set of socket APIs that conform to the Portable Operating System Interface (POSIX) standard can be defined, and the socket APIs can be used to obtain indication information. Then, adaptation can be performed based on the data path and the carrier layer network card to ensure that data can be transmitted between different protocol stacks. After that, adaptation can be performed based on the operating system of the RTOS platform to ensure that multiple protocol stacks can be integrated with the RTOS platform. Since the operating system simulation layer is an abstraction layer used to connect the protocol stack and the operating system kernel. Therefore, the synchronization mechanisms such as semaphores and queues of the underlying operating system can be encapsulated in the operating system simulation layer to provide an abstract access method for the protocol stack to the resources of the underlying operating system, thereby improving the flexibility and maintainability of the system.
[0112] For ease of understanding, specific examples are given below to illustrate the method of this application.
[0113] Figure 9 It is a schematic diagram of determining the protocol stack provided by the embodiment of this application Figure 3 As Figure 9As shown in the figure, the data application protocol stack (DAPS) is the protocol stack of the RTOS platform. After being adapted by multiple protocol stacks, the current RTOS platform can support the TCP / IP protocol stack and the LwIP protocol stack.
[0114] This example mainly focuses on the module and mobile wireless fidelity (Mi-Fi) scenarios. Among them, the module can be used to provide specific network connection functions. The RTOS platform can be connected to the host computer through a wireless access point (Wi-Fi AP) or an RNDIS module, and act as a router to provide Internet access functions for the host computer. The host computer can be a device such as a mobile phone. The local area network (LAN) port is used to connect wired network devices. Mi-Fi refers to a portable wireless router device that can share the network for other devices through Wi-Fi signals.
[0115] Specifically, in scenarios such as modules and Mi-Fi, it is usually necessary to support multiple network protocols and advanced functions. For example, in the Mi-Fi scenario, it is necessary to convert the mobile network connection into a Wi-Fi signal, which requires the use of the network address translation (NAT) protocol to manage the IP addresses of devices and the dynamic host configuration protocol (DHCP) to automatically assign IP addresses. Similarly, in the module scenario, it is also necessary to provide comprehensive network connection and management capabilities to support various network protocols and functions. Since the LwIP protocol stack is mainly oriented to resource-constrained embedded systems, some advanced functions are omitted in the design, so it does not support the NAT protocol and DHCP. Therefore, in such scenarios, the more comprehensive TCP / IP protocol stack can be used to transmit external data to ensure the stability of network connections and the implementation of advanced functions. In contrast, for the transmission of internal data, such as application networking, the LwIP protocol stack with less resource occupancy can be used to meet the needs of resource-constrained devices and improve the overall performance and efficiency of the system.
[0116] Figure 10 It is a schematic structural diagram of the communication device 10 provided in the embodiment of the present application. The device 10 is applied to an electronic device that supports multiple protocol stacks. Please refer to Figure 10 , the device 10 includes:
[0117] An acquisition module 11, configured to acquire at least one data to be transmitted;
[0118] A determining module 12, configured to determine, for any one of at least one data to be transmitted, a target protocol stack for transmitting the data to be transmitted among multiple protocol stacks;
[0119] A transmitting module 13, configured to transmit the data to be transmitted through the target protocol stack.
[0120] In an implementation manner, the determining module 12 is specifically configured to:
[0121] Determine the type of the data to be transmitted;
[0122] According to the type of the data to be transmitted, determine the target protocol stack among multiple protocol stacks.
[0123] In an implementation manner, the determining module 12 is specifically configured to:
[0124] Obtain indication information according to the type of the data to be transmitted;
[0125] According to the indication information, determine the target protocol stack among multiple protocol stacks.
[0126] In an implementation manner, the obtaining module 11 is specifically configured to:
[0127] When the type of the data to be transmitted is internal data, obtain the indication information through an API;
[0128] When the type of the data to be transmitted is external data, obtain the indication information by triggering an event.
[0129] In an implementation manner, the multiple protocol stacks include a TCP / IP protocol stack and an LwIP protocol stack; the determining module 12 is specifically configured to:
[0130] If the indication information indicates the LwIP protocol stack, determine the LwIP protocol stack as the target protocol stack; or, if the indication information indicates the TCP / IP protocol stack, determine the TCP / IP protocol stack as the target protocol stack.
[0131] In an implementation manner, the multiple protocol stacks include a TCP / IP protocol stack and an LwIP protocol stack; the determining module 12 is specifically configured to:
[0132] If the type of the data to be transmitted is internal data, determine the LwIP protocol stack as the target protocol stack; or, if the type of the data to be transmitted is external data, determine the TCP / IP protocol stack as the target protocol stack.
[0133] In an implementation manner, the internal data is data generated by an application deployed in an electronic device; or, the external data is USB data or Wi-Fi data received by the electronic device.
[0134] It should be noted here that the above data transmission device 10 provided by this application can implement all the method steps implemented in the above method embodiments and can achieve the same technical effects. Therefore, the same parts and beneficial effects as those in the method embodiments will not be specifically described herein.
[0135] Figure 11 This is a schematic structural diagram of the data transmission device 20 provided by an embodiment of this application. This device 20 is applied to an electronic device that supports multiple protocol stacks, such as Figure 11 As shown, this device 20 includes: a transceiver 21, a memory 22, and a processor 23. The transceiver 21 may include: a transmitter and / or a receiver. The transmitter may also be referred to as a sender, transmitter, transmission port, or transmission interface, etc., and the receiver may also be referred to as a receiver, receiver, reception port, or reception interface, etc. Exemplarily, the transceiver 21, the memory 22, and the processor 23 are interconnected with each other through a bus 24.
[0136] The transceiver 21 is used to perform the transceiver function of the data transmission device 20 in the above data transmission method.
[0137] The memory 22 is used to store a computer program;
[0138] The processor 23 is used to read the computer program in the memory 22, so that the data transmission device 20 performs the following operations:
[0139] Obtain at least one data to be transmitted;
[0140] For any one of the at least one data to be transmitted, determine a target protocol stack for transmitting the data to be transmitted among multiple protocol stacks;
[0141] Transmit the data to be transmitted through the target protocol stack.
[0142] In one implementation, the processor 23 is specifically used to perform the following operations:
[0143] Determine the type of the data to be transmitted;
[0144] According to the type of the data to be transmitted, determine the target protocol stack among multiple protocol stacks.
[0145] In one implementation, the processor 23 is specifically used to perform the following operations:
[0146] According to the type of the data to be transmitted, obtain indication information;
[0147] According to the indication information, determine the target protocol stack among multiple protocol stacks.
[0148] In one implementation, the processor 23 is specifically used to perform the following operations:
[0149] The type of data to be transmitted is internal data, and indication information is obtained through the API;
[0150] The type of data to be transmitted is external data, and indication information is obtained by triggering an event.
[0151] In one embodiment, the multiple protocol stacks include a TCP / IP protocol stack and an LwIP protocol stack; the processor 23 is specifically configured to perform the following operations:
[0152] If the indication information indicates the LwIP protocol stack, then the LwIP protocol stack is determined as the target protocol stack; or, if the indication information indicates the TCP / IP protocol stack, then the TCP / IP protocol stack is determined as the target protocol stack.
[0153] In one embodiment, the multiple protocol stacks include a TCP / IP protocol stack and an LwIP protocol stack; the processor 23 is specifically configured to perform the following operations:
[0154] If the type of data to be transmitted is internal data, then the LwIP protocol stack is determined as the target protocol stack; or, if the type of data to be transmitted is external data, then the TCP / IP protocol stack is determined as the target protocol stack.
[0155] In one embodiment, the internal data is data generated by an application deployed in the electronic device; or, the external data is USB data or Wi-Fi data received by the electronic device.
[0156] The data transmission device 20 may be a chip, a module, an integrated development environment (IDE), etc.
[0157] It should be noted here that the above data transmission device 20 provided in the present application can implement all the method steps implemented in the above method embodiments, and can achieve the same technical effects. The same parts and beneficial effects as those in the method embodiments are not specifically described herein again.
[0158] The embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed on a computer, the communication method in any one of the above is executed.
[0159] The embodiment of the present application may further provide a computer program product, which can be executed by a processor. When the computer program product is executed by a computer, the communication method in any one of the above is executed.
[0160] All or part of the steps of the above method embodiments can be completed by hardware related to program instructions. The foregoing program can be stored in a readable memory. When the program is executed, it performs the steps including the above method embodiments; and the foregoing memory (storage medium) includes: read only memory (ROM), random access memory (RAM), flash memory, hard disk, solid state drive, magnetic tape, floppy disk, optical disc, and any combination thereof.
[0161] Embodiments of the present application are described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, and the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processing unit of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate for implementation in the process Figure 1 one process or multiple processes and / or blocks Figure 1 a device for the function specified in one block or multiple blocks.
[0162] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory generate a manufactured product including an instruction device, and the instruction device implements the process Figure 1 one process or multiple processes and / or blocks Figure 1 a function specified in one block or multiple blocks.
[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide for implementing the process Figure 1 one process or multiple processes and / or blocks Figure 1 steps for the function specified in one block or multiple blocks.
[0164] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application also intends to include these changes and modifications.
Claims
1. A data transmission method, characterized in that, Applied to an electronic device supporting multiple protocol stacks, the method includes: Obtain at least one data to be transmitted; For any one of the at least one data to be transmitted, determine a target protocol stack for transmitting the data to be transmitted among the multiple protocol stacks; Transmit the data to be transmitted through the target protocol stack.
2. The method according to claim 1, wherein The determining a target protocol stack for transmitting the data to be transmitted among the multiple protocol stacks includes: Determine the type of the data to be transmitted; According to the type of the data to be transmitted, determine the target protocol stack among the multiple protocol stacks.
3. The method according to claim 2, wherein The determining the target protocol stack among the multiple protocol stacks according to the type of the data to be transmitted includes: Obtain indication information according to the type of the data to be transmitted; According to the indication information, determine the target protocol stack among the multiple protocol stacks.
4. The method according to claim 3, characterized in that The obtaining indication information according to the type of the data to be transmitted includes: When the type of the data to be transmitted is internal data, obtain the indication information through an application programming interface (API); When the type of the data to be transmitted is external data, obtain the indication information by triggering an event.
5. The method according to claim 3 or 4, characterized in that The multiple protocol stacks include a TCP / IP protocol stack and an LwIP protocol stack; The determining the target protocol stack among the multiple protocol stacks according to the indication information includes: If the indication information indicates the LwIP protocol stack, determine the LwIP protocol stack as the target protocol stack; Or, If the indication information indicates the TCP / IP protocol stack, determine the TCP / IP protocol stack as the target protocol stack.
6. The method according to claim 2, wherein The multiple protocol stacks include a TCP / IP protocol stack and an LwIP protocol stack; The determining the target protocol stack among the multiple protocol stacks according to the type of the data to be transmitted includes: If the type of the data to be transmitted is internal data, determine the LwIP protocol stack as the target protocol stack; Or, If the type of the data to be transmitted is external data, determine the TCP / IP protocol stack as the target protocol stack.
7. The method according to any one of claims 3-6, characterized in that, The internal data is data generated by an application deployed in the electronic device; or, The external data is universal serial bus (USB) data or Wi-Fi data received by the electronic device.
8. A data transmission device, characterized in that, Applied to an electronic device supporting multiple protocol stacks, the apparatus includes: An obtaining module, configured to obtain at least one data to be transmitted; A determining module, configured to, for any one of the at least one data to be transmitted, determine a target protocol stack for transmitting the data to be transmitted among the multiple protocol stacks; A transmitting module, configured to transmit the data to be transmitted through the target protocol stack.
9. A data transmission device, characterized in that, Applied to an electronic device supporting multiple protocol stacks, the apparatus includes: a processor and a memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, the method according to any one of claims 1-7 is implemented.
11. A computer program product, characterized in that, It includes a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1-7 is implemented.