Data transmission method

文档序号:1908206 发布日期:2021-11-30 浏览:16次 中文

阅读说明:本技术 一种数据传输方法 (Data transmission method ) 是由 陶虎刚 朱凌杉 王頠 张甲强 胡敏 张立业 谢军军 林海 于 2021-08-03 设计创作,主要内容包括:本发明公开了一种数据传输方法,S01:建立byte数组:根据需要传输的数据对象中各个属性数据类型,先计算得到序列化后byte数组长度,建立结果byte数组,然后逐一把属性转换为byte数组类型,并放入结果byte数组中;S02:分包方法:将序列化后的byte进行分包,更便于网络传输,尤其是文件或视频传输数据较大时。本发明,该数据传输方法,将视频或文件建立bety数组,然后进行分包传输,极大化的提高其数据的效率,并且降低数据丢失的风险,因分包传输,单个数据包泄露,也不会造成整个数据信息泄露,提高数据传输的安全性,并且在使用的过程中,可根据传输数据的大小,判断此数据是否需要分包传输。(The invention discloses a data transmission method, S01: establishing a byte array: according to each attribute data type in the data object needing to be transmitted, calculating to obtain the length of the serialized byte array, establishing a result byte array, converting the attribute into the byte array type one by one, and putting the byte array type into the result byte array; s02: the subpackage method comprises the following steps: and the serialized byte is packetized, so that network transmission is more convenient, especially when the file or video transmission data is large. The data transmission method establishes the beta array for the video or the file, then performs sub-packet transmission, maximizes the data efficiency, reduces the risk of data loss, prevents the leakage of the whole data information due to the leakage of a single data packet during sub-packet transmission, improves the safety of data transmission, and can judge whether the data needs sub-packet transmission according to the size of the transmission data during the use process.)

1. A data transmission method, comprising the steps of;

s01: establishing a byte array: according to each attribute data type in the data object needing to be transmitted, calculating to obtain the length of the serialized byte array, establishing a result byte array, converting the attribute into the byte array type one by one, and putting the byte array type into the result byte array;

s02: the subpackage method comprises the following steps: the serialized byte is subjected to sub-packaging, so that network transmission is facilitated, and especially when the file or video transmission data is large;

s03: setting the size of each packet, judging whether the data needs to be transmitted in a sub-packet mode or not according to the actual length of the byte arrays needing to be transmitted and the size of each packet, transmitting the data in the sub-packet mode, intercepting the byte arrays into a plurality of byte arrays with the set packet size according to the packet size until a target array is completely transmitted, packaging packet objects according to the sequence from front to back, and returning to a packet object List set;

s04: and the packet mixing method comprises the following steps: creating and storing a packet buffer set, which is used for receiving the data needing to be combined and judging the total number of packets in the received packet object, if the total number is 1, the current packet is complete, directly receiving the data, if the total number is more than 1, the packet is required to be combined, and the packet combining process, firstly judging whether the number of packets in the packet buffer is consistent with the total number of the packets in the received packet object, if the total number is consistent, the data is received, and performing the packet combining process.

S05: and packet processing: and sequencing all the packet objects in the cache according to the sequence numbers, then taking out the packet objects one by one, splicing the byte arrays of the packet objects until the splicing is finished, and returning to the complete packet.

2. The data transmission method according to claim 1, wherein in step S04, the data to be packed is received, the total number of packets in the received packet object is determined, if the total number of packets is 1, it indicates that the current packet is complete, the current packet is directly received, and then the parsing and deserializing are directly performed.

3. The data transmission method according to claim 2, wherein the deserializing method is performed by inverting the serialization process to obtain the corresponding bit of the corresponding attribute from the byte array, removing the byte array corresponding to the corresponding attribute, and performing conversion according to the data type of the attribute.

4. The data transmission method according to claim 1, wherein in step S02, it is determined whether the data needs to be transmitted in a sub-packet manner according to the actual length of the byte array to be transmitted and the size of each packet, and if the data does not need to be transmitted in a sub-packet manner, the encapsulated packet object is directly returned.

5. The data transmission method according to claim 1, wherein in step S04, it is determined whether the number of packets in the packet buffer is consistent with the total number of packets in the received packet object, and if not, the packet is not accepted, and the packet object is placed in the packet buffer list.

Technical Field

The invention relates to the technical field of data transmission, in particular to a data transmission method.

Background

Data transmission is to transmit data from a data source to a data terminal through one or more data links according to a certain rule, and the main function of the data transmission is to realize information transmission and exchange between points. A good data transmission mode can improve the real-time performance and reliability of data transmission, a data transmission part is in an important position in the whole system, namely, nerves of a human body transmit signals to all parts of the body, and how to efficiently, accurately and timely transmit digital information acquired by an acquisition module is an important subject, and data transmission is a communication process of transmitting data from one place to another place. Data transmission systems typically consist of a transmission channel and data circuit terminating equipment (DCE) at both ends of the channel, and in some cases, multiplexing equipment at both ends of the channel. The transmission channel may be a dedicated communication channel or may be provided by a data switching network, a telephone switching network or other types of switching networks. The input and output devices of a data transmission system are terminals or computers, generally called Data Terminal Equipment (DTE), and the data information sent by the DTE is generally a combination of letters, numbers and symbols, and each letter, number or symbol needs to be represented by a binary code in order to transmit the information.

The existing data transmission system is generally composed of a transmission channel and data circuit terminating equipment (DCE) at two ends of the transmission channel, and has problems in the actual use process, such as slow efficiency of file transmission of video and other files with larger data, poor safety of data transmission, and easy data loss.

Disclosure of Invention

The invention aims to solve the defects in the prior art and provides a data transmission method.

In order to achieve the purpose, the invention adopts the following technical scheme: a data transmission method, S01: establishing a byte array: according to each attribute data type in the data object needing to be transmitted, calculating to obtain the length of the serialized byte array, establishing a result byte array, converting the attribute into the byte array type one by one, and putting the byte array type into the result byte array;

s02: the subpackage method comprises the following steps: the serialized byte is subjected to sub-packaging, so that network transmission is facilitated, and especially when the file or video transmission data is large;

s03: setting the size of each packet, judging whether the data needs to be transmitted in a sub-packet mode or not according to the actual length of the byte arrays needing to be transmitted and the size of each packet, transmitting the data in the sub-packet mode, intercepting the byte arrays into a plurality of byte arrays with the set packet size according to the packet size until a target array is completely transmitted, packaging packet objects according to the sequence from front to back, and returning to a packet object List set;

s04: and the packet mixing method comprises the following steps: creating and storing a packet buffer set, which is used for receiving the data needing to be combined and judging the total number of packets in the received packet object, if the total number is 1, the current packet is complete, directly receiving the data, if the total number is more than 1, the packet is required to be combined, and the packet combining process, firstly judging whether the number of packets in the packet buffer is consistent with the total number of the packets in the received packet object, if the total number is consistent, the data is received, and performing the packet combining process.

S05: and packet processing: and sequencing all the packet objects in the cache according to the sequence numbers, then taking out the packet objects one by one, splicing the byte arrays of the packet objects until the splicing is finished, and returning to the complete packet.

As a further description of the above technical solution:

in step S04, the data to be packed is received, the total number of packets in the received packet object is determined, if the total number of packets is 1, the current packet is complete, the current packet is directly received, and then the parsing and deserializing are directly performed.

As a further description of the above technical solution:

the deserialization method is that the corresponding bit of the corresponding attribute is obtained from the byte array by reversing the serialization process, the byte array corresponding to the corresponding attribute is removed, and conversion is carried out according to the data type of the attribute.

As a further description of the above technical solution:

in step S02, it is determined whether the data needs to be transmitted in a sub-packet manner according to the actual length of the byte array to be transmitted and the size of each packet, and if the data does not need to be transmitted in a sub-packet manner, the encapsulated packet object is directly returned.

As a further description of the above technical solution:

in step S04, it is determined whether the number of packets in the packet cache is consistent with the total number of packets in the received packet object, and if not, the packet is not accepted, and the packet object is placed in the packet cache list.

Advantageous effects

The invention provides a data transmission method, which has the following beneficial effects:

the data transmission method establishes a beta array for a video or a file, then performs sub-packet transmission, maximizes the data efficiency and reduces the risk of data loss, single data packet leakage cannot cause whole data information leakage, and the data transmission safety is improved.

Drawings

FIG. 1 is a block diagram of a packetization method according to the present invention;

fig. 2 is a flow chart of a neutralization packet method according to the present invention.

Detailed Description

The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments.

Referring to fig. 1-2, a data transmission method includes the steps of;

s01: establishing a byte array: according to each attribute data type in the data object needing to be transmitted, calculating to obtain the length of the serialized byte array, establishing a result byte array, converting the attribute into the byte array type one by one, and putting the byte array type into the result byte array;

s02: the subpackage method comprises the following steps: the serialized byte is subjected to sub-packaging, so that network transmission is facilitated, and especially when the file or video transmission data is large;

s03: setting the size of each packet, judging whether the data needs to be transmitted in a sub-packet mode or not according to the actual length of the byte arrays needing to be transmitted and the size of each packet, transmitting the data in the sub-packet mode, intercepting the byte arrays into a plurality of byte arrays with the set packet size according to the packet size until a target array is completely transmitted, packaging packet objects according to the sequence from front to back, and returning to a packet object List set;

s04: and the packet mixing method comprises the following steps: creating and storing a packet buffer set, which is used for receiving the data needing to be combined and judging the total number of packets in the received packet object, if the total number is 1, the current packet is complete, directly receiving the data, if the total number is more than 1, the packet is required to be combined, and the packet combining process, firstly judging whether the number of packets in the packet buffer is consistent with the total number of the packets in the received packet object, if the total number is consistent, the data is received, and performing the packet combining process.

S05: and packet processing: and sequencing all the packet objects in the cache according to the sequence numbers, then taking out the packet objects one by one, splicing the byte arrays of the packet objects until the splicing is finished, and returning to the complete packet.

In step S04, the data to be packed is received to determine the total number of packets in the received packet object, if the total number is 1, the current packet is complete, and the current packet is directly received, and then the current packet is directly analyzed and deserialized.

The deserialization method is that the corresponding attribute corresponding bit is obtained from the byte array by reversing the serialization process, the byte array corresponding to the corresponding attribute is removed, and the conversion is carried out according to the data type of the attribute, wherein the byte array is a unit for transmitting information through a network, in an ASCII code, one English letter occupies the space of one byte, one Chinese character occupies the space of two bytes, a symbol, an English punctuation mark occupies one byte, a Chinese punctuation mark occupies two bytes, and a binary digit sequence is used as a digit unit in a computer, generally an 8-bit binary digit is converted into a decimal system.

In step S02, it is determined whether the data needs to be transmitted in a sub-packet manner according to the actual length of the byte array to be transmitted and the size of each packet, and if the data does not need to be transmitted in a sub-packet manner, the encapsulated packet object is returned directly.

In step S04, it is determined whether the number of packets in the packet cache is consistent with the total number of packets in the received packet object, and if not, the packet is not accepted, and the packet object is placed in the packet cache list.

The data transmission method of the invention, the data transmission method, set up the beta array in the video or file, then transmit by sub-packet, the efficiency of its data of maximization improvement, and reduce the risk of data loss, because of sub-packet transmission, single data packet reveals, will not cause the whole data information to reveal either, improve the security of data transmission, and in the course of using, can be according to the size of the transmission data, judge whether this data need sub-packet transmission, and in the course of making a packet, can judge the packet total number in the object of receiving the packet according to the data used for accepting needing to make a packet and carry on classification and packet processing, the processing efficiency of its data of maximization improvement, further raise the transmission efficiency of the data.

In the description herein, references to the description of "one embodiment," "an example," "a specific example," etc., mean that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above do not necessarily refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.

The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art should be considered to be within the technical scope of the present invention, and the technical solutions and the inventive concepts thereof according to the present invention should be equivalent or changed within the scope of the present invention.

6页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种网络拥塞控制方法及网络设备

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!