Data transmission method, system and network device
By judging the network busyness based on the number of routing hops and communication delay in the LAN, and choosing to split the data into message shards to send or compress and send, the problem of the risk of bandwidth occupancy and loss of giant message shards is solved, and the effect of reducing bandwidth occupancy and improving transmission efficiency is achieved.
Patent Information
- Application Number
- CN202310168220.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-24
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2043-02-24
AI Technical Summary
In a LAN, when sending and receiving huge packets frequently, too many shards will occupy too much network bandwidth and bring more risk of packet loss, resulting in wasted network bandwidth resources.
By determining the number of routing hops and communication delay between the sending end and the receiving end, the network is busy. If the number of route hops is not greater than the preset hops, the communication delay is not greater than the preset delay, and the data length is greater than the preset value, the data is divided into message fragments to send. If the number of route hops is greater than the preset hops, the communication delay is greater than the preset delay, and the data length is greater than the preset value, the data is compressed and sent.
Reduce or avoid the number of data shard reorganization, reduce the link bandwidth usage at the sending and receiving ends, and improve network transmission efficiency.
Smart Images

Figure CN116192693B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data transmission, and in particular to a data transmission method, system and network equipment. Background Art
[0002] In a local area network, the most common way to interconnect network devices is Ethernet wired connection. In the Ethernet protocol, data is transmitted in units of Ethernet frames. According to the IEEE802.3 standard followed by Ethernet, the maximum length of an Ethernet frame cannot exceed 1514 bytes, of which the Ethernet header length occupies 14 bytes. Therefore, the maximum length of an Ethernet encapsulated data message is 1500 bytes, which is the value specified by the MTU (Maximum Transmission Unit). If the total length of the data at the sender exceeds 1500 bytes, the message needs to be divided into multiple sub-messages and then sent, which is message fragmentation. Message fragmentation is the default processing method of the protocol layer for overlong data, but in the scenario of frequent sending and receiving of giant messages, too many fragments will occupy too much network bandwidth, and also bring more risks of message loss, resulting in a waste of network bandwidth resources. Compressing data before sending to reduce the number of fragments and decompressing the compressed data at the receiving end is a feasible solution. However, the difficulty lies in that data compression and decompression also consume system resources. Therefore, in some scenarios, if data is compressed and transmitted indiscriminately, the latency will be higher than without compression. Summary of the invention
[0003] The object of the present invention is to provide a data transmission method, system and network equipment to avoid the number of data fragmentation and reorganization and reduce the link bandwidth occupancy of the sending and receiving ends.
[0004] In order to solve the above technical problems, the present invention provides a data transmission method, comprising:
[0005] Determine the number of routing hops and communication delay between the sender and the receiver;
[0006] Determining the length of data sent to the receiving end;
[0007] When the number of routing hops is not greater than a preset number of hops, the communication delay is not greater than a preset delay, and the length of the data is greater than a preset value, cutting the data into message fragments and sending them to the receiving end;
[0008] When the number of routing hops is greater than a preset number of hops, the communication delay is greater than a preset delay, and the length of the data is greater than a preset value, the data is compressed and sent to the receiving end.
[0009] Preferably, determining the number of routing hops between the sending end and the receiving end includes:
[0010] Set the initial TTL of the detection message to 1;
[0011] Sending the detection message to the port of the receiving end, where the port is an unused port;
[0012] Determine whether a timeout response is received;
[0013] If the timeout response is received, the TTL of the detection message is increased by one, and the step of sending the detection message to the port of the receiving end is returned;
[0014] If no timeout response is received, determine whether an error response is received;
[0015] If an error response is received, the TTL value of the current detection message is the number of routing hops between the detection message and the receiving end.
[0016] Preferably, determining the communication delay between the transmitting end and the receiving end includes:
[0017] Sending a message to the receiving end;
[0018] The communication delay is determined according to the response message returned by the receiving end.
[0019] Preferably, sending a message to the receiving end includes:
[0020] Send an ICMP request message to the receiving end.
[0021] Preferably, dividing the data into message fragments and sending them to the receiving end includes:
[0022] The data is cut into message fragments according to the length of the data and the MTU of the transmission protocol, and the fragments are sent to the receiving end, wherein the length of each message fragment is no greater than the MTU.
[0023] Preferably, compressing the data and sending it to the receiving end comprises:
[0024] A message header is defined for the compressed data so that the receiving end determines that the data is compressed data when receiving the compressed data.
[0025] Preferably, compressing the data and sending it to the receiving end comprises:
[0026] The data is compressed using the LZO algorithm and then sent to the receiving end.
[0027] Preferably, compressing the data and sending it to the receiving end comprises:
[0028] The length of the data before compression, the length of the data after compression, and the compressed data are sent to the receiving end.
[0029] In order to solve the above technical problems, the present invention further provides a data transmission system, comprising:
[0030] A first determining unit, used to determine the number of routing hops and communication delay between the sending end and the receiving end;
[0031] A second determining unit, used to determine the length of data sent to the receiving end;
[0032] A first sending unit, configured to cut the data into message fragments and send them to the receiving end when the number of routing hops is not greater than a preset number of hops, the communication delay is not greater than a preset delay, and the length of the data is greater than a preset value;
[0033] The second sending unit is used to compress the data and send it to the receiving end when the routing hop number is greater than the preset hop number, the communication delay is greater than the preset delay and the length of the data is greater than the preset value.
[0034] In order to solve the above technical problems, the present invention further provides a network device, characterized in that it includes:
[0035] Memory for storing computer programs;
[0036] A processor is used to implement the steps of the above-mentioned data transmission method when executing the computer program.
[0037] The present application provides a data transmission method, system and network device, which are applied to the field of data transmission. Determine the number of routing hops between the sending end and the receiving end; determine the communication delay between the sending end and the receiving end; determine the length of the data sent to the receiving end; when the number of routing hops is not greater than the preset number of hops, the communication delay is not greater than the preset delay, and the length of the data is greater than the preset value, divide the data into message fragments and send them to the receiving end; when the number of routing hops is greater than the preset number of hops, the communication delay is greater than the preset delay, and the length of the data is greater than the preset value, compress the data and send it to the receiving end. When the number of routing hops is greater than the preset number of hops and the communication delay is greater than the preset delay, it indicates that the current transmission link is in a high network load and congestion state, reduce or avoid the number of data fragment reassembly times, and reduce the link bandwidth occupancy of the sending and receiving ends. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the prior art and the drawings required for use in the embodiments are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0039] Figure 1 A flow chart of a data transmission method provided by the present invention;
[0040] Figure 2 A schematic diagram of an MTU provided by the present invention;
[0041] Figure 3 A schematic diagram of message fragmentation provided by the present invention;
[0042] Figure 4 A schematic diagram of compressed data provided by the present invention;
[0043] Figure 5 A schematic diagram of the structure of a data transmission system provided by the present invention;
[0044] Figure 6 A schematic diagram of the structure of a network device provided by the present invention. DETAILED DESCRIPTION
[0045] The core of the present invention is to provide a data transmission method, system and network equipment to avoid the number of data fragmentation and reorganization, and reduce the link bandwidth occupancy of the sending and receiving ends.
[0046] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] In a local area network, the most common way to interconnect network devices is Ethernet wired connection. In the Ethernet protocol, data is transmitted in units of Ethernet frames. According to the IEEE802.3 standard followed by Ethernet, the maximum length of an Ethernet frame cannot exceed 1514 bytes, of which the Ethernet header length occupies 14 bytes. Therefore, the maximum length of an Ethernet encapsulated data message is 1500 bytes, which is the value specified by the MTU (Maximum Transmission Unit). If the total length of the data at the sender exceeds 1500 bytes, the message needs to be divided into multiple sub-messages and then sent, which is message fragmentation. Message fragmentation is the default processing method of the protocol layer for overlong data, but in the scenario of frequent sending and receiving of giant messages, too many fragments will occupy too much network bandwidth, and also bring more risks of message loss, resulting in a waste of network bandwidth resources. Compressing data before sending to reduce the number of fragments and decompressing the compressed data at the receiving end is a feasible solution. However, the difficulty lies in that data compression and decompression also consume system resources. Therefore, in some scenarios, if data is compressed and transmitted indiscriminately, the latency will be higher than without compression.
[0048] Figure 1 A flowchart of a data transmission method provided by the present invention, the data transmission method comprising:
[0049] S11: Determine the number of routing hops and communication delay between the sending end and the receiving end;
[0050] Considering that there are two methods of sending oversized data in the prior art, one is to send the message fragments to the receiving end in sequence. In this method, the message fragments will occupy too much network bandwidth, and if there are other message fragments being sent in the network during the transmission process, too many message fragments may be lost. The other is to compress the larger data, send it to the receiving end, and then decompress it at the receiving end. In some cases, such as when there is less data transmitted in the network, it will take more time to compress the data and send it. Therefore, the choice of the above two methods is based on the current busyness of the network. Through the number of routing hops and communication delay between the sending end and the receiving end, it is determined whether the network between the sending end and the receiving end is busy, and then the subsequent method of sending data can be selected.
[0051] It should be noted that both the sending end and the receiving end are network devices, the sending end network device and the receiving end network device are connected via Ethernet wired, and the sending end and the receiving end send and receive data via Ethernet.
[0052] S12: Determine the length of the data sent to the receiving end;
[0053] Since Ethernet has a fixed MTU (Maximum Transmission Unit), which refers to the maximum datagram size that can be passed on a certain layer of a communication protocol, the length of the data needs to be determined before sending it. If the length of the data exceeds the MTU, the data cannot be sent directly through Ethernet and needs to be split or compressed before sending. If the length of the data does not exceed the MTU, it will be sent directly regardless of whether the network is busy or not.
[0054] S13: When the number of routing hops is not greater than the preset number of hops, the communication delay is not greater than the preset delay, and the length of the data is greater than the preset value, the data is cut into message fragments and sent to the receiving end;
[0055] If the number of routing hops is not greater than the preset number of hops, and the communication delay is not greater than the preset delay, it means that the network between the sender and the receiver is not busy. If the length of the data is greater than the preset value, the data can be divided into message fragments and sent to the receiver. The receiver combines the multiple message fragments received to obtain complete data.
[0056] Figure 2 A schematic diagram of an MTU provided for this application;
[0057] The data includes the Ethernet frame header (DMAC, SMAC and Type), IP message frame header IP Header, message data IP Payload and CRC check bit. The length of the IP message frame header IP Header and message data IP Payload is 46-1500Bytes (bytes), and 1500 bytes is the MTU of the data, that is, the data cannot exceed 1500 bytes.
[0058] Figure 3 A schematic diagram of message fragmentation provided by the present invention;
[0059] If the length of the message frame header is 20 bytes and the length of the data is 2000 bytes, and the longest Ethernet can transmit is 1500 bytes, the 2000 bytes of data need to be split into 1480 bytes and 520 bytes, and the 1480 bytes of data and 520 bytes of data are respectively combined with the 20-byte message frame header to form two message fragments. The receiving end combines the two messages together to obtain the original data sent by the sending end.
[0060] S14: When the number of routing hops is greater than the preset number of hops, the communication delay is greater than the preset delay, and the length of the data is greater than the preset value, the data is compressed and sent to the receiving end.
[0061] If the number of routing hops is greater than the preset number of hops and the communication delay is greater than the preset delay, it means that the network between the sender and the receiver is relatively busy. At this time, the data whose length is greater than the preset value is fragmented and sent. It is easy to be lost during the transmission process, the message is lost and retransmitted, or the fragment reordering is abnormal. The current network is already busy. Continuing to send too many message fragments will make the network even busier. Therefore, the data is compressed and sent to the receiver. After receiving the compressed data, the receiver decompresses the data to obtain the original data sent by the sender.
[0062] The present application provides a data transmission method, which is applied to the field of data transmission. Determine the number of routing hops between the sending end and the receiving end; determine the communication delay between the sending end and the receiving end; determine the length of the data sent to the receiving end; when the number of routing hops is not greater than the preset number of hops, the communication delay is not greater than the preset delay, and the length of the data is greater than the preset value, divide the data into message fragments and send them to the receiving end; when the number of routing hops is greater than the preset number of hops, the communication delay is greater than the preset delay, and the length of the data is greater than the preset value, compress the data and send it to the receiving end. When the number of routing hops is greater than the preset number of hops and the communication delay is greater than the preset delay, it indicates that the current transmission link is in a high network load and congestion state, reduce or avoid the number of data fragment reassembly times, and reduce the link bandwidth occupancy of the sending and receiving ends.
[0063] Based on the above embodiments:
[0064] As a preferred embodiment, determining the number of routing hops between the sending end and the receiving end includes:
[0065] Set the initial TTL (Time To Live) of the detection message to 1;
[0066] Send a detection message to the port of the receiving end, which is an unused port;
[0067] Determine whether a timeout response is received;
[0068] If a timeout response is received, the TTL of the detection message is increased by one, and the process returns to the step of sending the detection message to the port of the receiving end;
[0069] If no timeout response is received, determine whether an error response is received;
[0070] If an error response is received, the TTL value of the current probe message is the number of routing hops between the probe message and the receiving end.
[0071] A probe message is sent with TTL set to 1. TTL specifies the maximum number of network segments (i.e., routing hops) that the IP packet is allowed to pass through before being discarded by the router. The destination port is set to a port that is unlikely to be used. TTL of 1 means that if the router cannot reach the receiving end after forwarding it once, it will be discarded by the first-hop router and a timeout response will be returned to the sender. After the receiving end receives the timeout response, it means that the number of routing hops between the sender and the receiver is greater than 1. Continue to increase the TTL for detection and set the TTL to 2. If the receiving end is still unable to reach the receiving end after forwarding it twice, the sender can determine that there are more than 2 hops in the current link through the timeout, and continue to increase the detection and so on. If the detection message reaches the receiving end within 3 routing forwardings, but the destination port is not enabled, the receiving end will return a port unreachable error response. At this time, the sender can predict that the number of routing hops is 3 based on the type of the response message, and end the detection and so on.
[0072] Specifically, the port that is unlikely to be used may be port 65533.
[0073] Generally, if the detected route hop count is greater than 64, it means that the sender and the receiver need to go through more than 64 routing forwardings, and the link state is marked as a long route. The specific preset hop count can be set according to actual needs, and this application does not make too many restrictions here.
[0074] As a preferred embodiment, determining the communication delay between the sending end and the receiving end includes:
[0075] Send a message to the receiving end;
[0076] The communication delay is determined based on the response message returned by the receiving end.
[0077] The communication delay between the sender and the receiver can be determined by sending a message to the receiver to determine the time of sending the message. After the receiver receives the message, it returns a message of successful reception to determine the time of receiving the message. The communication delay between the sender and the receiver can be determined by the time of sending the message and the time of receiving the message.
[0078] Furthermore, the larger the interval between the two times, the busier the current communication link is, and the smaller the time interval is, the idler the current communication link is.
[0079] Specifically, if the link delay is higher than 200ms, the link is marked as a high delay state. The preset delay can be set according to the actual needs of the user, and this application does not make too many restrictions here.
[0080] As a preferred embodiment, sending a message to a receiving end includes:
[0081] Send an ICMP (Internet Control Message Protocol) request message to the receiving end.
[0082] ICMP is a sub-protocol of the TCP / IP (Transmission Control Protocol / Internet Protocol) protocol family, used to transmit control messages between IP hosts and routers.
[0083] ICMP is a very important protocol and is extremely important for network security. By using the characteristics of the ICMP protocol that can record the delay of a single message request and response, sending an ICMP request message to the receiving end and judging the delay based on the returned response message, the communication delay between the sender and the receiver can be determined more conveniently and quickly.
[0084] As a preferred embodiment, dividing the data into message fragments and sending them to the receiving end includes:
[0085] The data is divided into message fragments according to the data length and the MTU of the transmission protocol and sent to the receiving end. The length of each message fragment shall not exceed the MTU.
[0086] Taking into account the different lengths of data and the different MTUs of transmission protocols, when data is divided into message fragments, the length of each message fragment should not be greater than the MTU to ensure the normal transmission of the message fragments. At the same time, each message fragment should not be divided into bytes that are too small, which will lead to too many message fragments. In the transmission process, message loss and retransmission or abnormal fragment reordering may also occur.
[0087] If the length of the data is 7000 bytes and the MTU of the transport protocol is 1500 bytes, then the data needs to be divided into 5 message fragments to ensure that the length of each message fragment does not exceed the MTU of the transport protocol, so that each message fragment can be transmitted using the current transport protocol.
[0088] As a preferred embodiment, the data is compressed and sent to the receiving end, including:
[0089] A message header is defined for the compressed data so that the receiving end can determine that the data is compressed data when receiving the compressed data.
[0090] Considering that during the transmission process, some data may not need to be compressed and can be sent directly to the receiving end, the data needs to be marked.
[0091] Figure 4 A schematic diagram of compressed data provided by the present invention;
[0092] If the original data header is 20 bytes and the data content is 2000 bytes, then the original data is 2020 bytes, which exceeds the MTU. When compressed for transmission, the 20-byte header is not compressed, and the 2000-byte data content is compressed to 200 bytes. At the same time, a 6-byte custom header is added before the header. After decompression, the receiving end will discard the 6-byte custom header, and retain the 20-byte header and the 2000-byte data content obtained by decompressing the 200-byte header.
[0093] It should be noted that the length of the defined message header is set according to actual needs, and this application does not make too many restrictions here.
[0094] As a preferred embodiment, the data is compressed and sent to the receiving end, including:
[0095] The data is compressed using the LZO algorithm and sent to the receiving end.
[0096] The LZO algorithm implements many of the following features: the algorithm is simple to decompress and is very fast, decompression does not require memory, compression is fast, compression requires 64kB of memory, allows compression to be increased at the expense of compression speed in the compression part, and decompression speed will not be reduced, includes the generation of compression levels for pre-compressed data, which can achieve very competitive compression ratios, compression levels that only require 8kB of memory, the algorithm is thread-safe, the algorithm is lossless, LZO supports repeated compression and in-place decompression, LZO is a block compression algorithm - compresses and decompresses data into blocks. The size of the blocks used for compression and decompression must be the same, LZO compresses data blocks into sequences of matching data (sliding dictionary) and non-matching text. LZO has special processing for long matching data and long non-matching text sequences, which can achieve good results for highly redundant data and acceptable results for incompressible data.
[0097] Therefore, using the LZO algorithm as the compression method of the present application can reduce the time in the compression and decompression process.
[0098] As a preferred embodiment, the data is compressed and sent to the receiving end, including:
[0099] The length of the data before compression, the length of the data after compression, and the compressed data are sent to the receiving end.
[0100] Specifically, the compression process provided by this application is as follows:
[0101] The sender calculates the length of the original data before compression, compresses the original data using the LZO algorithm, calculates the length of the compressed data, combines the length of the data before compression, the length of the compressed data, and the compressed data into the data to be sent, and sends the data to the receiver. After receiving the data, the receiver extracts the length of the data before compression, the length of the compressed data, and the compressed data, decompresses the compressed data using the LZO algorithm, and compares the length of the decompressed data and the length of the data before decompression with the length of the received data before compression and the length of the compressed data. If the lengths are equal, the verification is passed. If the lengths are not equal, the verification fails.
[0102] Figure 5 A schematic diagram of a data transmission method provided by the present invention, wherein the data transmission method comprises:
[0103] A first determining unit 51 is used to determine the number of routing hops and communication delay between the sending end and the receiving end;
[0104] A second determining unit 52 determines the length of the data sent to the receiving end;
[0105] The first sending unit 53 is used to cut the data into message fragments and send them to the receiving end when the number of routing hops is not greater than the preset number of hops, the communication delay is not greater than the preset delay, and the length of the data is greater than the preset value;
[0106] The second sending unit 54 is used to compress the data and send it to the receiving end when the number of routing hops is greater than the preset number of hops, the communication delay is greater than the preset delay, and the length of the data is greater than the preset value.
[0107] Considering that there are two methods of sending oversized data in the prior art, one is to send the message fragments to the receiving end in sequence. In this method, the message fragments will occupy too much network bandwidth, and if there are other message fragments being sent in the network during the transmission process, too many message fragments may be lost. The other is to compress the larger data, send it to the receiving end, and then decompress it at the receiving end. In some cases, such as when there is less data transmitted in the network, it will take more time to compress the data and send it. Therefore, the choice of the above two methods is based on the current busyness of the network. Through the number of routing hops and communication delay between the sending end and the receiving end, it is determined whether the network between the sending end and the receiving end is busy, and then the subsequent method of sending data can be selected.
[0108] It should be noted that both the sending end and the receiving end are network devices, the sending end network device and the receiving end network device are connected via Ethernet wired, and the sending end and the receiving end send and receive data via Ethernet.
[0109] Since Ethernet has a fixed MTU (Maximum Transmission Unit), which refers to the maximum datagram size that can be passed on a certain layer of a communication protocol, the length of the data needs to be determined before sending it. If the length of the data exceeds the MTU, the data cannot be sent directly through Ethernet and needs to be split or compressed before sending. If the length of the data does not exceed the MTU, it will be sent directly regardless of whether the network is busy or not.
[0110] If the number of routing hops is not greater than the preset number of hops, and the communication delay is not greater than the preset delay, it means that the network between the sender and the receiver is not busy. If the length of the data is greater than the preset value, the data can be divided into message fragments and sent to the receiver. The receiver combines the multiple message fragments received to obtain complete data.
[0111] Figure 2 A schematic diagram of an MTU provided for this application;
[0112] The data includes the Ethernet frame header (DMAC, SMAC and Type), IP message frame header IP Header, message data IP Payload and CRC check bit. The length of the IP message frame header IP Header and message data IP Payload is 46-1500Bytes (bytes), and 1500 bytes is the MTU of the data, that is, the data cannot exceed 1500 bytes.
[0113] Figure 3 A schematic diagram of message fragmentation provided by the present invention;
[0114] If the length of the message frame header is 20 bytes and the length of the data is 2000 bytes, and the longest Ethernet can transmit is 1500 bytes, the 2000 bytes of data need to be split into 1480 bytes and 520 bytes, and the 1480 bytes of data and 520 bytes of data are respectively combined with the 20-byte message frame header to form two message fragments. The receiving end combines the two messages together to obtain the original data sent by the sending end.
[0115] If the number of routing hops is greater than the preset number of hops and the communication delay is greater than the preset delay, it means that the network between the sender and the receiver is relatively busy. At this time, the data whose length is greater than the preset value is fragmented and sent. It is easy to be lost during the transmission process, the message is lost and retransmitted, or the fragment reordering is abnormal. The current network is already busy. Continuing to send too many message fragments will make the network even busier. Therefore, the data is compressed and sent to the receiver. After receiving the compressed data, the receiver decompresses the data to obtain the original data sent by the sender.
[0116] The present application provides a data transmission system, which is applied to the field of data transmission. Determine the number of routing hops between the sending end and the receiving end; determine the communication delay between the sending end and the receiving end; determine the length of the data sent to the receiving end; when the number of routing hops is not greater than the preset number of hops, the communication delay is not greater than the preset delay, and the length of the data is greater than the preset value, divide the data into message fragments and send them to the receiving end; when the number of routing hops is greater than the preset number of hops, the communication delay is greater than the preset delay, and the length of the data is greater than the preset value, compress the data and send it to the receiving end. When the number of routing hops is greater than the preset number of hops and the communication delay is greater than the preset delay, it indicates that the current transmission link is in a high network load and congestion state, reduce or avoid the number of data fragment reassembly times, and reduce the link bandwidth occupancy of the sending and receiving ends.
[0117] Based on the above embodiments:
[0118] As a preferred embodiment, it also includes:
[0119] A setting unit, used to set the initial TTL (Time To Live, message lifetime) of the detection message to 1;
[0120] A third sending unit is used to send a detection message to a port of the receiving end, where the port is an unused port;
[0121] A first judgment unit is used to judge whether a timeout response is received; if so, the adding unit is triggered; if not, the second judgment unit is triggered;
[0122] An adding unit, used for increasing the TTL of the detection message by one and triggering the third sending unit;
[0123] A second determination unit, configured to determine whether an error response is received; if so, triggering the first determination unit 51;
[0124] The first determining subunit is used for the TTL value of the current detection message to be the number of routing hops between the current detection message and the receiving end.
[0125] A probe message is sent with TTL set to 1. TTL specifies the maximum number of network segments (i.e., routing hops) that the IP packet is allowed to pass through before being discarded by the router. The destination port is set to a port that is unlikely to be used. TTL of 1 means that if the router cannot reach the receiving end after forwarding it once, it will be discarded by the first-hop router and a timeout response will be returned to the sender. After the receiving end receives the timeout response, it means that the number of routing hops between the sender and the receiver is greater than 1. Continue to increase the TTL for detection and set the TTL to 2. If the receiving end is still unable to reach the receiving end after forwarding it twice, the sender can determine that there are more than 2 hops in the current link through the timeout, and continue to increase the detection and so on. If the detection message reaches the receiving end within 3 routing forwardings, but the destination port is not enabled, the receiving end will return a port unreachable error response. At this time, the sender can predict that the number of routing hops is 3 based on the type of the response message, and end the detection and so on.
[0126] Specifically, the port that is unlikely to be used may be port 65533.
[0127] Generally, if the detected route hop count is greater than 64, it means that the sender and the receiver need to go through more than 64 routing forwardings, and the link state is marked as a long route. The specific preset hop count can be set according to actual needs, and this application does not make too many restrictions here.
[0128] As a preferred embodiment, it also includes:
[0129] A fourth sending unit, used to send a message to a receiving end;
[0130] The second determining subunit is used to determine the communication delay according to the response message returned by the receiving end.
[0131] The communication delay between the sender and the receiver can be determined by sending a message to the receiver to determine the time of sending the message. After the receiver receives the message, it returns a message of successful reception to determine the time of receiving the message. The communication delay between the sender and the receiver can be determined by the time of sending the message and the time of receiving the message.
[0132] Furthermore, the larger the interval between the two times, the busier the current communication link is, and the smaller the time interval is, the idler the current communication link is.
[0133] Specifically, if the link delay is higher than 200ms, the link is marked as a high delay state. The preset delay can be set according to the actual needs of the user, and this application does not make too many restrictions here.
[0134] As a preferred embodiment, the fourth sending unit is specifically configured to send an ICMP (
[0135] Internet Control Message Protocol (ICMP) request message.
[0136] ICMP is a sub-protocol of the TCP / IP (Transmission Control Protocol / Internet Protocol) protocol family, used to transmit control messages between IP hosts and routers.
[0137] ICMP is a very important protocol and is extremely important for network security. By using the characteristics of the ICMP protocol that can record the delay of a single message request and response, sending an ICMP request message to the receiving end and judging the delay based on the returned response message, the communication delay between the sender and the receiver can be determined more conveniently and quickly.
[0138] As a preferred embodiment, the first sending unit 53 is specifically used to divide the data into message fragments according to the length of the data and the MTU of the transmission protocol and send them to the receiving end, and the length of each message fragment is not greater than the MTU.
[0139] Taking into account the different lengths of data and the different MTUs of transmission protocols, when data is divided into message fragments, the length of each message fragment should not be greater than the MTU to ensure the normal transmission of the message fragments. At the same time, each message fragment should not be divided into bytes that are too small, which will lead to too many message fragments. In the transmission process, message loss and retransmission or abnormal fragment reordering may also occur.
[0140] If the length of the data is 7000 bytes and the MTU of the transport protocol is 1500 bytes, then the data needs to be divided into 5 message fragments to ensure that the length of each message fragment does not exceed the MTU of the transport protocol, so that each message fragment can be transmitted using the current transport protocol.
[0141] As a preferred embodiment, it further comprises a definition unit, which is used to define a message header for the compressed data, so that when a receiving end receives the compressed data, it determines that the data is compressed data.
[0142] Considering that during the transmission process, some data may not need to be compressed and can be sent directly to the receiving end, the data needs to be marked.
[0143] Figure 4 A schematic diagram of compressed data provided by the present invention;
[0144] If the original data header is 20 bytes and the data content is 2000 bytes, then the original data is 2020 bytes, which exceeds the MTU. When compressed for transmission, the 20-byte header is not compressed, and the 2000-byte data content is compressed to 200 bytes. At the same time, a 6-byte custom header is added before the header. After decompression, the receiving end will discard the 6-byte custom header, and retain the 20-byte header and the 2000-byte data content obtained by decompressing the 200-byte header.
[0145] It should be noted that the length of the defined message header is set according to actual needs, and this application does not make too many restrictions here.
[0146] As a preferred embodiment, the data is compressed and sent to the receiving end, including:
[0147] The data is compressed using the LZO algorithm and sent to the receiving end.
[0148] The LZO algorithm implements many of the following features: the algorithm is simple to decompress and is very fast, decompression does not require memory, compression is fast, compression requires 64kB of memory, allows compression to be increased at the expense of compression speed in the compression part, and decompression speed will not be reduced, includes the generation of compression levels for pre-compressed data, which can achieve very competitive compression ratios, compression levels that only require 8kB of memory, the algorithm is thread-safe, the algorithm is lossless, LZO supports repeated compression and in-place decompression, LZO is a block compression algorithm - compresses and decompresses data into blocks. The size of the blocks used for compression and decompression must be the same, LZO compresses data blocks into sequences of matching data (sliding dictionary) and non-matching text. LZO has special processing for long matching data and long non-matching text sequences, which can achieve good results for highly redundant data and acceptable results for incompressible data.
[0149] Therefore, using the LZO algorithm as the compression method of the present application can reduce the time in the compression and decompression process.
[0150] As a preferred embodiment, the second sending unit 54 is specifically configured to send the length of the data before compression, the length of the data after compression, and the compressed data to the receiving end.
[0151] Specifically, the compression process provided by this application is as follows:
[0152] The sender calculates the length of the original data before compression, compresses the original data using the LZO algorithm, calculates the length of the compressed data, combines the length of the data before compression, the length of the compressed data, and the compressed data into the data to be sent, and sends the data to the receiver. After receiving the data, the receiver extracts the length of the data before compression, the length of the compressed data, and the compressed data, decompresses the compressed data using the LZO algorithm, and compares the length of the decompressed data and the length of the data before decompression with the length of the received data before compression and the length of the compressed data. If the lengths are equal, the verification is passed. If the lengths are not equal, the verification fails.
[0153] Figure 6 A schematic diagram of the structure of a network device provided by the present invention, the network device includes:
[0154] A memory 61, used for storing computer programs;
[0155] The processor 62 is used to implement the steps of the above data transmission method when executing the computer program.
[0156] Specifically, the steps of implementing the above data transmission method when the processor 62 executes the computer program are as follows:
[0157] S11: Determine the number of routing hops and communication delay between the sending end and the receiving end;
[0158] Considering that there are two methods of sending oversized data in the prior art, one is to send the message fragments to the receiving end in sequence. In this method, the message fragments will occupy too much network bandwidth, and if there are other message fragments being sent in the network during the transmission process, too many message fragments may be lost. The other is to compress the larger data, send it to the receiving end, and then decompress it at the receiving end. In some cases, such as when there is less data transmitted in the network, it will take more time to compress the data and send it. Therefore, the choice of the above two methods is based on the current busyness of the network. Through the number of routing hops and communication delay between the sending end and the receiving end, it is determined whether the network between the sending end and the receiving end is busy, and then the subsequent method of sending data can be selected.
[0159] It should be noted that both the sending end and the receiving end are network devices, the sending end network device and the receiving end network device are connected via Ethernet wired, and the sending end and the receiving end send and receive data via Ethernet.
[0160] S12: Determine the length of the data sent to the receiving end;
[0161] Since Ethernet has a fixed MTU (Maximum Transmission Unit), which refers to the maximum datagram size that can be passed on a certain layer of a communication protocol, the length of the data needs to be determined before sending it. If the length of the data exceeds the MTU, the data cannot be sent directly through Ethernet and needs to be split or compressed before sending. If the length of the data does not exceed the MTU, it will be sent directly regardless of whether the network is busy or not.
[0162] S13: When the number of routing hops is not greater than the preset number of hops, the communication delay is not greater than the preset delay, and the length of the data is greater than the preset value, the data is cut into message fragments and sent to the receiving end;
[0163] If the number of routing hops is not greater than the preset number of hops, and the communication delay is not greater than the preset delay, it means that the network between the sender and the receiver is not busy. If the length of the data is greater than the preset value, the data can be divided into message fragments and sent to the receiver. The receiver combines the multiple message fragments received to obtain complete data.
[0164] Figure 2 A schematic diagram of an MTU provided for this application;
[0165] The data includes the Ethernet frame header (DMAC, SMAC and Type), IP message frame header IP Header, message data IP Payload and CRC check bit. The length of the IP message frame header IP Header and message data IP Payload is 46-1500Bytes (bytes), and 1500 bytes is the MTU of the data, that is, the data cannot exceed 1500 bytes.
[0166] Figure 3 A schematic diagram of message fragmentation provided by the present invention;
[0167] If the length of the message frame header is 20 bytes and the length of the data is 2000 bytes, and the longest Ethernet can transmit is 1500 bytes, the 2000 bytes of data need to be split into 1480 bytes and 520 bytes, and the 1480 bytes of data and 520 bytes of data are respectively combined with the 20-byte message frame header to form two message fragments. The receiving end combines the two messages together to obtain the original data sent by the sending end.
[0168] S14: When the number of routing hops is greater than the preset number of hops, the communication delay is greater than the preset delay, and the length of the data is greater than the preset value, the data is compressed and sent to the receiving end.
[0169] If the number of routing hops is greater than the preset number of hops and the communication delay is greater than the preset delay, it means that the network between the sender and the receiver is relatively busy. At this time, the data whose length is greater than the preset value is fragmented and sent. It is easy to be lost during the transmission process, the message is lost and retransmitted, or the fragment reordering is abnormal. The current network is already busy. Continuing to send too many message fragments will make the network even busier. Therefore, the data is compressed and sent to the receiver. After receiving the compressed data, the receiver decompresses the data to obtain the original data sent by the sender.
[0170] The present application provides a network device, which is applied to the field of data transmission. Determine the number of routing hops between the sending end and the receiving end; determine the communication delay between the sending end and the receiving end; determine the length of the data sent to the receiving end; when the number of routing hops is not greater than the preset number of hops, the communication delay is not greater than the preset delay, and the length of the data is greater than the preset value, divide the data into message fragments and send them to the receiving end; when the number of routing hops is greater than the preset number of hops, the communication delay is greater than the preset delay, and the length of the data is greater than the preset value, compress the data and send it to the receiving end. When the number of routing hops is greater than the preset number of hops and the communication delay is greater than the preset delay, it indicates that the current transmission link is in a high network load and congestion state, reduce or avoid the number of data fragment reassembly times, and reduce the link bandwidth occupancy of the sending and receiving ends.
[0171] Based on the above embodiments:
[0172] As a preferred embodiment, determining the number of routing hops between the sending end and the receiving end includes:
[0173] Set the initial TTL (Time To Live) of the detection message to 1;
[0174] Send a detection message to the port of the receiving end, which is an unused port;
[0175] Determine whether a timeout response is received;
[0176] If a timeout response is received, the TTL of the detection message is increased by one, and the process returns to the step of sending the detection message to the port of the receiving end;
[0177] If no timeout response is received, determine whether an error response is received;
[0178] If an error response is received, the TTL value of the current probe message is the number of routing hops between the probe message and the receiving end.
[0179] A probe message is sent with TTL set to 1. TTL specifies the maximum number of network segments (i.e., routing hops) that the IP packet is allowed to pass through before being discarded by the router. The destination port is set to a port that is unlikely to be used. TTL of 1 means that if the router cannot reach the receiving end after forwarding it once, it will be discarded by the first-hop router and a timeout response will be returned to the sender. After the receiving end receives the timeout response, it means that the number of routing hops between the sender and the receiver is greater than 1. Continue to increase the TTL for detection and set the TTL to 2. If the receiving end is still unable to reach the receiving end after forwarding it twice, the sender can determine that there are more than 2 hops in the current link through the timeout, and continue to increase the detection and so on. If the detection message reaches the receiving end within 3 routing forwardings, but the destination port is not enabled, the receiving end will return a port unreachable error response. At this time, the sender can predict that the number of routing hops is 3 based on the type of the response message, and end the detection and so on.
[0180] Specifically, the port that is unlikely to be used may be port 65533.
[0181] Generally, if the detected route hop count is greater than 64, it means that the sender and the receiver need to go through more than 64 routing forwardings, and the link state is marked as a long route. The specific preset hop count can be set according to actual needs, and this application does not make too many restrictions here.
[0182] As a preferred embodiment, determining the communication delay between the sending end and the receiving end includes:
[0183] Send a message to the receiving end;
[0184] The communication delay is determined based on the response message returned by the receiving end.
[0185] The communication delay between the sender and the receiver can be determined by sending a message to the receiver to determine the time of sending the message. After the receiver receives the message, it returns a message of successful reception to determine the time of receiving the message. The communication delay between the sender and the receiver can be determined by the time of sending the message and the time of receiving the message.
[0186] Furthermore, the larger the interval between the two times, the busier the current communication link is, and the smaller the time interval is, the idler the current communication link is.
[0187] Specifically, if the link delay is higher than 200ms, the link is marked as a high delay state. The preset delay can be set according to the actual needs of the user, and this application does not make too many restrictions here.
[0188] As a preferred embodiment, sending a message to a receiving end includes:
[0189] Send an ICMP (Internet Control Message Protocol) request message to the receiving end.
[0190] ICMP is a sub-protocol of the TCP / IP (Transmission Control Protocol / Internet Protocol) protocol family, used to transmit control messages between IP hosts and routers.
[0191] ICMP is a very important protocol and is extremely important for network security. By using the characteristics of the ICMP protocol that can record the delay of a single message request and response, sending an ICMP request message to the receiving end and judging the delay based on the returned response message, the communication delay between the sender and the receiver can be determined more conveniently and quickly.
[0192] As a preferred embodiment, dividing the data into message fragments and sending them to the receiving end includes:
[0193] The data is divided into message fragments according to the data length and the MTU of the transmission protocol and sent to the receiving end. The length of each message fragment shall not exceed the MTU.
[0194] Taking into account the different lengths of data and the different MTUs of transmission protocols, when data is divided into message fragments, the length of each message fragment should not be greater than the MTU to ensure the normal transmission of the message fragments. At the same time, each message fragment should not be divided into bytes that are too small, which will lead to too many message fragments. In the transmission process, message loss and retransmission or abnormal fragment reordering may also occur.
[0195] If the length of the data is 7000 bytes and the MTU of the transport protocol is 1500 bytes, then the data needs to be divided into 5 message fragments to ensure that the length of each message fragment does not exceed the MTU of the transport protocol, so that each message fragment can be transmitted using the current transport protocol.
[0196] As a preferred embodiment, the data is compressed and sent to the receiving end, including:
[0197] A message header is defined for the compressed data so that the receiving end can determine that the data is compressed data when receiving the compressed data.
[0198] Considering that during the transmission process, some data may not need to be compressed and can be sent directly to the receiving end, the data needs to be marked.
[0199] Figure 4 A schematic diagram of compressed data provided by the present invention;
[0200] If the original data header is 20 bytes and the data content is 2000 bytes, then the original data is 2020 bytes, which exceeds the MTU. When compressed for transmission, the 20-byte header is not compressed, and the 2000-byte data content is compressed to 200 bytes. At the same time, a 6-byte custom header is added before the header. After decompression, the receiving end will discard the 6-byte custom header, and retain the 20-byte header and the 2000-byte data content obtained by decompressing the 200-byte header.
[0201] It should be noted that the length of the defined message header is set according to actual needs, and this application does not make too many restrictions here.
[0202] As a preferred embodiment, the data is compressed and sent to the receiving end, including:
[0203] The data is compressed using the LZO algorithm and sent to the receiving end.
[0204] The LZO algorithm implements many of the following features: the algorithm is simple to decompress and is very fast, decompression does not require memory, compression is fast, compression requires 64kB of memory, allows compression to be increased at the expense of compression speed in the compression part, and decompression speed will not be reduced, includes the generation of compression levels for pre-compressed data, which can achieve very competitive compression ratios, compression levels that only require 8kB of memory, the algorithm is thread-safe, the algorithm is lossless, LZO supports repeated compression and in-place decompression, LZO is a block compression algorithm - compresses and decompresses data into blocks. The size of the blocks used for compression and decompression must be the same, LZO compresses data blocks into sequences of matching data (sliding dictionary) and non-matching text. LZO has special processing for long matching data and long non-matching text sequences, which can achieve good results for highly redundant data and acceptable results for incompressible data.
[0205] Therefore, using the LZO algorithm as the compression method of the present application can reduce the time in the compression and decompression process.
[0206] As a preferred embodiment, the data is compressed and sent to the receiving end, including:
[0207] The length of the data before compression, the length of the data after compression, and the compressed data are sent to the receiving end.
[0208] Specifically, the compression process provided by this application is as follows:
[0209] The sender calculates the length of the original data before compression, compresses the original data using the LZO algorithm, calculates the length of the compressed data, combines the length of the data before compression, the length of the compressed data, and the compressed data into the data to be sent, and sends the data to the receiver. After receiving the data, the receiver extracts the length of the data before compression, the length of the compressed data, and the compressed data, decompresses the compressed data using the LZO algorithm, and compares the length of the decompressed data and the length of the data before decompression with the length of the received data before compression and the length of the compressed data. If the lengths are equal, the verification is passed. If the lengths are not equal, the verification fails.
[0210] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprises a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
[0211] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0212] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A data transmission method, characterized in that: include: Determine the number of routing hops and communication delay between the sender and the receiver; The receiving end and the transmitting end transmit and receive data via Ethernet; Determining the length of data sent to the receiving end; When the number of routing hops is not greater than a preset number of hops, the communication delay is not greater than a preset delay, and the length of the data is greater than a preset value, cutting the data into message fragments and sending them to the receiving end; When the number of routing hops is greater than a preset number of hops, the communication delay is greater than a preset delay, and the length of the data is greater than a preset value, compressing the data and sending it to the receiving end; When the length of the data is less than or equal to a preset value, the data is directly sent to the receiving end; The method comprises: compressing the data and sending it to the receiving end, comprising: Sending the length of the data before compression, the length of the data after compression and the compressed data to the receiving end; Determine the number of routing hops between the sender and the receiver, including: Set the initial TTL of the detection message to 1; Sending the detection message to the port of the receiving end, where the port is an unused port; Determine whether a timeout response is received; If the timeout response is received, the TTL of the detection message is increased by one, and the step of sending the detection message to the port of the receiving end is returned; If no timeout response is received, determine whether an error response is received; If an error response is received, the TTL value of the current detection message is the number of routing hops between the receiving end and the receiving end; The method comprises: compressing the data and sending it to the receiving end, comprising: defining a message header for the compressed data so that the receiving end determines that the data is compressed data when receiving the compressed data; The method comprises: compressing the data and sending it to the receiving end, comprising: The data is compressed using an LZO algorithm and then sent to the receiving end.
2. The data transmission method according to claim 1, characterized in that: Determine the communication delay between the sender and the receiver, including: Sending a message to the receiving end; The communication delay is determined according to the response message returned by the receiving end.
3. The data transmission method according to claim 2, characterized in that: Sending a message to the receiving end includes: Send an ICMP request message to the receiving end.
4. The data transmission method according to claim 1, characterized in that: The step of dividing the data into message segments and sending them to the receiving end includes: The data is cut into message fragments according to the length of the data and the MTU of the transmission protocol, and the fragments are sent to the receiving end, wherein the length of each message fragment is no greater than the MTU.
5. A data transmission system, characterized in that: include: A first determining unit, used to determine the number of routing hops and communication delay between the sending end and the receiving end; The receiving end and the transmitting end transmit and receive data via Ethernet; A second determining unit, used to determine the length of data sent to the receiving end; A first sending unit, configured to cut the data into message fragments and send them to the receiving end when the number of routing hops is not greater than a preset number of hops, the communication delay is not greater than a preset delay, and the length of the data is greater than a preset value; A second sending unit, used for compressing the data and sending it to the receiving end when the number of routing hops is greater than a preset number of hops, the communication delay is greater than a preset delay, and the length of the data is greater than a preset value; The second sending unit is specifically configured to send the length of the data before compression, the length of the data after compression, and the compressed data to the receiving end; It also includes a definition unit, which is used to define a message header for the compressed data, so that the receiving end determines that the data is compressed data when receiving the compressed data; Also includes: A setting unit, used to set the initial TTL of the detection message to 1; A third sending unit, used to send the detection message to a port of the receiving end, where the port is an unused port; A first judgment unit is used to judge whether a timeout response is received; if so, the adding unit is triggered; if not, the second judgment unit is triggered; The adding unit is used to increase the TTL of the detection message by one and trigger the third sending unit; The second determining unit is configured to determine whether an error response is received; if so, triggering the first determining unit; A first determining subunit, wherein the TTL value of the current detection message is the number of routing hops between the detection message and the receiving end; When the length of the data is less than or equal to a preset value, the data is directly sent to the receiving end; The data is compressed and sent to the receiving end, including: The data is compressed using the LZO algorithm and sent to the receiving end.
6. A network device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the data transmission method according to any one of claims 1 to 4 when executing the computer program.
Citation Information
Patent Citations
Data packet efficient transmission method and system
CN112995055A
Frame switchboard
JP1995095235A
Wireless communication device, method, and program
JP2012209905A