CN109246036B - Method and device for processing fragment message - Google Patents

Method and device for processing fragment message Download PDF

Info

Publication number
CN109246036B
CN109246036B CN201710557080.4A CN201710557080A CN109246036B CN 109246036 B CN109246036 B CN 109246036B CN 201710557080 A CN201710557080 A CN 201710557080A CN 109246036 B CN109246036 B CN 109246036B
Authority
CN
China
Prior art keywords
fragment
new
correct
tail
address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710557080.4A
Other languages
Chinese (zh)
Other versions
CN109246036A (en
Inventor
唐美芹
朱道松
朱海英
祝海凤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sanechips Technology Co Ltd
Original Assignee
Sanechips 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 Sanechips Technology Co Ltd filed Critical Sanechips Technology Co Ltd
Priority to CN201710557080.4A priority Critical patent/CN109246036B/en
Publication of CN109246036A publication Critical patent/CN109246036A/en
Application granted granted Critical
Publication of CN109246036B publication Critical patent/CN109246036B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • H04L49/9057Arrangements for supporting packet reassembly or resequencing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L49/00Packet switching elements
    • H04L49/90Buffering arrangements
    • H04L49/9015Buffering arrangements for supporting a linked list

Abstract

The invention discloses a method and a device for processing a fragment message, which comprises the following steps: a correct queue chain table and an incorrect queue chain table are created in advance, and a head pointer, a tail pointer and a virtual tail pointer are created for each queue chain table; when a new fragment arrives, allocating an address for the new fragment, respectively storing the address of the new fragment into tail nodes of a correct queue chain table and an error queue chain table, and respectively pointing a correct virtual tail pointer and an error virtual tail pointer to the address of the new fragment; checking whether the new fragment is correct and whether the new fragment is a tail fragment; if the pointer is correct and is the tail fragment, the correct chain tail pointer is updated to be the value of the correct virtual tail pointer, and the wrong virtual tail pointer is updated to be the value of the wrong chain tail pointer; and if the pointer is wrong, updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer. The invention saves storage resources and improves the message inspection efficiency by creating the linked list and adopting the virtual enqueue method.

Description

Method and device for processing fragment message
Technical Field
The present invention relates to the field of network communication technologies, and in particular, to a method and an apparatus for processing a fragment packet.
Background
Because ethernet is low in cost, flexible in networking and good in scalability, more and more IP (internet protocol) data are loaded on ethernet, but because the length of payload loaded by ethernet has an upper limit of 1500 bytes (Byte), when an IP message passes through ethernet, the message with an excessively long length must be fragmented and reassembled.
However, because a network transmitting a packet may have a delay or jitter, and a fragmented packet may have errors such as loss, disorder, and the like, a conventional method for checking a fragmented error is to apply for a large buffer first, and when a first fragment of the packet arrives, place the first fragment of the packet into the buffer, as shown in fig. 1, store the fragment into a position of a buffer 0, and when a subsequent fragment of the packet arrives, place the fragment into positions of a buffer 1, a buffer 2, and a buffer 3 in sequence according to a sequence number of the fragment until a last fragment of the packet arrives. If the fragmentation message is checked to be correct, the fragmentation message is sent to a destination, and the cache is emptied; and if the fragmentation message is checked to be wrong, the cache of the fragmentation message with the wrong storage is emptied. For example, when the 4 th slice arrives at the discovery error, the space of buffer 0 to buffer 3 is released. In order to prevent congestion at the output end in case of message burst, the buffer space needs to consider the maximum congestion amount. The method has the disadvantages that when different types of messages arrive in an interleaved manner, when the tail fragment of one message does not arrive completely, the head fragments of other types may arrive, and a new storage space needs to be allocated for the head fragment of the type at the moment to wait for the error checking and the error recombination to be completed. Therefore, when there are multiple types of messages arriving in an interleaved manner, M buffer spaces need to be allocated for each type of message for error checking and reassembly. If there are N types of messages, the amount of memory space required is M N. Therefore, the prior art needs to apply for a large cache, and when the connection is large, a large amount of storage space is needed; and the speed of message inspection and recombination is slow, the transmission rate of message data is not fast, and congestion is easily caused when the flow is large.
Disclosure of Invention
In order to solve the technical problem, the invention provides a method and a device for processing a fragment message, which can save storage resources and improve message inspection efficiency.
In order to achieve the purpose of the invention, the technical scheme of the embodiment of the invention is realized as follows:
the embodiment of the invention provides a method for processing a fragment message, which comprises the following steps:
a correct queue chain table, an error queue chain table and an idle address chain table are created in advance and are respectively used for storing correct fragment addresses, wrong fragment addresses and idle fragment addresses; creating a correct chain head pointer, a correct chain tail pointer, a correct virtual tail pointer, an error chain head pointer, an error chain tail pointer and an error virtual tail pointer, wherein the correct chain head pointer and the error chain head pointer respectively point to head nodes of a correct queue chain table and an error queue chain table, and the correct chain tail pointer and the error chain tail pointer respectively point to tail nodes of the correct queue chain table and the error queue chain table;
when a new fragment arrives, allocating an address for the new fragment from the idle address linked list, storing the new fragment into the allocated address, respectively storing the address of the new fragment into tail nodes of a correct queue linked list and an error queue linked list, and respectively pointing a correct virtual tail pointer and an error virtual tail pointer to the address of the new fragment;
checking whether the new fragment is correct and whether the new fragment is a tail fragment;
if the new fragment is correct and the new fragment is a tail fragment, updating the correct chain tail pointer to the value of the correct virtual tail pointer and updating the wrong virtual tail pointer to the value of the wrong chain tail pointer;
and if the new fragment is wrong, updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer.
Further, the checking whether the new fragment is correct and whether the new fragment is a tail fragment specifically includes:
checking whether the new fragment is a tail fragment and whether the fragment number of the new fragment is continuous with the fragment number of the last fragment;
if the new fragment is not the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, temporarily judging that the new fragment is correct and the new fragment is not the tail fragment, and continuing judging after the next new fragment arrives;
if the new fragment is not the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, checking whether the new fragment is the head fragment, and if the new fragment is the head fragment, judging that the new fragment of the message arrived before the head fragment is wrong; if the new fragment is not the first fragment, judging that the new fragment is wrong;
if the new fragment is the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, judging that the new fragment is correct and the new fragment is the tail fragment;
and if the new fragment is the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, judging that the new fragment is wrong.
Further, the checking whether the new fragment is correct and whether the new fragment is a tail fragment further includes:
when a new fragment is judged to be wrong, a new fragment which arrives before the new fragment and belongs to the same reassembly message as the wrong new fragment or a new fragment which arrives after the new fragment and belongs to the same reassembly message as the wrong new fragment is also judged to be wrong.
Further, the method further comprises:
checking whether the head fragment of the correct queue linked list is scheduled;
if the head fragment of the correct queue linked list is scheduled, storing the address of the scheduled head fragment into the idle address linked list, and updating the correct link head pointer to the address of the next fragment pointed by the address of the scheduled head fragment.
Further, the method further comprises:
checking whether the address of the head fragment of the error queue linked list is recycled;
if the address of the head fragment of the error queue linked list is recovered, storing the recovered address of the head fragment into the idle address linked list, and updating the error chain head pointer to the address of the next fragment pointed by the recovered address of the head fragment.
The embodiment of the invention also provides a device for processing the fragment message, which comprises a linked list module, a distribution module and an inspection module, wherein:
the linked list module is used for creating a correct queue linked list, an error queue linked list and an idle address linked list in advance, and respectively storing a correct fragment address, an error fragment address and an idle fragment address; creating a correct chain head pointer, a correct chain tail pointer, a correct virtual tail pointer, an error chain head pointer, an error chain tail pointer and an error virtual tail pointer, wherein the correct chain head pointer and the error chain head pointer respectively point to the addresses of the first fragments of the correct queue chain table and the error queue chain table, and the correct chain tail pointer and the error chain tail pointer respectively point to the tail nodes of the correct queue chain table and the error queue chain table;
the distribution module is used for distributing addresses for the new fragments from the idle address linked list of the linked list module when the new fragments arrive, storing the new fragments into the distributed addresses, respectively storing the addresses of the new fragments into tail nodes of a correct queue linked list and an error queue linked list of the linked list module, respectively pointing a correct virtual tail pointer and an error virtual tail pointer to the addresses of the new fragments, and informing the checking module;
the checking module is used for receiving the notification of the distribution module and checking whether the new fragment is correct and whether the new fragment is a tail fragment; if the new fragment is correct and the new fragment is a tail fragment, updating the correct chain tail pointer to the value of the correct virtual tail pointer and updating the wrong virtual tail pointer to the value of the wrong chain tail pointer; and if the new fragment is wrong, updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer.
Further, the checking module checks whether the new fragment is correct and whether the new fragment is a tail fragment, and specifically includes:
checking whether the new fragment is a tail fragment and whether the fragment number of the new fragment is continuous with the fragment number of the last fragment;
if the new fragment is not the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, temporarily judging that the new fragment is correct and the new fragment is not the tail fragment, and continuing judging after the next new fragment arrives;
if the new fragment is not the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, checking whether the new fragment is the head fragment, and if the new fragment is the head fragment, judging that the new fragment of the message arrived before the head fragment is wrong; if the new fragment is not the first fragment, judging that the new fragment is wrong;
if the new fragment is the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, judging that the new fragment is correct and the new fragment is the tail fragment;
and if the new fragment is the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, judging that the new fragment is wrong.
Further, when the checking module determines that a new fragment is in error, a new fragment that arrives before the new fragment and belongs to the same reassembly packet as the new fragment in error or a new fragment that arrives after the new fragment and belongs to the same reassembly packet as the new fragment in error is also determined to be in error.
Further, the checking module is further configured to:
checking whether the head fragment of the correct queue linked list is scheduled;
if the head fragment of the correct queue linked list is scheduled, storing the address of the scheduled head fragment into the idle address linked list, and updating the correct link head pointer to the address of the next fragment pointed by the address of the scheduled head fragment.
Further, the checking module is further configured to:
checking whether the address of the head fragment of the error queue linked list is recycled;
if the address of the head fragment of the error queue linked list is recovered, storing the recovered address of the head fragment into the idle address linked list, and updating the error chain head pointer to the address of the next fragment pointed by the recovered address of the head fragment.
The technical scheme of the invention has the following beneficial effects:
the method and the device for processing the fragment message provided by the invention enable the fragment to be virtually enqueued before message inspection by creating a correct queue chain table and a virtual queue chain table and setting a head pointer, a tail pointer and a virtual tail pointer for each queue chain table; after the message is checked, the fragments are actually queued, so that the storage resource is saved, the message checking efficiency is improved, the scheduling speed after recombination is accelerated, the wrong message is quickly emptied from the cache, and the occupied time of invalid cache is reduced, so that the transmission speed of message data is improved, and the congestion during large flow is reduced; and each queue is independent, so that the diversity of queue scheduling is increased.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
fig. 1 is a schematic diagram of a cache structure of a conventional method for processing a fragment packet;
fig. 2 is a schematic flow chart of a method for processing a fragment packet according to an embodiment of the present invention;
fig. 3 is a schematic structural diagram of a device for processing a fragment packet according to an embodiment of the present invention;
fig. 4 is a schematic flow chart of checking a fragmentation message according to a preferred embodiment of the present invention;
FIG. 5 is a diagram illustrating a structure of a correct queue link table in accordance with a preferred embodiment of the present invention;
FIG. 6 is a diagram illustrating a storage structure of a correct queue chain table or an incorrect queue chain table according to an embodiment of the present invention;
FIG. 7 is a schematic diagram of a structure of a correct queue chain table when the first segment in FIG. 5 is scheduled to dequeue;
FIG. 8 is a diagram illustrating a structure of a correct queue chain table when a correct non-tail fragment c arrives in FIG. 5;
FIG. 9 is a diagram illustrating a structure of a correct queue chain table when the slice c with the error in FIG. 5 arrives;
FIG. 10 is a diagram illustrating a structure of a correct queue chain table when a correct tail fragment c arrives in FIG. 5;
FIG. 11 is a diagram illustrating the structure of an error queue linked list according to a preferred embodiment of the present invention;
FIG. 12 is a diagram illustrating a structure of an error queue chain table when the first fragment address in FIG. 11 is recycled and dequeued;
FIG. 13 is a structural diagram of an error queue chain table in FIG. 11 when a correct non-tail fragment c arrives;
FIG. 14 is a structural diagram of an error queue chain table in FIG. 11 when a correct tail fragment c arrives;
fig. 15 is a schematic structural diagram of an error queue chain table when the slice c with an error in fig. 11 arrives.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
As shown in fig. 2, a method for processing a fragment packet according to the present invention includes the following steps:
step 201: a correct queue chain table, an error queue chain table and an idle address chain table are created in advance, wherein the correct queue chain table, the error queue chain table and the idle address chain table are respectively used for storing a correct fragment address, an error fragment address and an idle fragment address; creating a correct chain head pointer, a correct chain tail pointer and a correct virtual tail pointer for each correct queue chain table, and creating an error chain head pointer, an error chain tail pointer and an error virtual tail pointer for each error queue chain table, wherein the correct chain head pointer and the error chain head pointer respectively point to the addresses of the head fragments of the correct queue chain table and the error queue chain table, and the correct chain tail pointer and the error chain tail pointer respectively point to the tail nodes of the correct queue chain table and the error queue chain table;
further, according to the type number N of the message, wherein N is a natural number, N correct queue chain tables and N wrong queue chain tables are created in advance.
Step 202: when a new fragment arrives, an address is distributed for the new fragment from the idle address linked list, meanwhile, the new fragment is stored into the distributed address, the addresses of the new fragment are respectively stored into tail nodes of a correct queue linked list and an error queue linked list, and a correct virtual tail pointer and an error virtual tail pointer respectively point to the address of the new fragment;
further, according to the fragment type of the new fragment, the address of the new fragment is respectively stored into the tail nodes of the correct queue chain table and the wrong queue chain table of the corresponding message type.
It should be noted that, when the fragments reach the downstream side, each fragment carries information such as the fragment TYPE (TYPE), the fragment number (SEQ), the first fragment flag (SOP), and the last fragment flag (EOP), as shown in table 1.
Sharded carrying information Description of the invention
Fragment TYPE TYPE Type of message
Fragment number SEQ If a message is cut into n pieces, the number range of the pieces is 0 to (n-1).
First segment mark SOP When the value is 1, the fragment is valid, and the fragment is the first fragment of a message.
Tail fragment marker EOP When the number is 1, it indicates that the fragment is a tail fragment of a message.
TABLE 1
It should be noted that, before the packet inspection is performed on the new fragment, the address of the new fragment is stored in the tail nodes of the correct queue chain table and the incorrect queue chain table at the same time, and the values of the correct chain tail pointer and the incorrect chain tail pointer are not updated at this time, that is, the correct chain tail pointer still points to the tail node of the packet which has been inspected to be correct in the correct queue chain table at this time, and the incorrect chain tail pointer still points to the tail node of the packet which has been inspected to be incorrect in the incorrect queue chain table at this time.
Step 203: checking whether the new fragment is correct and whether the new fragment is a tail fragment;
if the new fragment is correct and the new fragment is a tail fragment, updating the correct chain tail pointer to the value of the correct virtual tail pointer and updating the wrong virtual tail pointer to the value of the wrong chain tail pointer;
and if the new fragment is wrong, updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer.
Further, if the new fragment is correct and the new fragment is not the tail fragment, waiting for the arrival of the next fragment, and going to step 202.
It should be noted that, the correct chain tail pointer is updated to the value of the correct virtual tail pointer, and the wrong virtual tail pointer is updated to the value of the wrong chain tail pointer, that is, the address of the new fragment which has been checked to be correct is stored in the correct queue chain table, and the address of the new fragment which has been checked to be correct is deleted from the wrong queue chain table; and updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer, namely storing the address of the new fragment checked as the error in the error queue chain table, and deleting the address of the new fragment checked as the error from the correct queue chain table.
Further, the checking whether the new fragment is correct and whether the new fragment is a tail fragment specifically includes:
checking whether the new fragment is a tail fragment and whether the fragment number of the new fragment is continuous with the fragment number of the last fragment;
if the new fragment is not the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, temporarily judging that the new fragment is correct and the new fragment is not the tail fragment, and continuing judging after the next new fragment arrives;
if the new fragment is not the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, checking whether the new fragment is the head fragment, and if the new fragment is the head fragment, judging that the new fragment of the message arrived before the head fragment is wrong; if the new fragment is not the first fragment, judging that the new fragment is wrong;
if the new fragment is the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, judging that the new fragment is correct and the new fragment is the tail fragment;
and if the new fragment is the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, judging that the new fragment is wrong.
It should be noted that, when a new fragment is determined to be in error, a new fragment that belongs to the same reassembly packet as the new fragment in error and that arrives before the new fragment or a new fragment that belongs to the same reassembly packet as the new fragment in error and that arrives after the new fragment is also determined to be in error.
Further, the method further comprises:
checking whether the head fragment of the correct queue chain table is scheduled;
if the head fragment of the correct queue linked list is scheduled, the address of the scheduled head fragment is stored in the idle address linked list, and the correct link head pointer is updated to the address of the next fragment pointed by the address of the scheduled head fragment.
Further, the method further comprises:
checking whether the address of the head fragment of the error queue linked list is recycled;
if the address of the head fragment of the error queue linked list is recovered, the address of the recovered head fragment is stored into the idle address linked list, and the error link head pointer is updated to the address of the next fragment pointed by the address of the recovered head fragment.
As shown in fig. 3, an apparatus for processing a fragmented packet according to the present invention includes a linked list module, an allocation module, and an inspection module, wherein:
the linked list module is used for creating a correct queue linked list, an error queue linked list and an idle address linked list in advance, wherein the correct queue linked list, the error queue linked list and the idle address linked list are respectively used for storing a correct fragment address, an error fragment address and an idle fragment address; creating a correct chain head pointer, a correct chain tail pointer and a correct virtual tail pointer for each correct queue chain table, and creating an error chain head pointer, an error chain tail pointer and an error virtual tail pointer for each error queue chain table, wherein the correct chain head pointer and the error chain head pointer respectively point to the addresses of the head fragments of the correct queue chain table and the error queue chain table, and the correct chain tail pointer and the error chain tail pointer respectively point to the tail nodes of the correct queue chain table and the error queue chain table;
the distribution module is used for distributing an address for a new fragment from an idle address linked list of the linked list module when the new fragment arrives, simultaneously storing the new fragment into the distributed address, respectively storing the address of the new fragment into tail nodes of a correct queue linked list and an error queue linked list of the linked list module, respectively pointing a correct virtual tail pointer and an error virtual tail pointer to the address of the new fragment, and informing the checking module;
the checking module is used for receiving the notification of the distribution module and checking whether the new fragment is correct and whether the new fragment is a tail fragment; if the new fragment is correct and the new fragment is a tail fragment, updating the correct chain tail pointer to the value of the correct virtual tail pointer and updating the wrong virtual tail pointer to the value of the wrong chain tail pointer; and if the new fragment is wrong, updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer.
Further, the linked list module creates N correct queue linked lists and N error queue linked lists in advance according to the type number N of the message, wherein N is a natural number;
and the distribution module stores the addresses of the new fragments into tail nodes of a correct queue chain table and an incorrect queue chain table of the corresponding message types respectively according to the fragment types of the new fragments.
It should be noted that, when the fragments reach the downstream side, each fragment carries information such as the fragment TYPE (TYPE), the fragment number (SEQ), the first fragment flag (SOP), and the last fragment flag (EOP), as shown in table 1.
It should be noted that, before the checking module performs packet checking on the new fragment, the address of the new fragment is stored in the tail nodes of the correct queue linked list and the incorrect queue linked list at the same time, and at this time, the values of the correct chain tail pointer and the incorrect chain tail pointer are not updated, that is, the correct chain tail pointer still points to the tail node of the packet checked as correct in the correct queue linked list, and the incorrect chain tail pointer still points to the tail node of the packet checked as incorrect in the incorrect queue linked list.
Further, when the checking module checks whether the new fragment is correct and whether the new fragment is a tail fragment, if the new fragment is correct and the new fragment is not the tail fragment, the checking module waits for the arrival of the next fragment.
It should be noted that, the checking module updates the correct chain tail pointer to the value of the correct virtual tail pointer, and updates the wrong virtual tail pointer to the value of the wrong chain tail pointer, that is, the address of the new fragment checked to be correct is stored in the correct queue chain table, and the address of the new fragment checked to be correct is deleted from the wrong queue chain table; and updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer, namely storing the address of the new fragment checked as the error in the error queue chain table, and deleting the address of the new fragment checked as the error from the correct queue chain table.
Further, the checking module checks whether the new fragment is correct and whether the new fragment is a tail fragment, and specifically includes:
checking whether the new fragment is a tail fragment and whether the fragment number of the new fragment is continuous with the fragment number of the last fragment;
if the new fragment is not the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, temporarily judging that the new fragment is correct and the new fragment is not the tail fragment, and continuing judging after the next new fragment arrives;
if the new fragment is not the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, checking whether the new fragment is the head fragment, and if the new fragment is the head fragment, judging that the new fragment of the message arrived before the head fragment is wrong; if the new fragment is not the first fragment, judging that the new fragment is wrong;
if the new fragment is the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, judging that the new fragment is correct and the new fragment is the tail fragment;
and if the new fragment is the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, judging that the new fragment is wrong.
It should be noted that, when the checking module determines that a new fragment is in error, a new fragment that belongs to the same reassembly packet as the new fragment in error and arrives before the new fragment or a new fragment that belongs to the same reassembly packet as the new fragment in error and arrives after the new fragment is also determined to be in error.
Further, the checking module is further configured to:
checking whether the head fragment of the correct queue chain table is scheduled;
if the head fragment of the correct queue linked list is scheduled, the address of the scheduled head fragment is stored in the idle address linked list, and the correct link head pointer is updated to the address of the next fragment pointed by the address of the scheduled head fragment.
Further, the checking module is further configured to:
checking whether the address of the head fragment of the error queue linked list is recycled;
if the address of the head fragment of the error queue linked list is recovered, the address of the recovered head fragment is stored into the idle address linked list, and the error link head pointer is updated to the address of the next fragment pointed by the address of the recovered head fragment.
The following describes how to apply the method and apparatus for processing a fragment packet according to the present invention by a preferred embodiment. It should be noted that the following preferred embodiments are only for better describing the present invention and should not be construed as unduly limiting the present invention.
According to the type number N of the message, wherein N is a natural number, N correct queue chain tables, N error queue chain tables and an idle address chain table are created in advance, and the correct queue chain table, the error queue chain table and the idle address chain table are respectively used for storing a correct fragment address, an error fragment address and an idle fragment address; creating a correct chain head pointer, a correct chain tail pointer and a correct virtual tail pointer for each correct queue chain table, and creating an error chain head pointer, an error chain tail pointer and an error virtual tail pointer for each error queue chain table, wherein the correct chain head pointer and the error chain head pointer respectively point to the addresses of the head fragments of the correct queue chain table and the error queue chain table, and the correct chain tail pointer and the error chain tail pointer respectively point to the tail nodes of the correct queue chain table and the error queue chain table;
when a new fragment arrives, an address is distributed for the new fragment from the idle address linked list, the new fragment is stored in the distributed address, the address of the new fragment is stored in the tail nodes of the correct queue linked list and the error queue linked list respectively, and the correct virtual tail pointer and the error virtual tail pointer point to the address of the new fragment respectively (before the message corresponding to the new fragment can be determined to be the correct message or the error message, the fragment address is stored in the correct queue and the error queue of the queue module at the same time);
checking whether the message is a correct fragment according to the information carried in the message header, if the message is checked to be correct, only storing the message in a correct queue, waiting for dequeue scheduling of a scheduling module, and recovering the address of the fragment after the dequeue scheduling; if the message is checked as an error, the message is only stored in the error queue and waits for the addresses of the fragments to be recycled. The specific packet inspection process is shown in fig. 4, and includes:
step 401: checking whether the newly arrived fragment is a tail fragment, namely checking whether a tail fragment mark (EOP) in a message header is 1; if not, go to step 402; if the tail fragment is obtained, go to step 407;
step 402: checking whether the fragment number (SEQ) is correct, namely whether the fragment number is continuous with the fragment number of the last fragment, and if so, turning to step 403; if not, go to step 404;
step 403: judging that the message is being recombined, virtually enqueuing the fragment, and continuously waiting for the arrival of the next fragment;
step 404: checking whether the newly arrived fragment is a first fragment, namely checking whether a first fragment mark (SOP) in a message header is 1; if the fragment is the first fragment, go to step 405; if not, go to step 406;
step 405: judging that some fragments of the previous message are lost, namely all fragments of the previous message are wrong, and continuing waiting for the arrival of the next fragment of the newly arrived fragment message;
step 406: judging that the message has errors;
step 407: checking whether the fragment number is correct; if true, go to step 408; if false, go to step 409;
step 408: judging that the message is a correct message, putting the message into a queue, and waiting for scheduling dequeuing;
step 409: and judging that the message is an error message, and discarding all the arrived fragments and fragments of the message which arrive subsequently.
As shown in fig. 5 to fig. 15, the present invention completes the reassembly of correct packets and the discarding of error packets through "virtual enqueuing". Each of the correct queue chain table and the incorrect queue chain table is composed of a chain table head, a chain table tail and a virtual chain table tail register, and all queues share one Random Access Memory (RAM).
As shown in fig. 5, the head of the correct queue linked list records the address of the first fragment of the queue, the tail of the linked list records the fragment address of the last fragment of the message that has been actually queued, and the head and the tail of the linked list records the fragment address of the message that has been checked to be correct. The storage of the fragments in the RAM is linked by using the address of the last fragment in the queue as a storage address, as shown in fig. 6, the RAM can be read by using the address of the fragment 2, and the read content is the address of the fragment 3.
The virtual chain tail of the correct queue chain records the fragment address of the last fragment of the queue of all enqueued messages (including the message being reassembled). The message between the chain table tail and the virtual chain table tail is the fragment address of the message under recombination, which is not reached by part of fragments, the part of fragment address belongs to 'virtual enqueue', and whether the message really joins the queue is correctly determined by checking whether the whole packet is in the queue or not.
As shown in fig. 7, since the fragment 1 is scheduled to be dequeued, the content in the head-of-chain register of the correct queue chain table needs to be updated to the next register pointed by the original head-of-chain pointer fragment 1, that is, the address of the fragment 2 stored in the RAM is read by using the address of the fragment 1, and the updated address is the new head of the chain table.
As shown in fig. 8, if the correct non-trailing fragment c arrives, the fragment c is linked behind the fragment b, and the address of the fragment c is written into the storage address of the fragment b.
As shown in fig. 9, when the segment c with the error is detected to arrive, it may be determined that the packet is an error, and the packet needs to be discarded, and the content of the virtual chain table tail is updated to be consistent with the chain table tail.
As shown in fig. 10, if the tail fragment c arrives and is checked to be correct, all fragments of the message have arrived and are correct messages, the chain tail register and the virtual chain tail register are updated to the address of the tail fragment c, and the address of the fragment c is written into the content of the address of the fragment b.
As shown in fig. 11, the fragments of the error message are reserved in the error queue linked list, and once the fragments are confirmed as errors, the addresses of the fragments are recovered. The list head register of the error queue linked list records the address of the first fragment of the error message queue, the linked list tail register records the fragment address of the last fragment of the queue of the message confirmed as error, and the fragment address of the message confirmed as error is arranged between the list head and the linked list tail.
The virtual chain table tail of the error queue chain table records the fragment address of the last fragment of the queue of all enqueued messages (including the messages being reassembled), and the messages between the chain table tail and the virtual chain table tail are the fragment addresses of the messages being reassembled, wherein part of the fragments of the messages do not reach.
As shown in fig. 12, slice 1 is scheduled to be dequeued due to recycling, and the head of the error queue linked list is updated to the next link address: the address of slice 2 is such that the RAM content is read with slice 1 as the read address.
As shown in fig. 13, when the correct non-tail fragment c arrives, it indicates that the packet is being reassembled, the fragment c is linked behind the fragment b, and the tail register of the virtual chain table is updated to the address of the fragment c.
As shown in fig. 14, when the correct tail fragment c arrives, the entire message is emptied from the error queue — the content of the tail register of the virtual chain table is updated to be consistent with the tail register of the chain table.
As shown in fig. 15, when the error checking fragment arrives, it indicates that the message is an error message. And (4) the address chain of the fragment c is behind the fragment b, and the virtual chain table tail and the chain table tail register are updated to the address of the fragment c.
The method and the device for processing the fragment message provided by the invention enable the fragment to be virtually enqueued before message inspection by creating a correct queue chain table and a virtual queue chain table and setting a head pointer, a tail pointer and a virtual tail pointer for each queue chain table; after the message is checked, the fragments are actually queued, so that the storage resource is saved, the message checking efficiency is improved, the scheduling speed after recombination is accelerated, the wrong message is quickly emptied from the cache, and the occupied time of invalid cache is reduced, so that the transmission speed of message data is improved, and the congestion during large flow is reduced; and each queue is independent, so that the diversity of queue scheduling is increased.
It will be understood by those skilled in the art that all or part of the steps of the above methods may be implemented by instructing the relevant hardware through a program, and the program may be stored in a computer readable storage medium, such as a read-only memory, a magnetic or optical disk, and the like. Alternatively, all or part of the steps of the foregoing embodiments may also be implemented by using one or more integrated circuits, and accordingly, each module/unit in the foregoing embodiments may be implemented in the form of hardware, and may also be implemented in the form of a software functional module. The present invention is not limited to any specific form of combination of hardware and software.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method for processing a fragment packet is characterized by comprising the following steps:
a correct queue chain table, an error queue chain table and an idle address chain table are created in advance and are respectively used for storing correct fragment addresses, wrong fragment addresses and idle fragment addresses; creating a correct chain head pointer, a correct chain tail pointer, a correct virtual tail pointer, an error chain head pointer, an error chain tail pointer and an error virtual tail pointer, wherein the correct chain head pointer and the error chain head pointer respectively point to head nodes of a correct queue chain table and an error queue chain table, and the correct chain tail pointer and the error chain tail pointer respectively point to tail nodes of the correct queue chain table and the error queue chain table;
when a new fragment arrives, allocating an address for the new fragment from the idle address linked list, storing the new fragment into the allocated address, respectively storing the address of the new fragment into tail nodes of a correct queue linked list and an error queue linked list, and respectively pointing a correct virtual tail pointer and an error virtual tail pointer to the address of the new fragment;
checking whether the new fragment is correct and whether the new fragment is a tail fragment;
if the new fragment is correct and the new fragment is a tail fragment, updating the correct chain tail pointer to the value of the correct virtual tail pointer and updating the wrong virtual tail pointer to the value of the wrong chain tail pointer;
and if the new fragment is wrong, updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer.
2. The method according to claim 1, wherein the checking whether the new fragment is correct and whether the new fragment is a tail fragment specifically includes:
checking whether the new fragment is a tail fragment and whether the fragment number of the new fragment is continuous with the fragment number of the last fragment;
if the new fragment is not the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, temporarily judging that the new fragment is correct and the new fragment is not the tail fragment, and continuing judging after the next new fragment arrives;
if the new fragment is not the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, checking whether the new fragment is the head fragment, and if the new fragment is the head fragment, judging that the new fragment of the message arrived before the head fragment is wrong; if the new fragment is not the first fragment, judging that the new fragment is wrong;
if the new fragment is the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, judging that the new fragment is correct and the new fragment is the tail fragment;
and if the new fragment is the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, judging that the new fragment is wrong.
3. The method according to claim 2, wherein said checking whether the new fragment is correct and whether the new fragment is a tail fragment further comprises:
when a new fragment is judged to be wrong, a new fragment which arrives before the new fragment and belongs to the same reassembly message as the wrong new fragment or a new fragment which arrives after the new fragment and belongs to the same reassembly message as the wrong new fragment is also judged to be wrong.
4. The method of claim 1, further comprising:
checking whether the head fragment of the correct queue linked list is scheduled;
if the head fragment of the correct queue linked list is scheduled, storing the address of the scheduled head fragment into the idle address linked list, and updating the correct link head pointer to the address of the next fragment pointed by the address of the scheduled head fragment.
5. The method of claim 1, further comprising:
checking whether the address of the head fragment of the error queue linked list is recycled;
if the address of the head fragment of the error queue linked list is recovered, storing the recovered address of the head fragment into the idle address linked list, and updating the error chain head pointer to the address of the next fragment pointed by the recovered address of the head fragment.
6. The device for processing the fragment message is characterized by comprising a linked list module, a distribution module and an inspection module, wherein:
the linked list module is used for creating a correct queue linked list, an error queue linked list and an idle address linked list in advance, and respectively storing a correct fragment address, an error fragment address and an idle fragment address; creating a correct chain head pointer, a correct chain tail pointer, a correct virtual tail pointer, an error chain head pointer, an error chain tail pointer and an error virtual tail pointer, wherein the correct chain head pointer and the error chain head pointer respectively point to the addresses of the first fragments of the correct queue chain table and the error queue chain table, and the correct chain tail pointer and the error chain tail pointer respectively point to the tail nodes of the correct queue chain table and the error queue chain table;
the distribution module is used for distributing addresses for the new fragments from the idle address linked list of the linked list module when the new fragments arrive, storing the new fragments into the distributed addresses, respectively storing the addresses of the new fragments into tail nodes of a correct queue linked list and an error queue linked list of the linked list module, respectively pointing a correct virtual tail pointer and an error virtual tail pointer to the addresses of the new fragments, and informing the checking module;
the checking module is used for receiving the notification of the distribution module and checking whether the new fragment is correct and whether the new fragment is a tail fragment; if the new fragment is correct and the new fragment is a tail fragment, updating the correct chain tail pointer to the value of the correct virtual tail pointer and updating the wrong virtual tail pointer to the value of the wrong chain tail pointer; and if the new fragment is wrong, updating the correct virtual tail pointer to the value of the correct chain tail pointer, and updating the wrong chain tail pointer to the value of the wrong virtual tail pointer.
7. The apparatus according to claim 6, wherein the checking module checks whether the new fragment is correct and whether the new fragment is a tail fragment, specifically comprising:
checking whether the new fragment is a tail fragment and whether the fragment number of the new fragment is continuous with the fragment number of the last fragment;
if the new fragment is not the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, temporarily judging that the new fragment is correct and the new fragment is not the tail fragment, and continuing judging after the next new fragment arrives;
if the new fragment is not the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, checking whether the new fragment is the head fragment, and if the new fragment is the head fragment, judging that the new fragment of the message arrived before the head fragment is wrong; if the new fragment is not the first fragment, judging that the new fragment is wrong;
if the new fragment is the tail fragment and the fragment number of the new fragment is continuous with the fragment number of the last fragment, judging that the new fragment is correct and the new fragment is the tail fragment;
and if the new fragment is the tail fragment and the fragment number of the new fragment is not continuous with the fragment number of the last fragment, judging that the new fragment is wrong.
8. The apparatus according to claim 7, wherein when the checking module determines that a new fragment is erroneous, a new fragment that arrives before the new fragment and belongs to the same reassembly packet as the erroneous new fragment or a new fragment that arrives after the new fragment and belongs to the same reassembly packet as the erroneous new fragment is also determined to be erroneous.
9. The apparatus of claim 6, wherein the inspection module is further configured to:
checking whether the head fragment of the correct queue linked list is scheduled;
if the head fragment of the correct queue linked list is scheduled, storing the address of the scheduled head fragment into the idle address linked list, and updating the correct link head pointer to the address of the next fragment pointed by the address of the scheduled head fragment.
10. The apparatus of claim 6, wherein the inspection module is further configured to:
checking whether the address of the head fragment of the error queue linked list is recycled;
if the address of the head fragment of the error queue linked list is recovered, storing the recovered address of the head fragment into the idle address linked list, and updating the error chain head pointer to the address of the next fragment pointed by the recovered address of the head fragment.
CN201710557080.4A 2017-07-10 2017-07-10 Method and device for processing fragment message Active CN109246036B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710557080.4A CN109246036B (en) 2017-07-10 2017-07-10 Method and device for processing fragment message

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710557080.4A CN109246036B (en) 2017-07-10 2017-07-10 Method and device for processing fragment message

Publications (2)

Publication Number Publication Date
CN109246036A CN109246036A (en) 2019-01-18
CN109246036B true CN109246036B (en) 2021-02-09

Family

ID=65083465

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710557080.4A Active CN109246036B (en) 2017-07-10 2017-07-10 Method and device for processing fragment message

Country Status (1)

Country Link
CN (1) CN109246036B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111352781B (en) * 2020-02-28 2023-07-04 飞腾信息技术有限公司 Message automatic comparison correctness checking method and device for retransmission component module level verification
CN112433884B (en) * 2020-11-12 2022-10-21 苏州长风航空电子有限公司 Double-backup cross storage method for preventing power failure data damage during writing
CN112600764B (en) * 2020-12-07 2022-04-15 苏州盛科通信股份有限公司 Scheduling method, device and storage medium of cut-through forwarding mode
CN113259715A (en) * 2021-05-07 2021-08-13 广州小鹏汽车科技有限公司 Method and device for processing multi-channel video data, electronic equipment and medium
CN115190089B (en) * 2022-05-26 2024-03-22 中科驭数(北京)科技有限公司 Message storage method, device, equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6910092B2 (en) * 2001-12-10 2005-06-21 International Business Machines Corporation Chip to chip interface for interconnecting chips
CN101594201A (en) * 2009-05-20 2009-12-02 清华大学 The method of integrally filtering error data in linked queue management structure
CN101676906A (en) * 2008-09-18 2010-03-24 中兴通讯股份有限公司 Method of managing memory database space by using bitmap

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100567320B1 (en) * 2003-11-28 2006-04-04 한국전자통신연구원 Flow generation method for Internet traffic measurement
CN100531147C (en) * 2007-03-07 2009-08-19 华为技术有限公司 Multi-link binding protocol message zone receiving method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6910092B2 (en) * 2001-12-10 2005-06-21 International Business Machines Corporation Chip to chip interface for interconnecting chips
CN101676906A (en) * 2008-09-18 2010-03-24 中兴通讯股份有限公司 Method of managing memory database space by using bitmap
CN101594201A (en) * 2009-05-20 2009-12-02 清华大学 The method of integrally filtering error data in linked queue management structure

Also Published As

Publication number Publication date
CN109246036A (en) 2019-01-18

Similar Documents

Publication Publication Date Title
CN109246036B (en) Method and device for processing fragment message
US11916781B2 (en) System and method for facilitating efficient utilization of an output buffer in a network interface controller (NIC)
US7843919B2 (en) Ethernet virtualization using a network packet alteration
US6937606B2 (en) Data structures for efficient processing of IP fragmentation and reassembly
CN107948094B (en) Device and method for conflict-free enqueue processing of high-speed data frames
US6957281B2 (en) Ingress processing optimization via traffic classification and grouping
EP3573297B1 (en) Packet processing method and apparatus
JP4779955B2 (en) Packet processing apparatus and packet processing method
WO2012162949A1 (en) Packet reassembly and resequence method, apparatus and system
US10601713B1 (en) Methods and network device for performing cut-through
CN111711566B (en) Receiving end disorder rearrangement method under multipath routing scene
US9853920B2 (en) Systems and methods for performing packet reorder processing
WO2010022629A1 (en) Method, equipment and system for segment data recombining on multilink protocol
US6026093A (en) Mechanism for dispatching data units via a telecommunications network
US9596193B2 (en) Messaging with flexible transmit ordering
US20050152355A1 (en) Reducing transmission time for data packets controlled by a link layer protocol comprising a fragmenting/defragmenting capability
US20120106567A1 (en) Mlppp occupancy based round robin
US8990422B1 (en) TCP segmentation offload (TSO) using a hybrid approach of manipulating memory pointers and actual packet data
US7480308B1 (en) Distributing packets and packets fragments possibly received out of sequence into an expandable set of queues of particular use in packet resequencing and reassembly
US7295564B2 (en) Virtual output queue (VoQ) management method and apparatus
US20040218592A1 (en) Method and apparatus for fast contention-free, buffer management in a multi-lane communication system
US10938739B1 (en) Efficient buffer utilization for network data units
US7822051B1 (en) Method and system for transmitting packets
WO2018171115A1 (en) Quality of service assurance method for fragment and field-programmable gate array
US20060187963A1 (en) Method for sharing single data buffer by several packets

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant