Data transmission method and device

By setting a preset send queue in the host, parallel data transmission of the USB interface is realized, which solves the problem of long-term transmission of multiple pending data on the USB interface and improves processing speed.

CN119324928APending Publication Date: 2025-01-17ZHENGZHOU XINDA JIEAN INFORMATION TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411250966.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2025-01-17

AI Technical Summary

Technical Problem

In the prior art, when the host communicates with an external device through a USB interface, it is unable to efficiently transmit multiple data to be processed, resulting in a long transmission time and affecting the overall processing speed.

Method used

By setting a preset send queue, it supports parallel encapsulation and filling of multiple pending data, and uses the USB interface to transmit in parallel, saving transmission time and improving processing speed.

Benefits of technology

The parallel encapsulation and transmission of multiple pending data is realized, which significantly saves transmission time and improves the overall processing speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119324928A_ABST
    Figure CN119324928A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data transmission method and device which are applied to a host, the host is in communication connection with external equipment through a USB interface, and the method comprises the following steps: acquiring a plurality of node application requests; distributing sending nodes in a preset sending queue to each node application request; packaging the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the packaged to-be-processed data into the corresponding sending node; sending the to-be-processed data filled in the sending node to the external equipment through the USB interface; and obtaining operation result data fed back by the external equipment. Compared with the prior art, according to the technical scheme of the embodiment of the invention, the packaging time of the to-be-processed data is saved, the transmission time of multiple pieces of to-be-processed data is further saved, and the overall processing speed is also improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the field of communication technology, and in particular to a data transmission method and device. Background Art

[0002] With the development of technology and economy, computers are becoming more and more popular in people's social life, and their application fields are becoming more and more extensive. Generally speaking, a computer consists of a host and external devices. Among them, the host includes core components such as the central processing unit, memory, and hard disk, which complete most of the computer's calculations. External devices communicate with the host through various communication interfaces to assist the host in completing computing tasks such as input, output, network connection, and encryption.

[0003] At present, the communication interfaces between the host and the external devices include USB (Universal Serial Bus) interface, HDMI (High Definition Multimedia Interface) interface, PCIE (Peripheral Component Interconnect Express) interface, etc. Among them, the USB interface has gradually become the most widely used communication interface between the host and the external devices due to its advantages such as high communication efficiency and hot plug support.

[0004] However, in some scenarios, the host needs to send the to-be-processed data of multiple users to an external device for auxiliary processing, which is not friendly to the host and external device connected by a USB interface. For example, in a scenario where the background server needs to send multiple to-be-processed data to a password card for signing, and feed back the to-be-processed data signed by the password card to the terminal device that initiated the data acquisition request, the existing technology can only encapsulate one to-be-processed data at a time and send it to the external device, resulting in a long transmission time for multiple to-be-processed data and affecting the overall processing speed. Summary of the invention

[0005] The embodiments of the present invention aim to solve one of the technical problems in the related art at least to a certain extent.

[0006] To this end, an embodiment of the present invention discloses a data transmission method and device, which supports parallel encapsulation and filling of multiple data to be processed by setting a preset sending queue, saving the encapsulation time of the data to be processed, thereby saving the transmission time of multiple data to be processed and improving the overall processing speed.

[0007] In a first aspect, an embodiment of the present invention provides a data transmission method, which is applied to a host, wherein the host is communicatively connected to an external device via a USB interface, and the method comprises: Obtain multiple node application requests, wherein each node application request is initiated by a user; Allocate the sending nodes in the preset sending queue to each node application request; In parallel, the to-be-processed data of each user and the corresponding sending node identifier are encapsulated according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node; Sending the to-be-processed data filled into the sending node to the external device via the USB interface; Obtaining the calculation result data fed back by the external device; wherein the calculation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.

[0008] In a specific embodiment of the first aspect, encapsulating the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the encapsulated to-be-processed data into the corresponding sending node, includes: The data to be processed of each user is divided in parallel, each divided data and the corresponding sending node identifier are encapsulated into a data packet of a preset size according to a preset communication protocol, and the data packet is filled into the corresponding sending node; Sending the data to be processed filled in the sending node to the external device through the USB interface includes: Send a preset number of data packets to the external device via the USB interface; wherein the preset number is determined according to the maximum cache data volume of the data received by the external device and the preset size.

[0009] In a specific embodiment of the first aspect, sending the to-be-processed data filled in the sending node to the external device through a USB interface includes: When the number of sending nodes in the filling state is greater than or equal to a preset number, sending the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than a preset number, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to the preset number, wait until the number of sending nodes in the filling state is greater than or equal to the preset number, and send the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than the preset number, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than the preset number, when all sending nodes are filled, all remaining data packets are sent to the external device through the USB interface.

[0010] In a specific embodiment of the first aspect, there are multiple preset sending queues, and the pending data with the same processing requirements are allocated to the sending nodes in the same preset sending queue, and the pending data with different processing requirements are allocated to the sending nodes in different preset sending queues.

[0011] In a specific embodiment of the first aspect, for each preset sending queue, the step of sending the to-be-processed data filled in the sending node to the external device through the USB interface is executed in a preset order, and each preset sending queue sends the to-be-processed data of a preset length each time.

[0012] In a specific embodiment of the first aspect, the method further includes: For any data to be processed, if the calculation result data fed back by the external device is not received within the preset time period, the step of obtaining the node application request corresponding to the data to be processed is performed again.

[0013] In a specific embodiment of the first aspect, when the user is an application program and there are multiple data to be processed, the process of the user initiating a node application request includes: The user initiates node application requests for each piece of data to be processed; or, The user creates multiple threads, each of which initiates a node application request; or, Alternatively, the user merges multiple data to be processed into one data to be processed and initiates a node application request.

[0014] In a specific embodiment of the first aspect, the method further includes: Allocating receiving nodes in a preset receiving queue to each node application request; wherein the sending nodes in the preset sending queue and the receiving nodes in the preset receiving queue are in a one-to-one correspondence; Parsing the calculation result data and filling the calculation result data into the corresponding receiving node; Each user obtains the operation result data from the receiving node in parallel.

[0015] In a specific embodiment of the first aspect, the preset receiving queue reuses the preset sending queue, or the preset receiving queue does not reuse the preset sending queue.

[0016] In a specific embodiment of the first aspect, the data to be processed filled into the sending node is sent to the external device through a USB interface; the step of receiving the calculation result data fed back by the external device is executed by the kernel thread, and the other steps are executed by the application in the user space.

[0017] In a specific embodiment of the first aspect, each sending node fills a data packet, and the preset size matches the single packet data length supported by the external device.

[0018] In a specific embodiment of the first aspect, the applied sending nodes are continuous, and the data packets sent to the external device through the USB interface originate from the continuous sending nodes.

[0019] In a specific embodiment of the first aspect, the external device is a password card.

[0020] In a second aspect, an embodiment of the present invention further discloses a data transmission device, which is applied to a host, and the host is communicatively connected with the external device via a USB interface, and the device comprises: An acquisition unit, used to acquire multiple node application requests, wherein each node application request is initiated by a user; An allocating unit, used for allocating a sending node in a preset sending queue to each node application request; A filling unit, used to encapsulate the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and fill the encapsulated to-be-processed data into the corresponding sending node; A sending unit, used to send the to-be-processed data filled in the sending node to the external device through a USB interface; The receiving unit is used to obtain the operation result data fed back by the external device; wherein the operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.

[0021] In a specific embodiment of the second aspect, the filling unit is specifically used for: The data to be processed of each user is divided in parallel, each divided data and the corresponding sending node identifier are encapsulated into a data packet of a preset size according to a preset communication protocol, and the data packet is filled into the corresponding sending node; The sending unit is specifically used for: Send a preset number of data packets to the external device via the USB interface; wherein the preset number is determined according to the maximum cache data volume of the data received by the external device and the preset size.

[0022] In a specific embodiment of the second aspect, the sending unit is specifically configured to: When the number of sending nodes in the filling state is greater than or equal to a preset number, sending the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than a preset number, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to the preset number, wait until the number of sending nodes in the filling state is greater than or equal to the preset number, and send the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than the preset number, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than the preset number, when all sending nodes are filled, all remaining data packets are sent to the external device through the USB interface.

[0023] In a specific embodiment of the second aspect, there are multiple preset sending queues, and the pending data with the same processing requirements are allocated to the sending nodes in the same preset sending queue, and the pending data with different processing requirements are allocated to the sending nodes in different preset sending queues.

[0024] In a specific embodiment of the second aspect, the sending unit is specifically used to execute the step of sending the to-be-processed data filled in the sending node to the external device through the USB interface in a preset order for each preset sending queue, and each preset sending queue sends the to-be-processed data of a preset length each time.

[0025] In a specific embodiment of the second aspect, the receiving unit is further used for: For any data to be processed, if the calculation result data fed back by the external device is not received within a preset time period, the acquisition unit is called again to execute the step of acquiring the node application request corresponding to the data to be processed.

[0026] In a specific embodiment of the second aspect, when the user is an application program and there are multiple data to be processed, the process of the user initiating a node application request includes: The user initiates node application requests for each piece of data to be processed; or, The user creates multiple threads, each of which initiates a node application request; or, Alternatively, the user merges multiple data to be processed into one data to be processed and initiates a node application request.

[0027] In a specific embodiment of the second aspect, the allocation unit is further used for: Allocating receiving nodes in a preset receiving queue to each node application request; wherein the sending nodes in the preset sending queue and the receiving nodes in the preset receiving queue are in a one-to-one correspondence; The receiving unit is further used to: parse the operation result data and fill the operation result data into the corresponding receiving node, so that each user can obtain the operation result data from the receiving node in parallel.

[0028] In a specific embodiment of the second aspect, the preset receiving queue reuses the preset sending queue, or the preset receiving queue does not reuse the preset sending queue.

[0029] In a specific embodiment of the second aspect, the sending unit and the receiving unit are located in a kernel thread, and the other units are located in an application program in a user space.

[0030] In a specific embodiment of the second aspect, each sending node fills a data packet, and the preset size matches the single packet data length supported by the external device.

[0031] In a specific embodiment of the second aspect, the applied sending nodes are continuous, and the data packets sent to the external device through the USB interface originate from the continuous sending nodes.

[0032] In a specific embodiment of the second aspect, the external device is a password card.

[0033] Beneficial effects of the embodiments of the present invention: A data transmission method and device provided by an embodiment of the present invention is applied to a host, and the host is connected to an external device through a USB interface. The method includes: obtaining multiple node application requests; assigning a sending node in a preset sending queue to each node application request; encapsulating the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the encapsulated to-be-processed data into the corresponding sending node; sending the to-be-processed data filled into the sending node to the external device through a USB interface; and obtaining the operation result data fed back by the external device. The technical solution of the embodiment of the present invention allocates a sending node in a preset sending queue to each node application request, so that each node application request has a sending node respectively, and then the to-be-processed data of each user and the corresponding sending node identifier can be encapsulated in parallel according to the preset communication protocol, so as to realize the parallel encapsulation of the to-be-processed data of each user. Compared with the prior art, the technical solution of the embodiment of the present invention saves the encapsulation time of the to-be-processed data because there is no need to wait for the encapsulation of the previous to-be-processed data to be completed before encapsulating the next to-be-processed data, thereby saving the transmission time of multiple to-be-processed data and improving the overall processing speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram of a data transmission method according to an embodiment of the present invention; Figure 2A schematic diagram of a flow chart of another data transmission method provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a data transmission device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0035] In order to more clearly understand the above-mentioned purposes, features and advantages of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the technical concept of the embodiments of the present invention belong to the scope of protection of the present invention.

[0036] As mentioned in the background technology, for application scenarios where the host needs to send the to-be-processed data of multiple users to an external device for auxiliary processing through a USB interface, the prior art can only encapsulate one to-be-processed data at a time and send it to the external device, resulting in a long transmission time for multiple to-be-processed data and affecting the overall processing speed. To address this problem, an embodiment of the present invention provides a data transmission method and device, which supports the parallel encapsulation and filling of multiple to-be-processed data by setting a preset sending queue, saving the encapsulation time of the to-be-processed data, thereby saving the transmission time of multiple to-be-processed data and improving the overall processing speed. The following is a more detailed description of the embodiment of the present invention.

[0037] Before describing the data transmission method of the embodiment of the present invention, the application scenario of the embodiment of the present invention is first exemplified so as to have a more intuitive understanding of the technical solution of the embodiment of the present invention. One possible scenario is that a background server (such as a background server providing high-precision map services, a server providing government services, etc.) provides services for terminal devices that access it. Each terminal device needs to determine the identity of the background server, and the background server needs to sign the information to be sent to the terminal device (i.e., the data to be processed). At this time, the background server needs to send multiple data to be processed to an external device connected to the USB interface for signature. Another possible scenario is that the host needs to assist in encrypting multiple data to be processed with the password card connected to it through the USB interface. At this time, the host needs to send multiple data to be processed to the external device connected to the USB interface for encryption. It should be noted that this is only an exemplary description of the application scenario of the embodiment of the present invention. The data transmission method of the embodiment of the present invention is not limited to the aforementioned application scenario. The working conditions such as gateways, domain controllers, etc. that need to process multiple data to be processed by external devices connected to the USB interface can all use the technical solution provided by the embodiment of the present invention.

[0038] Furthermore, after the application scenarios of the embodiments of the present invention are exemplarily described, the technical solution itself is described in conjunction with the accompanying drawings. Figure 1 As shown, Figure 1 A flow chart of a data transmission method provided by an embodiment of the present invention. The data transmission method is applied to a host, and the host is connected to an external device through a USB interface. The host can be a background server, a desktop host, a laptop computer, or other electronic device that can be connected to an external device through a USB interface, and the external device is required to sign, hash, and / or encrypt multiple data to be processed. The external device can be an electronic device such as an encryption card, a multimedia computer, etc. that can assist the host in data processing.

[0039] Specifically, Figure 1 The data transmission method shown comprises the following steps: In step S101, multiple node application requests are obtained.

[0040] Each node application request is initiated by a user. In actual applications, a user can be an application or a thread of an application. When a user needs to send data to be processed to an external device for data processing, the user initiates a node application request.

[0041] In step S102, a sending node in a preset sending queue is allocated to each node application request.

[0042] Among them, the preset sending queue can be pre-configured in the kernel of the host, and each sending node in the preset sending queue has a corresponding sending node identifier. It can be understood that the sending node here is a logical node. For any node application request, the number of nodes allocated for the node application request is determined according to the length of the pending data of the user who initiated the node application request and the storage space of each sending node. For example, the effective data length that can be accommodated by the storage space of each sending node in the preset sending queue is 2KB, and the length of the pending data of the user who initiated a node application request is 10KB, then 5 sending nodes need to be allocated for the node application request. It can be concluded here that the node application request should include the length information of the user's pending data. It should be noted that when the effective data length that can be stored in the storage space of each sending node is 2KB, 2KB is only the effective data length, and the storage space of each sending node should actually be greater than 2KB, because the storage space of each sending node needs to store data description information such as data length and check value in addition to storing the effective data length.

[0043] Generally, a sending node is assigned to each node application request according to the order in which each user initiates the node application request, and the sending nodes corresponding to each node application request are continuous, and the sending nodes of each node application request are also continuous. Of course, in theory, there can be other allocation rules, such as assigning each sending node to each node application request at intervals. But it is obvious that the sequential allocation method is simple in logic, easier to implement in code, and in line with people's thinking habits.

[0044] In step S103, the to-be-processed data of each user and the corresponding sending node identifier are encapsulated in parallel according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node.

[0045] Among them, the preset encapsulation protocol is a private communication data packet format between the host and the external device. The host encapsulates the data to be processed according to this data packet format and fills it into the corresponding sending node. The destination tag data source identified by the encapsulated sending node is convenient for establishing the corresponding relationship between the host's data to be processed and the calculation result data of the external device. Generally, the preset encapsulation protocol is related to the data processing requirements. For example, if the data to be processed needs to be signed by SM2, the preset encapsulation protocol is the data packet format required by the SM2 key interaction protocol.

[0046] Furthermore, when the user's pending data is long and there are multiple sending nodes assigned to the user's pending data, it is necessary to divide the pending data of each user in parallel, encapsulate each divided data and the corresponding sending node identifier into a data packet of a preset size according to the preset communication protocol, and fill the data packet into the corresponding sending node. Generally, the preset size matches the storage space size of the sending node, that is, one data packet occupies one sending node. Obviously, the length of each divided data is also related to the preset size, and it is necessary to satisfy that the length after encapsulating the divided data and the corresponding sending node identifier is equal to the preset size. If the remaining data length after the division is not enough to fill a sending node, the remaining data length and the corresponding sending node identifier are also encapsulated into a data packet. In addition, in actual applications, when setting the storage space and preset size of each sending node, the single-packet data length supported by the external device can be considered at the same time, so that the preset size matches the single-packet data length supported by the external device, that is, the length of the divided data is equal to the single-packet data length supported by the external device. In this way, the external device can directly process the received data packet, further improving the data processing and transmission efficiency.

[0047] It should be noted that, in theory, the storage space of each sending node can be designed to be large enough, and there is no need to split the data to be processed, but this will cause a waste of storage space, and because the lengths of the data to be processed are different or even quite different, it may cause a large gap in filling time, which ultimately affects the data transmission efficiency. In addition, in theory, multiple data packets can also be stored in one sending node, but this will require the storage order of multiple data packets belonging to the same sending node to be stored at the same time, and multiple data packets belonging to the same sending node cannot be stored synchronously, which will make the data transmission logic complicated and affect the data transmission efficiency to a certain extent. Therefore, it is generally adopted to split the data to be processed, and to separately assign a sending node to each data packet obtained by encapsulating the split data and the sending node identifier. It is understandable that when the length of the data to be processed is small and one sending node can meet the filling requirements, there is no need to split the data to be processed.

[0048] In this step, the parallel relationship between the sending nodes enables each user's to-be-processed data and the corresponding sending node identifier to be encapsulated according to the preset communication protocol, and the process of filling the encapsulated to-be-processed data into the corresponding sending node can be carried out in parallel without affecting each other, thereby realizing the parallel encapsulation and filling of multiple to-be-processed data. Compared with the prior art, multiple to-be-processed data do not need to be encapsulated sequentially. In addition, due to the high transmission rate of USB, the parallel processing method can greatly improve the overall data transmission efficiency.

[0049] In step S104, the data to be processed filled in the sending node is sent to the external device through the USB interface.

[0050] Specifically, for the to-be-processed data filled into the sending node, the host may send the to-be-processed data in one sending node at a time, or may send the to-be-processed data in multiple sending nodes to the external device in batches.

[0051] In step S105, the calculation result data fed back by the external device is obtained.

[0052] The operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one. Generally, the sending node identifier and the receiving node identifier are the same to characterize the correspondence between the operation result data and the sending node, or the one-to-one correspondence between the standard operation result data and the encapsulated data to be processed.

[0053] It should be noted that, due to the inherent characteristics of the USB protocol, the host needs to actively send a request to obtain a calculation result to the external device in order to obtain the calculation result data fed back by the external device.

[0054] The data transmission method provided by the embodiment of the present invention is applied to a host, and the host is connected to an external device through a USB interface. The method includes: obtaining multiple node application requests; assigning a sending node in a preset sending queue to each node application request; encapsulating the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and filling the encapsulated to-be-processed data into the corresponding sending node; sending the to-be-processed data filled into the sending node to the external device through a USB interface; and obtaining the calculation result data fed back by the external device. The technical solution of the embodiment of the present invention allocates a sending node in a preset sending queue to each node application request, so that each node application request has a sending node respectively, and then the to-be-processed data of each user and the corresponding sending node identifier can be encapsulated in parallel according to the preset communication protocol, so as to realize the parallel encapsulation of the to-be-processed data of each user. Compared with the prior art, the technical solution of the embodiment of the present invention saves the encapsulation time of the to-be-processed data, thereby saving the transmission time of multiple to-be-processed data, and also improves the overall processing speed.

[0055] Furthermore, considering that the actual transmission capacity of the USB transmission protocol is strong and the encapsulated data packets are generally small, if single-packet transmission is adopted, the transmission efficiency and processing rate of the data to be processed will be affected, resulting in low transmission efficiency and processing efficiency of the data to be processed. Therefore, in some implementations of the embodiments of the present invention, the encapsulated data packets are transmitted in batch transmission. Specifically, step S104 may include: Send a preset number of data packets to an external device via the USB interface.

[0056] The preset number is determined according to the maximum cache data volume and the preset size of the data received by the external device. For example, if the maximum cache data volume of the data received by the external device is 26KB and the preset size is 2KB, the preset number is equal to 13. In practical applications, the preset number of data packets can be packaged and sent to the external device through the USB interface.

[0057] This specific implementation method transmits data packets in batches, fully utilizing the strong actual transmission capability of the USB transmission protocol, thereby improving the transmission efficiency and overall processing efficiency of the data to be processed.

[0058] Furthermore, considering that in some working conditions, the number of data packets filled into the sending node is not always an integer multiple of the preset number, in some implementations of the embodiments of the present invention, step S104 may include: When the number of sending nodes in the filling state is greater than or equal to a preset number, the preset number of data packets are sent to the external device via the USB interface; When the number of sending nodes in the filling state is less than the preset number, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to the preset number, wait until the number of sending nodes in the filling state is greater than or equal to the preset number, and then send the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than the preset number, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than the preset number, when all sending nodes are filled, all remaining data packets are sent to the external device through the USB interface.

[0059] Among them, since the data in the sending node is constantly filled, the number of sending nodes in the filling state is constantly changing. Each time step S104 is executed, the number of sending nodes in the filling state will be obtained in real time. The remaining number of applied sending nodes refers to the number of sending nodes that have been applied for but not yet filled each time step S104 is executed. Obviously, under some working conditions, the number of sending nodes that have been applied for but not yet filled can be equal to 0.

[0060] This specific implementation method can dynamically adjust the number of data packets sent to the external device in batches while minimizing the number of data transmission times according to the filling and application status of the sending node, thereby fully utilizing the data transmission capacity of the USB interface.

[0061] Furthermore, considering that some external devices support multiple operations, such as some password cards that support SM2 signature operations, SM3 hash operations, and SM4 encryption and decryption operations at the same time, the inventors have come up with the idea of ​​configuring preset sending queues for the data to be processed with different processing requirements, and for each preset sending queue, synchronously executing the steps of encapsulating the data to be processed of each user and the corresponding sending node identifier according to the preset communication protocol in parallel, so as to achieve synchronous transmission and processing of the data to be processed with different requirements, and further improve the data transmission efficiency.

[0062] Specifically, in some implementations of the embodiments of the present invention, there are multiple preset sending queues, and the to-be-processed data with the same processing requirements are allocated to the sending nodes in the same preset sending queue, and the to-be-processed data with different processing requirements are allocated to the sending nodes in different preset sending queues. It should be noted that when there are multiple preset sending queues, if a data packet batch transmission method is adopted, then for each preset sending queue, the step of sending a preset number of data packets to the external device through the USB interface is performed separately, that is, the preset number corresponding to each preset sending queue is counted separately. In addition, in order to enable the external device to distinguish data from different preset sending queues, the data packet sent to the external device should also include a queue identifier. Of course, the corresponding operation result data should also include the same queue identifier.

[0063] Furthermore, when there are multiple preset sending queues, considering that the USB interface is unique, different preset sending queues may preempt or continuously occupy the USB interface, resulting in the inability to carry out related services in a timely manner. In some implementations of the embodiments of the present invention, for each preset sending queue, the step of sending the to-be-processed data filled in the sending node to the external device through the USB interface is executed in a preset order, and each preset sending queue sends the to-be-processed data of a preset length each time. Among them, the preset order of each preset sending queue can be agreed in advance in the host. The preset length can be flexibly set according to actual needs. For example, the preset length can be equal to the length of a preset number of data packets. For another example, the preset length can be equal to n times the length of a preset number of data packets, where n≥2. In addition, in actual applications, different logical channels can be configured for to-be-processed data with different processing requirements so that external devices can distinguish the received data.

[0064] In this specific implementation, each preset sending queue sends a preset length of pending data each time, and each preset sending queue cyclically sends the pending data in a preset order to balance the transmission and processing of pending data for various processing requirements, avoid continuous inability to execute related services, and improve user experience.

[0065] Considering that in actual applications, due to various reasons such as the interruption of the connection between the host and the external device, the host fails to receive the calculation result data in time, which leads to the failure of related services. To this end, in some implementations of the embodiments of the present invention, the data transmission method may also include: for any data to be processed, if the calculation result data fed back by the external device is not received within a preset time, the step of obtaining the node application request corresponding to the data to be processed is executed again. The preset time is determined according to the needs of the related services.

[0066] In this implementation, for any data to be processed, when the calculation result data fed back by the external device is not received within the preset time period, the step of obtaining the node application request corresponding to the data to be processed is executed again to execute the processing and transmission process of the data to be processed again, thereby improving the business success rate.

[0067] It should be noted that, in theory, for any data to be processed, if the calculation result data fed back by the external device is not received within the preset time, the step of sending the data to be processed filled in the sending node to the external device through the USB interface can be executed again. However, this implementation method requires retaining the data to be processed in the sending node until the corresponding calculation result data is received, and the corresponding data search logic needs to be designed. Compared with the method of directly obtaining the node application request corresponding to the data to be processed, the implementation method is complicated.

[0068] Furthermore, when the user is an application, each user may have multiple data to be processed. When the user is an application and there are multiple data to be processed, one possible solution is that the user initiates node application requests for each data to be processed respectively; another possible solution is that the user creates multiple threads, and each thread initiates a node application request; another possible solution is that the user merges multiple data to be processed into one data to be processed and initiates a node application request.

[0069] Alternatively, see Figure 2 As shown, in Figure 1 Based on the illustrated embodiment, the data transmission method of the embodiment of the present invention may further include: In step S201, a receiving node in a preset receiving queue is allocated to each node application request.

[0070] Among them, the preset receiving queue can be pre-configured in the kernel of the host, and is specifically obtained by the driver program. The sending node in the preset sending queue and the receiving node in the preset receiving queue are in a one-to-one correspondence. Correspondingly, the sending node identifier and the receiving node identifier also correspond one-to-one. In addition, it is obvious that it is necessary to ensure that each sending node and receiving node only corresponds to one user, and there will not be a situation where multiple users apply for the same sending node or receiving node.

[0071] In step S202, the calculation result data is parsed and filled into the corresponding receiving node.

[0072] Specifically, the corresponding receiving node is determined according to the receiving node identifier in the operation result data.

[0073] In step S203, each user obtains the calculation result data from the receiving node in parallel.

[0074] It is understandable that when there are multiple preset sending queues, there are also multiple preset receiving queues, and the preset sending queues correspond to the preset receiving queues one by one. The one-to-one corresponding preset sending queues and preset receiving queues have the same queue identifier, and the preset receiving queue corresponding to the operation result data can be determined according to the queue identifier.

[0075] In this specific implementation, by setting a preset receiving queue, each user can obtain operation result data from the receiving node in parallel, further improving data transmission efficiency.

[0076] In particular, since sending and receiving are sequential, in theory, after the data in the sending node of the preset sending queue is sent out, the subsequently received calculation result data can be filled into the node, that is, the preset receiving queue reuses the preset sending queue. Of course, the preset receiving queue may not reuse the preset sending queue. Generally, the method of using the preset receiving queue not to reuse the preset sending queue is adopted, so that it is easy to implement when programming, and easy to troubleshoot when errors occur.

[0077] Optionally, in some implementations of the embodiments of the present invention, the data to be processed filled into the sending node is sent to an external device via a USB interface; the step of receiving the calculation result data fed back by the external device is executed by a driver located in the kernel, specifically by a kernel thread in the driver, and the other steps are executed by an application in the user space. It should be noted that the application in the user space here is not the user who initiates the node application request, and the application can be understood as an application that executes the data transmission method of the embodiment of the present invention. The kernel thread plays a monitoring role and a sending and receiving role. When the data of the sending node meets the sending requirements, the corresponding data to be processed is sent to the external device, and the calculation result data fed back by the external device is received.

[0078] For example, for Figure 1 For example, steps S101, S102, and S103 are executed by the application program in the user space, and steps S104 and S105 are executed by the kernel thread. Figure 1 In the illustrated embodiment, step S101, step S102, step S103 and step S201 are executed by an application in the user space, and step S104, step S105 and step S202 are executed by a kernel thread.

[0079] Specifically, in this implementation, the kernel thread is responsible for sending the to-be-processed data in the preset sending queue to the external device through the USB interface, and receiving the operation result data returned by the external device through the USB interface. When a preset receiving queue is also included, the kernel thread is also used to parse the operation result data and put the operation result data into the node corresponding to the receiving queue for the user to read.

[0080] More specifically, the kernel thread can be the kernel thread of the external device driver. In actual development, the producer-consumer mode in the design mode can be referred to. For the data sending process, the application in the user space is responsible for filling the to-be-processed data into the sending node of the preset sending queue, and the application in the user space belongs to the producer; the kernel thread is responsible for sending the data in the sending node of the preset sending queue to the external device through the USB interface, and the kernel thread belongs to the consumer. For the data receiving process, the kernel thread is responsible for receiving the operation result data returned by the external device, parsing the operation result data, and filling the parsed operation result data into the receiving node of the preset receiving queue, and the kernel thread belongs to the producer; the application in the user space is responsible for returning the operation result data in the receiving node of the preset receiving queue to the address specified by the user, and the application in the user space belongs to the consumer.

[0081] In particular, the above process can also be implemented entirely by the user space application. The purpose of introducing the kernel thread is to enable the user space application to continuously fill the to-be-processed data into the sending node of the preset sending queue while the kernel thread can simultaneously send the filled to-be-processed data to the external device, and then request the processed operation result data from the external device, and fill the requested operation result data into the receiving node corresponding to the preset receiving queue. It can be seen that the processing process of the user space application and the processing process of the kernel thread can overlap in time, so the introduction of the kernel thread to be responsible for sending and receiving improves the data transmission efficiency and processing efficiency as a whole.

[0082] Furthermore, in order to simplify the program coding, in general, the applied sending nodes are continuous. And in order to ensure that the pending data of a certain user is continuously sent to the external device, in some implementations of the embodiments of the present invention, the data packets sent to the external device through the USB interface are from continuous sending nodes. Obviously, at this time, if the sending nodes at the lower order have been filled, and the sending nodes at the upper order have not been filled, it is necessary to wait until the sending nodes at the upper order are filled to ensure that the data packets sent to the external device through the USB interface are from continuous sending nodes.

[0083] Corresponding to the above method embodiment, the embodiment of the present invention also discloses a data transmission device, which is applied to a host, and the host is connected to an external device through a USB interface. Figure 3 As shown, the data transmission device of the embodiment of the present invention may include: an acquisition unit 301 , an allocation unit 302 , a filling unit 303 , a sending unit 304 and a receiving unit 305 .

[0084] The acquisition unit 301 is used to acquire multiple node application requests, wherein each node application request is initiated by a user; The allocation unit 302 is used to allocate the sending nodes in the preset sending queue to each node application request; The filling unit 303 is used to encapsulate the to-be-processed data of each user and the corresponding sending node identifier in parallel according to the preset communication protocol, and fill the encapsulated to-be-processed data into the corresponding sending node; The sending unit 304 is used to send the to-be-processed data filled in the sending node to the external device through the USB interface; The receiving unit 305 is used to obtain the operation result data fed back by the external device; wherein the operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.

[0085] A data device provided by an embodiment of the present invention is applied to a host, and the host is connected to an external device through a USB interface. The technical solution of the embodiment of the present invention allocates a sending node in a preset sending queue to each node application request, so that each node application request has a sending node, and then the to-be-processed data of each user and the corresponding sending node identifier can be encapsulated in parallel according to a preset communication protocol, thereby realizing parallel encapsulation of the to-be-processed data of each user. Compared with the prior art, the technical solution of the embodiment of the present invention saves the encapsulation time of the to-be-processed data, thereby saving the transmission time of multiple to-be-processed data, and also improves the overall processing speed.

[0086] In some implementations of the embodiments of the present invention, the filling unit 303 is specifically used to: divide the to-be-processed data of each user in parallel, encapsulate each divided data and the corresponding sending node identifier into a data packet of a preset size according to a preset communication protocol, and fill the data packet into the corresponding sending node; The sending unit 304 is specifically used to send a preset number of data packets to the external device through the USB interface; wherein the preset number is determined according to the maximum cache data volume of the data received by the external device and the preset size.

[0087] In some implementations of the embodiments of the present invention, the sending unit 304 is specifically used to: When the number of sending nodes in the filling state is greater than or equal to a preset number, sending the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than a preset number, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to the preset number, wait until the number of sending nodes in the filling state is greater than or equal to the preset number, and send the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than the preset number, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than the preset number, when all sending nodes are filled, all remaining data packets are sent to the external device through the USB interface.

[0088] In some implementations of the embodiments of the present invention, the number of the preset sending queues is multiple, and the pending data with the same processing requirements are allocated to the sending nodes in the same preset sending queue, and the pending data with different processing requirements are allocated to the sending nodes in different preset sending queues.

[0089] In some implementations of the embodiments of the present invention, the sending unit 304 is specifically used to execute the step of sending the to-be-processed data filled in the sending node to the external device through the USB interface in a preset order for each preset sending queue, and each preset sending queue sends the to-be-processed data of a preset length each time.

[0090] In some implementations of the embodiments of the present invention, the receiving unit 305 is also used to: for any data to be processed, if the calculation result data fed back by the external device is not received within a preset time period, call the acquisition unit 301 again to execute the step of obtaining the node application request corresponding to the data to be processed.

[0091] In some implementations of the embodiments of the present invention, when the user is an application program and there are multiple data to be processed, the process of the user initiating a node application request includes: The user initiates node application requests for each piece of data to be processed; or, The user creates multiple threads, each of which initiates a node application request; or, Alternatively, the user merges multiple data to be processed into one data to be processed and initiates a node application request.

[0092] In some implementations of the embodiments of the present invention, the allocation unit 302 is further used to: allocate the receiving nodes in the preset receiving queue to each node application request; wherein the sending nodes in the preset sending queue and the receiving nodes in the preset receiving queue are in a one-to-one correspondence; The receiving unit 305 is further used to: parse the operation result data and fill the operation result data into the corresponding receiving node, so that each user can obtain the operation result data from the receiving node in parallel.

[0093] In some implementations of the embodiments of the present invention, the preset receiving queue reuses the preset sending queue, or the preset receiving queue does not reuse the preset sending queue.

[0094] In some implementations of the embodiments of the present invention, the sending unit 304 and the receiving unit 305 are located in the kernel thread, and other units are located in the application program in the user space.

[0095] In some implementations of the embodiments of the present invention, each sending node fills a data packet, and the preset size matches the single-packet data length supported by the external device.

[0096] In some implementations of the embodiments of the present invention, the applied sending nodes are continuous, and the data packets sent to the external device through the USB interface originate from the continuous sending nodes.

[0097] In some implementations of the embodiments of the present invention, the external device is a password card.

[0098] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention or certain parts of the embodiments.

[0099] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. In the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system and device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0100] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein, for example. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0101] The above-described embodiments of the present invention do not constitute a limitation on the protection scope of the present invention. Any modification, equivalent replacement and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A data transmission method, characterized in that: Applied to a host, the host is connected to an external device through a USB interface, and the method includes: Obtain multiple node application requests, wherein each node application request is initiated by a user; Allocate the sending nodes in the preset sending queue to each node application request; In parallel, the to-be-processed data of each user and the corresponding sending node identifier are encapsulated according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node; Sending the to-be-processed data filled into the sending node to the external device via the USB interface; Obtaining the calculation result data fed back by the external device; wherein the calculation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.

2. The method according to claim 1, characterized in that In parallel, each user's to-be-processed data and the corresponding sending node identifier are encapsulated according to a preset communication protocol, and the encapsulated to-be-processed data is filled into the corresponding sending node, including: The data to be processed of each user is divided in parallel, each divided data and the corresponding sending node identifier are encapsulated into a data packet of a preset size according to a preset communication protocol, and the data packet is filled into the corresponding sending node; Sending the data to be processed filled in the sending node to the external device through the USB interface includes: Send a preset number of data packets to the external device via the USB interface; wherein the preset number is determined according to the maximum cache data volume of the data received by the external device and the preset size.

3. The method according to claim 2, characterized in that Sending the data to be processed filled in the sending node to the external device through the USB interface includes: When the number of sending nodes in the filling state is greater than or equal to a preset number, sending the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than a preset number, and the number of sending nodes in the filling state plus the number of remaining applied sending nodes is greater than or equal to the preset number, wait until the number of sending nodes in the filling state is greater than or equal to the preset number, and send the preset number of data packets to the external device through the USB interface; When the number of sending nodes in the filling state is less than the preset number, and the number of sending nodes in the filling state plus the remaining number of applied sending nodes is less than the preset number, when all sending nodes are filled, all remaining data packets are sent to the external device through the USB interface.

4. The method according to claim 1, characterized in that: There are multiple preset sending queues, and the to-be-processed data with the same processing requirement are allocated to the sending nodes in the same preset sending queue, and the to-be-processed data with different processing requirements are allocated to the sending nodes in different preset sending queues.

5. The method according to claim 4, characterized in that For each preset sending queue, the step of sending the to-be-processed data filled in the sending node to the external device through the USB interface is executed in a preset order, and each preset sending queue sends the to-be-processed data of a preset length each time.

6. The method according to claim 1, characterized in that The method further comprises: For any data to be processed, if the calculation result data fed back by the external device is not received within the preset time period, the step of obtaining the node application request corresponding to the data to be processed is performed again.

7. The method according to claim 1, characterized in that The method further comprises: Allocating receiving nodes in a preset receiving queue to each node application request; wherein the sending nodes in the preset sending queue and the receiving nodes in the preset receiving queue are in a one-to-one correspondence; Parsing the calculation result data and filling the calculation result data into the corresponding receiving node; Each user obtains the operation result data from the receiving node in parallel.

8. The method according to any one of claims 1 to 7, characterized in that: The steps of sending the data to be processed filled in the sending node to the external device through the USB interface and receiving the operation result data fed back by the external device are executed by the kernel thread, and the other steps are executed by the application program in the user space.

9. The method according to any one of claims 2 or 3, characterized in that: Each sending node fills a data packet, and the preset size matches the single-packet data length supported by the external device.

10. A data transmission device, characterized in that: Applied to a host, the host is connected to the external device through a USB interface, and the device includes: An acquisition unit, used to acquire multiple node application requests, wherein each node application request is initiated by a user; An allocating unit, used for allocating a sending node in a preset sending queue to each node application request; A filling unit, used to encapsulate the to-be-processed data of each user and the corresponding sending node identifier in parallel according to a preset communication protocol, and fill the encapsulated to-be-processed data into the corresponding sending node; A sending unit, used to send the to-be-processed data filled in the sending node to the external device through a USB interface; The receiving unit is used to receive the operation result data fed back by the external device; wherein the operation result data includes a receiving node identifier, and the sending node identifier and the receiving node identifier correspond one to one.