CN110971387A - Data transmission processing method, sending equipment and receiving equipment - Google Patents

Data transmission processing method, sending equipment and receiving equipment Download PDF

Info

Publication number
CN110971387A
CN110971387A CN201911255830.8A CN201911255830A CN110971387A CN 110971387 A CN110971387 A CN 110971387A CN 201911255830 A CN201911255830 A CN 201911255830A CN 110971387 A CN110971387 A CN 110971387A
Authority
CN
China
Prior art keywords
data packet
data
communication data
sending
segment
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
CN201911255830.8A
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.)
Shanghai Bangbang Robot Co ltd
Original Assignee
Shanghai Bangbang Robot 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 Shanghai Bangbang Robot Co ltd filed Critical Shanghai Bangbang Robot Co ltd
Priority to CN201911255830.8A priority Critical patent/CN110971387A/en
Publication of CN110971387A publication Critical patent/CN110971387A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L5/00Arrangements affording multiple use of the transmission path
    • H04L5/003Arrangements for allocating sub-channels of the transmission path
    • H04L5/0053Allocation of signaling, i.e. of overhead other than pilot signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L5/00Arrangements affording multiple use of the transmission path
    • H04L5/003Arrangements for allocating sub-channels of the transmission path
    • H04L5/0044Arrangements for allocating sub-channels of the transmission path allocation of payload

Abstract

The invention provides a data transmission processing method, sending equipment and receiving equipment, wherein the method comprises the following steps: and the sending end judges the qualification of the communication data packet to be sent, processes the unqualified communication data packet to obtain a single-segment data frame conforming to a preset data frame format so as to carry out segmented transmission and send the single-segment data frame to the receiving end. In addition, the receiving end judges the qualification of the received communication data packet, and processes the unqualified communication data packet, namely the communication data packet with the packet sticking phenomenon or the packet unpacking phenomenon to obtain a single-segment data frame which accords with a preset data frame format so as to perform segmented transmission and transmit the single-segment data frame to a data layer. The invention reliably avoids the data abnormity in the data sending process, so that the information is accurately transmitted to meet the application in complex scenes.

Description

Data transmission processing method, sending equipment and receiving equipment
Technical Field
The present invention relates to the field of data communication, and in particular, to a data transmission processing method, a transmitting device, and a receiving device.
Background
In the age of mobile internet today, data communication is becoming more and more popular and important. As the amount of data increases, problems of packet sticking and unpacking easily occur in data communication.
When data communication is carried out, the two communication parties generally prescribe the format of a data packet in advance to realize effective transmission of information, but various uncontrollable factors exist in the communication environment, so that various data anomalies (such as packet sticking, packet unpacking, data frame length exceeding the data load of a communication mode and the like) occur in the actual communication process, and finally, the information transmission is inaccurate or even fails.
Therefore, how to reliably avoid the data abnormality in the data sending process, so that the accurate information transmission to meet the application in a complex scene becomes an urgent technical problem to be solved.
Disclosure of Invention
The invention aims to provide a data transmission processing method, sending equipment and receiving equipment, which can reliably avoid the data abnormity in the sending process of data and ensure that information is accurately transmitted to meet the application under a complex scene.
The technical scheme provided by the invention is as follows:
the invention provides a data transmission processing method, which is applied to a sending end and comprises the following steps:
s1100, when acquiring a data transmission request of a service logic layer and a corresponding communication data packet to be transmitted, judging whether the communication data packet is qualified; if yes, go to step S1300, otherwise go to step S1200;
s1200, processing the communication data packet to obtain a plurality of single-segment data frames which accord with the preset data frame format, and creating corresponding sending tasks according to the single-segment data frames;
s1300, creating a corresponding sending task according to the communication data packet;
and S1400, sequentially sending the sending tasks in the sending queue to the corresponding receiving ends according to the time sequence pushed by the sending tasks.
The invention also provides a data transmission processing method, which is applied to a receiving end and comprises the following steps:
s2100 receives a communication data packet from a transmitting end;
s2200 determines whether the communication data packet is qualified; if yes, go to step S2500, otherwise go to step S2300;
s2300, processing the communication data packet to obtain a plurality of single-segment data frames which accord with a preset data frame format;
s2400 carries out protocol verification on the plurality of single-segment data frames, splices all the single-segment data frames passing the verification and pushes the splicing result to a data layer;
and S2500, carrying out protocol verification on the qualified communication data packet, and pushing the qualified communication data packet to a data layer after the verification is passed.
The invention also provides a sending device, which comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the processor is used for executing the computer program stored in the memory and realizing the operation executed by the data transmission processing method applied to the sending end.
The invention also provides a receiving device, which comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the processor is used for executing the computer program stored on the memory and realizing the operation executed by the data transmission processing method applied to the receiving end.
By the data transmission processing method, the sending equipment and the receiving equipment, the data abnormity in the sending process of the data can be reliably avoided, and the information can be accurately transmitted to meet the application in a complex scene.
Drawings
The above features, technical features, advantages and implementations of a data transmission processing method, a transmitting device and a receiving device will be further described in the following preferred embodiments in a clearly understandable manner with reference to the accompanying drawings.
FIG. 1 is a flow chart of one embodiment of a data transfer processing method of the present invention;
FIG. 2 is a schematic diagram of a default data frame format according to the present invention;
FIG. 3 is a flow chart of another embodiment of a data transfer processing method of the present invention;
FIG. 4 is a schematic diagram of an ideal case of communication packets;
FIG. 5 is a schematic diagram of a communication packet in a non-ideal case;
fig. 6 is a schematic structural diagram of a transmitting device or a receiving device in a data transmission method;
FIG. 7 is a flow chart of another embodiment of a data transfer processing method of the present invention;
fig. 8 is a schematic diagram of the structure of task resending processing;
FIG. 9 is a flow chart of another embodiment of a data transfer processing method of the present invention;
FIG. 10 is a flow chart of another embodiment of a data transfer processing method of the present invention;
fig. 11 and 12 are flowcharts of another embodiment of a data transmission processing method of the present invention.
Detailed Description
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following description will be made with reference to the accompanying drawings. It is obvious that the drawings in the following description are only some examples of the invention, and that for a person skilled in the art, other drawings and embodiments can be derived from them without inventive effort.
For the sake of simplicity, the drawings only schematically show the parts relevant to the present invention, and they do not represent the actual structure as a product. In addition, in order to make the drawings concise and understandable, components having the same structure or function in some of the drawings are only schematically illustrated or only labeled. In this document, "one" means not only "only one" but also a case of "more than one".
An embodiment of the present invention, as shown in fig. 1, is a data transmission processing method applied to a sending end, including the steps of:
s1100, when acquiring a data transmission request of a service logic layer and a corresponding communication data packet to be transmitted, judging whether the communication data packet is qualified; if yes, go to step S1300, otherwise go to step S1200;
s1200, processing the communication data packet to obtain a plurality of single-segment data frames which accord with a preset data frame format, and creating a corresponding sending task according to each single-segment data frame;
s1300, creating a corresponding sending task according to the communication data packet;
and S1400, sending the sending tasks in the sending queue to the corresponding receiving ends in sequence according to the time sequence pushed by the sending tasks.
Specifically, in the related art, the processing method for avoiding the occurrence of the sticky package and the unpacking includes: the message has a fixed length, each message has the same content length and is sent periodically, and each data packet is separated by a certain time to avoid correlation. For example, if unpacking occurs, special characters are used for filling, and if sticky packages occur, special characters are used for dividing the packages, and a special mark is added at the tail of each package. The problems of the traditional modes are obvious, the message fixed length and the special character separating packet are not flexible enough, the application under the complex scene is not satisfied, the data packet is sent periodically, the efficiency is low, the reliability is not high, and the communication requirement under the mass data request cannot be satisfied. In addition, as shown in fig. 2, the preset data frame format provided by the present invention is data header, valid data and other bytes, and the check byte is at other bytes. The data frame format is preset to be suitable for various communication protocols.
Because the size of the data load is usually limited by the adopted communication mode (for example, the maximum length of the data frame of each data transmission limited by bluetooth transmission does not exceed 20 bytes), if the size of the communication data packet exceeds the maximum data load of the communication mode, the communication data packet needs to be sent in segments, so that the data transmitted each time meets the data load limit corresponding to the used communication mode. A sending end in a data communication process judges whether a communication data packet to be sent is qualified after obtaining the communication data packet to be sent from a business logic layer, if the communication data packet is unqualified, the length of a data frame of the communication data packet to be sent out exceeds a data load limit corresponding to a used communication mode, the sending end needs to process the sent communication data packet into a plurality of single data frames meeting the requirement of a preset data frame format in a segmented mode, and then the sending end creates corresponding sending tasks according to the single data frames so as to send the single data frames in sequence according to the pushed time sequence (namely, the time sequence of the sending queue receiving the sending tasks). Of course, if the communication data packet is qualified, it indicates that the data frame length of the communication data packet to be sent out does not exceed the data load limit corresponding to the communication mode used by the communication data packet, the sending end directly creates a corresponding sending task for the communication data packet and pushes the communication data packet to the sending queue, so as to sequentially send the communication data packet according to the pushed time sequence (i.e., the time sequence in which the sending queue receives the sending task).
In the embodiment, whether the communication data packet is qualified or not is judged, once the communication data packet is unqualified, the communication data packet is processed into a plurality of single-segment data frames which accord with the preset data frame format, and then the corresponding sending tasks are established for the single-segment data frames and are pushed to the sending queue for sending, so that the oversized communication data packet is sent in a segmented mode, the condition that sending is interrupted due to the fact that the data volume is too large is avoided, the condition that data are abnormal in the sending process of the data is reliably avoided, and information is accurately transmitted to meet the application under the complex scene.
An embodiment of the present invention, as shown in fig. 3, is a data transmission processing method applied to a sending end, including the steps of:
s1110, judging whether the frame length of the communication data packet obtained from the service logic layer is larger than the maximum data load of the communication mode used by the communication data packet; if the communication data packet is unqualified, entering the step S1200, otherwise, checking the communication data packet and entering the step S1300;
s1210, dividing effective data of a communication data packet into a first effective subdata segment, a plurality of middle effective subdata segments and a last effective subdata segment according to a preset segmentation mode; the first effective subdata segment, the plurality of middle effective subdata segments and the last subdata are obtained by sequentially dividing according to the content of the effective data;
s1220, calculating the number of bytes corresponding to the first effective subdata segment, the plurality of middle effective subdata segments and the last effective subdata segment respectively, and acquiring the segment sequence number of each effective subdata segment in the segmentation stage;
s1230, according to the number of bytes of each effective subdata segment, obtaining a frame length mark corresponding to each effective subdata segment, and according to the segment sequence number of each effective subdata segment, obtaining a segment sequence mark corresponding to each effective subdata segment;
s1240, according to the frame length mark, the segment sequence mark, and the frame head mark and the frame command code corresponding to the communication data packet, respectively processing the first effective subdata segment, the plurality of intermediate effective subdata segments and the last effective subdata segment into a first single-segment data frame, a plurality of intermediate single-segment data frames and a last single-segment data frame which accord with a preset data frame format;
s1250 is to create corresponding sending tasks according to the sequence of the segment sequence marks of the single segment data frames in sequence and push the sending tasks to a sending queue;
s1300, creating a corresponding sending task according to the communication data packet;
s1400, sending the sending tasks in the sending queue to the corresponding receiving ends in sequence according to the time sequence pushed by the sending tasks;
the preset data frame format comprises a data head and effective data, the data head is positioned in front of the effective data and accords with the format of the preset data head, and the preset data head comprises a frame head mark, a segment sequence mark, a frame length mark and a frame command code; the sending task comprises a single-segment data frame to be sent and a corresponding communication mode, and the single-segment data frame is a qualified communication data packet.
Specifically, in an ideal situation, the communication data packet is a complete data frame conforming to the format, and the communication data packet in the ideal state does not have a packet sticking phenomenon and/or a packet unpacking phenomenon in the transmission process. Illustratively, fig. 4 is a schematic diagram showing various possibilities of communicating data packets in an ideal situation. In an undesirable situation, the communication packet may be a complete and part of a single data frame that meets the predetermined data frame format requirement, which is a case of unpacking. Or the communication data packet may be a plurality of continuous and complete single-segment data frames meeting the preset data frame format requirement, which is a case of the packet sticking phenomenon. Or the communication data packet may be a complete single data frame meeting the format requirement of the preset data frame + a part of another single data frame meeting the format requirement of the preset data frame, which is a case where the packet sticking phenomenon and the packet unpacking phenomenon coexist. For example, fig. 5 shows a schematic diagram corresponding to the possibility of the unpacking phenomenon occurring in the communication data packet in the non-ideal case, and other schematic diagrams are not described in detail herein.
The preset data header format includes the following contents, that is, the data header of the communication data packet under the non-ideal condition needs to be processed into the contents conforming to the following preset data header format:
1) a frame header flag indicating the start of a single-segment data frame, which when received, is deemed to be ready to receive a new single-segment data frame;
2) segment sequence flag for indicating segmentation information of a single segment data frame, comprising:
a) whether the single segment data frame is a segment after a certain communication data packet is segmented (if not, the single segment data frame is an independent short frame without segmentation, namely, a communication data packet without segmentation);
b) if the data frame is segmented, the sequence numbers of the single-segment data frame in all the segments and the segment type of the frame (the segment type comprises a first segment, a middle segment and a tail segment) are included;
3) a frame length flag indicating the length (number of bytes) of a single data frame (when the single data frame is a section after a certain communication data packet is segmented, the frame length flag indicates the frame length of the communication data packet before the segmentation);
4) and a frame command code for indicating a function of a single-segment data frame.
The invention needs to consider the condition of segmented transmission while processing sticky unpacking. The processing strategy uses a frame header mark, a segment sequence mark and a frame length mark in a preset data header. For convenience of describing the flow, it is assumed that the position sequence of each mark in the data header is "frame header mark → frame length mark → segment sequence mark", and of course, the position sequence of each mark in the data header is not fixed, which is only an example here, and the description of other cases is omitted. In addition, a single data frame is assumed to conform to the format of the predetermined data frame, including the header, the valid data and other data conforming to the format of the predetermined header.
As shown in fig. 6, in the data communication process, at the current time, the first terminal is a data sender and the second terminal is a data receiver, and at the next time, the first terminal may be a data receiver and the second terminal is a data sender. Therefore, the first terminal and the second terminal having the data communication function may each include a service logic layer, a communication control layer, and a data layer, and the communication control layer includes a transmitting end and a receiving end. Of course, it is also possible that the first terminal (or the second terminal) comprises only the transmitting end (or the receiving end) of the service logic layer, the data layer and the communication control layer. The service logic layer represents an internal program processing logic of a first terminal (or a second terminal) in data communication, and is responsible for consuming data, completing specific service logic, initiating data outgoing and the like. The data layer maintains and manages all the received data, and provides required data to the business logic layer and the like in an event notification mode. The communication control layer is responsible for flow control and data processing during data receiving and transmitting, including connection establishment, connection maintenance, data encapsulation, data analysis, unpacking processing, packet sticking processing, retransmission processing and the like.
The service logic layer initiates a data outgoing request according to the actual service function requirement, the sending end receives the data sending request sent by the service logic layer, if the data sending request is received and allowed, the service logic layer is responded, and the service logic layer sends the communication data packet to be sent to the sending end. Ideally, the service logic layer provides a communication data packet meeting the requirement of the preset frame format to the sending end, but because the communication mode adopted by the communication data packet often limits the size of the data load (for example, bluetooth transmission limits that the maximum of each packet data is not more than 20 bytes), if the size of the data frame exceeds the data load of the communication mode, the data frame needs to be sent in segments, so that each segment meets the limitation of the data load of the communication mode.
And the service logic layer sends the current communication data packet to the sending end, then a subsection sending module of the sending end judges whether the length of the received current communication data packet is larger than the maximum data load of the used communication mode, if the length of the current communication data packet is not larger than the maximum data load of the used communication mode, the communication data packet is qualified, and the current communication data packet is directly pushed to a sending queue of the sending end to be sent. If the length of the current communication data packet exceeds the data load size of the used communication mode, the communication data packet is unqualified, the effective data of the current communication data packet is divided into a plurality of sections, namely the effective data is divided into a first effective sub-data section, a plurality of middle effective sub-data sections and a last effective sub-data section according to the content sequence of the effective data of the current communication data packet, a plurality of complete single-section data frames meeting the frame format requirement are regenerated by utilizing each section of effective sub-data section, and the plurality of single-section data frames are output in order, so that a first single-section data frame, a plurality of middle single-section data frames and a last single-section data frame corresponding to the sequence numbers of the first effective sub-data section, the plurality of middle effective sub-data sections and the last effective sub-data section are obtained, wherein the frame head flag and the frame command code of each single-section data frame (including the first single-section data frame, the middle single-section data frame and the single-section data, are the same as the frame header flag and frame command code of the current communication data packet before fragmentation.
In addition, the frame length of the last single segment data frame does not exceed the maximum data load of the communication mode used by the current communication data packet, and the frame lengths of the first single segment data frame and the middle single segment data frame are equal to the maximum data load of the communication mode used by the current communication data packet. In addition, the segment sequence flag serial numbers corresponding to each single segment data frame are sequentially incremented, and certainly, the segment types corresponding to each single segment data frame are not completely consistent, for example, the segment types of a plurality of middle single segment data frames are all middle segments, the segment type of the first single segment data frame is the first segment, and the segment type of the last single segment data frame is the last segment, so that the segment types of any plurality of middle single segment data frames are consistent, the segment types of any one middle single segment data frame is inconsistent with the segment types of the first single segment data frame and the segment type of the last single segment data frame, and certainly, the segment types of the first single segment data frame and the segment type of the last single segment data frame are also inconsistent.
And when the sending task module receives a single or a plurality of data frames sent by the subsection sending module, the sending task module sequentially creates sending tasks according to the section types of the 'first section, the middle section and the tail section' and the sequence of the section sequence marks, and pushes the sending tasks to a sending queue. The sending task comprises data information of data to be sent and a communication mode adopted by the data information. And the sending queue receives the sending tasks output by the sending task module, sequentially executes the sending tasks in the sending queue in the sending sub-thread, and calls the target communication module matched with the communication mode corresponding to the communication data packet to finish the outgoing of the data in the sending tasks.
Generally, the lengths of other data and data headers included in each single data frame are consistent, so the preset segmentation mode is to calculate the segmentation interval according to the frame length flag of the communication data packet before segmentation and the maximum data load corresponding to the communication mode used by the frame length flag. Illustratively, the frame length of a certain communication data packet a is 96, the sum of the frame lengths of other data and the frame length of the data header is 5, and the maximum data load corresponding to the bluetooth communication mode is 20, the preset segmentation mode is to segment the effective data according to the following formula (1):
(L-D)÷(Q-D)(1)
wherein, L is the frame length of the communication data packet, D is the sum of the frame lengths of other data and the frame length of the data header, and Q is the maximum data load corresponding to the communication mode.
Then, according to the above formula and data, it is possible to obtain a desired quotient of 6 and a remainder of 1, and divide the communication data packet a into 7 segments, and the first 6 segments are respectively a first significant sub-data segment (whose segment sequence number is 1 and includes the first 15-byte content of the significant data), a first intermediate significant sub-data segment (whose segment sequence number is 2 and includes the 15 th-30 th-byte content of the significant data), a second intermediate significant sub-data segment (whose segment sequence number is 2 and includes the 30 th-45 th-byte content of the significant data), a third intermediate significant sub-data segment (whose segment sequence number is 3 and includes the 45 th-60 th-byte content of the significant data), a fourth intermediate significant sub-data segment (whose segment sequence number is 4 and includes the 60 th-75 th-byte content of the significant data), a fifth intermediate significant sub-data segment (whose segment sequence number is 5, and includes the 75 th to 90 th byte contents of valid data), and the last 1 segment is the last valid sub-data segment (whose segment sequence number is 16 and includes the last byte content of valid data).
In this embodiment, when the frame length of a communication data packet is greater than the maximum data load of the communication mode used by the communication data packet, the effective data of the communication data packet is segmented, and it is ensured that the frame length of a single-segment data frame obtained by adding a corresponding frame header flag, a segment sequence flag, a frame command code, and a segment type flag to an effective sub-data segment obtained by the segmentation is less than or equal to the maximum data load of the communication mode used by the communication data packet, so that not only the communication data packet with an excessively large data amount is segmented and transmitted, and a data transmission interruption is avoided, but also a data function is not changed because the frame header flag and the frame command code of each single-segment data frame are the same, exemplarily, the effective data of a certain communication data packet b is a "heating mode for turning on an air conditioner, and the temperature of the air conditioner is adjusted to 30 ℃", and the corresponding frame header flag thereof is assumed to be "KTKZ", the frame command code is 'KTZRWD 30 ℃', and if the frame length of the communication data packet B is larger than the maximum data load corresponding to the Bluetooth transmission, the communication data packet B is divided into a single-segment data frame A and a single-segment data frame B according to the segmentation mode of the invention, the effective data respectively included in the single-segment data frame A and the single-segment data frame B is 'heating mode for opening air conditioner' and 'temperature for adjusting air conditioner is 30 ℃', and the frame headers of the single-segment data frame A and the single-segment data frame B are both 'KTKZ', and the frame command codes are both 'KTZRWD 30 ℃'. Then, by the way of obtaining a plurality of single-segment data frames by the segmentation processing of the invention, because the frame head mark and the frame command code of each single-segment data frame are the same, the air conditioner can know that the instruction is incomplete when receiving the single-segment data frame A, so as to wait for receiving the single-segment data frame B, and then the complete control instruction is obtained by analyzing the single-segment data frame A and the single-segment data frame B. Therefore, the communication data packet is segmented into a plurality of single-segment data frames which accord with the preset data frame format according to the frame head mark and the frame command code corresponding to the communication data packet before segmentation, and then corresponding sending tasks are created according to the single-segment data frames and are pushed to the sending queue for sending, so that the oversized communication data packet is sent in a segmented manner, the condition that sending is interrupted due to the fact that the data volume is too large is avoided, the condition that data are abnormal in the sending process is greatly reduced, and information is accurately transmitted to meet the application under the complex scene.
An embodiment of the present invention, as shown in fig. 7, is a data transmission processing method, including the steps of:
s0100, setting a command code table, wherein the command code table comprises a retransmission rule corresponding to each frame command code;
s1100, when acquiring a data transmission request of a service logic layer and a corresponding communication data packet to be transmitted, judging whether the communication data packet is qualified; if yes, go to step S1300, otherwise go to step S1200;
s1200, processing the communication data packet to obtain a plurality of single-segment data frames which accord with a preset data frame format, and creating a corresponding sending task according to each single-segment data frame;
s1300, creating a corresponding sending task according to the communication data packet;
s1310, acquiring a target communication mode corresponding to the sending task, and inquiring a command code table according to a frame command code of the sending task to obtain a target retransmission rule corresponding to the command code table;
s1320, according to the target retransmission rule, a target sending task needing to be retransmitted is created and pushed to a sending queue;
s1410, controlling the target communication module matched with the target communication mode to sequentially send the sending tasks to the corresponding receiving end according to the time sequence, and feeding back the sending state event to the service logic layer;
the sending state event comprises data information corresponding to the sending task, sending times and a communication mode of the sending task.
Specifically, in this embodiment, as shown in fig. 6, in the "request-response" mechanism, after the sending end sends the sending task in the sending queue to the receiving end, the sending end does not receive the response feedback of the receiving end for a long time (which indicates that a packet loss situation may occur), and needs to complete the retransmission with a certain policy. In order to ensure accurate issuing of information or instructions, a retransmission rule corresponding to each frame command code needs to be set, that is, a command code table is set, and the command code table is set in advance according to actual service requirements. After the sending end obtains the communication data packet to be sent from the service logic layer each time, the length judgment is carried out by referring to the embodiment, and the corresponding sending task is established by the sending task module according to the judgment result. After a sending task is created, the command code table is inquired according to the frame command code of the sending task to obtain a corresponding target retransmission rule, then the sending task needing to be retransmitted is registered to the task retransmission module, and the task retransmission module pushes the sending task needing to be retransmitted to the sending queue. The task retransmission module receives the sending tasks output by the sending task module, and executes retransmission registration logic for each sending task when the corresponding command retransmission rule of the sending task is that the sending task needs to be retransmitted; when the corresponding command retransmission rule is that retransmission is not needed, retransmission registration logic is not executed. The sending queue receives the sending tasks output by the sending task module or the target sending tasks output by the task retransmitting module, the sending tasks (including the sending tasks output by the sending task module or the target sending tasks output by the task retransmitting module) in the sending task sub-thread are sequentially executed, and the target communication module matched with the target communication mode used by the sending tasks is called to finish data outgoing.
Preferably, the step S1320 of creating a target sending task to be retransmitted according to the target retransmission rule and pushing the target sending task to the sending queue includes the steps of:
s1321, creating a target sending task according to the target resending rule, and judging whether a sending task which is being sent and has the same type as the target sending task exists in a sending queue; if yes, go to step S1322; otherwise, go to step S1323;
s1322 cancels the retransmission thread of the sending task with the same type as the target sending task, and pushes the target sending task to a sending queue;
s1323, pushing the target sending task to a sending queue;
preferably, the step S1410 of controlling the target communication module matched with the target communication mode to sequentially send the sending tasks to the corresponding receiving end according to the time sequence, and feeding back the sending state event to the service logic layer includes the steps of:
s1411, inquiring according to a target communication mode to obtain a target communication module, controlling the target communication module to execute the sending tasks in the sending queue, counting and judging whether the sending times of the sending tasks exceed the corresponding sending time threshold; if yes, go to step S1412; otherwise, repeatedly executing step S1411 until the transmission number reaches the transmission number threshold;
s1412 deletes the transmission task push from the transmission queue, and cancels the transmission of the transmission task.
Specifically, as shown in fig. 8 and fig. 9, the task re-sending module receives a target sending task (a sending task with a re-sending requirement), where the sending task includes data information of data to be sent and a communication method used, and determines whether there is a sending task in the sending queue that is being sent and has the same type as the target sending task, where the definition of the sending task of the same type is: and if the frame command codes of the data frames of the two sending tasks are consistent, the sending tasks are of the same type. If the sending queue has sending tasks which are being sent and have the same type as the target sending task, the resending thread of the sending task which has the same type as the target sending task is cancelled, and the resending thread of the target sending task is newly built, namely the target sending task is pushed to the sending queue to be sent. If the sending queue has no sending task which is being sent and is the same as the target sending task type, a new sending thread of the target sending task type is directly established.
It should be noted that the retransmission number threshold set in the target retransmission rule may be 0, and if the task corresponding to the retransmission number threshold of 0 is a transmission task that does not require retransmission, the corresponding transmission number threshold is one. If the task corresponding to the retransmission number threshold of 1 or more is a target transmission task that is a transmission task requiring retransmission, the corresponding transmission number threshold is set to at least two times. The sending queue executes sending tasks or target sending tasks in sequence according to the time sequence of receiving the sending tasks and a first-in first-out mode, monitors the sending times of the sending queue for sending the same sending task in real time, counts the sending times of the same sending task and judges whether the sending times exceed the corresponding sending time threshold. If the task is not over, the sending thread of the sending task or the sending thread of the target sending task is continuously executed, if the task is over, the sending task or the target sending task is deleted from the sending queue, the sending thread of the sending task or the target sending task is cancelled, and the sending of the sending task or the target sending task is terminated. In the process of sending the execution task, the sending queue externally notifies the sending state in an event mode, and the process comprises the following steps: current number of transmissions, upper limit of number of transmissions, success of transmission execution, failure of transmission execution, cancellation of transmission information, and the like.
Preferably, when the command event in response to the target transmission task is monitored at any time when the transmission queue performs transmission, the retransmission of the target transmission task is canceled, that is, the target transmission task is deleted from the transmission queue, the transmission thread of the target transmission task is canceled, and the transmission of the target transmission task is terminated.
Preferably, the method for creating the target sending task comprises the following steps: and creating a timer which takes the frame command code of the target sending task as a unique identifier, presetting the upper limit of the timing period and the retransmission times of the timer, setting the timing task of the timer as pushing the target sending task to the head of a sending queue, and generating a queue execution ID (identity), wherein the ID is bound with the timer.
Preferably, the target sending task retransmitting method includes: and when the timing task of the timer is triggered, pushing the target sending task to the head of the sending task queue, and directly executing the target sending task in the next execution period of the sending queue.
Preferably, the method for canceling the retransmission of the target transmission task includes: and searching and destroying the corresponding timer by taking the frame command code of the sending task as a unique identifier, searching all queue execution IDs bound with the timer, and deleting the sending task corresponding to the queue execution ID in the sending queue.
In this embodiment, by establishing the retransmission mechanism, it can be ensured that the information is transmitted to the receiving end, and the reliability of data transmission is improved.
An embodiment of the present invention, as shown in fig. 10, is a data transmission processing method applied to a receiving end, including:
s2100 receives a communication data packet from a transmitting end;
s2200 judges whether the communication data packet is qualified; if yes, go to step S2500, otherwise go to step S2300;
s2300, processing the communication data packet to obtain a plurality of single-segment data frames which accord with a preset data frame format;
s2400 carries out protocol check on a plurality of single-segment data frames, splices all the single-segment data frames passing the check and pushes the splicing result to a data layer;
and S2500, carrying out protocol verification on the qualified communication data packet, and pushing the qualified communication data packet to a data layer after the verification is passed.
Specifically, the sending end in the above embodiment is an execution main body, this embodiment is applied to the receiving end, and the details of the preset data frame format and the single segment data frame refer to the above embodiment corresponding to the sending end, which is not described in detail herein. Because the size of the data load is usually limited by the adopted communication mode (for example, the maximum length of the data frame of each data transmission limited by bluetooth transmission does not exceed 20 bytes), if the size of the communication data packet exceeds the maximum data load of the communication mode, the communication data packet needs to be sent in segments, so that the data transmitted each time meets the data load limit corresponding to the used communication mode.
After receiving the communication data packet, the receiving end in the data communication process judges whether the communication data packet is qualified, and if the communication data packet is qualified, the communication data packet is a complete frame of communication data packet which conforms to the preset data frame format, that is, the communication data packet conforms to the ideal condition mentioned in the above embodiment. And pushing the qualified communication data packet to a check queue, performing protocol check on the qualified communication data packet in the check queue, if the check is passed, pushing the qualified communication data packet to a data layer, otherwise, if the check is not passed, discarding the qualified communication data packet. If the communication data packet is unqualified, the communication data packet is not a complete communication data packet conforming to the preset data frame format, namely the communication data packet conforms to the non-ideal condition mentioned in the embodiment, the unqualified communication data packet is processed to obtain a plurality of single-section data frames conforming to the preset data frame format, then the plurality of single-section data frames conforming to the preset data frame format are pushed to a check queue, protocol check is carried out on the plurality of single-section data frames in the check queue according to the pushing time sequence, and if the check is passed, the current single-section data frame is pushed to a data layer, and protocol check is carried out on the next single-section data frame until all the single-section data frames are checked. Otherwise, if the check is not passed, the current single-segment data frame is discarded, the protocol check is carried out on the next single-segment data frame until all the single-segment data frames are checked, all the single-segment data frames which pass the check are spliced, and the splicing result is pushed to the data layer.
In the embodiment, by judging whether the communication data packet is qualified or not, once the communication data packet is unqualified, the communication data packet is processed into a plurality of single-segment data frames which accord with the preset data frame format, then each single-segment data frame is pushed to a check queue for checking, the single-segment data frames passing the checking are spliced, thereby synthesizing and outputting a new communication data packet which is in accordance with the preset data frame format again to realize the unqualified communication data packet, can also process the unqualified communication data packet to obtain a complete new communication data packet which accords with the preset data frame format, thus, the receiving end processes the unqualified communication data packet into a qualified communication data packet after receiving the unqualified communication data packet, and then the qualified communication data packet is transmitted to the data layer, so that the integrity of the data is ensured, and meanwhile, the information can be accurately transmitted to meet the application in a complex scene.
An embodiment of the present invention provides a data transmission processing method, applied to a receiving end, including:
s2100 receives a communication data packet from a transmitting end;
s2210 determines whether the first byte of the current communication data packet is a frame header flag; if yes, go to step S2220; otherwise, discarding the current communication data packet and returning to step S2100 until the data reception is completed;
s2220 judges whether the current communication data packet includes at least one single-segment data frame conforming to the format of the preset data frame; if yes, go to step S2230; otherwise, go to step S2240;
s2230 determines whether the number of data frames in the current communication data packet is one; if yes, go to step S2250; otherwise, go to step S2240;
s2240 determines that the current communication data packet is unqualified and enters the step S2300;
s2250 determines the current communication data packet lattice and proceeds to step S2500;
s2300, processing the communication data packet to obtain a plurality of single-segment data frames which accord with a preset data frame format;
s2400 carries out protocol check on a plurality of single-segment data frames, splices all the single-segment data frames passing the check and pushes the splicing result to a data layer;
and S2500, carrying out protocol verification on the qualified communication data packet, and pushing the qualified communication data packet to a data layer after the verification is passed.
The preset data frame format comprises a data head and effective data, the data head is positioned in front of the effective data and accords with the format of the preset data head, and the preset data head comprises a frame head mark, a segment sequence mark, a frame length mark and a frame command code.
Specifically, as shown in fig. 6, in the data communication process, at the current time, the first terminal is a data sender, and the second terminal is a data receiver, while at the next time, the first terminal may be a data receiver, and the second terminal is a data sender. Therefore, the first terminal and the second terminal having the data communication function may each include a service logic layer, a communication control layer, and a data layer, and the communication control layer includes a transmitting end and a receiving end. Of course, it is also possible that the first terminal (or the second terminal) comprises only the transmitting end (or the receiving end) of the service logic layer, the data layer and the communication control layer. The service logic layer represents an internal program processing logic of a first terminal (or a second terminal) in data communication, and is responsible for consuming data, completing specific service logic, initiating data outgoing and the like. The data layer maintains and manages all the received data, and provides required data to the business logic layer and the like in an event notification mode. The communication control layer is responsible for flow control and data processing during data receiving and transmitting, including connection establishment, connection maintenance, data encapsulation, data analysis, unpacking processing, packet sticking processing, retransmission processing and the like.
After receiving the current communication data packet, the receiving end judges whether the first byte of the current communication data packet is the frame header mark or not by the sticky packet unpacking processing module, and if not, the current communication data packet is directly discarded. If so, further judging whether the content of the communication data packet is the content of a complete single-segment data frame, namely judging whether the current communication data packet comprises at least one single-segment data frame which accords with a preset data frame format, and judging whether the number of the single-segment data frames in the current communication data packet is one. If the first byte of the current communication data packet is a frame header mark and comprises a single-segment data frame which accords with the preset data frame format, the current communication data packet is qualified, and the unpacking phenomenon and the sticking phenomenon do not exist. If the first byte of the current communication data packet is a frame header mark and comprises a part of a single-segment data frame which accords with the preset data frame format, the current communication data packet is unqualified and the unpacking phenomenon exists. If the first byte of the current communication data packet is a frame header mark and comprises at least one single-segment data frame which accords with the preset data frame format, the current communication data packet is unqualified and the packet sticking phenomenon exists. If the first byte of the current communication data packet is a frame header mark, and comprises at least one single-segment data frame which accords with the preset data frame format and a part of the single-segment data frame which accords with the preset data frame format, the current communication data packet is unqualified, and the phenomena of packet sticking and packet unpacking exist.
And the sticky packet unpacking processing module processes the communication data packets (namely the communication data packets with the unpacking phenomenon and/or the sticky packet phenomenon) judged to be unqualified and sequentially outputs the processed communication data packets to obtain complete data frames without the sticky packet and the unpacking phenomenon, namely single-section data frames conforming to the preset data frame format. And the sticky packet unpacking processing module pushes the single-segment data frame or the qualified communication data packet to a check queue, a cyclic redundancy check method is adopted to calculate to obtain check bytes corresponding to the single-segment data frame (or the qualified communication data packet) in the check queue, the calculated check bytes are compared with preset check bytes of the single-segment data frame (or the qualified communication data packet), when the comparison result is consistent, the check is passed, and the single-segment data frame passing the check is pushed to the segmented transmission module. And when the comparison result is inconsistent, the check is failed, and the single data frame (or the qualified communication data packet) is discarded.
If the segmented transmission module receives the single-segment data frame pushed by the sticky packet unpacking processing module, whether the current single-segment data frame is an independent short frame which does not need to be segmented is judged according to the segment sequence mark of the current single-segment data frame, if so, the segmented transmission module directly transmits the current single-segment data frame to a message pool of the data layer for storage and recording, and notifies the service logic layer through a message event mode. If not, the segmented transmission module continues to acquire the checked single-segment data frame from the sticky packet unpacking processing module until the segment type of the received single-segment data frame is known as the tail single-segment data frame according to the segment sequence mark, sequentially splices the received first single-segment data frame, a plurality of middle single-segment data frames and the tail single-segment data frame according to the sequence of the segment sequence mark, splices the first single-segment data frame, the middle single-segment data frame and the tail single-segment data frame again to obtain a complete new communication data packet which accords with the preset data frame format, then, the segmented transmission module splices the synthesized new communication data packet again to transmit the message pool of the data layer for storage and recording, and informs the service logic layer and the like in a message event mode.
An embodiment of the present invention provides a data transmission processing method, which is applied to a receiving end, and the step of S2300 processing a communication data packet to obtain a plurality of single-segment data frames conforming to a preset data frame format includes:
s2310, if the current communication data packet is unqualified, and the first byte of the current communication data packet is a frame header marker, and the number of single-segment data frames included in the current communication data packet is more than one, pushing the first single-segment data frame of the current communication data packet to a protocol check queue for checking, and performing recursion processing on the rest data except the first single-segment data frame in the current communication data packet;
s2320, if the current communication data packet is not qualified, and the first byte of the current communication data packet is the frame header flag, and the number of single data frames included in the current communication data packet is less than one, determining whether the current communication data packet includes the frame length flag; if yes, go to step S2330; otherwise, go to step S2380;
s2330, according to the frame length flag, judging whether the frame length of the current communication data packet is larger than the maximum data load of the communication mode used by the current communication data packet; if yes, go to step S2340; otherwise, the process proceeds to step S2370 after step S2360;
s2340 judging whether the current communication data packet includes a segment sequence flag; if yes, the process proceeds to step S2370 after step S2350; otherwise, go to step S2380;
s2350, pushing the current communication data packet to a cache queue, and calculating to obtain the target remaining byte number required for splicing the current communication data packet into a single-segment data frame according to the byte number, the frame length mark and the segment sequence mark of the current communication data packet;
s2360 pushing the current communication data packet to a buffer queue, and calculating to obtain the target remaining byte number needed by splicing the current communication data packet into a single-segment data frame according to the byte number and the frame length mark of the current communication data packet;
s2370 compares the byte number of the next communication data packet newly acquired in the buffer queue with the target remaining byte number, and executes corresponding operation on the next communication data packet according to the comparison result;
preferably, S2370 compares the byte number of the next communication data packet newly acquired from the buffer queue with the target remaining byte number, and performs a corresponding operation on the next communication data packet according to the comparison result, including the steps of:
s2371 comparing the byte number of the next communication data packet newly acquired from the buffer queue with the target remaining byte number;
s2372 if the comparison result shows that the number of bytes is equal to the target remaining number of bytes, splicing the next communication data packet with the current communication data packet to obtain a spliced communication data packet, and pushing the spliced communication data packet to a protocol check queue for checking;
s2373 if the byte number is less than the target residual byte number, emptying the data in the buffer queue and returning to the step S2100 until the data receiving is completed;
s2374 if the comparison result shows that the number of bytes is greater than the target remaining number of bytes, the next communication data packet and the current communication data packet are spliced to obtain a spliced communication data packet, a first single data frame in the spliced communication data packet is pushed to a protocol check queue for checking, and the rest of data except the first single data frame in the spliced communication data packet is subjected to recursive processing.
S2380 reserving the current communication data packet in the buffer queue, pushing the newly acquired next communication data packet to the buffer queue, splicing the current communication data packet and the newly acquired next communication data packet to obtain a spliced communication data packet, and judging the validity of the spliced communication data packet again;
specifically, as shown in fig. 11 and 12, the receiving end acquires a communication data packet from an external sending device, if it is determined that the current communication data packet is not qualified, and a first byte of the current communication data packet is a frame header marker, and the number of single data frames included in the current communication data packet is more than one, which indicates that the current communication data packet is sticky, the first single data frame of the current communication data packet is pushed to a protocol check queue for checking, and the rest of data in the current communication data packet except the first single data frame is pushed to a buffer queue to obtain a buffered communication data packet, and the buffered communication data packet is subjected to validity determination again, that is, the buffered communication data packet is re-executed in steps S2200 to S2500 (including the refining steps corresponding to S2200 to S2500).
If the current communication data packet is determined to be unqualified, and the first byte of the current communication data packet is a frame header marker, and the number of single-segment data frames included in the current communication data packet is less than one, which indicates that the unpacking phenomenon of the current communication data packet occurs, then further determining whether the current communication data packet includes a frame length marker, if the frame length marker is not included, the number of bytes required for splicing into a complete single-segment data frame cannot be calculated, further caching and acquiring a new communication data packet until the acquired new communication data packet includes the frame length marker, splicing the current communication data packet and the newly acquired next communication data packet to obtain a spliced communication data packet, and re-executing the step S2200-S2500 on the spliced communication data packet (of course, also including the step of refining corresponding to S2200-S2500).
Once the current communication data packet is unqualified, the first byte of the current communication data packet is a frame header mark, the number of single-section data frames included in the current communication data packet is less than one, when the current communication data packet includes a frame length mark, whether the frame length of the current communication data packet is greater than the maximum data load is judged according to the frame length mark due to the frame length mark, if the frame length of the current communication data packet is less than or equal to the maximum data load, the current communication data packet is an independent short frame which does not need to be segmented, the byte number corresponding to the current communication data packet is obtained through statistical calculation, and then the target residual byte number required for processing the current communication data packet into a complete single-section data frame is obtained through calculation according to the frame length mark and the byte number. Of course, if the frame length of the current communication data packet is greater than the maximum data load, it is further determined whether the current communication data packet includes the segment sequence flag, if the current communication data packet does not include the segment sequence flag, the current communication data packet and the newly acquired next communication data packet are spliced to obtain a spliced communication data packet, and steps S2200 to S2500 are performed again on the spliced communication data packet (including, of course, the refining steps corresponding to steps S2200 to S2500). If the current communication data packet comprises the segment sequence mark, the byte number corresponding to the current communication data packet is obtained through statistical calculation, and the target residual byte number required for processing the current communication data packet into a complete single-segment data frame is obtained through calculation according to the frame length mark, the segment sequence mark and the byte number. For example, assuming that the current communication data packet is the first section of the complete valid data, that is, the first valid sub-data section, according to the section sequence flag, the section sequence flag and the number of bytes, the target remaining number of bytes required for processing the current communication data packet into the first single-section data frame may be calculated according to the frame length flag, the section sequence flag and the number of bytes. In other cases, the calculation is performed in the above manner, and details are not repeated here.
After the target remaining byte number required for processing the current communication data packet into a complete single-segment data frame is obtained through calculation, as the receiving end continuously receives a new communication data packet, the byte number of the next communication data packet is obtained through statistical calculation, and the byte number of the next communication data packet is compared with the target remaining byte number. And if the byte number of the next communication data packet is equal to the target residual byte number, the current communication data packet and the next communication data packet are spliced to obtain the spliced communication data packet, the unpacking phenomenon and the sticking phenomenon do not occur, the next communication data packet and the current communication data packet are spliced to obtain the spliced communication data packet, the spliced communication data packet is pushed to a protocol check queue to be checked, and the subsequent steps refer to the step of executing the current communication data packet.
And if the byte number of the next communication data packet is larger than the target residual byte number, which indicates that the spliced communication data packet obtained by splicing the current communication data packet and the next communication data packet has a sticky packet phenomenon, re-executing S2200-S2500 on the spliced communication data packet (including the refining steps corresponding to S2200-S2500). If the number of bytes of the next communication data packet is less than the target remaining number of bytes, emptying the data in the cache queue and returning to step S2100 until the data reception is completed, or reserving the current communication data packet and the next communication data packet, and splicing the newly acquired next communication data packet (which is another communication data packet after the next communication data packet is acquired, the first acquisition time of the next communication data packet is after the second acquisition time of the next communication data packet is acquired, and the first acquisition time is adjacent to the second acquisition time), the current communication data packet and the next communication data packet to obtain a second spliced communication data packet, and the target remaining number of bytes is updated according to the number of bytes of the current communication data packet and the next communication data packet, thereby calculating a new target remaining number of bytes, and determining whether the number of bytes of the next communication data packet is greater than the new target remaining number of bytes, for the remaining processes, reference is made to the above judgment and comparison for the next communication data packet, which is not described in detail herein.
S2372 if the comparison result shows that the number of bytes is equal to the target remaining number of bytes, splicing the next communication data packet with the current communication data packet to obtain a spliced communication data packet, and pushing the spliced communication data packet to a protocol check queue for checking;
s2373 if the byte number is less than the target residual byte number, emptying the data in the buffer queue and returning to the step S2100 until the data receiving is completed;
s2374 if the comparison result shows that the number of bytes is greater than the target remaining number of bytes, the next communication data packet and the current communication data packet are spliced to obtain a spliced communication data packet, a first single data frame in the spliced communication data packet is pushed to a protocol check queue for checking, and the rest of data except the first single data frame in the spliced communication data packet is subjected to recursive processing.
In the above embodiment, if the transmitted or received communication data packet is not qualified, the unqualified communication data packet is processed to obtain the single-segment data frame conforming to the preset data frame format, so that the phenomena of segmentation, packet sticking, unpacking and packet loss in the data transmission process based on the communication protocol are solved, the unqualified communication data packet is processed, and the data transmission processing flow is optimized. In addition, because the unqualified communication data packets are processed, the data transmitted by the transmitting end can be correctly analyzed by the receiving end, so that the information is successfully transmitted, the reliability of data transmission is greatly improved, and the data transmitted by the transmitting end can be correctly analyzed by the receiving end, so that the data transmission efficiency is improved.
In one embodiment of the invention, a transmitting device comprises a processor and a memory, wherein the memory is used for storing a computer program; and a processor, configured to execute the computer program stored in the memory, and implement the data transmission processing method in the method embodiments corresponding to fig. 1 to 9.
In one embodiment of the invention, a receiving device comprises a processor and a memory, wherein the memory is used for storing a computer program; and a processor, configured to execute the computer program stored in the memory, to implement the data transmission processing method in the method embodiments corresponding to fig. 10 to fig. 12.
It should be noted that the above embodiments can be freely combined as necessary. The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (10)

1. A data transmission processing method is applied to a sending end and comprises the following steps:
s1100, when acquiring a data transmission request of a service logic layer and a corresponding communication data packet to be transmitted, judging whether the communication data packet is qualified; if yes, go to step S1300, otherwise go to step S1200;
s1200, processing the communication data packet to obtain a plurality of single-segment data frames which accord with the preset data frame format, and creating corresponding sending tasks according to the single-segment data frames;
s1300, creating a corresponding sending task according to the communication data packet;
and S1400, sequentially sending the sending tasks in the sending queue to the corresponding receiving ends according to the time sequence pushed by the sending tasks.
2. The data transmission processing method according to claim 1, wherein the step of judging whether the communication data packet is qualified or not when the S1100 obtains the data transmission request of the service logic layer and the corresponding communication data packet to be transmitted includes:
s1110 determining whether the frame length of the communication data packet obtained from the service logic layer is greater than the maximum data load of the communication mode used by the service logic layer; if the communication data packet is unqualified, the step S1200 is carried out, otherwise, the step S1300 is carried out;
s1200, processing the communication data packet to obtain a plurality of single-segment data frames which accord with the preset data frame format, and creating a corresponding sending task according to each single-segment data frame comprises the following steps:
s1210, dividing the effective data of the communication data packet into a first effective sub-data segment, a plurality of middle effective sub-data segments and a last effective sub-data segment according to a preset segmentation mode; the first effective subdata segment, the plurality of middle effective subdata segments and the last subdata are obtained by sequentially dividing according to the content sequence of the effective data;
s1220, calculating the byte number corresponding to the first effective subdata segment, the middle effective subdata segments and the last effective subdata segment, and acquiring the segment sequence number of each effective subdata segment in the segmentation stage;
s1230, according to the number of bytes of each effective subdata segment, obtaining a frame length mark corresponding to each effective subdata segment, and according to the segment sequence number of each effective subdata segment, obtaining a segment sequence mark corresponding to each effective subdata segment;
s1240, according to the frame length flag, the segment sequence flag, and the frame header flag and the frame command code corresponding to the communication data packet, respectively processing the first valid sub-data segment, the plurality of intermediate valid sub-data segments, and the last valid sub-data segment into a first single-segment data frame, a plurality of intermediate single-segment data frames, and a last single-segment data frame conforming to the preset data frame format;
s1250 is used for sequentially creating corresponding sending tasks according to the sequence of the segment sequence marks of the single-segment data frames and pushing the sending tasks to the sending queue;
the preset data frame format comprises a data head and effective data, wherein the data head is positioned in front of the effective data and accords with the format of a preset data head, and the preset data head comprises a frame head mark, a segment sequence mark, a frame length mark and a frame command code; the sending task comprises a single-segment data frame to be sent and a corresponding communication mode, and the single-segment data frame is a qualified communication data packet.
3. The data transmission processing method according to claim 1 or 2, further comprising the steps of:
s0100, setting a command code table, wherein the command code table comprises a retransmission rule corresponding to each frame command code;
the S1300 creates a corresponding sending task according to the communication data packet;
s1310, acquiring a target communication mode corresponding to the sending task, and inquiring the command code table according to the frame command code of the sending task to obtain a corresponding target retransmission rule;
s1320, according to the target retransmission rule, creating a target transmission task to be retransmitted and pushing the target transmission task to the transmission queue;
the step of S1400, where sequentially sending the sending tasks in the sending queue to the corresponding receiving ends according to the time sequence pushed by the sending tasks includes:
s1410 controlling the target communication module matched with the target communication mode to sequentially send the sending task to the corresponding receiving end according to the time sequence, and feeding back the sending state event to the service logic layer;
the sending state event comprises data information corresponding to the sending task, sending times and a communication mode of the sending task.
4. The data transmission processing method according to claim 3, wherein the step S1320 of creating the target sending task to be retransmitted according to the target retransmission rule and pushing the target sending task to the sending queue comprises the steps of:
s1321, creating the target sending task according to the target resending rule, and judging whether a sending task which is being sent and has the same type as the target sending task exists in the sending queue; if yes, go to step S1322; otherwise, go to step S1323;
s1322 cancels the retransmission thread of the sending task with the same type as the target sending task, and pushes the target sending task to a sending queue;
s1323, pushing the target sending task to a sending queue;
the step of S1410 controlling the target communication module matched with the target communication mode to sequentially send the sending task to the corresponding receiving end according to the time sequence, and feeding back the sending status event to the service logic layer includes:
s1411, inquiring according to the target communication mode to obtain the target communication module, controlling the target communication module to execute the sending tasks in the sending queue, counting and judging whether the sending times of the sending tasks exceed the corresponding sending time threshold; if yes, go to step S1412; otherwise, repeatedly executing the step S1411 until the transmission frequency reaches the transmission frequency threshold or the receiving end receives a response;
s1412 deletes the sending task push from the sending queue, and cancels the sending of the sending task.
5. A data transmission processing method is applied to a receiving end and comprises the following steps:
s2100 receives a communication data packet from a transmitting end;
s2200 determines whether the communication data packet is qualified; if yes, go to step S2500, otherwise go to step S2300;
s2300, processing the communication data packet to obtain a plurality of single-segment data frames which accord with a preset data frame format;
s2400 carries out protocol verification on the plurality of single-segment data frames, splices all the single-segment data frames passing the verification and pushes the splicing result to a data layer;
and S2500, carrying out protocol verification on the qualified communication data packet, and pushing the qualified communication data packet to a data layer after the verification is passed.
6. The data transmission processing method according to claim 5, wherein the step of S2200 judging whether the communication data packet is qualified comprises the steps of:
s2210 determines whether the first byte of the current communication data packet is a frame header flag; if yes, go to step S2220; otherwise, discarding the current communication data packet and returning to step S2100 until data reception is completed;
s2220 judges whether the current communication data packet includes at least one single-segment data frame conforming to a preset data frame format; if yes, go to step S2230; otherwise, go to step S2240;
s2230 determines whether the number of data frames in the current communication data packet is one; if yes, go to step S2250; otherwise, go to step S2240;
s2240 determines that the current communication data packet is unqualified and the step S2300 is performed;
s2250 determining the current communication data packet lattice and proceeding to step S2500;
the preset data frame format comprises a data head and effective data, the data head is positioned in front of the effective data and accords with the format of the preset data head, and the preset data head comprises a frame head mark, a segment sequence mark, a frame length mark and a frame command code.
7. The data transmission processing method of claim 6, wherein the step of S2300 processing the communication data packet to obtain a plurality of single data frames conforming to a preset data frame format comprises the steps of:
s2310, if the current communication data packet is not qualified, and a first byte of the current communication data packet is a frame header flag, and the number of single-segment data frames included in the current communication data packet is more than one, pushing a first single-segment data frame of the current communication data packet to a protocol check queue for checking, and performing recursive processing on the remaining data of the current communication data packet except the first single-segment data frame;
s2320, if the current communication data packet is not qualified, and the first byte of the current communication data packet is a frame header flag, and the number of single data frames included in the current communication data packet is less than one, determining whether the current communication data packet includes a frame length flag; if yes, go to step S2330; otherwise, go to step S2380;
s2330, according to the frame length mark, judging whether the frame length of the current communication data packet is larger than the maximum data load of the communication mode used by the current communication data packet; if yes, go to step S2340; otherwise, the process proceeds to step S2370 after step S2360;
s2340 determining whether the current communication data packet includes a segment sequence flag; if yes, the process proceeds to step S2370 after step S2350; otherwise, go to step S2380;
s2350, pushing the current communication data packet to a cache queue, and calculating to obtain the target remaining byte number required for splicing the current communication data packet into a single-segment data frame according to the byte number, the frame length mark and the segment sequence mark of the current communication data packet;
s2360 pushing the current communication data packet to a buffer queue, and calculating to obtain the target remaining byte number needed by splicing the current communication data packet into a single-segment data frame according to the byte number and the frame length mark of the current communication data packet;
s2370 compares the byte number of the next communication data packet newly acquired in the cache queue with the target remaining byte number, and executes corresponding operation on the next communication data packet according to the comparison result;
s2380 retains the current communication data packet in the buffer queue, pushes the newly acquired next communication data packet to the buffer queue, splices the current communication data packet and the newly acquired next communication data packet to obtain a spliced communication data packet, and judges the validity of the spliced communication data packet again.
8. The data transmission processing method according to claim 7, wherein the S2370 compares the number of bytes of the next communication packet newly acquired from the buffer queue with the target remaining number of bytes, and the performing corresponding operation on the next communication packet according to the comparison result includes:
s2371 comparing the number of bytes of the next communication data packet newly acquired from the buffer queue with the target remaining number of bytes;
s2372, if the byte number is equal to the target remaining byte number as a result of the comparison, splicing the next communication data packet with the current communication data packet to obtain a spliced communication data packet, and pushing the spliced communication data packet to a protocol check queue for checking;
s2373 if the byte number is smaller than the target remaining byte number, emptying the data in the cache queue and returning to the step S2100 until the data reception is completed;
s2374 if the comparison result shows that the number of bytes is greater than the target remaining number of bytes, splicing the next communication data packet with the current communication data packet to obtain a spliced communication data packet, pushing a first single-segment data frame in the spliced communication data packet to a protocol check queue for checking, and performing recursive processing on the rest of data in the spliced communication data packet except the first single-segment data frame.
9. A transmitting device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor is configured to execute the computer program stored in the memory to perform the operations performed by the data transmission processing method according to any one of claims 1 to 4.
10. A receiving device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor is configured to execute the computer program stored in the memory to perform the operations performed by the data transmission processing method according to any one of claims 5 to 8.
CN201911255830.8A 2019-12-10 2019-12-10 Data transmission processing method, sending equipment and receiving equipment Pending CN110971387A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911255830.8A CN110971387A (en) 2019-12-10 2019-12-10 Data transmission processing method, sending equipment and receiving equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911255830.8A CN110971387A (en) 2019-12-10 2019-12-10 Data transmission processing method, sending equipment and receiving equipment

Publications (1)

Publication Number Publication Date
CN110971387A true CN110971387A (en) 2020-04-07

Family

ID=70033516

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911255830.8A Pending CN110971387A (en) 2019-12-10 2019-12-10 Data transmission processing method, sending equipment and receiving equipment

Country Status (1)

Country Link
CN (1) CN110971387A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111629279A (en) * 2020-04-13 2020-09-04 北京创享苑科技文化有限公司 Video data transmission method based on fixed-length format
CN111726300A (en) * 2020-06-15 2020-09-29 哈工大机器人(合肥)国际创新研究院 Data sending method and device
CN112153413A (en) * 2020-08-25 2020-12-29 广州市保伦电子有限公司 Method and server for processing screen splash in one-screen broadcast
CN113596155A (en) * 2021-07-29 2021-11-02 青岛海信医疗设备股份有限公司 Data processing method and device, electronic equipment and storage medium
CN114338848A (en) * 2021-12-21 2022-04-12 深圳市洲明科技股份有限公司 Communication data processing method, device, programmable logic device, transmission card and medium
CN114363390A (en) * 2022-01-21 2022-04-15 西安羚控电子科技有限公司 Unmanned aerial vehicle ground control system and control method
WO2023143030A1 (en) * 2022-01-25 2023-08-03 武汉微智创大科技有限公司 Simple no-response communication method and apparatus
CN116668195A (en) * 2023-07-28 2023-08-29 沈阳航盛科技有限责任公司 Transmission method for radio frequency analog terminal 429 communication protocol
CN117349322A (en) * 2023-12-05 2024-01-05 摩尔元数(福建)科技有限公司 SPC real-time analysis method and system based on analysis control chart

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104734810A (en) * 2012-06-07 2015-06-24 飞天诚信科技股份有限公司 Method and device for processing transmission data
CN106411560A (en) * 2016-06-01 2017-02-15 深圳市永兴元科技有限公司 Data transmission method and device
CN106549845A (en) * 2016-10-26 2017-03-29 郑州云海信息技术有限公司 A kind of communication means and system based on NTB hardware
EP3223467A1 (en) * 2014-12-08 2017-09-27 Huawei Technologies Co., Ltd. Data transmission method and device
CN107835040A (en) * 2017-11-30 2018-03-23 深圳市文鼎创数据科技有限公司 A kind of method, equipment and the storage medium of the data communication based on bluetooth
CN107872422A (en) * 2016-09-23 2018-04-03 杭州海康威视数字技术股份有限公司 A kind of data transmission method, device and electronic equipment
CN109587733A (en) * 2019-01-18 2019-04-05 苏州德姆斯信息技术有限公司 Low-consumption wireless communication transmission method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104734810A (en) * 2012-06-07 2015-06-24 飞天诚信科技股份有限公司 Method and device for processing transmission data
EP3223467A1 (en) * 2014-12-08 2017-09-27 Huawei Technologies Co., Ltd. Data transmission method and device
CN106411560A (en) * 2016-06-01 2017-02-15 深圳市永兴元科技有限公司 Data transmission method and device
CN107872422A (en) * 2016-09-23 2018-04-03 杭州海康威视数字技术股份有限公司 A kind of data transmission method, device and electronic equipment
CN106549845A (en) * 2016-10-26 2017-03-29 郑州云海信息技术有限公司 A kind of communication means and system based on NTB hardware
CN107835040A (en) * 2017-11-30 2018-03-23 深圳市文鼎创数据科技有限公司 A kind of method, equipment and the storage medium of the data communication based on bluetooth
CN109587733A (en) * 2019-01-18 2019-04-05 苏州德姆斯信息技术有限公司 Low-consumption wireless communication transmission method

Cited By (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111629279B (en) * 2020-04-13 2021-04-16 北京创享苑科技文化有限公司 Video data transmission method based on fixed-length format
CN111629279A (en) * 2020-04-13 2020-09-04 北京创享苑科技文化有限公司 Video data transmission method based on fixed-length format
CN111726300A (en) * 2020-06-15 2020-09-29 哈工大机器人(合肥)国际创新研究院 Data sending method and device
CN112153413A (en) * 2020-08-25 2020-12-29 广州市保伦电子有限公司 Method and server for processing screen splash in one-screen broadcast
CN113596155A (en) * 2021-07-29 2021-11-02 青岛海信医疗设备股份有限公司 Data processing method and device, electronic equipment and storage medium
CN114338848B (en) * 2021-12-21 2024-04-19 深圳市洲明科技股份有限公司 Communication data processing method, device, programmable logic device, transmitting card and medium
CN114338848A (en) * 2021-12-21 2022-04-12 深圳市洲明科技股份有限公司 Communication data processing method, device, programmable logic device, transmission card and medium
CN114363390A (en) * 2022-01-21 2022-04-15 西安羚控电子科技有限公司 Unmanned aerial vehicle ground control system and control method
CN114363390B (en) * 2022-01-21 2023-09-12 西安羚控电子科技有限公司 Unmanned aerial vehicle ground control system and control method
WO2023143030A1 (en) * 2022-01-25 2023-08-03 武汉微智创大科技有限公司 Simple no-response communication method and apparatus
CN116668195A (en) * 2023-07-28 2023-08-29 沈阳航盛科技有限责任公司 Transmission method for radio frequency analog terminal 429 communication protocol
CN116668195B (en) * 2023-07-28 2023-09-26 沈阳航盛科技有限责任公司 Transmission method for radio frequency analog terminal 429 communication protocol
CN117349322A (en) * 2023-12-05 2024-01-05 摩尔元数(福建)科技有限公司 SPC real-time analysis method and system based on analysis control chart
CN117349322B (en) * 2023-12-05 2024-03-08 摩尔元数(福建)科技有限公司 SPC real-time analysis method and system based on analysis control chart

Similar Documents

Publication Publication Date Title
CN110971387A (en) Data transmission processing method, sending equipment and receiving equipment
EP1009138B1 (en) Data transmission method
US8949600B2 (en) Composed message authentication code
EP3537827A1 (en) Method and system for sending and receiving data
US9379852B2 (en) Packet recovery method, communication system, information processing device, and program
US8078668B2 (en) Method and device for processing a message in a communication network
WO1999022306A1 (en) Offload of tcp segmentation to a smart adapter
CN112769939B (en) Big data reliable transmission method for real-time communication
CN109257143A (en) Method for there is sliced transmission data packet in the network transmission protocol of length limitation
CN111147184B (en) Ethernet transmitting and receiving equipment supporting multi-service preemption and continuous transmission and transmission device
CN110704133B (en) Satellite subpackage remote control receiving control method based on finite-state machine
US8166127B2 (en) Apparatus and methods for efficient insertion and removal of MPA markers and RDMA CRC digest
CN114788199A (en) Data verification method and device
US9036659B2 (en) Method for transferring network event protocol messages
CN109936859B (en) Small data volume transmission method suitable for high-delay low-bandwidth satellite communication
CN108400976A (en) Efficient message combined communication exchange system
EP1255407A2 (en) Storage data broadcast system for determining whether reception has been correctly made
EP3672189B1 (en) Data transmission method, device and system
CN111447046B (en) Service data transmission method, device, equipment and storage medium
JP3950865B2 (en) ATM communication system
CN104219178A (en) Openflow-based control message processing method, Openflow-based control message transmitting device, Openflow-based control message receiving device and Openflow-based control message processing system
CN114615354A (en) Method and device for processing message
CN116601892A (en) Network interface supporting time sensitive network and MACsec protection
CN114979793A (en) Live broadcast data transmission method, device, system, equipment and medium
JP7067956B2 (en) Relay device

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