CN113438241B - Data transmission method and system - Google Patents
Data transmission method and system Download PDFInfo
- Publication number
- CN113438241B CN113438241B CN202110712792.5A CN202110712792A CN113438241B CN 113438241 B CN113438241 B CN 113438241B CN 202110712792 A CN202110712792 A CN 202110712792A CN 113438241 B CN113438241 B CN 113438241B
- Authority
- CN
- China
- Prior art keywords
- data
- memory
- receiving end
- data transmission
- layer
- 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
Links
- 230000005540 biological transmission Effects 0.000 title claims abstract description 33
- 238000000034 method Methods 0.000 title claims abstract description 27
- 238000012790 confirmation Methods 0.000 claims abstract description 17
- 230000015556 catabolic process Effects 0.000 abstract description 3
- 230000009286 beneficial effect Effects 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/16—Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
- H04L69/161—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields
- H04L69/162—Implementation details of TCP/IP or UDP/IP stack architecture; Specification of modified or new header fields involving adaptations of sockets based mechanisms
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L69/00—Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
- H04L69/30—Definitions, standards or architectural aspects of layered protocol stacks
- H04L69/32—Architecture of open systems interconnection [OSI] 7-layer type protocol stacks, e.g. the interfaces between the data link level and the physical level
- H04L69/321—Interlayer communication protocols or service data unit [SDU] definitions; Interfaces between layers
Landscapes
- Engineering & Computer Science (AREA)
- Computer Security & Cryptography (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Communication Control (AREA)
Abstract
The invention relates to the field of data transmission, and particularly discloses a method and a system for realizing data transmission. According to the method and the device, the socket protocol family is arranged, so that data can be directly received and transmitted at the link layer, the data is not required to be transmitted layer by layer through the data link layer, the network layer, the transmission layer, the session layer, the presentation layer and the application layer, a great deal of consumption of system resources caused by layer data transmission is avoided, and meanwhile, the risk of system breakdown caused by memory overflow caused by data transmission is also avoided; meanwhile, the stability and the accuracy of data transmission and reception are further improved by arranging the annular memory of the transmitting end, the annular memory of the receiving end message confirmation data and the annular memory of the transmitting end message confirmation data.
Description
Technical Field
The invention belongs to the field of data transmission, and particularly discloses a data transmission method and a data transmission system.
Background
Because the internet can exchange information without being limited by space, people have shadows everywhere in life and work, the importance of the internet is increasing, and data transmission is the most basic and important part for realizing information interaction.
In the prior art, a socket data transmission method is often adopted to transmit data, but in the existing socket data transmission method, the data is transmitted layer by layer mainly through a data link layer, a network layer, a transmission layer, a session layer, a presentation layer and an application layer, the adoption of layer by layer transmission of the data can cause a great deal of consumption of system resources, and meanwhile, the risk that a great deal of transmitted data overflows to cause memory so as to cause system breakdown exists.
Disclosure of Invention
In order to solve the above problems, the present application provides a data transmission method, specifically:
s1, acquiring data and data parameters, and distributing the memory size of a transmitting end annular memory according to the data parameters;
s2, writing the data into a transmitting end annular memory, circularly reading the data in the transmitting end annular memory by using a transmitting end message confirmation data annular memory, and transmitting the data to a receiving end message confirmation data annular memory;
and S3, the receiving end message confirms that the data annular memory circularly stores the data to the receiving end annular memory, and the receiving end application program circularly reads the data in the receiving end annular memory.
Further, the S1 specifically is:
the data parameters include a data structure, a size of a used memory block, and a number of practical memory blocks.
Further, the S2 specifically is:
s21: setting a socket protocol family, and writing data into the transmitting end annular memory of a link layer;
s22: and the sending end message confirms that the data annular memory circularly reads the data in the sending end annular memory and judges whether the data exists in the sending end annular memory.
Further, the step S22 specifically includes:
if yes, calling a socket to send the data to a receiving end message confirmation data ring memory;
if not, the sender message confirms that the data ring memory is in a waiting state.
Further, the step S3 specifically includes:
s31: calling socket to receive data;
s32: the receiving end message confirmation data annular memory judges whether the data in the sending end annular memory is received or not;
if yes, circularly storing the data in the sending end annular memory to the receiving end annular memory, and circularly reading the data in the receiving end annular memory by an application program;
if not, the receiving end information confirms that the data ring memory is in a waiting state.
A data transmission system is used for realizing the data transmission method.
Compared with the prior art, the application has the following beneficial effects: according to the method and the device, the socket protocol family is set, so that data is transmitted between link layers, a large amount of consumption of system resources caused by layer-by-layer data transmission is avoided, and meanwhile, the risk of system breakdown caused by memory overflow caused by data transmission is also avoided; meanwhile, the stability and the accuracy of data transmission and reception are further improved by arranging the annular memory of the transmitting end, the annular memory of the receiving end message confirmation data and the annular memory of the transmitting end message confirmation data.
Drawings
Fig. 1 is a schematic flow chart of a method for implementing data transmission according to an embodiment of the present invention;
Detailed Description
In order to make the technical solution of the present invention better understood by those skilled in the art, the present invention will be further described in detail with reference to the accompanying drawings and specific embodiments.
As shown in fig. 1, an embodiment of the present invention provides a data transmission method, applied to a data transmission system, where the system includes a ring memory at a transmitting end, a ring memory at a receiving end, a ring memory for receiving end message confirmation data, and a ring memory for transmitting end message confirmation data, and the specific method includes:
s1, acquiring data and data parameters, and distributing the memory size of a transmitting end annular memory according to the data parameters;
s2, writing the data into a transmitting end annular memory, circularly reading the data in the transmitting end annular memory by using a transmitting end message confirmation data annular memory, and transmitting the data to a receiving end message confirmation data annular memory;
and S3, the receiving end message confirms that the data annular memory circularly stores the data to the receiving end annular memory, and the receiving end application program circularly reads the data in the receiving end annular memory.
The ring memory is a fixed memory space, the user puts data into the ring memory one by one, the write pointer moves backwards until the difference between the write pointer and the read pointer is zero, the ring memory is full of data, and the write data is in a waiting state. When the user reads the ring memory data, the reading pointer moves backwards every time when one piece of data is read, and when the reading pointer and the writing pointer are equal, no data can be read, and the reading data is in a waiting state.
Therefore, to maximize the storage efficiency of the ring memory, it is necessary to analyze the data according to the parameters of the data, and then allocate the memory size of the ring memory according to the result of the data analysis.
As shown in fig. 1, other application programs at the transmitting end firstly generate data, and allocate the memory size of the ring-shaped memory at the transmitting end according to the data parameters, wherein the data parameters comprise a data structure, the size of the used memory blocks and the number of practical memory blocks; setting a socket protocol family, storing the data to a ring memory of a link layer transmitting end according to the allocated memory size, circularly reading the data in the transmitting end ring memory by a transmitting end message confirmation data ring memory, judging whether the data exists in the transmitting end ring memory, circularly reading and judging the transmitting end ring memory to prevent the condition of data missing, and calling the socket to transmit the data to a receiving end message confirmation data ring memory if the data is read; if the data is not read, the sending end information confirms that the data ring memory is in a waiting state, and the sending end information confirms that the data ring memory continues to carry out the next cycle reading judgment.
The setting of the socket protocol family, specifically, setting the socket type as the SOCK_RAW by setting the socket protocol family as PF_PACKET and using the standard physical layer address structure, which is irrelevant to the device, enables data to be directly received and transmitted at the link layer without passing through protocols of the upper layers of the link layer.
At a receiving end, calling a socket to receive data of a ring memory of a transmitting end, and judging whether the data in the ring memory of the transmitting end is received by the ring memory of the receiving end information confirmation data; if the data are stored in the judgment result, circularly storing the data in the sending end annular memory into the receiving end annular memory, and circularly reading the data in the receiving end annular memory by an application program; if the judging result is that no data exists, the receiving end information confirms that the data ring memory is in a waiting state.
The specific implementation process of the data transmission system for implementing the data transmission method is described above, and will not be described herein.
It should be noted that, in the present specification, each embodiment is described in a progressive manner, and each embodiment is mainly described as different from other embodiments, and identical and similar parts between the embodiments are all enough to be referred to each other.
It is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (5)
1. A method of data transmission, the method comprising:
s1, acquiring data and data parameters, and distributing the memory size of a transmitting end annular memory according to the data parameters;
s2, setting a socket protocol family, and writing data into the transmitting end annular memory of a link layer; the sending end message confirms that the data ring memory circularly reads the data in the sending end ring memory, judges whether the data exists in the sending end ring memory,
specifically, setting a protocol family of socket as PF_PACKET, setting socket_type as SOCK_RAW, and using a standard physical layer address structure sockaddr_ll;
and S3, the receiving end information confirms that the data annular memory circularly stores the data to the receiving end annular memory, and the receiving end application program circularly reads the data in the receiving end annular memory.
2. The data transmission method according to claim 1, wherein S1 specifically is:
the data parameters include a data structure, a size of a used memory block, and a number of practical memory blocks.
3. The data transmission method according to claim 1, wherein S2 is specifically:
if yes, calling a socket to send the data to a receiving end message confirmation data ring memory;
if not, the sender message confirms that the data ring memory is in a waiting state.
4. The data transmission method according to claim 1, wherein the S3 specifically is:
s31: calling socket to receive data;
s32: the receiving end message confirmation data annular memory judges whether the data in the sending end annular memory is received or not;
if yes, circularly storing the data in the sending end annular memory to the receiving end annular memory, and circularly reading the data in the receiving end annular memory by an application program;
if not, the receiving end information confirms that the data ring memory is in a waiting state.
5. A data transmission system for performing the data transmission method of any one of claims 1-4.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110712792.5A CN113438241B (en) | 2021-06-25 | 2021-06-25 | Data transmission method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202110712792.5A CN113438241B (en) | 2021-06-25 | 2021-06-25 | Data transmission method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN113438241A CN113438241A (en) | 2021-09-24 |
CN113438241B true CN113438241B (en) | 2024-02-13 |
Family
ID=77754598
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202110712792.5A Active CN113438241B (en) | 2021-06-25 | 2021-06-25 | Data transmission method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113438241B (en) |
Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1129388A1 (en) * | 1998-11-09 | 2001-09-05 | Silverbrook Research Pty. Limited | Digital camera device with internal printer |
CN101729869A (en) * | 2009-12-21 | 2010-06-09 | 山东大学 | Embedded camera video acquisition and network transmission module and working method thereof |
CN103617142A (en) * | 2013-09-09 | 2014-03-05 | 南京邮电大学 | High-speed network data collection method based on pf_ring |
CN104035884A (en) * | 2014-06-30 | 2014-09-10 | 河南百旺金赋电脑有限公司 | Double-annular-array data storage method and intelligent gateway |
WO2018103565A1 (en) * | 2016-12-09 | 2018-06-14 | Zhejiang Dahua Technology Co., Ltd. | Methods and systems for data transmission |
CN109729024A (en) * | 2018-12-29 | 2019-05-07 | 中盈优创资讯科技有限公司 | Data packet handling system and method |
CN110418376A (en) * | 2019-07-29 | 2019-11-05 | 国广东方网络(北京)有限公司 | Data transmission method and device |
CN111831596A (en) * | 2020-07-28 | 2020-10-27 | 山东有人信息技术有限公司 | RTOS serial port network transmission method and device |
CN111988230A (en) * | 2020-08-19 | 2020-11-24 | 海光信息技术有限公司 | Virtual machine communication method, device and system and electronic equipment |
-
2021
- 2021-06-25 CN CN202110712792.5A patent/CN113438241B/en active Active
Patent Citations (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
EP1129388A1 (en) * | 1998-11-09 | 2001-09-05 | Silverbrook Research Pty. Limited | Digital camera device with internal printer |
CN101729869A (en) * | 2009-12-21 | 2010-06-09 | 山东大学 | Embedded camera video acquisition and network transmission module and working method thereof |
CN103617142A (en) * | 2013-09-09 | 2014-03-05 | 南京邮电大学 | High-speed network data collection method based on pf_ring |
CN104035884A (en) * | 2014-06-30 | 2014-09-10 | 河南百旺金赋电脑有限公司 | Double-annular-array data storage method and intelligent gateway |
WO2018103565A1 (en) * | 2016-12-09 | 2018-06-14 | Zhejiang Dahua Technology Co., Ltd. | Methods and systems for data transmission |
CN109729024A (en) * | 2018-12-29 | 2019-05-07 | 中盈优创资讯科技有限公司 | Data packet handling system and method |
CN110418376A (en) * | 2019-07-29 | 2019-11-05 | 国广东方网络(北京)有限公司 | Data transmission method and device |
CN111831596A (en) * | 2020-07-28 | 2020-10-27 | 山东有人信息技术有限公司 | RTOS serial port network transmission method and device |
CN111988230A (en) * | 2020-08-19 | 2020-11-24 | 海光信息技术有限公司 | Virtual machine communication method, device and system and electronic equipment |
Non-Patent Citations (3)
Title |
---|
"基于CM平台的网络数据包捕获和解析系统的设计与实现";徐路路;《中国优秀硕士学位论文信息科技辑》;20140601;第33页第19-21行 * |
"高速网卡数据传输的研究与实现";刘津铭;《中国优秀硕士学位论文信息科技辑》;20130301;第15页19-20行,第30页1-2行,第35页4-6行 * |
刘津铭."高速网卡数据传输的研究与实现".《中国优秀硕士学位论文信息科技辑》.2013, * |
Also Published As
Publication number | Publication date |
---|---|
CN113438241A (en) | 2021-09-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109949111B (en) | Electronic bill identification distribution method, electronic bill generation method, device and system | |
CN106603394B (en) | Method and device for realizing subscription notification | |
CN103139157B (en) | A kind of based on the network communication method of socket, Apparatus and system | |
CN104410557A (en) | Dynamic networking method and communication method based on RS-485 | |
CN103647726A (en) | Message dispatching method and device thereof | |
TW201732694A (en) | Task allocation method, system and device | |
CN101388887A (en) | Network service processing method and system | |
CN107181821A (en) | A kind of information push method and device based on SSE specifications | |
CN108228363A (en) | A kind of message method and device | |
CN111263338A (en) | Network distribution method of Bluetooth Mesh network and related network distribution equipment and system | |
CN103581846B (en) | A kind of user's business card update method and system | |
JP6251927B2 (en) | Method and apparatus for sharing environmental context | |
CN112422485B (en) | Communication method and device of transmission control protocol | |
CN103327129A (en) | Domain name analyticmethod for multi-WAN-port gateway device | |
CN113438241B (en) | Data transmission method and system | |
CN105163171A (en) | File transmission method between set top box and mobile terminal and system | |
CN104994141A (en) | Cooperative storage system relieving storing and computing pressures of cloud server | |
CN112019452B (en) | Method, system and related device for processing service requirement | |
CN105068430B (en) | Household appliance set operation method and device | |
CN109041022B (en) | Network management method, Bluetooth module, medium and computer | |
CN105281944B (en) | Method for setting network protocol address and service management system | |
WO2021244548A1 (en) | Instant message processing method and device | |
JP2007221522A (en) | Polling device, terminal device, polling method and program | |
JP6200587B2 (en) | Miniblog information sharing method | |
CN103139723A (en) | Method and system of processing multimedia message and multimedia information and 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |