Specific embodiment
Many details are explained in the following description in order to fully understand the application.But the application can be withMuch it is different from other way described herein to implement, those skilled in the art can be without prejudice to the application intension the case whereUnder do similar popularization, therefore the application is not limited by following public specific implementation.
In this application, a kind of data transmission method and device are provided, calculates equipment and computer readable storage medium,It is described in detail one by one in the following embodiments.
The data transmission method of the embodiment of the present application is applied in the scene of the transmission data of first terminal, such as in clientDuring data transmission between end and server.Referring to Fig. 1, data transmission method disclosed in the embodiment of the present application is mainly wrappedIt includes step 102~104 for sending the first UDP message and receives the step 106 of the 2nd UDP message.It should be noted that step106 and step 102~104 be it is parallel execute, not executed according to sequencing.
102, the first object data that will acquire are split as at least one first data packet, and by least one described firstPacket encapsulation is at least one first User Datagram Protocol UDP message.
Wherein, first data packet and the first UDP message correspond.
In the present embodiment, first object data can for http (Hyper Text Transport Protocol, it is super literaryThis transport protocol) data, guarantee reliable transmission.
Wherein, it should be noted that each first data packet is encapsulated as a first UDP message, such as the first number respectivelyCapacity according to packet is 1300 bytes, if the first object data that this needs is sent are 100 bytes, then 1 will be generatedFirst data packet, 1 the first UDP message of corresponding generation;If the first object data that this needs is sent are 2000 bytes,2 the first data packets, 2 the first UDP messages of corresponding generation will so be generated.
First UDP message includes connection identifier (connection ID), to distinguish the first data packet that homogeneous is not sent,To realize the multiplex function of protocol link.
Also, for the first object data that single is sent, at least one split by a first object dataA first data packet, corresponding connection identifier is all the same, and each first data packet carries sequence number.Wherein, connection markKnow is that first terminal generates at random before cutting first object data.Such as currently needing the first object data sent is 2000A byte, then 2 the first data packets will be generated, the corresponding connection identifier of 2 the first data packets is all the same.
In the next steps, second terminal can determine which is counted after receiving the first UDP message according to connection identifierAccording to the first data packet that packet needs to receive for this, and this can be judged according to the corresponding sequence number of the first data packetWhether the first data packet received is complete.
104, the first UDP message is sent to second terminal, and in the first weight for receiving second terminal transmissionIn the case where passing request, the first UDP message for being packaged with the first data packet corresponding with first retransmission request is sent out againIt send to second terminal.
More at large, the first retransmission request carries the sequence of connection identifier and the first data packet for needing to retransmitNumber, so that the first packet encapsulation corresponding with the first retransmission request is that the first UDP message is re-transmitted to the by first terminalTwo terminals.
106, the 2nd UDP message for being packaged with the second data packet that second terminal is sent is received, and the 2nd UDP is reportedText is parsed to obtain the second data packet.
More at large, referring to fig. 2, step 106 includes:
202, receive second terminal transmission be packaged with the 2nd UDP message of the second data packet after, described in acquisitionThe connection identifier of 2nd UDP message, and compared with the connection identifier having been received, to judge the 2nd UDP messageWhether connection identifier is newly-increased connection identifier, if so, step 204 is executed, if it is not, executing step 206.
Wherein, identical as the create-rule of the first data packet, for being split at least by second target dataOne the second data packet, corresponding connection identifier are all the same.First terminal, can basis after receiving the 2nd UDP messageConnection identifier determines which data packet is the second data packet that this needs to receive, and can be corresponding according to the second data packetSequence number it is whether complete come the second data packet for judging that this is received.
It should be noted that the 2nd UDP message that first terminal receives is possible to be new, it is also possible to not be new(such as the 2nd UDP message of request retransmission), then, first terminal needs first after receiving the 2nd UDP message to secondThe connection identifier of UDP message is judged.
204, the 2nd UDP message for being packaged with the second data packet is parsed, then executes step 208.
206, by obtained the second data packet the second data packet having received corresponding with the connection identifier of parsing intoThen row split executes step 208.
208, whether the second data packet that judgement receives is complete, if it is not, step 210 is executed, if so, executing step 212.
210, the first terminal generates the second retransmission request and is sent to second terminal, is lost with triggering second terminal and retransmittingThe second data packet.
More at large, the second retransmission request carries the sequence of connection identifier and the second data packet for needing to retransmitNumber, so that the second packet encapsulation corresponding with the second retransmission request is that the 2nd UDP message is re-transmitted to this by second terminalFirst terminal.
212, the first terminal generation finishes receiving message and is sent to second terminal, and raw according to second data packetAt the second target data.
Wherein, first terminal gets the second target data, then means that first terminal receives the process completion of data.
Similarly, first terminal finishes receiving message receive that the second terminal sends, then means that firstThe process that terminal sends data is completed.
Data transmission method provided by the present application generates the first UDP message by the first object data that will acquire and sendsTo second terminal, the 2nd UDP message that second terminal is sent is received, and in the case where receiving the first retransmission request, it willIt is re-transmitted to second terminal in the corresponding first UDP message of the first retransmission request, thus can udp protocol transmission is utilizedWhile the advantages of to reduce performance cost, and realize reliable transmission.
The embodiment of the present application discloses a kind of data transmission method, in the scene applied to the transmission data of first terminal,Referring to Fig. 3, data transmission method disclosed in the embodiment of the present application mainly includes the steps that sending 302~306 He of the first UDP messageReceive step 308~310 of the 2nd UDP message.Wherein:
302, the first object data that will acquire are split as at least one first data packet, and by least one described firstPacket encapsulation is at least one first User Datagram Protocol UDP message.
304, the first UDP message is sent to second terminal, and in the first weight for receiving second terminal transmissionIn the case where passing request, the first UDP message for being packaged with the first data packet corresponding with first retransmission request is sent out againIt send to second terminal.
Wherein, step 302,304 with the step 102 of previous embodiment, 104 identical, the detailed solutions in relation to step 302,304Releasing can be respectively referring to abovementioned steps 102,104, and the present embodiment just repeats no more.
306, first data packet is grouped, generates at least one first packet data package, and by least oneFirst packet data package is encapsulated as the first UDP message, and by be packaged with the first packet data package the first UDP message andThe first UDP message for being packaged with the first data packet is sent to second terminal.
In this step, in transmission process, first terminal, which removes, sends the first data packet, also extraly sends the first groupingData packet, to effectively guarantee reliable transmission.Certainly, while guaranteeing reliable transmission, the transmission of data has certainRedundancy.Such as 3 the first data packets are generated into a packet data package, then the redundancy of data is 33%.The rule of groupingIt can artificially go to set according to demand.
It is received in second terminal and is packaged with the first UDP message of the first packet data package and is packaged with the first data packetThe first UDP message in the case where, when one grouping in lose first data packet after, still can pass through the first packet countRestored according to packet, it is effectively anti-dropout.
It should be noted that sending the first UDP message and envelope for being packaged with the first packet data package for first terminalThe first UDP message equipped with the first data packet, there is no sequencings, but are transmitted as data flow incessantly.It is rightIn second terminal in parsing, it can't also distinguish two kind of the first UDP message and parse with removing sequencing.
308, the 2nd UDP message for being packaged with the second data packet that second terminal is sent is received, and the 2nd UDP is reportedText is parsed to obtain the second data packet.
Wherein, step 308 is identical as the step 106 of previous embodiment, and the present embodiment just repeats no more.
310, the 2nd UDP message for being packaged with second packet data packet that second terminal is sent is received, and to being packaged with the2nd UDP message of two data packets and the 2nd UDP message for being packaged with second packet data packet are parsed, described in obtainingSecond data packet.
Wherein, the second packet data packet is that the second terminal generates second data packet grouping.With firstThe effect of packet data package is identical, receives the 2nd UDP message for being packaged with the second data packet of second terminal and is packaged with2nd UDP message of two packet data packages, to effectively guarantee reliable transmission.When one the second data of loss in a groupingBao Hou still can be restored by second packet data packet, effectively anti-dropout.
It should be noted that receiving the 2nd UDP message and envelope for being packaged with second packet data packet for first terminalThe 2nd UDP message equipped with the second data packet, there is no sequencings, but are received as data flow incessantly.
Optionally, during first terminal receives data, first terminal can not wait always to be received incompleteData, because of the timeliness of data, be more than the regular hour after will fail.So referring to fig. 4, the embodiment of the present applicationData transmission method further include:
If 402, not receiving complete second data packet within the first threshold time, generates and stop receiving message and sendTo second terminal, and the corresponding connection identifier of second data packet is stored in into caching.
Wherein, stop receiving the connection identifier connection identifier corresponding with the second data packet being located in caching that message carriesIt is identical.
The first threshold time can set according to actual needs, such as be set as 10 seconds.
If 404, receiving the 2nd UDP message identical with the connection identifier of second data packet being located in caching,Stopping reception message is sent to second terminal, to stop receiving the 2nd UDP message.
406, after the stopping for receiving second terminal transmission receives message, stop transmission and stop receiving message with describedThe identical first UDP message of connection identifier.
It should be noted that step 406 and step 402~404 are parallel processing, not successive sequence is executed.
Optionally, during first terminal sends data, first terminal is being more than the regular hour not receive theWhat two terminals returned finishes receiving message, then no matter whether first terminal is received again by second terminal return in the follow-up processAny request related with this data, this send data failed.So referring to Fig. 5, the embodiment of the present applicationData transmission method further include:
502, during sending first data packet, if not receiving second terminal hair within the second threshold timeThat send finishes receiving message, and the corresponding connection identifier of first data packet is stored in into caching.
Wherein, the connection identifier connection corresponding with the first data packet being located in caching for finishing receiving message carryingIt identifies identical.
The second threshold time can set according to actual needs, such as be set as 10 seconds.
If 504, receiving connection identifier identical first corresponding with first data packet being located in caching againRetransmission request sends to second terminal and stops sending message to stop sending the first UDP message.
Wherein, the connection identifier connection corresponding with the first data packet being located in caching for stopping sending that message carriesIt identifies identical.
506, after the stopping for receiving second terminal transmission sends message, stop reception and stop sending message with describedThe identical 2nd UDP message of connection identifier.
It should be noted that step 506 and step 502~504 are parallel processing, not successive sequence is executed.
Optionally, the data transmission method of the present embodiment further include: in the case where time interval reaches third threshold value, clearlyManage the caching of the first terminal.
Third threshold time can be set according to actual needs, such as be set as 1 hour.
Optionally, the data transmission method of the present embodiment further include: transmission detection messages to second terminal, and receive secondThen the response message that terminal returns is determined with determining the link information between two first terminals according to the link informationThe transmission frequency of the first UDP message.
Wherein, the link information includes: the time delay and packet loss of link.
In actual use, first terminal can send 10 detection messages at the moment such as starting, network switchings.
Data transmission method provided by the present application generates the first UDP message by the first object data that will acquire and sendsTo second terminal, the 2nd UDP message that second terminal is sent is received, and in the case where receiving the first retransmission request, it willIt is re-transmitted to second terminal in the corresponding first UDP message of the first retransmission request, thus can udp protocol transmission is utilizedWhile the advantages of to reduce performance cost, and realize reliable transmission.
Also, it solves the end of a thread obstructing problem of http protocol using udp protocol when passing through transmitting message, solvesThe problem of network bandwidth cannot be fully utilized at the beginning of transmitting in data, facilitates the rapid deployment and iteration of agreement.
In addition, the present embodiment receives second by sending the first packet data package and the first data packet to second terminalTerminal send second packet data packet and the second data packet, alleviate network in packet loss the problem of.
Again, the present embodiment realizes that the first terminal of data transmission sends mutually request message by making two, to solveUdp protocol transmits insecure problem.
The embodiment of the present application discloses a kind of data transmission device 600, referring to Fig. 6, comprising:
Module 602 is split, the first object data for will acquire are split as at least one first data packet, and will at leastOne first packet encapsulation is at least one the first UDP message, wherein first data packet and the first UDPMessage corresponds;
Sending module 604 for the first UDP message to be sent to second terminal, and is receiving second terminalIn the case where the first retransmission request sent, the first of the first data packet is packaged with by corresponding with first retransmission requestUDP message is re-transmitted to second terminal via transport layer;
Receiving module 606, for receiving the 2nd UDP message for being packaged with the second data packet of second terminal transmission, and it is rightThe 2nd UDP message is parsed to obtain the second data packet.
Optionally, receiving module 606 includes:
Judgment module 6062, whether the second data packet for judging to receive is complete, if it is not, then executing the first processing mouldThe corresponding movement of block, if it is not, then executing the corresponding movement of Second processing module;
First processing module 6064 is sent to second terminal for generating the second retransmission request, to trigger second terminal weightPass the second data packet lost;
Second processing module 6066 finishes receiving message for generation and is sent to second terminal, and according to second numberThe second target data is generated according to packet.
Optionally, the data transmission device of the present embodiment further include:
Grouping module generates at least one first packet data package, and will for first data packet to be groupedAt least one described first packet data package is encapsulated as the first UDP message;
The first UDP message for being packaged with the first packet data package is sent to second terminal by the sending module 604.
Optionally, the data transmission device of the present embodiment further include:
The receiving module 606 is also used to receive the 2nd UDP for being packaged with second packet data packet of second terminal transmissionMessage, wherein the second packet data packet is that the second terminal generates second data packet grouping;
The receiving module 606 is also used to the 2nd UDP message for being packaged with the second data packet and is packaged with second point2nd UDP message of group data packet is parsed, to obtain second data packet.
Optionally, the first UDP message and the 2nd UDP message include connection identifier;
For at least one first data packet split by the first object data, corresponding connection markKnow all the same;For at least one second data packet split by second target data, corresponding connectionIt identifies all the same.
Optionally, the 2nd UDP for being packaged with the second data packet of second terminal transmission is received in the receiving module 606After message, further includes:
The receiving module 606 obtains the connection identifier of the 2nd UDP message, and with the connection identifier that has been receivedIt compares, to judge whether the connection identifier of the 2nd UDP message is newly-increased connection identifier;
If so, the receiving module 606 parses the 2nd UDP message for being packaged with the second data packet, withObtain second data packet;
If it is not, then the receiving module 606 has connect obtained the second data packet of parsing is corresponding with the connection identifierThe second data packet received carries out split.
Optionally, described if the receiving module 606 does not receive complete second data packet within the first threshold timeSending module 604 generates stopping reception message and is sent to second terminal, and the corresponding connection identifier of second data packet is depositedEnter into caching;Wherein, described to stop receiving the connection identifier that message carries and second data packet pair being located in cachingThe connection identifier answered is identical;
If the receiving module 606 receives identical with the connection identifier of second data packet being located in caching theStopping reception message is sent to second terminal by two UDP messages, the sending module 604, to stop receiving described secondUDP message.
Optionally, during the sending module 604 sends first data packet, if within the second threshold timeDo not receive second terminal transmission finishes receiving message, and the corresponding connection identifier of first data packet is stored in cachingIn;Wherein, the connection identifier connection corresponding with first data packet being located in caching for finishing receiving message carryingIt identifies identical;
If the sending module 604 receives connection identifier corresponding with first data packet being located in caching againIdentical first retransmission request, the receiving module is sent to second terminal to be stopped sending message, to stop sending the first UDP reportText;Wherein, the connection identifier connection corresponding with first data packet being located in caching for stopping sending that message carriesIt identifies identical.
Optionally, after the stopping for receiving second terminal transmission receives message, sending module 604 stops receiving module 606Only send the first UDP message identical with the reception connection identifier of message is stopped.
Optionally, after the stopping for receiving second terminal transmission sends message, receiving module 606 stops sending module 604Only receive the 2nd UDP message identical with the transmission connection identifier of message is stopped.
Data transmission device provided by the present application generates the first UDP message by the first object data that will acquire and sendsTo second terminal, the 2nd UDP message that second terminal is sent is received, and in the case where receiving the first retransmission request, it willIt is re-transmitted to second terminal in the corresponding first UDP message of the first retransmission request, thus can udp protocol transmission is utilizedWhile the advantages of to reduce performance cost, and realize reliable transmission.
A kind of exemplary scheme of above-mentioned data transmission device for the present embodiment.It should be noted that the data are transmittedThe technical solution of device and the technical solution of above-mentioned data transmission method belong to same design, the technical side of data transmission deviceThe detail content that case is not described in detail may refer to the description of the technical solution of above-mentioned data transmission method.
Fig. 7 is to show the structural block diagram of the calculating equipment 700 according to one embodiment of the application.The calculating equipment 700Component includes but is not limited to memory 710 and processor 720.Processor 720 is connected with memory 710.It is deposited in memory 710The computer instruction that can be run on processor 720 is contained, the processor 720 is realized as described above when executing described instructionThe step of data are transmitted.
Although being not shown in Fig. 7, it will be appreciated that calculating equipment 700 can also include network interface, network interfaceEnable and calculates equipment 700 via one or more network communications.The example of these networks includes local area network (LAN), wide areaThe combination of the communication network of net (WAN), personal area network (PAN) or such as internet.Network interface may include wired or wirelessOne or more of any kind of network interface (for example, network interface card (NIC)), such as IEEE802.11 wireless local areaNet (WLAN) wireless interface, worldwide interoperability for microwave accesses (Wi-MAX) interface, Ethernet interface, universal serial bus (USB) connectMouth, cellular network interface, blue tooth interface, near-field communication (NFC) interface, etc..
In one embodiment of the application, unshowned other component can also in above-mentioned and Fig. 7 of calculating equipment 700To be connected to each other, such as pass through bus.It should be appreciated that calculating device structure block diagram shown in Fig. 7 is merely for the sake of exemplaryPurpose, rather than the limitation to the application range.Those skilled in the art can according to need, and increase or replace other component.
Calculating equipment 700 can be any kind of static or mobile computing device, including mobile computer or mobile meterCalculate equipment (for example, tablet computer, personal digital assistant, laptop computer, notebook computer, net book etc.), movementPhone (for example, smart phone), wearable calculating equipment (for example, smartwatch, intelligent glasses etc.) or other kinds of shiftingDynamic equipment, or the static calculating equipment of such as desktop computer or PC.Calculating equipment 700 can also be mobile or state typeServer.
A kind of exemplary scheme of above-mentioned calculating equipment for the present embodiment.It should be noted that the skill of the calculating equipmentArt scheme and the technical solution of above-mentioned data transmission method belong to same design, and the technical solution for calculating equipment is not described in detailDetail content, may refer to the description of the technical solution of above-mentioned data transmission method.
One embodiment of the application also provides a kind of computer readable storage medium, is stored with computer instruction, the instructionThe step of data transmission method as previously described is realized when being executed by processor.
A kind of exemplary scheme of above-mentioned computer readable storage medium for the present embodiment.It should be noted that this is depositedThe technical solution of storage media and the technical solution of above-mentioned data transmission method belong to same design, the technical solution of storage mediumThe detail content being not described in detail may refer to the description of the technical solution of above-mentioned data transmission method.
The computer instruction includes computer program code, the computer program code can for source code form,Object identification code form, executable file or certain intermediate forms etc..The computer-readable medium may include: that can carry instituteState any entity or device, recording medium, USB flash disk, mobile hard disk, magnetic disk, CD, the computer storage of computer program codeDevice, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory),Electric carrier signal, telecommunication signal and software distribution medium etc..It should be noted that the computer-readable medium include it is interiorIncrease and decrease appropriate can be carried out according to the requirement made laws in jurisdiction with patent practice by holding, such as in certain jurisdictions of courtsArea does not include electric carrier signal and telecommunication signal according to legislation and patent practice, computer-readable medium.
It should be noted that for the various method embodiments described above, describing for simplicity, therefore, it is stated as a series ofCombination of actions, but those skilled in the art should understand that, the application is not limited by the described action sequence becauseAccording to the application, certain steps can use other sequences or carry out simultaneously.Secondly, those skilled in the art should also knowIt knows, the embodiments described in the specification are all preferred embodiments, and related actions and modules might not all be this ShenIt please be necessary.
In the above-described embodiments, it all emphasizes particularly on different fields to the description of each embodiment, there is no the portion being described in detail in some embodimentPoint, it may refer to the associated description of other embodiments.
The application preferred embodiment disclosed above is only intended to help to illustrate the application.There is no detailed for alternative embodimentAll details are described, are not limited the invention to the specific embodiments described.Obviously, according to the content of this specification,It can make many modifications and variations.These embodiments are chosen and specifically described to this specification, is in order to preferably explain the applicationPrinciple and practical application, so that skilled artisan be enable to better understand and utilize the application.The application is onlyIt is limited by claims and its full scope and equivalent.