CN108111523B - Data transmission method and device - Google Patents

Data transmission method and device Download PDF

Info

Publication number
CN108111523B
CN108111523B CN201711464345.2A CN201711464345A CN108111523B CN 108111523 B CN108111523 B CN 108111523B CN 201711464345 A CN201711464345 A CN 201711464345A CN 108111523 B CN108111523 B CN 108111523B
Authority
CN
China
Prior art keywords
data
target
field
data message
target process
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
CN201711464345.2A
Other languages
Chinese (zh)
Other versions
CN108111523A (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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN201711464345.2A priority Critical patent/CN108111523B/en
Publication of CN108111523A publication Critical patent/CN108111523A/en
Application granted granted Critical
Publication of CN108111523B publication Critical patent/CN108111523B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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/03Protocol definition or specification 
    • 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/22Parsing or analysis of headers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a data transmission method and a data transmission device. The method comprises the following steps: determining data to be transmitted; constructing a data message based on data to be sent, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process; and sending the data message to each network card in the same local area network. By the invention, the effect of improving the data transmission efficiency is achieved.

Description

Data transmission method and device
Technical Field
The invention relates to the field of computers, in particular to a data transmission method and device.
Background
In a distributed service cluster, objects distributed among processes on physical machines need to cooperate with each other through mutual communication and information exchange in real time, an efficient message transmission mechanism is a basis for constructing real-time services, for example, in a distributed game server, a player chats around the world, the server needs to broadcast messages of the player object to player objects on all other processes in real time, and a common implementation manner is to use an internet protocol suite (such as TCP/IP).
The method is simple and general, but has the disadvantage that in order to mask differences of underlying network environments, the internet protocol suite needs to add extra (IP layer and transport layer protocol encapsulation and interpretation) processing overhead at both ends of transceiving every time of data transmission, and the inventor finds that machines in the same service cluster are often deployed in the same ethernet environment of the same machine room, machines in the same ethernet can use hardware addresses to realize higher-speed and efficient communication by using ethernet cards, but the application based on the internet protocol suite technology ignores the characteristics because the internet protocol relies on self protocols to use IP addresses and ports for message routing and distribution, as if knowing that neighboring houses are opposite, a telephone line is connected for communication without the help of a telecommunication office to be busy every time, the method is obviously not as efficient as going directly to direct opposite-to-door communication, but also incurs the additional overhead of communication costs and the quality of communication is limited by the quality of service of the telecommunications operator.
At present, the mainstream network data transmission method is to use the internet protocol family such as TCP/IP or UDP/IP to perform data transmission, and this method uses the internet protocol family built in the operating system to support network communication and data transmission. The method has the advantages of strong universality, simplicity and easy use, because the implementation of TCP, UDP and IP protocols is provided by an operating system, and comprises protocol interpretation, network packet unpacking, multiplexing and the like.
However, the method using TCP/IP or UDP/IP communication has the following disadvantages:
1. an internet protocol stack implementation has an additional kernel overhead, which may reduce the speed of data transmission of an application layer, fig. 1 is a typical TCP/IP protocol stack diagram of the related art, as shown in fig. 1, an operating system is responsible for unpacking packets of a protocol stack, and each data packet is received and sent through an interpretation of a protocol of each layer in the protocol stack, which may have an additional computation overhead.
2. Fig. 2 is a schematic diagram of packets of each layer protocol in a TCP/IP protocol stack in the related art, and as shown in fig. 2, taking IPv4 and TCP/UDP as examples, the minimum length of an IP header is 20 bytes (no option), and the lengths of TCP/UDP headers are 20/8 bytes, so the maximum transmission efficiency using TCP/IP is:
Figure BDA0001530909590000021
the Max Ether Payload For TCP/IP represents the maximum effective load of a single Ethernet frame when a TCP/IP data packet is transmitted, and does not comprise the message head and tail of the Ethernet frame and the message head information of the TCP/IP; the Ether Frame Size indicates a single ethernet Frame Size, including all header information.
3. The transmission efficiency and behavior are constrained by the implementation of an operating system and an internet protocol stack, and mechanisms such as active avoidance and flow control of the TCP can greatly affect the transmission speed and efficiency.
Aiming at the problem of low efficiency in data transmission between devices in the same service cluster through a TCP/IP protocol in the related art, no effective solution is provided at present.
Disclosure of Invention
The invention mainly aims to provide a data transmission method and a data transmission device, which aim to solve the problem of low efficiency when data transmission is carried out between equipment in the same service cluster through a TCP/IP protocol.
In order to achieve the above object, according to an aspect of the present invention, there is provided a data transmission method including: determining data to be transmitted; constructing a data message based on the data to be sent, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process; and sending the data message to each network card in the same local area network.
Further, constructing a data packet based on the data to be transmitted includes: acquiring a target process of the data to be sent; determining a target field according to the target process, wherein the target field is used for identifying the target process; and adding the target field in the head of the data to be sent to obtain the data message.
Further, prior to determining a target field from the target process, the method further comprises: registering a corresponding target ID for the target process; and determining the target field according to the target ID.
Further, the data packet includes an ethernet frame header, a data length field, a target ID field, the data field to be sent, and an ethernet frame tail, where the data length field is used to identify the length of the data packet.
Further, the number of bytes occupied by the identification information for identifying the target process is 2 bytes, and the number of bytes occupied by the data length field is 2 bytes.
In order to achieve the above object, according to another aspect of the present invention, there is also provided a data transmission method, including: receiving a data message, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process; analyzing the data message to obtain a physical address of a target receiving end carried in the data message and identification information for identifying a target process; judging whether the physical address and the identification information of the current kernel filter are consistent with the physical address of the target receiving end carried in the data message and the identification information for identifying the target process or not to obtain a judgment result; and sending the data message to the target process under the condition that the judgment result is yes.
Further, after obtaining the determination result, the method further includes: and under the condition that the judgment result is negative, discarding the data message.
Further, the data packet includes an ethernet frame header, a data length field, a target ID field, the data field to be sent, and an ethernet frame tail, where the data length field is used to identify the length of the data packet.
In order to achieve the above object, according to another aspect of the present invention, there is also provided a data transmission apparatus, including: a first determining unit, configured to determine data to be transmitted; a constructing unit, configured to construct a data packet based on the to-be-sent data, where the data packet carries a physical address of a target receiving end and identification information for identifying a target process; and the sending unit is used for sending the data message to each network card in the same local area network.
Further, the construction unit includes: the acquisition module is used for acquiring a target process of the data to be sent; a determining module, configured to determine a target field according to the target process, where the target field is used to identify the target process; and the adding unit is used for adding the target field in the head of the data to be sent to obtain the data message.
Further, the apparatus further comprises: a registering unit, configured to register a corresponding target ID for the target process before determining a target field according to the target process; a second determining unit, configured to determine the target field according to the target ID.
In order to achieve the above object, according to another aspect of the present invention, there is also provided a data transmission apparatus, including: a receiving unit, configured to receive a data packet, where the data packet carries a physical address of a target receiving end and identification information for identifying a target process; the analysis unit is used for analyzing the data message to obtain a physical address of a target receiving end carried in the data message and identification information used for identifying a target process; the judging unit is used for judging whether the physical address and the identification information of the current kernel filter are consistent with the physical address of the target receiving end carried in the data message and the identification information used for identifying the target process or not to obtain a judging result; and the sending unit is used for sending the data message to the target process under the condition that the judgment result is yes.
In order to achieve the above object, according to another aspect of the present invention, there is also provided a storage medium including a stored program, wherein when the program runs, a device in which the storage medium is located is controlled to execute the data transmission method according to the present invention.
In order to achieve the above object, according to another aspect of the present invention, there is also provided a processor for executing a program, wherein the program executes the data transmission method according to the present invention.
The invention determines the data to be sent; constructing a data message based on data to be sent, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process; the data message is sent to each network card in the same local area network, so that the problem of low efficiency in data transmission between the devices in the same service cluster through a TCP/IP protocol is solved, and the effect of improving the data transmission efficiency is further achieved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, illustrate embodiments of the invention and, together with the description, serve to explain the invention and not to limit the invention. In the drawings:
FIG. 1 is a diagram of a typical TCP/IP protocol stack of the related art;
FIG. 2 is a diagram illustrating protocol packets of layers in a TCP/IP protocol stack in the related art; and
fig. 3 is a flowchart of a data transmission method according to a first embodiment of the present invention;
fig. 4 is a flowchart of a data transmission method according to a second embodiment of the present invention;
FIG. 5 is a schematic diagram of link communications according to an embodiment of the present invention;
FIG. 6 is a diagram of a protocol packet according to an embodiment of the invention;
FIG. 7 is a schematic view of an inner core layer filter according to an embodiment of the invention;
FIG. 8 is a schematic diagram of an Echo server and client for data transmission according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of an interface for dynamically generating filter binaries using a tcpdump program under a LINUX system according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of the interface of a read-write wrapper implemented by a C program under a LINUX system;
FIG. 11 is a schematic diagram of an interface for a write operation of a C program protocol encapsulator in a LINUX system;
fig. 12 is a schematic diagram of a data transmission apparatus according to a first embodiment of the present invention;
fig. 13 is a schematic diagram of a data transmission apparatus according to a second embodiment of the present invention.
Detailed Description
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present invention will be described in detail below with reference to the embodiments with reference to the attached drawings.
In order to make the technical solutions better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only partial embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that the terms "first," "second," and the like in the description and claims of this application and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be used. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
For convenience of description, several terms referred to in the embodiments of the present application are explained below:
TCP/IP protocol: the translation of Transmission Control Protocol/Internet Protocol is named as Transmission Control Protocol/Internet interconnection Protocol, also named as network communication Protocol, which is the most basic Protocol of Internet and the basis of Internet, and consists of IP Protocol in network layer and TCP, UDP and other protocols in Transmission layer.
UDP is an abbreviation of User Datagram Protocol, a chinese name is a User Datagram Protocol, and is a connectionless transport layer Protocol in an OSI (Open System Interconnection) reference model, and provides a transaction-oriented simple unreliable information transfer service.
The internet protocol suite: the Internet Protocol Suite (IPS) is a network communication model, and an entire network transmission Protocol family, which is the basic communication architecture of the Internet. Commonly known as the TCP/IP Protocol Suite (English: TCP/IP Protocol Suite, or TCP/IP Protocols), referred to as TCP/IP for short. TCP/IP provides a point-to-point link mechanism that standardizes how data should be encapsulated, addressed, transmitted, routed, and received at the destination. Software communication process is abstracted into four abstraction layers, and different communication protocols are respectively realized in a protocol stack mode.
Data link layer: the data link layer is the second layer in the OSI reference model, which is between the physical layer and the network layer. The data link layer provides services to the network layer on the basis of the services provided by the physical layer, and the most basic service is to reliably transmit data from the source machine network layer to the target machine network layer of the adjacent node.
Socket connection: in an operating system, it is common to provide a set of Application Program Interfaces (APIs) for applications, called socket APIs. Applications may use network sockets through a socket interface for data exchange.
Kernel space and user space: in an operating system, virtual memory is typically divided into two blocks, User space (english) and Kernel space (Kernel space). This is a loop in the memory protection mechanism, the kernel, core extensions (kernel extensions), and drivers, running on the kernel space. And other applications run on the user space. All applications running in user space are collectively referred to as user-level (userland).
Ethernet: ethernet (english: Ethernet) is a computer local area network technology. The IEEE802.3 standard of the IEEE organization sets forth a technical standard for ethernet, which specifies the contents of the wiring, electrical signals, and medium access layer protocols, including the physical layer. Ethernet is currently the most commonly used local area network technology, replacing other local area network standards such as token ring, FDDI, and ARCNET.
RTT: round-trip communication delay (Round-trip delay time), in the field of communications, computer networks, means: in two-party communication, the time for the Signal (Signal) from the sending party to propagate (Propagation) to the receiving party (i.e., Propagation delay) is added to the time for the receiving party to return the message to the sending party (if there is no factor causing the difference in the two-way Propagation rates, this time is as long as the time for the sending party to propagate the Signal to the receiving party).
The embodiment of the invention provides a data transmission method.
Fig. 3 is a flowchart of a data transmission method according to a first embodiment of the present invention, as shown in fig. 3, the method including the steps of:
step S102: determining data to be transmitted;
step S104: constructing a data message based on data to be sent, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process;
step S106: and sending the data message to each network card in the same local area network.
The embodiment determines data to be transmitted; constructing a data message based on data to be sent, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process; the data message is sent to each network card in the same local area network, so that the problem of low efficiency in data transmission between the devices in the same service cluster through a TCP/IP protocol is solved, and the effect of improving the data transmission efficiency is further achieved.
The embodiment of the invention is executed by a sending end, in the embodiment of the invention, data is sent to a data receiving end by the sending end, the sending end determines the data to be sent, wherein the data to be sent can be data generated on a certain terminal in the same local area network, for example, a message to be sent by a certain game player, a data message is constructed based on the data to be sent, the data message can be an encapsulated data packet, the data message carries a necessary physical address of a target receiving end and identification information for identifying a target process, the target process can be a process of a target application program, the physical address of the receiving end can be an MAC address, the identification information of the target process can be identified by a target ID, the format of the data message is redefined without additional encapsulation of a transmission layer and a network layer, and without an IP header, a message in a related technology, The method comprises the steps of adding a physical address of a target receiving end and identification information for identifying a target process on the basis of a data layer by using additional overhead bytes such as a TCP/UDP header, wherein the bytes are shorter and the overhead is less, then sending a packaged data message to each network card in the same local area network, wherein each network card in the same local area network is connected in the same Ethernet, so that the data message can be sent to each network card in the same local area network through the Ethernet, each receiving end receiving the data message judges whether the data message is matched according to the identification information, and under the condition of matching, the data is sent to a corresponding machine and process through a link layer socket so as to realize the transmission of the data. Because the data message in the embodiment of the invention can be sent to the target end in the same local area network without carrying excessive redundant bytes, the data transmission efficiency is improved,
in the embodiment of the present invention, the data packet refers to a packet including an ethernet header, the physical address of the target receiving end is included in the ethernet frame header, but not in the target process identification field, and the target process identification field is only used for identifying the target physical process. The physical address of the target receiving end occupies 8 bytes and is contained in the header of the Ethernet frame, the kernel filter also realizes filtering by the target physical address of the header of the Ethernet frame, and the target process identifier of the embodiment of the invention does not contain physical address information, only contains identification information for identifying the target process and occupies 2 bytes.
Optionally, constructing a data packet based on data to be sent includes: acquiring a target process of data to be sent; determining a target field according to the target process, wherein the target field is used for identifying the target process; and adding a target field at the head of the data to be sent to obtain a data message. When the data message is constructed, a target field for identifying a target process can be added to the head of data to be sent, the target field is determined based on the target process, so that the target process needs to be obtained first, then the target field is obtained based on the target process, the target field is added to the head of the data, and the data message is obtained, so that the constructed data message can be accurately distributed to the corresponding target process, and the receiving and sending chaos is prevented.
Optionally, before determining the target field according to the target process, registering a corresponding target ID for the target process; the destination field is determined based on the destination ID. When determining the target field, the target field may be determined by a target ID registered by the target process, for example, a corresponding target ID is registered for the target process, so that different target processes may be distinguished.
Optionally, the data packet includes an ethernet frame header, a data length field, a target ID field, a data field to be sent, and an ethernet frame tail, where the data length field is used to identify the length of the entire encapsulation packet of the data packet. The header of the data message has an ethernet frame header, the trailer has an ethernet frame trailer, and the data message also has three fields, wherein the target ID field is used for indicating a target ID to which the data message is to be sent, the data length field is used for identifying the length of the data field to be sent, the data length field refers to the length of valid data, and does not include the header and the trailer of the ethernet frame, does not include the data lengths of the target ID field and the data length field, and only includes the length of the data to be sent.
Optionally, the number of bytes occupied by the identification information for identifying the target process is 2 bytes, and the number of bytes occupied by the data length field is 2 bytes.
The physical address of the target receiving end and the identification information for identifying the target process are both recorded in the target ID field, which may be two bytes, and the data length field may also be two bytes.
Fig. 4 is a flowchart of a data transmission method according to a second embodiment of the present invention, as shown in fig. 4, the method including the steps of:
step S202: receiving a data message, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process;
step S204: analyzing the data message to obtain a physical address of a target receiving end carried in the data message and identification information for identifying a target process;
step S206: judging whether the physical address and the identification information of the current kernel filter are consistent with the physical address of the target receiving end carried in the data message and the identification information for identifying the target process or not to obtain a judgment result;
step S208: and sending the data message to the target process under the condition that the judgment result is yes.
The embodiment of the invention is executed by a receiving end, in the embodiment of the invention, after the receiving end receives a data message sent by a sending end, the data message is analyzed to obtain a physical address and a target process of a target receiving end carried in the data message, then the receiving end judges whether the information obtained by analysis is consistent with the physical address and the target process of the receiving end, the data message is sent to the corresponding target process under the condition of consistency, and the data message is discarded under the condition of no judgment result.
It should be noted that, the receiving end is a device located in the same lan as the sending end, and after the sending end sends a data packet, all devices located in the same lan as the sending end receive the data packet, including the sending end itself.
Optionally, the data packet includes an ethernet frame header, a data length field, a target ID field, a data field to be sent, and an ethernet frame tail, where the data length field is used to identify the length of the data packet.
The structure of the data packet is the same as that of the data packet in the sending end, and is not described herein again.
The technical scheme of the embodiment of the invention can be used as an efficient network communication and data transmission method based on the Ethernet, and can provide an Ethernet data transmission method with lower computing resource overhead, higher transmission speed and higher transmission efficiency.
Fig. 5 is a schematic diagram of link communications according to an embodiment of the present invention. As shown in fig. 5, the data link layer ethernet data frame can be directly constructed and explained, and ethernet packet transmission and routing are performed through the data link layer, so as to implement inter-process communication. Compared with the mode that the TCP/IP is charged with protocol encapsulation and unpacking by the operating system kernel, the embodiment of the invention carries out encapsulation and unpacking on the application layer, and can reduce the kernel overhead. Monitoring all data packets in the network card, providing fields which can be used for target process identification by the extended link layer protocol, and realizing the screening and distribution of the data packets through a packet filter which runs in a kernel space. Because the application layer data is directly transmitted and received through the link layer socket, the expense of kernel interpretation is reduced.
Fig. 6 is a diagram of a protocol packet according to an embodiment of the invention. As shown in fig. 6, the embodiment of the present invention designs a transmission protocol that is simpler than TCP/IP and occupies fewer bits, and the transmission efficiency is improved by 2% compared with TCP/IP.
In the embodiments of the present invention, it is necessary to define a new transport protocol. In the original transmission protocol, because the link layer protocol only provides the service of communication between data link layers (such as network card to network card), and the header information of the message only contains the physical addresses of the sender and the receiver, the protocol number, etc., an extended protocol is needed to support the distribution of data packets from the link layer to the application layer in order to realize the inter-process communication of the application layer. In the embodiment of the present invention, the extended protocol passes through the 2-byte destination ID field of the packet header to identify the destination process of this packet, similar to the port numbers in TCP and UDP. The target process can register the corresponding target ID and realize data distribution through the kernel filter. The header length is 4 bytes, and the transmission efficiency is as follows: compared with the related technology, the Efficiency is greatly improved by (Max Payload Size)/(Max Ether Frame Size) (1500-4)/(1538) ((97.26)).
FIG. 7 is a schematic view of an inner core layer filter according to an embodiment of the invention. As shown in fig. 7, by installing an ethernet frame filter customized by the application layer for the socket, kernel layer packet filtering is implemented, and the filter cooperates with the above transport protocol to implement efficient data distribution.
The kernel filter plays an important role in improving transmission efficiency. Because the packet header information obtained from the link layer alone cannot identify the target process of the packet, further interpretation of the packet content is required to achieve application layer data routing and distribution. If all the link layer data packets are processed by the application layer program, the data needs to be copied from the kernel space to the user space, and then the content of the extension protocol in the data packets needs to be interpreted by the application program, that is, each process needs to process all the data packets of the network card, so that a large amount of system calls and data copies are generated, and the efficiency is greatly reduced.
The kernel layer is used for filtering, the extended protocol can be interpreted in the kernel space, a data packet matched with the kernel space is screened for the application program, redundant data copying and transmission are avoided, data copying between the kernel layer and the user layer is greatly reduced, and the expenditure of system calling is reduced.
Fig. 7 shows the process of process X in machine a sending packet 1 to process Y in machine B using socket a. Process X assembles packet 1 following an ethernet frame format (e.g., IEEE 802.3) and fills the 4-byte protocol header with the data length and target id, and the assembled data frame is sent to the ethernet via socket a. The data packet 1 is transmitted to each network card on the same link through a physical link, and after the data packet is transmitted to the kernel, only the data packet successfully matched by the filter is distributed to a user space, namely, the data packet can be read from the socket by an application layer program. Packet 1 is received by the network cards of machine a and machine B and filtered by filter A, B, C, respectively. The kernel will drop packet 1 for socket A, C because it does not match the conditions specified by filter A, C, and the kernel will distribute packet 1 to socket B because the conditions in all filters B are satisfied. Finally process Y will be able to read the data it passed to it by process X from socket B. It should be noted that, when the network card operates in the promiscuous mode, the socket receives all the packets in the link, including the data sent by the network card itself, and is also received by itself, which is why the packet 1 is sent to the kernel filter 1, so that the case that the network card may operate in the promiscuous mode needs to be considered in the filter design process.
Fig. 8 is a schematic diagram of an Echo server and a client for data transmission according to an embodiment of the present invention, as shown in fig. 8, the client sends a data packet to the server through a socket and records a time stamp ts of the sending time, the server returns data to the client after receiving the data packet, the client records a current time stamp te after receiving the data packet returned by the server, and estimates an RTT of the data packet by te and ts: EstimatedRTT is te-ts.
A link layer socket is a socket that is capable of sending and receiving link layer data packets. Because most operating systems manage the processing of standard protocol packets (i.e., packets of these standard protocols are not handled by the application) and discard packets of non-standard protocols, to implement link layer custom protocol transmission, a socket capable of receiving all link layer packets is required to be created to manage packets whose protocol numbers are not recognized by the kernel. A LINUX down C program creates a link layer socket that may be:
sock_fd=socket(AF_PACKET,SOCK_RAW,htons(ETH_P_ALL))
the parameter AF _ PACKET indicates that a protocol cluster for processing PACKETs is to be created instead of the internet protocol cluster (AF _ INET), the parameter SOCK _ RAW indicates that we are to create a socket that can read "naked data", i.e. includes a PACKET header, and the parameter ETH _ P _ ALL indicates that the socket will receive ALL ethernet frame data instead of data of a particular protocol.
The kernel layer FILTER is a program capable of filtering packets according to a specified rule at the kernel layer, and the kernel FILTER may have different implementations under different operating systems, for example, BPF may be utilized under UNIX system, and setsockopt interface and SO _ ATTACH _ FILTER option may be used under LINUX system to apply a specified FILTER code to a corresponding socket. The C program under a LINUX system installs kernel filters as follows:
struck sock_fprog filter;
create_sock_filter_program(&filter);
setsockopt(sock_fd,SOL_SOCKET,SO_ATTACH_FILTER,&filter,sizeof(filter));
filter code generator
Since each socket can receive all packets, but each socket actually only concerns packets with a matching target ID, a filter that can be customized for each socket can be implemented to filter to a specified target ID. The filter program code may be written by a developer or generated by an auxiliary program, and fig. 9 is an interface diagram illustrating dynamic generation of filter binary code by using a tcpdump program under the LINUX system according to an embodiment of the present invention.
The protocol encapsulator is actually an encapsulation of the link layer socket read-write interface, and functions to perform protocol encapsulation and unpacking using specified parameters (such as target ID, etc.). Fig. 10 is an interface schematic diagram of a read-write wrapper implemented by a C program in the LINUX system, and because of the kernel filter, an application program only needs to call an operating system read interface, and only a data packet meeting a filter condition is read.
Fig. 11 is an interface schematic diagram of a write operation of a C program protocol encapsulator in the LINUX system, and as shown in fig. 11, a frame header in IEEE802.3 frame format is first constructed, a header in a custom protocol is immediately followed, the header includes an application layer data length and a target ID, and finally, the application layer data, and the encapsulated data packet can be sent out by using an operating system API.
According to the technical scheme of the embodiment of the invention, the application layer data is directly sent and received from the link layer by using the link layer socket, so that the number of protocol layers of the application layer data packet reaching the physical layer is reduced, and the kernel processing overhead is reduced; the kernel filter is utilized to filter and screen the data packets received by the link layer socket, so that only the data packets meeting the filtering rule can be processed and distributed by the kernel, and the system processing overhead is further reduced; by defining a more simplified protocol, the length of the header of the protocol message is reduced, the complexity of protocol interpretation is reduced, and the system overhead and the network bandwidth can be saved, so that higher data transmission speed can be achieved.
Table 1 shows a comparison between transmission data and UDP transmission efficiency data in the technical solution of the embodiment of the present invention, and UDP is selected for data comparison because, compared to TCP, UDP is closer to the service provided by the present invention in nature, and does not involve complex algorithms such as reliable data transmission and flow control, and has faster transmission efficiency and thus stronger comparability. The test program uses the ECHO program logic, the client sends 100,000 packets per set of test data by sending packets of different sizes to the server and estimating the RTT, which is averaged.
TABLE 1
Figure BDA0001530909590000111
Figure BDA0001530909590000121
In table 1, the first column is the transmission packet size; the unit is byte/data packet, the second column is the total number of the transmitted data packets, namely the test times of each group of use cases; the third column is the average RTT using the present invention; the fourth column is RTT using UDP; the fifth column shows that compared with UDP, the transmission average RTT of the embodiment of the invention is improved by 20-40%.
As can be seen from the data in table 1, compared with UDP, the transmission speed in the embodiment of the present invention can be increased by 20% to 40%, and when transmitting a data packet with less than 600 bytes, the average increase is more than 30%.
The experimental environment of the data is two physical machines with the same configuration in the same local area network, and each machine is configured as follows:
operating system information:
3.16.0-4-amd64#1SMP Debian 3.16.7-ckt20-1+deb8u2(2016-01-02)x86_64 GNU/Linux
CPU information:
Figure BDA0001530909590000122
Figure BDA0001530909590000131
network card:
Figure BDA0001530909590000132
Figure BDA0001530909590000141
memory information:
Figure BDA0001530909590000142
Figure BDA0001530909590000151
it should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer-executable instructions and that, although a logical order is illustrated in the flowcharts, in some cases, the steps illustrated or described may be performed in an order different than presented herein.
The embodiment of the invention provides a data transmission device, which can be used for executing the data transmission method of the embodiment of the invention.
Fig. 12 is a schematic diagram of a data transmission apparatus according to a first embodiment of the present invention, as shown in fig. 12, the apparatus including:
a first determining unit 10, configured to determine data to be transmitted;
a constructing unit 20, configured to construct a data packet based on data to be sent, where the data packet carries a physical address of a target receiving end and identification information for identifying a target process;
and the sending unit 30 is configured to send the data packet to each network card located in the same local area network.
Optionally, the building unit 20 comprises: the acquisition module is used for acquiring a target process of data to be sent; the determining module is used for determining a target field according to the target process, wherein the target field is used for identifying the target process; and the adding unit is used for adding a target field in the head of the data to be sent to obtain the data message.
Optionally, the apparatus further comprises: the registration unit is used for registering a corresponding target ID for the target process before determining the target field according to the target process; a second determining unit for determining the target field according to the target ID.
By the device, the problem of low efficiency in data transmission between equipment in the same service cluster through a TCP/IP protocol is solved, and the effect of improving the data transmission efficiency is further achieved.
The embodiment of the invention also provides a data transmission device, which can be used for executing the data transmission method of the embodiment of the invention.
Fig. 13 is a schematic diagram of a data transmission apparatus according to a second embodiment of the present invention, as shown in fig. 13, the apparatus including:
a receiving unit 40, configured to receive a data packet, where the data packet carries a physical address of a target receiving end and identification information for identifying a target process;
the analysis unit 50 is configured to analyze the data packet to obtain a physical address of a target receiving end and identification information used for identifying a target process, where the physical address is carried in the data packet;
a judging unit 60, configured to judge whether the physical address and the identification information of the current kernel filter are consistent with the physical address of the target receiving end and the identification information used for identifying the target process, which are carried in the data packet, to obtain a judgment result;
and a sending unit 70, configured to send the data packet to the target process if the determination result is yes.
By the device, the problem of low efficiency in data transmission between equipment in the same service cluster through a TCP/IP protocol is solved, and the effect of improving the data transmission efficiency is further achieved.
The data transmission device comprises a processor and a memory, wherein the receiving unit, the analyzing unit, the judging unit, the sending unit and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more, and the data transmission efficiency is improved by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
An embodiment of the present invention provides a storage medium on which a program is stored, the program implementing the data transmission method when executed by a processor.
The embodiment of the invention provides a processor, which is used for running a program, wherein the data transmission method is executed when the program runs.
The embodiment of the invention provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein the processor executes the program and realizes the following steps: determining data to be transmitted; constructing a data message based on data to be sent, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process; and sending the data message to each network card in the same local area network. The device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application further provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device: determining data to be transmitted; constructing a data message based on data to be sent, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process; and sending the data message to each network card in the same local area network.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that 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 an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (12)

1. A method of data transmission, comprising:
determining data to be transmitted;
constructing a data message based on the data to be sent, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process;
sending the data message to each network card in the same local area network;
the data packet is composed of an ethernet frame header, a data length field, a target ID field, the data field to be sent, and an ethernet frame tail, where the data length field is used to identify the length of the data packet, and the target ID field records identification information used to identify a target process.
2. The method of claim 1, wherein constructing a data message based on the data to be transmitted comprises:
acquiring a target process of the data to be sent;
determining a target field according to the target process, wherein the target field is used for identifying the target process;
and adding the target field in the head of the data to be sent to obtain the data message.
3. The method of claim 2, wherein prior to determining a target field from the target process, the method further comprises:
registering a corresponding target ID for the target process;
and determining the target field according to the target ID.
4. The method of claim 1, wherein the identification information for identifying the target process occupies 2 bytes, and the data length field occupies 2 bytes.
5. A method of data transmission, comprising:
receiving a data message, wherein the data message carries a physical address of a target receiving end and identification information for identifying a target process;
analyzing the data message to obtain a physical address of a target receiving end carried in the data message and identification information for identifying a target process;
judging whether the physical address and the identification information of the current kernel filter are consistent with the physical address of the target receiving end carried in the data message and the identification information for identifying the target process or not to obtain a judgment result;
if the judgment result is yes, sending the data message to the target process;
the data message is composed of an ethernet frame header, a data length field, a target ID field, a data field to be sent, and an ethernet frame tail, where the data length field is used to identify the length of the data message, and the target ID field records target information for marking a target process.
6. The method of claim 5, wherein after obtaining the determination, the method further comprises:
and under the condition that the judgment result is negative, discarding the data message.
7. A data transmission apparatus, comprising:
a first determining unit, configured to determine data to be transmitted;
a constructing unit, configured to construct a data packet based on the to-be-sent data, where the data packet carries a physical address of a target receiving end and identification information for identifying a target process;
the sending unit is used for sending the data message to each network card in the same local area network;
the data message is composed of an ethernet frame header, a data length field, a target ID field, a data field to be sent, and an ethernet frame tail, where the data length field is used to identify the length of the data message, and the target ID field records target information for marking a target process.
8. The apparatus of claim 7, wherein the building unit comprises:
the acquisition module is used for acquiring a target process of the data to be sent;
a determining module, configured to determine a target field according to the target process, where the target field is used to identify the target process;
and the adding unit is used for adding the target field in the head of the data to be sent to obtain the data message.
9. The apparatus of claim 8, further comprising:
a registering unit, configured to register a corresponding target ID for the target process before determining a target field according to the target process;
a second determining unit, configured to determine the target field according to the target ID.
10. A data transmission apparatus, comprising:
a receiving unit, configured to receive a data packet, where the data packet carries a physical address of a target receiving end and identification information for identifying a target process;
the analysis unit is used for analyzing the data message to obtain a physical address of a target receiving end carried in the data message and identification information used for identifying a target process;
the judging unit is used for judging whether the physical address and the identification information of the current kernel filter are consistent with the physical address of the target receiving end carried in the data message and the identification information used for identifying the target process or not to obtain a judging result;
a sending unit, configured to send the data packet to the target process if the determination result is yes;
the data message is composed of an ethernet frame header, a data length field, a target ID field, a data field to be sent, and an ethernet frame tail, where the data length field is used to identify the length of the data message, and the target ID field records target information for marking a target process.
11. A storage medium, characterized in that the storage medium comprises a stored program, wherein when the program runs, a device where the storage medium is located is controlled to execute the data transmission method according to any one of claims 1 to 6.
12. A processor, characterized in that the processor is configured to run a program, wherein the program is configured to execute the data transmission method according to any one of claims 1 to 6 when running.
CN201711464345.2A 2017-12-28 2017-12-28 Data transmission method and device Active CN108111523B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711464345.2A CN108111523B (en) 2017-12-28 2017-12-28 Data transmission method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711464345.2A CN108111523B (en) 2017-12-28 2017-12-28 Data transmission method and device

Publications (2)

Publication Number Publication Date
CN108111523A CN108111523A (en) 2018-06-01
CN108111523B true CN108111523B (en) 2021-02-19

Family

ID=62214356

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711464345.2A Active CN108111523B (en) 2017-12-28 2017-12-28 Data transmission method and device

Country Status (1)

Country Link
CN (1) CN108111523B (en)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109491804A (en) * 2018-10-11 2019-03-19 视联动力信息技术股份有限公司 Method for message transmission and device
CN109802727B (en) * 2018-12-14 2021-09-17 上海威固信息技术股份有限公司 Method for blind plugging of transmission medium between communication devices
CN110035016B (en) * 2019-02-26 2023-03-10 北京钰安信息科技有限公司 Data transmission method and device
CN112448966A (en) * 2019-08-28 2021-03-05 华东师范大学 Network chatting program based on TCP/IP
CN111031027A (en) * 2019-12-09 2020-04-17 广州信天翁信息科技有限公司 Efficient data transmission method and heterogeneous data transmission layer
CN111796950B (en) * 2020-07-16 2023-06-30 网易(杭州)网络有限公司 Data processing method and system
CN114531378B (en) * 2020-10-30 2024-04-12 华为技术有限公司 Communication method, electronic device, and computer-readable storage medium
CN112511609B (en) * 2020-11-19 2023-04-07 航天银山电气有限公司 Data transmission method, device and storage medium
CN112511526B (en) * 2020-11-25 2023-01-24 深圳致星科技有限公司 Data transmission method, device and readable storage medium
CN113364790B (en) * 2021-06-12 2022-10-18 四川虹美智能科技有限公司 Data transmission method and device
CN114158036B (en) * 2021-12-06 2024-01-23 成都飞鱼星科技股份有限公司 Method, equipment, system and medium for configuration management of AP
CN115190070A (en) * 2022-06-07 2022-10-14 阿里巴巴(中国)有限公司 Route detection method and device
CN115857420B (en) * 2023-03-03 2023-05-12 深圳市综科智控科技开发有限公司 IO mutual control method between industrial control equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101163065A (en) * 2006-10-13 2008-04-16 中兴通讯股份有限公司 IP packet compression negotiating method in wireless LAN
CN103546368A (en) * 2013-11-08 2014-01-29 长沙钢为网络科技有限公司 Data transmission method, device, instant messaging method and system
CN104283916A (en) * 2013-07-05 2015-01-14 中国科学院声学研究所 Data message transmission method and device applied to HFC network
WO2015014316A1 (en) * 2013-08-02 2015-02-05 Hangzhou H3C Technologies Co., Ltd. Packet forwarding

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101163065A (en) * 2006-10-13 2008-04-16 中兴通讯股份有限公司 IP packet compression negotiating method in wireless LAN
CN104283916A (en) * 2013-07-05 2015-01-14 中国科学院声学研究所 Data message transmission method and device applied to HFC network
WO2015014316A1 (en) * 2013-08-02 2015-02-05 Hangzhou H3C Technologies Co., Ltd. Packet forwarding
CN103546368A (en) * 2013-11-08 2014-01-29 长沙钢为网络科技有限公司 Data transmission method, device, instant messaging method and system

Also Published As

Publication number Publication date
CN108111523A (en) 2018-06-01

Similar Documents

Publication Publication Date Title
CN108111523B (en) Data transmission method and device
US20190132251A1 (en) Method and system for supporting multiple qos flows for unstructured pdu sessions
CN110999265B (en) Managing network connectivity between cloud computing service endpoints and virtual machines
US11497077B2 (en) Method and apparatus for port management of ethernet bridges
CN113326228B (en) Message forwarding method, device and equipment based on remote direct data storage
CN114189905A (en) Message processing method and related equipment
CN112671628A (en) Business service providing method and system
CN107231269B (en) Accurate cluster speed limiting method and device
EP4209905A1 (en) Service mesh system employing microservice, and service governance method
WO2015078320A1 (en) Network service processing method and apparatus
WO2018150223A1 (en) A method and system for identification of traffic flows causing network congestion in centralized control plane networks
US20180309647A1 (en) Length Control For Packet Header Sampling
EP4057576A1 (en) Packet encapsulating method and apparatus, and packet decapsulating method and apparatus
FI112308B (en) Sharing protocol processing
CN114338432A (en) Method, device and equipment for transmitting message and computer readable storage medium
CN111262782B (en) Message processing method, device and equipment
CN110351394B (en) Network data processing method and device, computer device and readable storage medium
CN113596192B (en) Communication method, device, equipment and medium based on gatekeeper networking
CN116346294A (en) Communication method, device, related equipment and storage medium
CN114327850A (en) Service grid system based on micro-service and service management method
Wagner et al. Improving Packet Processing Speed on SCION Endhosts
CN113691410B (en) Network performance data acquisition method, device and server
CN116132435B (en) Double-stack cross-node communication method and system of container cloud platform
WO2022063245A1 (en) Message transmission method and apparatus, device, and computer readable storage medium
CN110011820B (en) Method and device for connecting systems and computer storage medium

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