CN115529282A - Data transmission method, terminal device and readable storage medium - Google Patents

Data transmission method, terminal device and readable storage medium Download PDF

Info

Publication number
CN115529282A
CN115529282A CN202110716703.4A CN202110716703A CN115529282A CN 115529282 A CN115529282 A CN 115529282A CN 202110716703 A CN202110716703 A CN 202110716703A CN 115529282 A CN115529282 A CN 115529282A
Authority
CN
China
Prior art keywords
data packet
data transmission
data
event
service
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110716703.4A
Other languages
Chinese (zh)
Inventor
周玉坤
翁同玖
付忞
王正
古亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sangfor Technologies Co Ltd
Original Assignee
Sangfor Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sangfor Technologies Co Ltd filed Critical Sangfor Technologies Co Ltd
Priority to CN202110716703.4A priority Critical patent/CN115529282A/en
Publication of CN115529282A publication Critical patent/CN115529282A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Abstract

The invention discloses a data transmission method, which comprises the following steps: after receiving a service data packet, adding the service data packet to a sending queue; monitoring a data transmission event through a preset event file descriptor; and if a data sending event is detected through the event file descriptor, taking out the service data packet in the sending queue, and sending the service data packet through a service thread. The invention also provides the terminal equipment and a readable storage medium. The data transmission method monitors the data transmission event through the preset event file descriptor, and further detects the data transmission event through the preset event file descriptor after receiving the service data packet, namely, the service data packet is transmitted through the service thread in time when the service data packet is transmitted, so that the CPU overhead is low, and the data packet can be actively transmitted.

Description

Data transmission method, terminal device and readable storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a data transmission method, a terminal device, and a readable storage medium.
Background
RDMA (Remote Direct Memory Access) is a new Memory Access technology that allows data to be transferred directly between the memories of two servers without the involvement of the CPU of either server, thus enabling more efficient communication.
For example, RDMA functionality may be implemented via RoCE (RDMA over conversion Ethernet), which is an Ethernet-based RDMA technique and runs an RDMA network protocol executing over Ethernet. However, in the process of implementing data transmission by the RoCE, due to the hardware mechanism of the RDMA network card, when a data packet to be transmitted exists, whether the data packet is transmitted or not can only be queried in a polling manner, which results in high CPU overhead, and an event signal for transmitting the data packet to be transmitted cannot be actively received, which results in failure to actively transmit the data packet.
The above is only for the purpose of assisting understanding of the technical aspects of the present invention, and does not represent an admission that the above is prior art.
Disclosure of Invention
The invention mainly aims to provide a data transmission method, a terminal device and a readable storage medium, and aims to solve the problem that when a data packet to be sent exists due to a hardware mechanism of an RDMA network card, an event signal for sending the data packet to be sent cannot be actively received, so that the data packet cannot be actively sent.
In order to achieve the above object, the present invention provides a data transmission method, including:
after receiving a service data packet, adding the service data packet to a sending queue;
monitoring a data transmission event through a preset event file descriptor;
and if a data sending event is monitored through the event file descriptor, taking out the service data packet in the sending queue, and sending the service data packet through a service thread.
Optionally, after the step of adding the service data packet to the transmission queue, the method includes:
acquiring a preset data transmission state identifier;
if the data transmission state identifier is an idle identifier, executing the monitoring of the data transmission event through a preset event file descriptor;
after the step of monitoring a data transmission event through the event file descriptor, the method includes:
switching the data transmission state identifier from an idle identifier to a working identifier
After the step of sending the service data packet through the service thread, the method includes:
and after the service data packet is sent, setting the data transmission state identifier as the idle identifier.
Optionally, after the step of adding the service data packet to the transmission queue, the method includes:
acquiring a preset data transmission state identifier;
if the data transmission state identifier is an idle identifier, switching the data transmission state identifier from the idle identifier to a working identifier, and executing the monitoring of the data transmission event through a preset event file descriptor;
after the step of sending the service data packet through the service thread, the method includes:
and after the service data packet is sent, setting the data transmission state identifier as the idle identifier.
Optionally, after the step of switching the data transmission status identifier from the idle identifier to the working identifier, the method includes:
starting a monitoring thread for detecting the data sending event through a preset event file descriptor;
after the service data packet is sent, the step of setting the data transmission state identifier as the idle identifier comprises the following steps:
and after the service data packet is sent, closing the monitoring thread for detecting the data sending event through the preset event file descriptor, and setting the data transmission state identifier as the idle identifier.
Optionally, the data transmission method includes:
after receiving the service data packet, judging whether the sending queue is empty;
if the sending queue is empty, sending the service data packet;
and if the sending queue is not empty, executing the step of adding the service data packet to the sending queue.
Optionally, after the step of sending the service data packet by the service thread, the method includes:
and receiving a message of the failure of sending the service data packet, and adding the service data packet to the sending queue.
Optionally, the step of obtaining the preset data transmission state identifier includes:
after establishing remote direct memory access connection with a data receiving end, establishing the event descriptor to monitor a data sending event through the event file descriptor;
the step of obtaining the preset data transmission state identifier comprises the following steps:
and when the remote direct memory access connection is disconnected with the data receiving end, the event file descriptor is cancelled.
Optionally, the data transmission method further includes:
monitoring a data receiving event corresponding to a preset file descriptor through a preset monitoring object, and acquiring a data packet to be received from a receiving queue, wherein the preset file descriptor does not include the event file descriptor;
and distributing the data packet to be received to a corresponding service thread according to the data identifier of the data packet to be received.
Optionally, after the step of distributing the data packet to be received to the corresponding service thread according to the data identifier of the data packet to be received, the method includes:
judging whether the receiving queue is empty or not;
if the receiving queue is not empty, executing the step of obtaining the data packet to be received from the receiving queue;
and if the receiving queue is empty, executing the step of monitoring a data receiving event corresponding to a preset file descriptor through a preset monitoring object.
In addition, to achieve the above object, the present invention further provides a terminal device, which includes a memory, a processor, and a data transmission program stored in the processor and operable on the processor, and when executed by the processor, the data transmission program implements the steps of the data transmission method as described above.
Furthermore, in order to achieve the above object, the present invention also provides a readable storage medium, which stores thereon a data transmission program, which when executed by the processor, implements the steps of the data transmission method as described above.
Compared with the problem that the CPU overhead is large because whether a data packet is sent or not can only be inquired in a polling mode, the data transmission method, the terminal device and the readable storage medium provided by the invention monitor the data sending event through the preset event file descriptor, and further detect the data sending event through the preset event file descriptor after the service data packet is received, namely, when the service data packet is sent, the service data packet is sent through the service thread in time, the CPU overhead is small, and the data packet can be sent actively.
Drawings
Fig. 1 is a block diagram of a terminal device according to various embodiments of a data transmission method of the present invention;
fig. 2 is a flowchart illustrating a first embodiment of a data transmission method according to the present invention;
FIG. 3 is a flowchart illustrating a data transmission method according to a second embodiment of the present invention;
fig. 4 is a flowchart illustrating a data transmission method according to a third embodiment of the present invention.
The implementation, functional features and advantages of the present invention will be further described with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In the following description, suffixes such as "module", "part", or "unit" used to indicate elements are used only for facilitating the description of the present invention, and have no particular meaning in themselves. Thus, "module", "component" or "unit" may be used mixedly.
In the embodiment of the present invention, the terminal device may include a terminal device such as a mobile phone, a tablet computer, a notebook computer, a palm computer, a Personal Digital Assistant (PDA), a wearable device, and the like.
Referring to fig. 1, fig. 1 is a block diagram of a terminal device according to various embodiments of the data transmission method of the present invention, where the terminal device may include: memory 101, processor 102, and communication module 103. It will be understood by those skilled in the art that the block diagram of the terminal shown in fig. 1 does not constitute a limitation of the terminal, which may include more or fewer components than shown, or some components may be combined, or a different arrangement of components. The memory 101 stores therein an operating system and a data transfer program. The processor 102 is a control center of the terminal device, and the processor 102 executes the data transmission program stored in the memory 101 to implement the steps of the embodiments of the data transmission method of the present invention. The communication module 103 establishes data communication with other terminals through a network protocol (the data communication may be IP communication or bluetooth channel) to achieve the purpose of sending the service data packet to other terminals through the service thread.
It should be noted that RDMA (Remote Direct Memory Access) is a new Memory Access technology, and is generated to solve the delay of server-side data processing in network transmission. The method directly transmits data from the memory of one computer to another computer without the intervention of operating systems of both computers, so that the method runs network communication with high throughput and low delay, and is particularly suitable for being used in a large-scale parallel computer cluster. RDMA network communications eliminate memory data replication, traditional network kernel protocol stack, and context switching overhead, thus saving CPU bandwidth and reducing CPU overhead.
Currently, there are three different hardware implementations of RDMA, which are InfiniBand, iWarp (internet Wide Area RDMA Protocol), and RoCE (RDMA large ethernet Protocol). Note that, roCE (RDMA over Convergent Ethernet): is an RDMA network protocol running over ethernet, whose lower network header is an ethernet header, whose upper network header (including data) is an InfiniBand header; the standard supports the use of RDMA over ethernet infrastructure (switch) in addition to network card specialization. The RoCEv protocol supports two versions of RoCEv1 and RoCEv2, the main difference is that RoCEv1 is an RDMA protocol implemented based on an Ethernet link layer (a switch needs to support flow control technologies such as PFC and the like, and reliable transmission is guaranteed in a physical layer), and RoCEv2 is implemented by a UDP layer in an Ethernet TCP/IP protocol. The InfiniBand network is best in performance, but the price of the network card and the switch is increased, and RoCE v2 only needs to use a special network card and is low in price.
Optionally, the data transmission method of the present invention is applicable to a multi-process and multi-thread distributed storage system.
Based on the structural block diagram of the terminal device, the present invention provides a data transmission method, please refer to fig. 2, and fig. 2 is a schematic flow chart of a first embodiment of the data transmission method of the present invention. In this embodiment, the data transmission method includes the steps of:
step S10, after receiving a service data packet, adding the service data packet to a sending queue;
the service data packet is a data packet to be sent, which the thread needs to send. In the actual application process, when there is a condition that the lock overhead contention of multithread simultaneous transmission of the service data packets causes transmission abnormality, the service data packets to be transmitted may be added to the transmission queue to transmit the service data packets according to the transmission sequence in the transmission queue.
As an optional implementation manner, the data transmission method further includes:
after receiving the service data packet, judging whether the sending queue is empty;
if the sending queue is empty, sending the service data packet;
if the sending queue is not empty, the operation of adding the service data packet to the sending queue in step S10 is performed.
In the actual application process, after receiving a service data packet, it may be determined whether a transmission queue is empty to determine whether the service data packet is transmitted for the first time, or it may be determined whether a current network card is busy, that is, whether the current network card is transmitting the service data packet to determine whether the service data packet can be directly transmitted, if the transmission queue is empty, it indicates that the service data packet is transmitted for the first time or the current network card is not transmitting the service data packet, that is, the current network card is idle, the service data packet may be directly transmitted, and if the transmission queue is non-empty, it indicates that the service data packet is not transmitted for the first time, the service data packet may be added to the transmission queue to wait for transmission, so as to avoid a situation that a contention CPU causes an abnormal transmission and reception.
Step S20, monitoring a data transmission event through a preset event file descriptor;
and step S30, if a data sending event is monitored through the event file descriptor, taking out the service data packet in the sending queue, and sending the service data packet through a service thread.
The event file descriptor is a system call of light-weight interprocess communication provided by the linux system, the event file descriptor completes interprocess communication through a 64-bit counter shared among processes, the counter is maintained by a linux kernel space, and a user can write a 64-bit value into the kernel space by calling a write method and can also call a read method to read the value.
And monitoring a data sending event through the event file descriptor, acquiring a service data packet from the sending queue, and sending the service data packet through a service thread to realize active sending of the service data packet. It should be noted that, in this embodiment, the multiple threads that need to send the service data packet to the service thread, such as the rdma packet receiving and sending thread, to send the service data packet.
Optionally, after the service data packet is sent by the service thread in step S30, the method includes:
and receiving a message of the failure of sending the service data packet, and adding the service data packet to the sending queue. It can be understood that, in an actual application process, during a process of sending a service data packet through a service thread, a service data packet may be unsuccessfully sent due to magnetic field interference or the like, or a service data packet may be unsuccessfully sent due to damage of the service data packet.
Based on the fact that in the process of achieving data transmission through the RoCE, due to the hardware mechanism of the RDMA network card, when a data packet to be sent exists, the problem that the CPU overhead is large due to the fact that whether the data packet is sent or not can only be inquired in a polling mode, in the technical scheme disclosed in the embodiment, a data sending event is monitored through a preset event file descriptor, then after the service data packet is received, the data sending event is detected through the preset event file descriptor, namely when the service data packet is sent, the service data packet is sent through a service thread in time, the CPU overhead is small, and active sending of the data packet can be achieved.
Referring to fig. 3, fig. 3 is a flowchart illustrating a data transmission method according to a second embodiment of the present invention. In this embodiment, after the step S10 of adding the service data packet to the transmission queue, the method includes:
step S40, acquiring a preset data transmission state identifier;
step S50, if the data transmission state identifier is an idle identifier, executing the step S20 of monitoring a data transmission event through a preset event file descriptor;
step S30 monitors a data transmission event through the event file descriptor, and the retrieving of the service data packet in the transmission queue includes:
step S31, monitoring a data transmission event through the event file descriptor, switching the data transmission state identifier from an idle identifier to a working identifier, and taking out a service data packet in the transmission queue;
after the service data packet is sent through the service thread in step S30, the method includes:
step S60, after the service data packet is sent, setting the data transmission status identifier as the idle identifier.
The data transmission status identifier may be used to determine whether the network card is busy, that is, whether the network card currently has a service data packet being sent. It is easy to understand that, by presetting the data transmission state identifier, in order to determine whether the network card is busy through the data transmission state identifier, the network card can be judged through the identifier value of the data transmission state identifier, for example, when the identifier value of the data transmission state identifier can be preset to be "0", that is, the data transmission state identifier is an idle identifier, it indicates that the network card is idle, and the network card has no service data packet being sent currently; when the identification value of the data transmission state identification is preset to be "1", that is, the data transmission state identification is a working identification, it indicates that the network card is busy and the network card is currently sending service data.
If the data transmission state identifier is an idle identifier, that is, if the identifier value of the data transmission state identifier is "0", it indicates that the network card is idle, and the network card does not currently have a service data packet being sent, and executes monitoring of the data sending event through a preset event file descriptor, so as to realize active monitoring of the data sending event, and actively and timely send the service data packet when the service data packet is sent. That is to say, when a data transmission event is monitored through the event file descriptor, that is, service data exists in the transmission queue to be transmitted, the data transmission state identifier is switched from the idle identifier to the working identifier, that is, the identifier value of the data transmission state identifier is set from "0" to "1", so as to indicate that the network card is idle, and when a service data packet exists in the transmission queue to be transmitted, the service data packet in the transmission queue can be directly acquired to be transmitted. It can be understood that, after the service data packet is sent, that is, the sending queue does not currently have a service data packet to be sent, the data transmission state identifier may be set to an idle identifier, that is, the identifier value of the data transmission state identifier is set from "1" to "0".
As an optional implementation manner, after the data transmission status flag is set as an idle flag in step S50 or the data transmission status flag is set as the idle flag in step S60, the method includes:
starting a monitoring thread for detecting the data sending event through a preset event file descriptor;
after the service data packet is sent, setting the data transmission status identifier as the idle identifier in step S60 includes:
and after the service data packet is sent, closing the monitoring thread for detecting the data sending event through the preset event file descriptor, and setting the data transmission state identifier as the idle identifier.
When the data transmission state identifier is set as an idle identifier, namely the data transmission state identifier is switched from the working identifier to the idle identifier or the data transmission identifier is the idle identifier, the network card is indicated that no service data packet is currently transmitted, a monitoring thread can be triggered to be started to monitor the operation of detecting a data transmission event through a preset event file descriptor in real time, then the data transmission event is monitored through the event file descriptor, namely the service data packet transmission exists in a transmission queue, the service data packet in the transmission queue is obtained, the service data packet is transmitted, the monitoring thread is closed after the service data packet is transmitted, and the data transmission state identifier is set as the idle identifier to wait for a data receiving event or the next data transmission event.
As an optional implementation manner, before acquiring the preset data transmission state identifier in step S40, the method includes:
after establishing remote direct memory access connection with a data receiving end, establishing the event descriptor to monitor a data sending event through the event file descriptor;
after the preset data transmission state identifier is obtained in step S40, the method includes:
and when the remote direct memory access connection is disconnected with the data receiving end, the event file descriptor is cancelled.
It should be noted that Remote Direct Memory Access (RDMA) is a new Memory Access technology, and data is directly transmitted from a Memory of a terminal device, such as a computer, to another terminal device without intervention of an operating system of the terminal device. In this embodiment, after establishing a remote direct memory access connection with a data receiving end, an event file descriptor may be established by using a LINUX system API eventfd () of a DEMU process call standard, specifically, the event fd () is a system interface provided by a LINUX system, a function prototype is int eventfd (unidentified int initval, int flags), and calling the function user state process may obtain an event file descriptor. After the event file descriptor is established, the data transmission event is monitored through the event file descriptor. It can be understood that, when the remote direct memory access connection is disconnected with the data receiving end, the registration of the event sending event processing function is cancelled by cancelling the event file descriptor, so as to release the resource.
To facilitate understanding of this embodiment, the following describes a flow of transmitting a service data packet by way of example:
when RDMA connection is established and initialized, an event file descriptor eventfd of a Linux interprocess communication mechanism is established and used for sending a packet instead of a data sending signal; specifically, 1 event file descriptor is created for each RDMA connection, and is initialized to be set to be non-blocking and not inherited by a sub-process, and a data transmission event processing function is registered; initializing the identification value of the data transmission state identification to be 0, wherein the identification value of the data transmission state identification is used for judging whether the network card is busy or not, and the identification value of the data transmission state identification is 0, namely the data transmission state identification is an idle identification, which indicates that the network card is idle and no service data packet is currently sent by the network card;
when a service thread sends a data packet, firstly judging whether a sending queue is empty;
if the sending queue is empty, the service data packet is directly delivered to the service thread to send the data packet (if the service data packet is failed to be sent, the data packet is added to the sending queue to be sent again);
and if the sending queue is not empty, adding the service data packet to the sending queue to wait for sending.
If the data transmission state identifier is an idle identifier, indicating that the network card is idle, starting a monitoring thread for detecting a data transmission event through a preset event file descriptor, so as to acquire the data transmission event through the monitoring thread based on the event file descriptor, that is, whether a service data packet is to be transmitted in a transmission queue or not;
when the monitoring thread monitors that the preset event file descriptor is passed and a data sending event is obtained, all the service data packets in the sending queue are taken out at one time:
sending all service data packets in batch;
if the service data packet which is not sent completely exists, namely the service data packet is failed to be sent, the service data packet which is failed to be sent is added to the sending queue again to wait for being sent;
closing a monitoring thread for detecting a data sending event through a preset event file descriptor, and setting a data transmission state identifier as an idle identifier, namely setting the identifier value of the data transmission state identifier to be 0;
and when the RDMA connection exits or is destroyed, destroying the event file descriptor, canceling the registration of the data transmission event processing function and releasing the resources.
In the technical scheme disclosed in this embodiment, whether the network card is busy or not is determined by the data transmission state identifier, the data transmission state identifier is in an idle identifier, which indicates that the network card is idle at present and no service data packet is being sent, and the data transmission state identifier is switched from the idle state to a working state to trigger a preset event file descriptor to monitor a data sending event, so that when the service data packet is sent, the service data packet is sent in time through a service thread, the CPU overhead is low, and active sending of the data packet can be realized.
Referring to fig. 4, fig. 4 is a flowchart illustrating a data transmission method according to a third embodiment of the present invention. In this embodiment, the data transmission method further includes:
step S70, monitoring a data receiving event corresponding to a preset file descriptor through a preset monitoring object, and acquiring a data packet to be received from a receiving queue, wherein the preset file descriptor does not include the event file descriptor;
and step S80, distributing the data packet to be received to a corresponding service thread according to the data identification of the data packet to be received.
The preset detection object refers to a mechanism (Epoll) for IO multiplexing in Linux. IO multiplexing allows one monitoring thread to listen for multiple file descriptors. When a file descriptor is ready, notifying to execute corresponding operation through a returned parameter, wherein the returned parameter only comprises the ready file descriptor; when no file descriptors are ready, the function blocks. The monitoring of the data receiving event is realized by registering a preset file descriptor to the monitoring object Epoll and setting a data receiving time processing function corresponding to the file descriptor. If a data receiving event is detected through a preset monitoring object, namely a data packet to be received exists in a receiving queue, the data packet to be received is obtained from the receiving queue, and a data identifier of the data packet to be received is identified, so that the data packet to be received is distributed to a corresponding service thread for processing according to the data identifier.
As an optional implementation manner, after the step S80 distributes the data packet to be received to the corresponding service thread according to the data identifier of the data packet to be received, the method includes:
judging whether the receiving queue is empty or not;
if the receiving queue is not empty, executing the step of obtaining the data packet to be received from the receiving queue;
and if the receiving queue is empty, executing the step of monitoring a data receiving event corresponding to a preset file descriptor through a preset monitoring object.
In the practical application process, judging whether the receiving queue is empty to determine whether the receiving queue has data packets to be received or not, if the receiving queue is not empty, indicating that the receiving queue has the data packets to be received, acquiring the data packets to be received from the receiving queue, and sending the data packets to be received to the corresponding service thread to realize the data packet receiving; if the sending queue is not empty, it indicates that there is no data packet to be received in the receiving queue, and the data packet to be received can be actively received in time when the data packet to be received exists in the receiving queue by monitoring the data receiving event corresponding to the file descriptor through the preset monitoring object.
To facilitate understanding of this embodiment, the following describes a process of receiving a packet to be received by way of example:
during the connection of RDMA, a data completion channel of the RDMA is established, a file descriptor fd of a data transmission channel is monitored, and the file descriptor fd is set to be non-blocking; registering the file descriptor fd to a detection object Epoll, setting a data receiving event processing function, and monitoring a data receiving event, namely an Epollin event;
when a data receiving event is received, calling a primitive interface of the RDMA for acquiring the event, and completing the acquisition of all the data packets to be received on a network card receiving queue to obtain the number of the data packets to be received;
circularly processing all the data packets to be received, namely calling an RDMA primitive polling receiving queue when the number of the data packets to be received is more than zero, acquiring the data packets to be received on the network card, distributing the data packets to be received to corresponding threads, and then continuously waiting for a data receiving event;
in addition, when the rdma connection exits, the descriptor fd of the data transmission channel is unregistered in the detection object/mechanism Epoll; and then when the channel is completed by destroying the connection data, recovering the corresponding file descriptor and releasing the resources.
In the technical scheme disclosed in this embodiment, when a data sending event is detected by an event file descriptor, a service data packet is sent by a service thread to realize active sending of the service data packet and saving of CPU overhead, when a data packet to be received exists, a data receiving event is detected by a preset file descriptor (the preset file descriptor does not include the event file descriptor), and the data packet to be received is distributed to a corresponding service thread according to a data identifier of the data packet to be received, so as to realize active receiving of the data packet to be received.
The invention also provides a terminal device, which comprises a memory, a processor and a data transmission program stored in the memory and capable of running on the processor, wherein the data transmission program realizes the steps of the data transmission method when being executed by the processor.
The present invention further provides a readable storage medium, in which a data transmission program is stored, and the data transmission program, when executed by a processor, implements the steps of the data transmission method in any of the above embodiments.
In the embodiments of the terminal device and the readable storage medium provided by the present invention, all technical features of the embodiments of the data transmission method are included, and the expanding and explaining contents of the specification are basically the same as those of the embodiments of the data transmission method, and are not described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrases "comprising a," "8230," "8230," or "comprising" does not exclude the presence of other like elements in a process, method, article, or system comprising the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the description of the foregoing embodiments, it is clear to those skilled in the art that the method of the foregoing embodiments may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better implementation. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a mobile terminal (such as a mobile phone, a computer, a server, a controlled terminal, or a network device) to execute the method of each embodiment of the present invention.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention, and all equivalent structures or equivalent processes performed by the present invention or directly or indirectly applied to other related technical fields are also included in the scope of the present invention.

Claims (10)

1. A data transmission method, characterized in that the data transmission method comprises:
receiving a service data packet, and adding the service data packet to a sending queue;
monitoring a data transmission event through a preset event file descriptor;
and if a data sending event is monitored through the event file descriptor, taking out the service data packet in the sending queue, and sending the service data packet through a service thread.
2. The data transmission method of claim 1, wherein the step of adding the service data packet to a transmission queue is followed by:
acquiring a preset data transmission state identifier;
if the data transmission state identifier is an idle identifier, executing the monitoring of the data transmission event through a preset event file descriptor;
after the step of monitoring a data transmission event through the event file descriptor, the method includes:
switching the data transmission state identifier from an idle identifier to a working identifier
After the step of sending the service data packet through the service thread, the method includes:
and after the service data packet is sent, setting the data transmission state identifier as the idle identifier.
3. The data transmission method as claimed in claim 2, wherein the step of switching the data transmission state identifier from an idle identifier to an active identifier is followed by:
starting a monitoring thread for detecting the data sending event through a preset event file descriptor;
after the service data packet is sent, the step of setting the data transmission state identifier as the idle identifier comprises the following steps:
and after the service data packet is sent, closing the monitoring thread for detecting the data sending event through the preset event file descriptor, and setting the data transmission state identifier as the idle identifier.
4. The data transmission method of claim 1, wherein the data transmission method comprises:
receiving the service data packet, and judging whether the sending queue is empty or not;
if the sending queue is empty, sending the service data packet;
and if the sending queue is not empty, executing the step of adding the service data packet to the sending queue.
5. The data transmission method according to claim 1, wherein the step of sending the service data packet through the service thread is followed by:
and receiving a message of failure in sending the service data packet, and adding the service data packet to the sending queue.
6. The data transmission method according to claim 2, wherein the step of obtaining the preset data transmission status flag comprises:
after establishing remote direct memory access connection with a data receiving end, establishing the event descriptor to monitor a data sending event through the event file descriptor;
the step of obtaining the preset data transmission state identifier comprises the following steps:
and when the remote direct memory access connection is disconnected with the data receiving end, the event file descriptor is cancelled.
7. The data transmission method of claim 1, wherein the data transmission method further comprises:
monitoring a data receiving event corresponding to a preset file descriptor through a preset monitoring object, and acquiring a data packet to be received from a receiving queue, wherein the preset file descriptor does not include the event file descriptor;
and distributing the data packet to be received to a corresponding service thread according to the data identification of the data packet to be received.
8. The data transmission method according to claim 7, wherein the step of distributing the data packet to be received to the corresponding service thread according to the data identifier of the data packet to be received is followed by:
judging whether the receiving queue is empty or not;
if the receiving queue is not empty, executing the step of acquiring the data packet to be received from the receiving queue;
and if the receiving queue is empty, executing the step of monitoring a data receiving event corresponding to a preset file descriptor through a preset monitoring object.
9. A terminal device, characterized in that the terminal device comprises: memory, a processor and a data transfer program stored in the memory and executable on the processor, the data transfer program when executed by the processor implementing the steps of the data transfer method according to any one of claims 1 to 8.
10. A readable storage medium, characterized in that the computer readable storage medium has stored thereon a data transfer program which, when executed by a processor, carries out the steps of the data transfer method according to any one of claims 1 to 8.
CN202110716703.4A 2021-06-25 2021-06-25 Data transmission method, terminal device and readable storage medium Pending CN115529282A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110716703.4A CN115529282A (en) 2021-06-25 2021-06-25 Data transmission method, terminal device and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110716703.4A CN115529282A (en) 2021-06-25 2021-06-25 Data transmission method, terminal device and readable storage medium

Publications (1)

Publication Number Publication Date
CN115529282A true CN115529282A (en) 2022-12-27

Family

ID=84694791

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110716703.4A Pending CN115529282A (en) 2021-06-25 2021-06-25 Data transmission method, terminal device and readable storage medium

Country Status (1)

Country Link
CN (1) CN115529282A (en)

Similar Documents

Publication Publication Date Title
EP2645674B1 (en) Interrupt management
CN111580995B (en) Synchronous communication method and system of distributed cloud platform and Internet of things intelligent terminal based on MQTT asynchronous communication scene
CN110958281B (en) Data transmission method and communication device based on Internet of things
CA2629694C (en) Centralized polling service
US9537786B2 (en) Method, device, and system for information processing based on distributed buses
CN108449239B (en) Heartbeat packet detection method, device, equipment and storage medium
CN110233881B (en) Service request processing method, device, equipment and storage medium
US9736034B2 (en) System and method for small batching processing of usage requests
US7529820B2 (en) Method and apparatus to perform automated task handling
CN102801737B (en) A kind of asynchronous network communication means and device
CN111193796B (en) Session keeping method based on delay queue, server and readable storage medium
CN112631788B (en) Data transmission method and data transmission server
US8732694B2 (en) Method and system for performing services in server and client of client/server architecture
US20180351889A1 (en) Method and system for transferring messages between messaging systems
CN105635083A (en) Service processing method and service processing system based on server and client architecture
CN110535811B (en) Remote memory management method and system, server, client and storage medium
KR100728276B1 (en) Network element management system and method thereof
CN108429703B (en) DHCP client-side online method and device
EP2944073A2 (en) Method and system for the handling of redundant long poll
CN115529282A (en) Data transmission method, terminal device and readable storage medium
CN102693434B (en) Communication apparatus and method for interface layer of radio frequency identification device
JP4415391B2 (en) Method and apparatus for transmitting data to a network and method and apparatus for receiving data from a network
EP1694007A2 (en) Method and apparatus for transmitting data to a network and method and apparatus for receiving data from a network
CN114615284A (en) Method and device for notifying and receiving messages in cluster
CN111130968A (en) Method and terminal for solving Modbus bus communication packet sticking

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination