CN117544572A - Message slicing method, device, system and storage medium - Google Patents

Message slicing method, device, system and storage medium Download PDF

Info

Publication number
CN117544572A
CN117544572A CN202311672545.2A CN202311672545A CN117544572A CN 117544572 A CN117544572 A CN 117544572A CN 202311672545 A CN202311672545 A CN 202311672545A CN 117544572 A CN117544572 A CN 117544572A
Authority
CN
China
Prior art keywords
message
forwarded
length
messages
network interface
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.)
Pending
Application number
CN202311672545.2A
Other languages
Chinese (zh)
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.)
Guangzhou Tongze Kangwei Technology Co ltd
Original Assignee
Guangzhou Tongze Kangwei Technology 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 Guangzhou Tongze Kangwei Technology Co ltd filed Critical Guangzhou Tongze Kangwei Technology Co ltd
Priority to CN202311672545.2A priority Critical patent/CN117544572A/en
Publication of CN117544572A publication Critical patent/CN117544572A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/36Flow control; Congestion control by determining packet size, e.g. maximum transfer unit [MTU]
    • H04L47/365Dynamic adaptation of the packet size
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/43Assembling or disassembling of packets, e.g. segmentation and reassembly [SAR]

Landscapes

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

Abstract

The invention discloses a message slicing method, a device, a system and a storage medium, which are characterized in that an exit network interface and a first message length are obtained by analyzing a message to be forwarded, an exit MTU value corresponding to the exit network interface is compared with the first message length, whether the exit MTU value is larger than the first message length is determined, if the exit MTU value is smaller than or equal to the first message length, slicing processing is carried out on the message to be forwarded, a plurality of sliced messages are obtained, and the sliced messages are sent to the exit network interface, so that the sliced forwarding processing of the message to be forwarded is realized. The invention realizes the forwarding processing of the ultra-long message by carrying out the fragment forwarding processing on the message which cannot be forwarded due to the problem of message length, and improves the success rate and accuracy of forwarding the system message.

Description

Message slicing method, device, system and storage medium
Technical Field
The present invention relates to the field of network communications technologies, and in particular, to a method, an apparatus, a system, and a storage medium for message fragmentation.
Background
Because of the requirement of networking topology, CPE and other devices are required to build a two-layer tunnel and add a bridge, a transparent channel for transmitting Ethernet messages is provided for the down-hanging device, and meanwhile, a new problem is generally introduced: the establishment of an ethernet two-layer tunnel is typically due to the fact that the tunnel requires some additional byte overhead. Therefore, when the length of the message sent by the down-hanging device is close to or equal to the MTU value and is transmitted to the CPE device, the CPE device needs to perform two-layer tunnel encapsulation on the message, which results in that the encapsulated message exceeds the size of the egress MTU of the underley network, and thus the message cannot be forwarded by the bridge and is discarded.
The solution to the above problems in the prior art is to manually adjust the MTU of the down-hanging device, however, if the MTU is manually adjusted, there are situations that different types of network interfaces cannot be distinguished and the outer packages of the network interfaces are different.
Disclosure of Invention
The invention provides a message slicing method, a device, a system and a storage medium, which are used for realizing the technical effect of slicing and forwarding an ultralong message to be forwarded to a corresponding network interface and reducing the message discarding rate.
In order to solve the technical problems, the invention provides a message slicing method, which comprises the following steps:
receiving and analyzing a message to be forwarded, obtaining an exit network interface corresponding to the message to be forwarded and a first message length of the message to be forwarded, and calling an exit MTU value of the exit network interface, so as to determine whether the exit MTU value is larger than the first message length;
and if the value of the exit MTU is smaller than or equal to the length of the first message, carrying out fragmentation processing on the message to be forwarded to obtain a plurality of fragmented messages, and transmitting the fragmented messages to the exit network interface so that the exit network interface can respectively forward the fragmented messages.
After receiving and analyzing a message to be forwarded, the message slicing method provided by the invention acquires an outlet network interface of the message to be forwarded according to analysis, invokes an outlet MTU value corresponding to the outlet network interface, compares the first message length of the message to be forwarded with the outlet MTU value, further determines whether the message to be forwarded can be directly and completely forwarded from the outlet network interface to a destination terminal, and determines whether the message to be forwarded needs to be sliced and forwarded according to a comparison result. Through the comparison and judgment process, the message to be forwarded is prevented from being forwarded directly, but the message to be forwarded is discarded due to the fact that the message length of the message to be forwarded exceeds the MTU value of the outlet network interface, and the success rate and the efficiency of message forwarding are improved.
When the system determines that the message to be forwarded needs to be fragmented according to the comparison result of the first message length and the exit MTU value, the system fragments the message to be forwarded according to a preset fragmentation method, transmits a plurality of fragmented messages generated after fragmentation to an exit network interface, and forwards the plurality of fragmented messages according to the destination address of the message to be forwarded by the exit network interface, so that the forwarding of the ultra-long message is realized, and the success rate and the accuracy of forwarding the system message are improved.
As a preferred example, the slicing processing is performed on the message to be forwarded to obtain a plurality of sliced messages, which specifically includes:
determining a message limit length of each segmented message according to the exit MTU value, and determining the number of segments of the segmented messages according to the determined message limit length and the first message length;
and carrying out fragmentation processing on the messages to be forwarded according to the determined fragmentation quantity, setting the source address of each fragment message according to the source address of the messages to be forwarded, setting the destination address of each fragment message according to the destination address of the messages to be forwarded, and further integrating to obtain the fragments messages.
In order to further improve the forwarding efficiency and the forwarding success rate of the system to the ultra-long message and reduce the discarding probability of the ultra-long message, the message slicing method provided by the invention needs to perform slicing processing on the message to be forwarded, namely the ultra-long message after determining that the message to be forwarded is the ultra-long message which cannot be directly forwarded, and the system determines the message limit length of each sliced message according to the exit MTU value of the exit network interface corresponding to the message to be forwarded, namely the space occupied by the message header which is necessary to exist in the message is removed, and the effective data length of each sliced message meeting the forwarding requirement of the exit network interface is the message limit length.
After determining the limit length of the message, the system divides the data in the message to be forwarded according to the limit length and the first message length of the message to be forwarded, and further determines the number of fragments of the generated fragments message according to the cutting times. After the cutting, namely the division is completed, the system correspondingly adjusts the source address and the destination address of each divided segmented message, namely the source address and the destination address of each segmented message are adjusted to be the same as the address of the message to be forwarded, so that the segmentation processing of the message to be forwarded is realized, and a plurality of segmented messages are obtained.
As a preferred example, after the determining that the egress MTU value is less than or equal to the first message length, the method further includes:
judging the message type of the message to be forwarded to obtain a corresponding first judgment result;
if the first judging result is that the message to be forwarded is an IPv4 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, subtracting the length of a first head from the message limit length of each fragment message;
if the first judgment result is that the message to be forwarded is an IPv6 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the length of a first head and the length of a first fragment head are subtracted from the limit length of each fragment message.
In order to further improve the success rate of message slicing forwarding, the message slicing method provided by the invention also judges the message type of the message to be forwarded after determining that the message to be forwarded is an ultra-long message and takes the length which needs to be subtracted from the message limit length of the reference data when calculating the determined number of slicing of a plurality of sliced messages generated by the message to be forwarded according to the determined message type.
If the message to be forwarded is judged to be IPv4 message, each piece of fragmented message after the message is fragmented is IPv4 message, and the IPv4 message only comprises a message header, so that when the system determines the number of fragments according to the calculation of the message limit length, the length of the message limit length serving as reference data needs to be subtracted by the length of the message header; if the message to be forwarded is judged and determined to be the IPv6 message, each piece of the message after the message is segmented is the IPv6 message, and compared with the IPv4 message, the IPv6 message comprises two message heads, so that when the system segments according to the message limit length, the length of the two heads needs to be subtracted, namely the length of one segment head needs to be subtracted after the length of one first head is subtracted. After the message limit length is confirmed by the message limit length determining method, the success rate of forwarding the generated fragmented message by the outlet network interface can be improved, and meanwhile, the probability of discarding the fragmented message due to errors is reduced.
As a preferred example, after said determining whether said egress MTU value is greater than said first message length, further comprising:
if the exit MTU value is larger than the first message length, analyzing and obtaining the message type of the message to be forwarded, judging the message type, and determining whether the message to be forwarded meets forwarding requirements according to a second judging result;
if the second judging result shows that the message type meets the forwarding requirement, transmitting the message to be forwarded to the outlet network interface so that the outlet network interface forwards the message to be forwarded;
and if the second judging result is that the message type does not meet the forwarding requirement, discarding the message to be forwarded.
After determining that the output MTU value of the output network interface is greater than the first message length, that is, the message to be forwarded meets the forwarding standard of the output network interface, the system further judges the message type of the message to be forwarded, determines whether the message type of the message to be forwarded meets the message forwarding requirement of the output network interface, and only through the two judgments, the system forwards the message to be forwarded to the output network interface and forwards the message to be forwarded by the output network interface.
If the message type is judged to be not in accordance with the forwarding requirement, the system does not forward the message to be forwarded to the outlet network interface, but discards the message to be forwarded even if the length of the first message of the message to be forwarded is smaller than the value of the outlet MTU.
Correspondingly, the invention also provides a message slicing device, which comprises a message receiving module and a message slicing module;
the message receiving module is used for receiving and analyzing a message to be forwarded, obtaining an outlet network interface corresponding to the message to be forwarded and a first message length of the message to be forwarded, and calling an outlet MTU value of the outlet network interface, so as to determine whether the outlet MTU value is larger than the first message length;
and the message slicing module is used for slicing the message to be forwarded to obtain a plurality of sliced messages if the MTU value of the outlet is smaller than or equal to the length of the first message, and transmitting the sliced messages to the outlet network interface so that the outlet network interface forwards the sliced messages respectively.
As a preferred example, the message slicing module performs slicing processing on the message to be forwarded to obtain a plurality of sliced messages, which specifically includes:
Determining a message limit length of each segmented message according to the exit MTU value, and determining the number of segments of the segmented messages according to the determined message limit length and the first message length;
and carrying out fragmentation processing on the messages to be forwarded according to the determined fragmentation quantity, setting the source address of each fragment message according to the source address of the messages to be forwarded, setting the destination address of each fragment message according to the destination address of the messages to be forwarded, and further integrating to obtain the fragments messages.
As a preferred example, after the determining that the egress MTU value is less than or equal to the first message length, the message slicing module further includes:
judging the message type of the message to be forwarded to obtain a corresponding first judgment result;
if the first judging result is that the message to be forwarded is an IPv4 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the length of a first head part is subtracted from the effective data length of each fragment message;
if the first judgment result is that the message to be forwarded is an IPv6 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the effective data length of each fragment message needs to be subtracted by the lengths of the first head and the first fragment head.
As a preferred example, after the determining whether the egress MTU value is greater than the first message length, the message receiving module further includes:
if the exit MTU value is larger than the first message length, analyzing and obtaining the message type of the message to be forwarded, judging the message type, and determining whether the message to be forwarded meets forwarding requirements according to a second judging result;
if the second judging result shows that the message type meets the forwarding requirement, transmitting the message to be forwarded to the outlet network interface so that the outlet network interface forwards the message to be forwarded;
and if the second judging result is that the message type does not meet the forwarding requirement, discarding the message to be forwarded.
Correspondingly, the invention also provides a message slicing system, which comprises a memory, a processor and a computer program stored in the memory and running on the processor, wherein the processor realizes a message slicing method according to any one of the above when processing the computer program.
Correspondingly, the invention further provides a storage medium, wherein the storage medium is stored with a computer program, and the computer program is called and executed by a processor to realize a message slicing method according to any one of the above.
Drawings
Fig. 1: a flow diagram of an embodiment of a message slicing method provided by the invention;
fig. 2: a schematic structural diagram of an embodiment of a message slicing device provided by the invention;
fig. 3: the invention provides a networking topology diagram of one embodiment of a message slicing method;
fig. 4: the invention provides a structural schematic diagram of one embodiment of an IPv4 type fragmented message;
fig. 5: a structural schematic diagram of an embodiment of an IPv6 type fragment packet provided by the present invention;
fig. 6: the invention provides a structural schematic diagram of another embodiment of the IPv6 type fragmentation message.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Example 1
Referring to fig. 1, a flow chart of an embodiment of a message slicing method provided by the present invention includes steps 101 to 102, where the steps are as follows:
Step 101: receiving and analyzing a message to be forwarded, obtaining an exit network interface corresponding to the message to be forwarded and a first message length of the message to be forwarded, and calling an exit MTU value of the exit network interface, thereby determining whether the exit MTU value is larger than the first message length.
After receiving and analyzing a message to be forwarded, the message slicing method provided by the embodiment of the invention obtains an outlet network interface of the message to be forwarded according to analysis, invokes an outlet MTU value corresponding to the outlet network interface, compares the first message length of the message to be forwarded with the outlet MTU value, further determines whether the message to be forwarded can be directly and completely forwarded from the outlet network interface to a destination terminal, and determines whether the message to be forwarded needs to be sliced and forwarded according to a comparison result. Through the comparison and judgment process, the message to be forwarded is prevented from being forwarded directly, but the message to be forwarded is discarded due to the fact that the message length of the message to be forwarded exceeds the MTU value of the outlet network interface, and the success rate and the efficiency of message forwarding are improved.
In this embodiment, referring to fig. 3, fig. 3 is a networking topology diagram of an embodiment of a packet slicing method provided by the present invention. As shown in fig. 3, it is assumed that the user equipment a is a source terminal, and the user equipment B and the user equipment C are corresponding destination terminals. User equipment A is connected with CPE equipment 1, user equipment B is connected with CPE equipment 2, user equipment C is connected with CPE equipment 3, and the visible user equipment performs message data transmission through the CPE equipment connected with the user equipment.
As can be seen from fig. 3, CPE device 1 establishes an ethernet two-layer transparent transmission link with CPE device 2 using NVGRE technology over the 5G link, and CPE device 1 establishes an ethernet two-layer transparent transmission link with CPE device 3 using VxLAN technology over the 5G link. When the NVGRE encapsulated message or the VxLAN encapsulated message needs to be sent from the 5G WAN network card, the MTU of the 5G link is limited to 1500, so that the MTU of the link corresponding to the NVGRE network card or the VxLAN network card becomes smaller, and the MTU of the whole path of forwarding the message becomes smaller. Thus, as shown in FIG. 3, the length of the message that a bridge in CPE device 1 can forward to the VxLAN network interface is at most 1450 and the length of the message that a bridge in CPE device 1 can forward to the NVGRE network interface is at most 1462. However, the MTU value of the network interface of the ue a is 1500, so when the IPv4 or IPv6 packet data sent by the ue a, that is, the source terminal, is larger, the CPE device 1 receives the packet to be forwarded from the ethernet card 1 interface, and if the packet length of the packet to be forwarded to the NVGRE network interface exceeds 1462, the packet will be discarded; if the message length of the message to be forwarded to the VxLAN network interface exceeds 1450, the message will be discarded.
Therefore, after receiving the message to be forwarded, the system of this embodiment first needs to perform an export MTU judgment on the message to be forwarded, that is, compares the message length of the message to be forwarded with the MTU value of the export network interface, and determines whether the message to be forwarded is an overlength message. Meanwhile, because the destination MAC address in the message received by the CPE device system in this embodiment is not submitted to the host, the message does not enter the routing mode of the system, but is forwarded to the corresponding outgoing interface by the forwarding function of the bridge based on the MAC address table, and the message is directly discarded when the message is too long. Therefore, in this embodiment, when the bridge forwards, the message content analysis is performed to perform the fragmentation processing, that is, the source device is simulated to perform the fragmentation processing on the message, where the ethernet two-layer header is unchanged.
In addition, before receiving and judging the message length of the message to be forwarded, the system firstly needs to initialize CPE equipment, create a VxLAN tunnel and an NVGRE tunnel, and simultaneously add the Ethernet card 1, the VxLAN card and the NVGRE card into a network bridge.
Step 102: and if the value of the exit MTU is smaller than or equal to the length of the first message, carrying out fragmentation processing on the message to be forwarded to obtain a plurality of fragmented messages, and transmitting the fragmented messages to the exit network interface so that the exit network interface can respectively forward the fragmented messages.
When the system determines that the message to be forwarded needs to be fragmented according to the comparison result of the first message length and the exit MTU value, the system fragments the message to be forwarded according to a preset fragmentation method, transmits a plurality of fragmented messages generated after fragmentation to an exit network interface, and forwards the plurality of fragmented messages according to the destination address of the message to be forwarded by the exit network interface, so that the forwarding of the ultra-long message is realized, and the success rate and the accuracy of forwarding the system message are improved.
In this embodiment, the slicing processing is performed on the message to be forwarded to obtain a plurality of sliced messages, which specifically includes:
determining a message limit length of each segmented message according to the exit MTU value, and determining the number of segments of the segmented messages according to the determined message limit length and the first message length;
and carrying out fragmentation processing on the messages to be forwarded according to the determined fragmentation quantity, setting the source address of each fragment message according to the source address of the messages to be forwarded, setting the destination address of each fragment message according to the destination address of the messages to be forwarded, and further integrating to obtain the fragments messages.
In order to further improve the forwarding efficiency and the forwarding success rate of the system to the ultra-long message and reduce the discarding probability of the ultra-long message, after determining that the message to be forwarded is the ultra-long message which cannot be forwarded directly, the message slicing method provided by the embodiment of the invention needs to perform slicing processing on the message to be forwarded, namely the ultra-long message, and the system determines the message limit length of each sliced message according to the exit MTU value of the exit network interface corresponding to the message to be forwarded, namely the effective data length of each sliced message meeting the forwarding requirement of the exit network interface, namely the message limit length, by removing the space occupied by the message header which must exist in the message.
After determining the limit length of the message, the system divides the data in the message to be forwarded according to the limit length and the first message length of the message to be forwarded, and further determines the number of fragments of the generated fragments message according to the cutting times. After the cutting, namely the division is completed, the system correspondingly adjusts the source address and the destination address of each divided segmented message, namely the source address and the destination address of each segmented message are adjusted to be the same as the address of the message to be forwarded, so that the segmentation processing of the message to be forwarded is realized, and a plurality of segmented messages are obtained.
In this embodiment, after the system determines that the message to be forwarded is an ultralong message and needs to be fragmented, the message limit length of the fragmented message is determined according to the output MTU value, then the number of fragments to be fragmented is determined according to the message limit length and the first message length, and then the fragmentation is performed on the message according to the determined number of fragments.
Further, after determining that the egress MTU value is less than or equal to the first message length, the embodiment further includes:
judging the message type of the message to be forwarded to obtain a corresponding first judgment result;
If the first judging result is that the message to be forwarded is an IPv4 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, subtracting the length of a first head from the message limit length of each fragment message;
if the first judgment result is that the message to be forwarded is an IPv6 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the length of a first head and the length of a first fragment head are subtracted from the limit length of each fragment message.
In order to further improve the success rate of message slicing forwarding, the message slicing method provided by the embodiment of the invention further judges the message type of the message to be forwarded after determining that the message to be forwarded is an ultra-long message and then takes the length which needs to be subtracted from the message limit length of the reference data when calculating the number of the slices of the plurality of sliced messages generated by the message to be forwarded according to the determined message type.
If the message to be forwarded is judged to be IPv4 message, each piece of fragmented message after the message is fragmented is IPv4 message, and the IPv4 message only comprises a message header, so that when the system determines the number of fragments according to the calculation of the message limit length, the length of the message limit length serving as reference data needs to be subtracted by the length of the message header; if the message to be forwarded is judged and determined to be the IPv6 message, each piece of the message after the message is segmented is the IPv6 message, and compared with the IPv4 message, the IPv6 message comprises two message heads, so that when the system segments according to the message limit length, the length of the two heads needs to be subtracted, namely the length of one segment head needs to be subtracted after the length of one first head is subtracted. After the message limit length is confirmed by the message limit length determining method, the success rate of forwarding the generated fragmented message by the outlet network interface can be improved, and meanwhile, the probability of discarding the fragmented message due to errors is reduced.
Accordingly, referring to fig. 4, fig. 4 is a schematic structural diagram of an embodiment of an IPv4 type fragmentation message according to the present invention.
The IP header in the fragmentation message includes the following key fields:
IP header length: ip. Hdr_len: for identifying the length of the IP header.
Total length: ip.len: which is used to represent the length of the entire IP packet.
Fragment flag: ip.flags.mf: for identifying whether the fragmented packet is the last fragmented packet, if the value is 1, it indicates that there are more fragmented packets in the back, and if the value is 0, it indicates the last packet.
Sheet offset: flag_offset: for identifying the offset of the message fragments.
And (3) checking a header: checksum: for the check code obtained by calculating the IP header.
Message identification: ip.id: used as a message identifier.
Source address: src.ip: for identifying the IP address of the source terminal.
Destination address: ip. dst: and the IP address is used for identifying the destination terminal, and the plurality of fragment messages are recombined based on the ID.
IP valid data: ip. data: for representing IP validity data.
As shown in fig. 4, if the message a is a message to be forwarded of the IPv4 message type, the first message length is 1500 (the header length is usually 14 bytes without considering the ethernet two-layer header length), and the egress MTU value is 600, so that the message a is fragmented into three fragmented messages, namely, the message A1, the message A2 and the message A3 in fig. 4.
Thus, the fields of the IP header of message A are as follows:
ethernet (ethernet two-layer header of message a, typically 14 bytes)
IP. Hdr len=20 (typically the IP header is a fixed 20 bytes)
Ip.len=1500 (IP total length is 1500 bytes)
Ip. Flags. Mf=0/1 (1 indicates that there are more slices behind, 0 indicates the last slice)
Ip. Frag_offset=n (assume here that the slice offset in message a is N)
Checksum=x (check code calculated based on IP header)
Ip. Src (source address of message A)
Ip. Dst (destination Address of message A)
A.ip.id (ID identification of message A)
IP. Datas [0-1479] (IP effective data length is 1480 bytes, IP total length minus IP header)
The IP header field of the packet A1 obtained after fragmentation is as follows:
a1. ethernet=a. Ethernet (message A1 ethernet two-layer header equals message a)
A1.ip. Hdr_len=a.ip. Hdr_len=20 (the IP header of message A1 is the same length as message a)
Ip.len=596 (outgoing interface MTU is 600, subtracting IP header 20 yields maximum transmissible IP effective data length of 580, maximum transmissible IP effective data length is 576 because the IP effective data length of the fragment needs to satisfy a multiple of 8 (standard definition), and the IP total length of message A1 is 596)
A1.Ip. Flags. Mf=1 (set the fragmentation flag to 1, the fragmentation message is also after the flag)
A.p. flag_offset=a.ip. flag_offset=n (the sheet offset of message A1 is the same as that of message a)
A.ip.src=a.ip.src (source address of A1 is equal to source address of a)
A.ip.dst=a.ip.dst (destination address of A1 is equal to destination address of a)
A1.ip.id=A.ip.id
1.ip.datas [0-575] = a.ip.datas [0-575] (A1 carries a first part of IP payload data of a 576 bytes in length
The IP header field of fragment A2 is as follows:
a2. ethernet=a. Ethernet (message A2 ethernet two-layer header equals message a)
A2.ip.hdr_len=A.ip.hdr_len=20
A2.ip.len=596 (message A2 has the same IP total length as message A1, 596)
A2.ip.flags.mf=1 (set the fragmentation flag to 1, and the fragmentation message is also after the flag)
A2.ip.frag_offset=a.ip.frag_offset+len (a.ip.data) =2960+576=3536 (the slice offset of message A2 takes into account both messages A1 and a)
A2.ip.src=a.ip.src (the source address of A2 is equal to the source address of a)
A2.ip.dst=a.ip.dst (the destination address of A2 is equal to the destination address of a)
A2.ip.id=A.ip.id
A2.ip.datas [0-575] =a.ip.datas [576-1151] (A2 carries IP valid data second part data 576 bytes length of a)
The IP header field of fragment A3 is as follows:
a3. ethernet=a. Ethernet (message A3 ethernet two-layer header equals message a)
A3.ip.hdr_len=A.ip.hdr_len=20
A3.ip.len=348 (IP effective data length of a is 1480, since A1 and A2 already carry 576+576 total 1152 bytes, IP effective data of 328 bytes (1480 minus 1152) remain, so the IP total length is 348)
A3.ip.flags.mf=a.ip.flags.mf (the last fragmented packet A3 fragmented flag equals the a fragmented flag)
A3.ip.frag_offset=a.ip.frag_offset+len (a.ip.data) +len (a2.ip.data) =n+576+576=n+1152 (the slice offset of packet A3 takes into account the first two fragmented packets and packet a)
A3.ip.src=a.ip.src (the source address of A3 is equal to the source address of a)
A3.ip.dst=a.ip.dst (destination address of A3 equals destination address of a)
A3.ip.id=A.ip.id
A3.ip.datas [0-327] =a.ip.datas [1152-1479] (A3 carries the data 328 bytes length of the third part of the IP payload data of a)
In addition, referring to fig. 5, fig. 5 is a schematic structural diagram of an embodiment of an IPv6 type fragmentation message according to the present invention. As shown in fig. 5, if the message a is a message to be forwarded of the IPv6 message type, the first message length is 1500 (the header length is usually 14 bytes without considering the ethernet two-layer header length), and the message a itself is not a fragmented message, and the output MTU value is 1300, the fragmentation processing of the message a will obtain two fragmented messages, namely, a fragmented message A1 and a fragmented message A2.
The key fields contained in the IPv6 header (fixed 40 bytes) of the fragment message are as follows:
load length: ip6.plen
The next head: ip6.Nxt: indicating upper layer protocol (ip 6. Nxt=44, indicating that the next header is an IPv6 segmented header)
Source address: ip6.Src
Destination address: ip6.Dst
Load data: ip6.Datas
IPv6 fragment header (fixed 8 bytes): ip6.Fraghdr, contains the following key fields:
the next head: ip6.Fraghdr. Nxt
Sheet offset: ip6.Fraghdr. Offset
And (5) slicing and marking: ip6. Fragdr. More (if the value is 1, this means that there are more messages later, if the value is 0, this means that the last message of the fragment)
And (3) slicing identification: ip6. Fragaddr. Ident (reassembling multiple fragmented messages based on the ID)
Thus, the IP header field of the message a to be forwarded is as follows:
ethernet (ethernet two-layer header of message a, typically 14 bytes)
Ip6. Plen=1460 (payload length equals a length minus IPv6 header fixed 40 bytes)
Ip6. Nxt=x (where X is not equal to 44, i.e. the next header is not an IPv6 segmented header)
Ip6.Src (source address of message A)
Ip6.Dst (destination address of message A)
A.ip6.datas[0-1459]
The corresponding IP header field of fragment A1 is as follows:
A1. ethernet=a. Ethernet (message A1 ethernet two-layer header equals message a)
Ip 6.plen=1256 (out interface MTU1300 minus IPv6 header fixed 40 bytes minus IPv6 fragment header 8 bytes, equal to 1252 bytes, since the effective data length of the fragment needs to satisfy a multiple of 8, 1248 bytes can be transmitted, so adding the IPv6 fragment header 8 bytes gives a payload length of 1256)
Ip6. Nxt=44 (i.e. the next header indication is an IPv6 segmented header)
A1.ip6. Src=a.ip 6.Src (equal to the source address of message a)
Ip6. Dst=a.ip 6.Dst (equal to the destination address of message a)
A1.ip6. Fragdr. Nxt=a. Ip6.Nxt (the next header value in the slice header is equal to the next header of a)
Ip6. Fragaddr. Offset=0 (chip offset 0)
Ip6. Fragdr. More=1 (indicating that there are further fragments following the message)
A1.ip6. Fragaddr. Id = random value
A1.ip6.Datas [0-1247] = a.ip6.Datas [0-1247] (i.e. A1 maximum carrying a first part of data of a total 1248 bytes)
The IP header field of fragment A2 is as follows:
a2. ethernet=a. Ethernet (message A2 ethernet two-layer header equals message a)
A2.ip 6.plen=220 (a payload data length remaining 1460-1248=212, plus IPv6 fragment header 8 bytes)
A2.ip6.nxt=44 (i.e. the next header indication is an IPv6 segmented header)
A2.ip6.src=a.ip6.src (equal to the source address of message a)
A2.ip6. Dst=a.ip 6.Dst (equal to the destination address of message a)
A2.iph6.fragaddr.nxt=a.iph6.nxt (the next header value in the slice header is equal to the next header of a)
A2.ip 6.fragaddr.offset=len (a 1.ip 6.datas) =1248 (chip offset 1248)
A2.ip6. Fragdr. More=0 (representing the last fragment message)
A2.ip 6.fraghdr.id=a1.ip 6.fraghdr.id (both are equal)
A2.ip6.datas [0-211] =a.ip 6.datas [1248-1459] (A2 carries a total of 212 bytes of data of the second part of a)
Accordingly, referring to fig. 6, fig. 6 is a schematic structural diagram of another embodiment of an IPv6 type fragmentation message according to the present invention. As shown in fig. 6, when the message a is an IPv6 type message to be forwarded and the message a itself is a fragmented message, it is assumed that the first message length of the message a is 1496 (without considering that the ethernet two-layer header is fixed by 14 bytes), the output MTU value is 1300, and the two fragmented messages obtained by fragmenting the message a are a fragmented message A1 and a fragmented message A2 respectively.
The IP header field of the message a is as follows:
ethernet (ethernet two-layer header of message a, typically 14 bytes)
A.ip6.plen=1456
Ip6. Nxt=44 (i.e. the next header is an IPv6 segmented header)
Ip6.Src (source address of message A)
Ip6.Dst (destination address of message A)
Ip6. Fragdr. Nxt=x (indicating the next header)
Ip6. Fragaddr. Offset=n (chip offset N)
Ip6. Fragdr. More=0/1 (1 indicates that there are more slices behind, 0 indicates the last slice)
A.ip6.fraghdr.id
Ip6.Datas [0-1447] (the effective data length of the fragment message is a multiple of 8)
The IP header field of fragment A1 is as follows:
a1. ethernet=a. Ethernet (message A1 ethernet two-layer header equals message a)
Ip 6.plen=1256 (out interface MTU1300 minus IPv6 header fixed 40 bytes minus IPv6 fragment header 8 bytes, equal to 1252 bytes, since the effective data length of the fragment needs to satisfy a multiple of 8, 1248 bytes can be transmitted, so adding the IPv6 fragment header 8 bytes gives a payload length of 1256)
Ip6. Nxt=44 (i.e. the next header indication is an IPv6 segmented header)
A1.ip6. Src=a.ip 6.Src (equal to the source address of message a)
Ip6. Dst=a.ip 6.Dst (equal to the destination address of message a)
A1.ip6. Fragdr. Nxt=a. Ip6.Nxt (the next header value in the slice header is equal to the next header of a)
A1.ip6. Fragdr. Offset=a. Ip6. Fragdr. Offset=n (slice offset)
Ip6. Fragdr. More=1 (indicating that there are further fragments following the message)
A1.ip6. Fragaddr. Id=a.ip 6. Fragaddr. Id (equal to the id of the slice header of a)
Ip6.Datas [0-1247] = a.ip6.Datas [0-1247] (consider MTU1300 out of interface, subtract 40 bytes from IPv6 header, subtract 8 bytes from IPv6 slice header, i.e. 1248 bytes from the first part of data that A1 can carry a maximum) in total
The IP header field of fragment A2 is as follows:
a2. ethernet=a. Ethernet (message A2 ethernet two-layer header equals message a)
A2.ip 6.plen=208 (a payload data length remaining 1448-1248=200, plus IPv6 fragmentation header 8 bytes for a total of 208 bytes)
A2.ip6.nxt=44 (i.e. the next header indication is an IPv6 segmented header)
A2.ip6.src=a.ip6.src (equal to the source address of message a)
A2.ip6. Dst=a.ip 6.Dst (equal to the destination address of message a)
A2.iph6.fragaddr.nxt=a.iph6.nxt (the next header value in the slice header is equal to the next header of a)
A2.ip 6.fraghdr.offset=a.ip 6.fraghdr.offset+len (a 1.ip 6.datas) =n+1248 (chip offset)
A2.ip 6.fragdr.more=a.ip 6.fragdr.more (last fragment message A2 fragment flag equals a fragment flag)
A2.ip 6.fraghdr.id=a1.ip 6.fraghdr.id (both are equal)
A2.ip6.datas [0-199] =a.ip 6.datas [1247-1447] (A2 carries a total of 200 bytes of data of the second part of a)
In summary, when the system performs the fragmentation processing on the message to be forwarded, the number of fragments of the message is determined according to the message type of the message to be forwarded, and then the fragmentation processing is performed on the message to be forwarded according to the determined number of fragments.
Further, after the determining whether the egress MTU value is greater than the first message length, the embodiment further includes:
if the exit MTU value is larger than the first message length, analyzing and obtaining the message type of the message to be forwarded, judging the message type, and determining whether the message to be forwarded meets forwarding requirements according to a second judging result;
if the second judging result shows that the message type meets the forwarding requirement, transmitting the message to be forwarded to the outlet network interface so that the outlet network interface forwards the message to be forwarded;
and if the second judging result is that the message type does not meet the forwarding requirement, discarding the message to be forwarded.
After determining that the output MTU value of the output network interface is greater than the first message length, that is, the message to be forwarded meets the forwarding standard of the output network interface, the system further judges the message type of the message to be forwarded, determines whether the message type of the message to be forwarded meets the message forwarding requirement of the output network interface, and only through the two judgments, the system forwards the message to be forwarded to the output network interface and forwards the message to be forwarded by the output network interface.
If the message type is judged to be not in accordance with the forwarding requirement, the system does not forward the message to be forwarded to the outlet network interface, but discards the message to be forwarded even if the length of the first message of the message to be forwarded is smaller than the value of the outlet MTU.
For better illustrating the working principle and the step flow of the method, the device, the system and the storage medium for message slicing according to the present invention, reference may be made to the above related description, but not limited thereto.
Correspondingly, the invention also provides a message slicing device, which comprises a message receiving module 201 and a message slicing module 202;
the message receiving module 201 is configured to receive and parse a message to be forwarded, obtain an egress network interface corresponding to the message to be forwarded and a first message length of the message to be forwarded, and call an egress MTU value of the egress network interface, so as to determine whether the egress MTU value is greater than the first message length.
Further, after the determining whether the egress MTU value is greater than the first message length, the message receiving module 201 further includes:
if the exit MTU value is larger than the first message length, analyzing and obtaining the message type of the message to be forwarded, judging the message type, and determining whether the message to be forwarded meets forwarding requirements according to a second judging result;
If the second judging result shows that the message type meets the forwarding requirement, transmitting the message to be forwarded to the outlet network interface so that the outlet network interface forwards the message to be forwarded; and if the second judging result is that the message type does not meet the forwarding requirement, discarding the message to be forwarded.
The message slicing module 202 is configured to perform slicing processing on the message to be forwarded to obtain a plurality of sliced messages if the value of the egress MTU is determined to be less than or equal to the first message length, and transmit the plurality of sliced messages to the egress network interface, so that the egress network interface performs forwarding processing on the plurality of sliced messages respectively.
Further, the message slicing module 202 performs slicing processing on the message to be forwarded to obtain a plurality of sliced messages, which specifically includes:
determining a message limit length of each segmented message according to the exit MTU value, and determining the number of segments of the segmented messages according to the determined message limit length and the first message length; and carrying out fragmentation processing on the messages to be forwarded according to the determined fragmentation quantity, setting the source address of each fragment message according to the source address of the messages to be forwarded, setting the destination address of each fragment message according to the destination address of the messages to be forwarded, and further integrating to obtain the fragments messages.
Further, after the determining that the egress MTU value is less than or equal to the first message length, the message slicing module 202 further includes:
judging the message type of the message to be forwarded to obtain a corresponding first judgment result;
if the first judging result is that the message to be forwarded is an IPv4 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the length of a first head part is subtracted from the effective data length of each fragment message; if the first judgment result is that the message to be forwarded is an IPv6 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the effective data length of each fragment message needs to be subtracted by the lengths of the first head and the first fragment head.
Correspondingly, the embodiment of the invention also provides a message slicing system, which comprises a memory, a processor and a computer program stored in the memory and running on the processor, wherein the processor realizes the message slicing method according to any one of the above when processing the computer program.
Correspondingly, the embodiment of the invention also provides a storage medium, wherein the storage medium is stored with a computer program, and the computer program is called and executed by a processor to realize a message slicing method according to any one of the above.
In summary, the embodiments of the present invention provide a method, an apparatus, a system, and a storage medium for slicing a message, where an egress network interface and a first message length are obtained by analyzing a message to be forwarded, and an egress MTU value corresponding to the egress network interface is compared with the first message length to determine whether the egress MTU value is greater than the first message length, and if it is determined that the egress MTU value is less than or equal to the first message length, the slicing process is performed on the message to be forwarded to obtain a plurality of sliced messages, and the plurality of sliced messages are sent to the egress network interface, so as to implement the slicing forwarding process of the message to be forwarded. The invention realizes the forwarding processing of the ultra-long message by carrying out the fragment forwarding processing on the message which cannot be forwarded due to the problem of message length, and improves the success rate and accuracy of forwarding the system message.
The foregoing embodiments have been provided for the purpose of illustrating the general principles of the present invention, and are not to be construed as limiting the scope of the invention. It should be noted that any modifications, equivalent substitutions, improvements, etc. made by those skilled in the art without departing from the spirit and principles of the present invention are intended to be included in the scope of the present invention.

Claims (10)

1. The message slicing method is characterized by comprising the following steps:
receiving and analyzing a message to be forwarded, obtaining an exit network interface corresponding to the message to be forwarded and a first message length of the message to be forwarded, and calling an exit MTU value of the exit network interface, so as to determine whether the exit MTU value is larger than the first message length;
and if the value of the exit MTU is smaller than or equal to the length of the first message, carrying out fragmentation processing on the message to be forwarded to obtain a plurality of fragmented messages, and transmitting the fragmented messages to the exit network interface so that the exit network interface can respectively forward the fragmented messages.
2. The method for fragmenting a message according to claim 1, wherein the fragmenting the message to be forwarded to obtain a plurality of fragmented messages comprises:
determining a message limit length of each segmented message according to the exit MTU value, and determining the number of segments of the segmented messages according to the determined message limit length and the first message length;
and carrying out fragmentation processing on the messages to be forwarded according to the determined fragmentation quantity, setting the source address of each fragment message according to the source address of the messages to be forwarded, setting the destination address of each fragment message according to the destination address of the messages to be forwarded, and further integrating to obtain the fragments messages.
3. The method of claim 1, further comprising, after said determining that said egress MTU value is less than or equal to said first message length:
judging the message type of the message to be forwarded to obtain a corresponding first judgment result;
if the first judging result is that the message to be forwarded is an IPv4 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, subtracting the length of a first head from the message limit length of each fragment message;
if the first judgment result is that the message to be forwarded is an IPv6 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the length of a first head and the length of a first fragment head are subtracted from the limit length of each fragment message.
4. The method of message slicing as set forth in claim 1, further comprising, after said determining if said egress MTU value is greater than said first message length:
if the exit MTU value is larger than the first message length, analyzing and obtaining the message type of the message to be forwarded, judging the message type, and determining whether the message to be forwarded meets forwarding requirements according to a second judging result;
If the second judging result shows that the message type meets the forwarding requirement, transmitting the message to be forwarded to the outlet network interface so that the outlet network interface forwards the message to be forwarded;
and if the second judging result is that the message type does not meet the forwarding requirement, discarding the message to be forwarded.
5. The message slicing device is characterized by comprising a message receiving module and a message slicing module;
the message receiving module is used for receiving and analyzing a message to be forwarded, obtaining an outlet network interface corresponding to the message to be forwarded and a first message length of the message to be forwarded, and calling an outlet MTU value of the outlet network interface, so as to determine whether the outlet MTU value is larger than the first message length;
and the message slicing module is used for slicing the message to be forwarded to obtain a plurality of sliced messages if the MTU value of the outlet is smaller than or equal to the length of the first message, and transmitting the sliced messages to the outlet network interface so that the outlet network interface forwards the sliced messages respectively.
6. The message slicing device of claim 5, wherein the message slicing module performs slicing processing on the message to be forwarded to obtain a plurality of sliced messages, specifically:
determining a message limit length of each segmented message according to the exit MTU value, and determining the number of segments of the segmented messages according to the determined message limit length and the first message length;
and carrying out fragmentation processing on the messages to be forwarded according to the determined fragmentation quantity, setting the source address of each fragment message according to the source address of the messages to be forwarded, setting the destination address of each fragment message according to the destination address of the messages to be forwarded, and further integrating to obtain the fragments messages.
7. The message slicing apparatus of claim 5, wherein the message slicing module, after said determining that the egress MTU value is less than or equal to the first message length, further comprises:
judging the message type of the message to be forwarded to obtain a corresponding first judgment result;
if the first judging result is that the message to be forwarded is an IPv4 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the length of a first head part is subtracted from the effective data length of each fragment message;
If the first judgment result is that the message to be forwarded is an IPv6 message, when the number of fragments is determined by carrying out fragment processing calculation on the message to be forwarded, the effective data length of each fragment message needs to be subtracted by the lengths of the first head and the first fragment head.
8. The message slicing apparatus of claim 5, wherein the message receiving module further comprises, after said determining whether the egress MTU value is greater than the first message length:
if the exit MTU value is larger than the first message length, analyzing and obtaining the message type of the message to be forwarded, judging the message type, and determining whether the message to be forwarded meets forwarding requirements according to a second judging result;
if the second judging result shows that the message type meets the forwarding requirement, transmitting the message to be forwarded to the outlet network interface so that the outlet network interface forwards the message to be forwarded;
and if the second judging result is that the message type does not meet the forwarding requirement, discarding the message to be forwarded.
9. A message slicing system comprising a memory, a processor and a computer program stored on the memory and running on the processor, the processor implementing a message slicing method according to any of claims 1-4 when processing the computer program.
10. A storage medium having stored thereon a computer program, the computer program being invoked and executed by a processor to implement a message slicing method according to any of the preceding claims 1-4.
CN202311672545.2A 2023-12-07 2023-12-07 Message slicing method, device, system and storage medium Pending CN117544572A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311672545.2A CN117544572A (en) 2023-12-07 2023-12-07 Message slicing method, device, system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311672545.2A CN117544572A (en) 2023-12-07 2023-12-07 Message slicing method, device, system and storage medium

Publications (1)

Publication Number Publication Date
CN117544572A true CN117544572A (en) 2024-02-09

Family

ID=89787990

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311672545.2A Pending CN117544572A (en) 2023-12-07 2023-12-07 Message slicing method, device, system and storage medium

Country Status (1)

Country Link
CN (1) CN117544572A (en)

Similar Documents

Publication Publication Date Title
KR101298407B1 (en) Method and apparatus for transmitting data packet, and method and apparatus for receiving data packet
EP1234428B1 (en) Method and apparatus for packet delay reduction using scheduling and header compression
US6845105B1 (en) Method and apparatus for maintaining sequence numbering in header compressed packets
US7602809B2 (en) Reducing transmission time for data packets controlled by a link layer protocol comprising a fragmenting/defragmenting capability
CN100433714C (en) Method for transmission processing IP fragment message
EP4274123A1 (en) Packet encapsulation and de-encapsulation method and device, storage medium, and electronic device
EP1648133B1 (en) A method for encapsulating data stream
CN114301576A (en) Method and communication device for generating and transmitting acknowledgement frame in IEEE802.15.4 network
EP2600569B1 (en) Method, apparatus and system for processing a tunnel packet
CN117714559A (en) Message processing method and device, electronic equipment and storage medium
EP2077637A1 (en) System and method for protecting payload information in radio transmission
CN111917786A (en) GRE tunnel-based data packet fragmentation method and data packet recombination method
CN117544572A (en) Message slicing method, device, system and storage medium
WO2020087250A1 (en) Data sending method and apparatus, and flexe switching system
KR100617818B1 (en) Method and device for transmitting data and method and device for receiving data in Broadband wireless communication system
EP4131869A1 (en) Communication method, apparatus, and system
CN108882304B (en) Method and device for encapsulating data packet in data link layer
CN117376272A (en) Message length adjustment method, device, system and storage medium
CN115460301A (en) ARINC664 protocol-based packet header filling method
CN115225711A (en) Ethernet equipment of high-efficient transmission
CN117527667A (en) Service function chain processing method and device
CN116260895A (en) Method and system for improving UDP (user datagram protocol) fragment packet forwarding performance based on PMTU (packet transfer request)
WO2002073908A2 (en) A method and a system for transmitting information through a communication line
CN112583731A (en) Method and device for fragmenting and recombining GRE (generic routing encapsulation) message
CN112688751A (en) Communication method, device and system

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