CN111683138B - Socket-based efficient custom data transmission method - Google Patents

Socket-based efficient custom data transmission method Download PDF

Info

Publication number
CN111683138B
CN111683138B CN202010504781.3A CN202010504781A CN111683138B CN 111683138 B CN111683138 B CN 111683138B CN 202010504781 A CN202010504781 A CN 202010504781A CN 111683138 B CN111683138 B CN 111683138B
Authority
CN
China
Prior art keywords
file
data
data transmission
socket
upper computer
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.)
Active
Application number
CN202010504781.3A
Other languages
Chinese (zh)
Other versions
CN111683138A (en
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.)
China Aluminum International Engineering Corp ltd
Chinese Nonferrous Metal Survey And Design Institute Of Changsha Co ltd
Original Assignee
China Aluminum International Engineering Corp ltd
Chinese Nonferrous Metal Survey And Design Institute Of Changsha 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 China Aluminum International Engineering Corp ltd, Chinese Nonferrous Metal Survey And Design Institute Of Changsha Co ltd filed Critical China Aluminum International Engineering Corp ltd
Priority to CN202010504781.3A priority Critical patent/CN111683138B/en
Publication of CN111683138A publication Critical patent/CN111683138A/en
Application granted granted Critical
Publication of CN111683138B publication Critical patent/CN111683138B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/12Arrangements for detecting or preventing errors in the information received by using return channel
    • H04L1/16Arrangements for detecting or preventing errors in the information received by using return channel in which the return channel carries supervisory signals, e.g. repetition request signals
    • H04L1/18Automatic repetition systems, e.g. Van Duuren systems
    • H04L1/1867Arrangements specially adapted for the transmitter end
    • H04L1/189Transmission or retransmission of more than one copy of a message
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/161Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
    • H04L69/162Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms

Abstract

The invention provides a Socket-based efficient self-defined data transmission method, which adopts a data transmission system of an upper computer and a plurality of lower computers, wherein the upper computer and the lower computers adopt sockets for bidirectional communication; after the upper computer and the lower computer are connected through Socket; transmitting file data by using a file data transmission protocol, and storing the file data in a data pool according to four tuples after analysis; then scanning the data pool and cleaning the data pool; after the file data is transmitted, the upper computer checks the file data according to a predefined file data transmission protocol, and if the checking fails, the upper computer sends an instruction to inform the lower computer to resend. The invention can realize the data transmission of a plurality of lower computers and an upper computer, can effectively process the receiving and splicing of data packets through a self-defined transmission protocol, reduces the problem of packet loss possibly generated due to the two-way communication between the upper computer and the lower computer in a weak network environment, and is particularly suitable for the transmission of larger file data on the basis of common Socket data transmission.

Description

Socket-based efficient custom data transmission method
Technical Field
The invention relates to the technical field of computer communication and software, in particular to a Socket-based efficient custom data transmission method.
Background
With the development of internet technology and sensor technology, more and more sensors can realize remote data transmission. At present, data acquisition of the sensor is mostly realized by adopting MQTT or TPC/IP technology. The data communicated is also mostly several bytes of data. However, in some monitoring devices, such as ground deformation monitoring radars, the data monitored at a time can reach several MB or even tens of MB, and is stored in the form of file data. If the conventional transmission method is adopted, a long time is required for transmitting a file, and once one byte is in error, the transmission fails. And, if the time of the two measurements is less than the time of one data transmission, confusion of the two measurement data may result. Therefore, the invention provides a high-efficiency self-defined data transmission method aiming at the situations, which is particularly suitable for the transmission of large file data on the basis of the common Socket data transmission.
In view of the foregoing, there is a strong need for a Socket-based efficient custom data transmission method to solve the problems in the prior art.
Disclosure of Invention
The invention aims to provide a Socket-based efficient custom data transmission method for realizing remote file data transmission.
In order to achieve the above purpose, the invention provides a Socket-based efficient custom data transmission method, which adopts a data transmission system, wherein the data transmission system comprises an upper computer and a plurality of lower computers, and the upper computer and the lower computers are in bidirectional communication by adopting a Socket mode; the data transmission method comprises the following steps:
step one: the upper computer and the lower computer are connected through Socket;
step two: transmitting file data by adopting a file data transmission protocol, and storing the file data in a data pool according to the quadruple after analysis; the quadruple is T < filename, current packet number, total packet number, filestream >;
step three: scanning the data pool and cleaning the data pool;
step four: after the file data is transmitted, the upper computer checks the file data according to a predefined file data transmission protocol, and if the checking fails, the upper computer sends an instruction to inform the lower computer to resend.
Preferably, when the Socket is adopted for bidirectional communication, the lower computer transmits file data to the upper computer except instruction information.
Preferably, the file data includes one or more of a text file, an image file, and a binary file.
Preferably, the file data is named by a suffix of yyyy-MM-dd-HH-MM-ss., wherein yyyy is year, MM is month, dd is day, HH is 24 hours, MM is minutes, and ss is seconds.
Preferably, the definition of the file data transfer protocol is as follows:
reading the file data to be transmitted according to a binary format, and equally dividing the file data, wherein each part of the file data is a K byte file stream, and the file is divided into L part of file streams;
where l=floor (M/K), floor () is an upward rounding function; the former L-1 part, the byte number of each part of file stream is K, the L-th part of file stream is M- (L-1) K.
Preferably, the file data transmission protocol comprises an identifier, a file header and a file body; the identifier is used for identifying the starting position of the message, comprises two characters and occupies two bytes;
the file header comprises a radar number start byte, a file name start byte, a file stream start byte, a total file packet number, a file body byte number and a total file byte number of the int32 type data, and the total file byte number of the int64 type data; the int32 data type occupies 4 bytes, the int64 data type occupies 8 bytes, and the file header occupies 36 bytes;
the file body comprises a radar number, a file name, a check code and a file stream which are sequentially stored in a binary format.
Preferably, the scanning frequency of the data pool is not lower than 5 seconds.
Preferably, the data pool is cleaned according to different situations, specifically:
A. when the file names in all the quadruples only exist one, and the number of the quadruples is smaller than the total package number, no processing is carried out; B. when only one file name exists in all the quadruples and the number of the quadruples is equal to the total number of packages, splicing the file streams in the quadruples from small to large according to the current number of packages to form a new file writing disc;
C. when more than two types of file names exist in all the quadruples, the transmission is considered as failure, and the upper computer sends a failure instruction to the lower computer and simultaneously clears all the quadruples in the data pool;
D. when the file names in all the tetrads are two, and the number of the tetrads of a certain file name exceeds 90% of the total number, the data pool continues to receive;
E. when two file names exist in all the tetrads, and the number of the tetrads of a certain file name is equal to the total number of the packages of the files, splicing the file streams in the tetrads of the file name from small to large according to the current number of the packages to form a new file writing disk. Removing the tetrad of the file name in the data pool;
F. when the file names in all the tetrads are two, the tetrad number of any one file name is smaller than the total package number of the file, the tetrad number of any one file name is lower than 60%, the data pool is cleared, an instruction is sent to a lower computer, and the two files are informed of failure in sending.
The technical scheme of the invention has the following beneficial effects:
the invention can realize the data transmission of a plurality of lower computers and an upper computer, can effectively process the receiving and splicing of data packets through a self-defined transmission protocol, reduces the problem of packet loss possibly generated due to the two-way communication between the upper computer and the lower computer in a weak network environment, and is particularly suitable for the transmission of larger file data on the basis of common Socket data transmission.
In addition to the objects, features and advantages described above, the present invention has other objects, features and advantages. The present invention will be described in further detail below.
Detailed Description
The following detailed description of embodiments of the invention is provided, but the invention may be embodied in many different forms, which are defined and covered by the claims.
Example 1:
a Socket-based high-efficiency self-defining data transmission method adopts a data transmission system, wherein the data transmission system comprises an upper computer and a plurality of lower computers, and the upper computer and the lower computers are in bidirectional communication in a Socket mode; when the Socket is used for bidirectional communication, besides instruction information, the lower computer transmits file data to the upper computer. The transmitted file data includes text files, image files, binary files, and the like. The file data is named by a suffix name of yyyy-MM-dd-HH-MM-ss., wherein yyyy is year, MM is month, dd is day, HH is 24 hours, MM is minutes, and ss is seconds.
The definition of the file data transmission protocol is as follows:
reading the file data to be transmitted according to a binary format, and equally dividing the file data, wherein each part of the file data is a K byte file stream, and the file is divided into L part of file streams;
where l=floor (M/K), floor () is an upward rounding function; the former L-1 part, the byte number of each part of file stream is K, the L-th part of file stream is M- (L-1) K.
The file data transfer protocol includes an identification (Flag), a Header (Header), and a Body (Body); the format is described as follows:
Figure GDA0002559837610000041
the identifier is used for identifying the starting position of the message, and comprises two characters "#", which occupy two bytes;
the file header comprises a radar number start byte, a file name start byte, a file stream start byte, a total file packet number, a file body byte number and a total file byte number of the int32 type data, and the total file byte number of the int64 type data; the int32 data type occupies 4 bytes, the int64 data type occupies 8 bytes, and the file header occupies 36 bytes;
the radar number initial byte is the initial position of the radar number in the message; the file name initial byte is the initial position of the file name in the message; the initial byte of the check code is the initial position of the check code in the message; the initial byte of the file stream is the initial position of the segmented file stream in the message; the total bytes of the file are the total bytes of the file; the current packet number of the file indicates the number of packets currently transmitted, and the number is counted from 1; the total package number of the file indicates how many packages the file is divided into in total; the number of bytes of the Body portion is the number of bytes of the Body portion.
The file body comprises a radar number, a file name, a check code and a file stream which are sequentially stored in a binary format. The file stream is a file stream dividing a subsequent packet.
For file data transmission, after the upper computer and a certain lower computer are connected through a Socket, data organized according to the defined protocol is received, and for each piece of data, the data is stored in a data pool according to four tuples after being analyzed, wherein the four tuples are T < file name, current packet number, total packet number and file stream >.
For the data pool, the data pool is scanned according to the frequency of not less than 5 seconds, and the data pool is cleaned according to different situations, specifically:
A. when the file names in all the quadruples only exist one, and the number of the quadruples is smaller than the total package number, no processing is carried out; B. when only one file name exists in all the quadruples and the number of the quadruples is equal to the total number of packages, splicing the file streams in the quadruples from small to large according to the current number of packages to form a new file writing disc;
C. when more than two types of file names exist in all the quadruples, the transmission is considered as failure, and the upper computer sends a failure instruction to the lower computer and simultaneously clears all the quadruples in the data pool;
D. when the file names in all the tetrads are two, and the number of the tetrads of a certain file name exceeds 90% of the total number, the data pool continues to receive;
E. when two file names exist in all the tetrads, and the number of the tetrads of a certain file name is equal to the total number of the packages of the files, splicing the file streams in the tetrads of the file name from small to large according to the current number of the packages to form a new file writing disk. Removing the tetrad of the file name in the data pool;
F. when the file names in all the tetrads are two, the tetrad number of any one file name is smaller than the total package number of the file, the tetrad number of any one file name is lower than 60%, the data pool is cleared, an instruction is sent to a lower computer, and the two files are informed of failure in sending.
After the file data is transmitted, the upper computer checks the file data according to a predefined file data transmission protocol, and if the checking fails, the upper computer sends an instruction to inform the lower computer to resend.
The above description is only of the preferred embodiments of the present invention and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (6)

1. The Socket-based efficient self-defined data transmission method is characterized by adopting a data transmission system, wherein the data transmission system comprises an upper computer and a plurality of lower computers, and the upper computer and the lower computers are in bidirectional communication in a Socket mode; the data transmission method comprises the following steps:
step one: the upper computer and the lower computer are connected through Socket;
step two: transmitting file data by adopting a file data transmission protocol, and storing the file data in a data pool according to the quadruple after analysis; the quadruple is T < filename, current packet number, total packet number, filestream >;
step three: scanning the data pool and cleaning the data pool;
step four: after the file data is transmitted, the upper computer checks the file data according to a predefined file data transmission protocol, and if the checking fails, the upper computer sends an instruction to inform the lower computer to resend;
the definition of the file data transmission protocol is as follows:
reading the file data to be transmitted according to a binary format, and equally dividing the file data, wherein each part of the file data is a K byte file stream, and the file is divided into L part of file streams;
where l=floor (M/K), floor () is an upward rounding function; the former L-1 part, the byte number of each part of file stream is K, the L-th part of file stream, the byte number is M- (L-1) K;
the file data transmission protocol comprises an identifier, a file header and a file body;
the identifier is used for identifying the starting position of the message and comprises two characters;
the file header comprises a radar number start byte, a file name start byte, a file stream start byte, a total file packet number, a file body byte number and a total file byte number of the int32 type data, and the total file byte number of the int64 type data;
the file body comprises a radar number, a file name, a check code and a file stream which are sequentially stored in a binary format.
2. The Socket-based efficient custom data transmission method according to claim 1, wherein when Socket sockets are used for bidirectional communication, the lower computer transmits file data to the upper computer except instruction information.
3. The Socket-based efficient custom data transmission method according to claim 2, wherein said file data comprises one or more of a text file, an image file and a binary file.
4. The Socket-based efficient custom data transmission method according to claim 3, wherein the file data naming mode is yyyy-MM-dd-HH-MM-ss. suffix, wherein yyyyy is year, MM is month, dd is day, HH is 24 hours, MM is minutes, and ss is seconds.
5. The Socket-based efficient custom data transmission method according to claim 4, wherein the scanning frequency of the data pool is not lower than 5 seconds.
6. The Socket-based efficient custom data transmission method according to any one of claims 1 to 5, wherein the data pool is cleaned according to different situations, specifically:
A. when the file names in all the quadruples only exist one, and the number of the quadruples is smaller than the total package number, no processing is carried out; B. when only one file name exists in all the quadruples and the number of the quadruples is equal to the total number of packages, splicing the file streams in the quadruples from small to large according to the current number of packages to form a new file writing disc;
C. when more than two types of file names exist in all the quadruples, the transmission is considered as failure, and the upper computer sends a failure instruction to the lower computer and simultaneously clears all the quadruples in the data pool;
D. when the file names in all the tetrads are two, and the number of the tetrads of a certain file name exceeds 90% of the total number, the data pool continues to receive;
E. when two file names exist in all the tetrads, and the number of the tetrads of a certain file name is equal to the total number of the packages of the files, splicing the file streams in the tetrads of the file name from small to large according to the current number of the packages to form a new file writing disk; removing the tetrad of the file name in the data pool;
F. when the file names in all the tetrads are two, the tetrad number of any one file name is smaller than the total package number of the file, the tetrad number of any one file name is lower than 60%, the data pool is cleared, an instruction is sent to a lower computer, and the two files are informed of failure in sending.
CN202010504781.3A 2020-06-05 2020-06-05 Socket-based efficient custom data transmission method Active CN111683138B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010504781.3A CN111683138B (en) 2020-06-05 2020-06-05 Socket-based efficient custom data transmission method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010504781.3A CN111683138B (en) 2020-06-05 2020-06-05 Socket-based efficient custom data transmission method

Publications (2)

Publication Number Publication Date
CN111683138A CN111683138A (en) 2020-09-18
CN111683138B true CN111683138B (en) 2023-06-16

Family

ID=72454272

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010504781.3A Active CN111683138B (en) 2020-06-05 2020-06-05 Socket-based efficient custom data transmission method

Country Status (1)

Country Link
CN (1) CN111683138B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113064158A (en) * 2021-03-17 2021-07-02 中国有色金属长沙勘察设计研究院有限公司 Engineering disaster intelligent monitoring radar communication system based on double middleware

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009030130A1 (en) * 2007-09-07 2009-03-12 Shenzhen Coship Electronics Co., Ltd. A method and system for transmitting data
CN103078707A (en) * 2013-01-03 2013-05-01 北京理工大学 File transmission method in deep space communication
CN103324587A (en) * 2012-03-20 2013-09-25 安凯(广州)微电子技术有限公司 Nandflash equipment encryption and decryption implementation method and system
CN106411907A (en) * 2016-10-13 2017-02-15 广西咪付网络技术有限公司 Data transmission method and system
CN106937287A (en) * 2017-04-01 2017-07-07 四川艾特赢泰智能科技有限责任公司 A kind of wireless data safe transmission method for Android device
CN107070613A (en) * 2017-03-22 2017-08-18 公安部交通管理科学研究所 Reliable data transmission method under distributed network environment
CN109525370A (en) * 2018-11-29 2019-03-26 苏州德姆斯信息技术有限公司 Data packet sending method based on zigbee

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102238002A (en) * 2010-04-30 2011-11-09 国际商业机器公司 Dynamic encryption and decryption methods and equipment for network communication
US8898244B2 (en) * 2011-10-20 2014-11-25 Allen Miglore System and method for transporting files between networked or connected systems and devices

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2009030130A1 (en) * 2007-09-07 2009-03-12 Shenzhen Coship Electronics Co., Ltd. A method and system for transmitting data
CN103324587A (en) * 2012-03-20 2013-09-25 安凯(广州)微电子技术有限公司 Nandflash equipment encryption and decryption implementation method and system
CN103078707A (en) * 2013-01-03 2013-05-01 北京理工大学 File transmission method in deep space communication
CN106411907A (en) * 2016-10-13 2017-02-15 广西咪付网络技术有限公司 Data transmission method and system
CN107070613A (en) * 2017-03-22 2017-08-18 公安部交通管理科学研究所 Reliable data transmission method under distributed network environment
CN106937287A (en) * 2017-04-01 2017-07-07 四川艾特赢泰智能科技有限责任公司 A kind of wireless data safe transmission method for Android device
CN109525370A (en) * 2018-11-29 2019-03-26 苏州德姆斯信息技术有限公司 Data packet sending method based on zigbee

Also Published As

Publication number Publication date
CN111683138A (en) 2020-09-18

Similar Documents

Publication Publication Date Title
EP1198926B1 (en) Bridge for can to tcp/ip connection
US6345301B1 (en) Split data path distributed network protocol
CA2205068C (en) Multi-processor environments
US20060280181A1 (en) Systems and methods for operating and management of RFID network devices
US20060101111A1 (en) Method and apparatus transferring arbitrary binary data over a fieldbus network
US6671273B1 (en) Method for using outgoing TCP/IP sequence number fields to provide a desired cluster node
US7395344B2 (en) Method for ACARS application communication over an IP network
CN102427446A (en) Packet coalescing
US20040258075A1 (en) Editing outbound TCP frames and generating acknowledgements
EP1345382A2 (en) System and method for identifying upper layer protocol message boundaries
CN1691669A (en) Method, system, and program for executing data transfer requests
US20030140149A1 (en) Communication protocol for use in controlling communications in a monitoring service system
CN109217983B (en) Industrial Internet of things operation terminal communication protocol design method
US6965571B2 (en) Precise error reporting
CN111683138B (en) Socket-based efficient custom data transmission method
CN1264235A (en) Data transmission protocol using short information service
CN206117730U (en) Thing networking environment real -time monitoring system based on 6LoWPAN agreement
CN102571732A (en) Method, device and system for processing sensor protocol information
US20030133464A1 (en) Customer-based service system including a cascaded pipeline with self-monitoring relays
US5675740A (en) System for sending messages in a session using a mixture of protocols and preventing usage of a protocol when the message failing to meet a set of criteria
US8587431B2 (en) Method and apparatus for tunneling information in RFID communications
CN1281563A (en) Network controller for processing status queries
CN108429797A (en) A kind of data communications method of more elevator safety operations
CN106027686B (en) Enhanced MODBUS communication method based on MPEG-2
CN108429729B (en) Data communication isolation system and isolation method in industrial big data acquisition environment

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
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20201230

Address after: No. 117, Tingyuan Road, Yuhua District, Changsha City, Hunan Province

Applicant after: CHINESE NONFERROUS METAL SURVEY AND DESIGN INSTITUTE OF CHANGSHA Co.,Ltd.

Applicant after: CHINA ALUMINUM INTERNATIONAL ENGINEERING Corp.,Ltd.

Address before: No. 117, Tingyuan Road, Yuhua District, Changsha City, Hunan Province

Applicant before: CHINESE NONFERROUS METAL SURVEY AND DESIGN INSTITUTE OF CHANGSHA Co.,Ltd.

GR01 Patent grant
GR01 Patent grant