Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of packet message processing method, Apparatus and system, to overcome the existing lower problem of fragment message efficient in processing procedure.
According to one embodiment of the invention, a kind of packet message processing method is provided, comprise the steps:
Message to receiving is discerned;
The first burst of the message that receives is deposited in the first fragment cache memory, the follow-up burst of the message that receives is deposited in the follow-up fragment cache memory;
At regular intervals first fragment cache memory and follow-up fragment cache memory are scanned respectively;
All bursts that will belong to same complete message according to scanning result are distributed in the fragment message formation in order.
According to still another embodiment of the invention, a kind of fragment message processing unit is provided, comprises:
Identification module is used to discern the message of receiving, the first burst of the message of receiving and the follow-up burst of receiving of message are deposited in respectively in first fragment cache memory and the follow-up fragment cache memory;
Scan module is connected with identification module, is used at regular intervals said first fragment cache memory and the follow-up fragment cache memory of identification module being scanned respectively;
Sending module is used for all bursts that scanning result according to scan module will belong to same complete message and is distributed to the fragment message formation in order.
According to still another embodiment of the invention, a kind of fragment message treatment system is provided, comprises: recognition unit, first fragment cache memory, follow-up fragment cache memory, common message queue buffer memory and fragment message formation buffer memory;
Said recognition unit; Be used for from the message common message of identification and the fragment message that receive; And common message is distributed in the said common message queue buffer memory, first burst is saved in the said first fragment cache memory, follow-up burst is saved in the said follow-up fragment cache memory;
Said first fragment cache memory; Be used for the first burst that first fragment cache memory inside deposits in is carried out timing scan; First burst and all follow-up bursts related with said first burst are distributed in the said fragment message formation buffer memory in order, and the corresponding follow-up burst of the first burst that the aging first burst of needs and needs are worn out wears out;
Said follow-up fragment cache memory is used for the follow-up burst that follow-up fragment cache memory inside deposits in is carried out timing scan, to the aging follow-up burst of needs and need the corresponding first burst of aging follow-up burst to wear out;
Said common message queue buffer memory is used to preserve common message;
Said fragment message formation buffer memory is used to preserve fragment message.
According to description to technique scheme; The embodiment of the invention has following advantage: through first burst in the fragment message and follow-up burst are carried out the processing of buffer memory and timing scan respectively; First burst and all corresponding follow-up bursts of said complete message are distributed in the fragment message formation in order; Guarantee the order output of fragment message, alleviate the burden that packet out-ordering causes to system, improve system effectiveness.
Embodiment
To combine the accompanying drawing in the embodiment of the invention below, the technical scheme in the embodiment of the invention is carried out clear, intactly description, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills are not making the every other embodiment that is obtained under the creative work prerequisite, all belong to the scope of the present invention's protection.
Fig. 1 is the sketch map of a kind of packet message processing method of providing of embodiments of the invention one, and this method can comprise the steps:
Step S101 discerns the message that receives, and deposits the first burst of the message that receives in first fragment cache memory, and the follow-up burst of the message that receives is deposited in the follow-up fragment cache memory.
This step specifically comprises: the message to receiving is discerned, if what receive is common message, it is distributed in the common message queue; If what receive is the first burst in the fragment message, it is saved in the first fragment cache memory (cache, cache memory); If what receive is the follow-up burst in the fragment message, it is saved in the follow-up fragment cache memory.The process that the message that receives is discerned can comprise: according to the id information of fragment message and burst mark identification message whether be fragment message and fragment message whether headed by burst.
The process that first burst is saved in first fragment cache memory also can comprise: follow-up fragment cache memory is scanned; Search whether exist in the follow-up fragment cache memory should head burst corresponding subsequent burst; If the corresponding follow-up burst burst first with it that finds carried out bi-directional association.
The process that follow-up burst is saved in follow-up fragment cache memory also can comprise: first fragment cache memory is scanned; Search and whether have the corresponding first burst of this follow-up burst in the first fragment cache memory; If this follow-up burst and the corresponding first burst of finding are carried out bi-directional association.
So-called follow-up burst and first burst are carried out the just first burst of bi-directional association utilize the corresponding follow-up burst of a pointed, thereby indicate corresponding follow-up burst and first burst is to belong to same complete message.
The process of preserving first burst and follow-up burst can also comprise: get in the process of buffer memory at first burst and follow-up burst, write down the time that first burst and follow-up burst deposit buffer memory in respectively.The time that the record fragment message gets into buffer memory is whether to reach the aging time limit for the ease of inspection fragment message when the follow up scan.The so-called aging time limit is the maximum duration that message can stop in buffer memory, if the time that message stops in buffer memory surpasses the aging time limit, need wear out to this message.
Step S102 scans respectively first fragment cache memory and follow-up fragment cache memory at regular intervals.
Every process that at regular intervals first fragment cache memory and follow-up fragment cache memory is scanned respectively is called timing scan.Scanning for first fragment cache memory and follow-up fragment cache memory can be synchronous, also can be asynchronous.In the process that first fragment cache memory and follow-up fragment cache memory are scanned respectively, can whether all receive according to first burst with all bursts that the follow-up burst inspection of its bi-directional association belongs to same complete message.
The process that first fragment cache memory is scanned can specifically comprise: scan each the first burst in the first fragment cache memory successively; The reception condition of the follow-up burst of the first burst that inspection scans; Judge whether all bursts that belong to same complete message are all received.
Utilize the timing scan module to scan each node in the first fragment cache memory successively,, continue the scanning next node if this node does not have any message; If the in store first burst of this node checks whether all follow-up bursts of first burst are all received.The reception condition of the follow-up burst of the first burst that the situation inspection of the first burst that can scan through inspection and its follow-up burst bi-directional association scans.Check that the process whether all follow-up bursts of first burst have all been received specifically can comprise: the length field according to message IP stem is judged; Can reach the length that writes down in the length field if all follow-up bursts of first burst and its bi-directional association combine, explain that all follow-up bursts of first burst are all received; Otherwise all follow-up bursts that first burst is described are not all received.
Owing to possibly have overlapping or space between each burst of fragment message, whether allow burst to exist overlapping or the space can be provided with flexibly.If it is overlapping not allow fragment message to occur, in a single day it is overlapping in scanning, to find that message fragment exists, and other burst that can belong to same complete message to overlapping burst and with it wears out; The fragment message in space is arranged for not allowing the space, can it be handled, wait for that it reaches the aging time limit and wears out.Wearing out here also can be adopted the foregoing aging method that aging mark is set.
If it is overlapping that system allows fragment message to exist, can check the reception condition of all bursts that belong to same complete message and judge exist between burst overlapping whether in allowed limits.The reception condition of the follow-up burst of the first burst that scans according to inspection is done as judging: if between burst overlap in the allowed band and all follow-up bursts of this first burst that scans are all received, judge that then all bursts that belong to same complete message all receive.
If system allows fragment message to have the space, can check the reception condition of all bursts that belong to same complete message and judge between burst the space whether in allowed limits and all bursts that except the gap, belong to same complete message whether all receive.The reception condition of the follow-up burst of the first burst that scans according to inspection is done as judging: if the space between burst in allowed limits and all follow-up bursts of the first burst that this scans except the gap all receive, judge that then all bursts that belong to same complete message all receive.
The process that first fragment cache memory is scanned also can comprise: whether the first burst that inspection scans has reached the aging time limit, if then aging this first burst reaches all bursts that belong to same complete message with it.
The process that first burst and corresponding follow-up burst thereof are worn out can comprise: if the first burst of scanning discovery reaches the aging time limit, headed by burst aging mark is set; If the first burst of scanning discovery has been provided with aging mark, then wearing out should head burst and its corresponding all follow-up burst.
Process to the initiation of follow-up fragment cache memory scanning comprises: scan each the follow-up burst in the follow-up fragment cache memory successively; According to the situation of the follow-up burst that scans, the follow-up burst that reaches the aging time limit is reached all bursts that belong to same complete message with it wear out.Here can utilize the timing scan module to scan each node in the follow-up fragment cache memory successively,, continue the scanning next node if this node does not have any message; If the in store follow-up burst of this node; Check whether this follow-up burst has reached the aging time limit; If follow-up burst has reached the aging time limit; Whether inspection has in first fragment cache memory and the corresponding first burst of this follow-up burst, if corresponding first burst is arranged, then aging this follow-up burst reaches all bursts that belong to same complete message with it; If there is not corresponding first burst, then only aging this follow-up burst.Aging follow-up burst and the process that belongs to all bursts of same complete message with it can comprise: with the corresponding first burst of said follow-up burst in aging mark is set, when carrying out first fragment cache memory scanning, wear out with first burst.
The described aging time limit is the time restriction of setting for each burst; As previously mentioned, owing to can write down the time of first burst and follow-up burst entering buffer memory, according to the time of record; In case a burst is kept at the time overtime restriction in the buffer memory, just need wear out to this burst.This process specifically comprises: deposit the time that the first burst of record in the process of first fragment cache memory deposits first fragment cache memory at first burst; Deposit the time that the follow-up burst of record in the process of follow-up fragment cache memory deposits fragment cache memory at follow-up burst; Whether the time that deposits first fragment cache memory according to first burst in surpasses the certain hour restriction, judges whether first burst reaches the aging time limit; Whether the time that deposits follow-up fragment cache memory according to follow-up burst in surpasses the certain hour restriction, judges whether follow-up burst reaches the aging time limit.
Step S103, all bursts that will belong to same complete message according to scanning result are distributed in the fragment message formation in order.All bursts that will belong to same complete message described here are distributed in order in the fragment message formation and comprise: said all bursts are arranged and are distributed in the fragment message formation according to the sequencing between burst.According to scanning result, all receive if belong to all bursts of same complete message, first burst and all corresponding follow-up bursts are distributed in the fragment message formation in order.First burst and all corresponding follow-up bursts are distributed in order in the fragment message formation and can comprise: all receive if find all follow-up bursts of certain first burst in the scanning, headed by burst the transmission mark is set; If find in the scanning that certain first burst has been provided with the transmission mark, should head burst and the formation of corresponding subsequent burst adding fragment message thereof.
Said method is through depositing first burst in different buffer memorys respectively with follow-up burst, and buffer memory is carried out timing scan, thereby realizes the arrangement in order in the fragment message formation of first burst and follow-up burst.
Further, present embodiment can also comprise step S104, and common message queue and fragment message formation are dispatched, and merges to form a row message queue.
This step forms a row message queue with common message queue and fragment message queue scheduling, can transmit easily and handle.
Present embodiment is through carrying out the processing of buffer memory and timing scan respectively to first burst in the fragment message and follow-up burst; First burst and all corresponding follow-up bursts of said complete message are distributed in the fragment message formation in order; Guarantee the order output of fragment message, alleviate the out of order burden that causes to system of fragment message.In addition, also there is following advantage in present embodiment: can control the forwarding of first burst through the situation of follow-up burst, effectively take precautions against fragment message and attack; The in time aging burst that need wear out; Need not to set up and inquiry burst conversational list, improve system effectiveness; Through first fragment cache memory and follow-up fragment cache memory storage fragment message is provided, avoid fragment message to take the original buffer memory of system, save system resource.
It will be appreciated by those skilled in the art that; All or part of flow process among the said method embodiment; Can instruct related hardware to accomplish through computer program; Described program can be stored in the computer read/write memory medium, and this program can comprise the flow process like the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only storage memory body (Read-Only Memory, ROM) or at random store memory body (Random Access Memory, RAM) etc.
Fig. 2 is the sketch map of a kind of fragment message processing unit of providing of embodiments of the invention two, and this device can comprise:
Identification module 21 is used to discern the message of receiving, the first burst of the message of receiving and the follow-up burst of receiving of message are deposited in respectively in first fragment cache memory and the follow-up fragment cache memory;
Scan module 22 is connected with identification module 21, is used at regular intervals said first fragment cache memory and the follow-up fragment cache memory of identification module being scanned respectively;
Sending module 23 is used for all bursts that scanning result according to scan module 22 will belong to same complete message and is distributed to the fragment message formation in order.
The device of this embodiment through first burst and follow-up burst are discerned, buffer memory and timing scan handle, and realized the order output of fragment message, alleviates the burden that packet out-ordering causes to system.
Fig. 3 is the sketch map of another fragment message processing unit of providing of embodiments of the invention three, and this device is the basis with embodiment two, comprising: identification module 31, scan module 32 and sending module 33 comprise aging module 34 in addition;
Said aging module 34 is used for according to the scanning result of scan module 32 the aging burst of needs being worn out.
Present embodiment need to prevent aging burst long-term existence occupying system resources in buffer memory through the aging burst of needs is carried out burin-in process.
Fig. 4 is the sketch map of another fragment message processing unit of providing of embodiments of the invention four; This device is the basis with embodiment three; Comprise: identification module 41, scan module 42, sending module 43 and aging module 44, scan module 42 wherein specifically can comprise:
Regularly submodule 421 is used for notifying at regular intervals first burst scanning submodule 422 and follow-up burst scanning submodule 423 respectively first fragment cache memory and follow-up fragment cache memory to be scanned;
First burst scanning submodule 422; Be used for scanning successively each first burst of first fragment cache memory; The reception condition of the follow-up burst of the first burst that inspection scans judges that whether all bursts that belong to same complete message are all received, send to said sending module 43 with the result;
Follow-up burst scans submodule 423, is used for scanning successively each follow-up burst of follow-up fragment cache memory, judges that whether the follow-up burst that scans reaches the aging time limit, sends to said aging module 44 with the result.
Submodule in the present embodiment in the scan module can carry out timing scan to first fragment cache memory and follow-up fragment cache memory respectively, and notifies sending module and aging module in time to handle corresponding message, and the realization fragment message is exported in proper order and worn out need aging burst.
It will be understood by those skilled in the art that the module among above-mentioned three device embodiment can be that hardware also can be software, can also or be merged into a module mutually with several modules fractionations and reach same function.
Fig. 5 is the sketch map of a kind of fragment message treatment system of providing of embodiments of the invention five, and this system can comprise: recognition unit 501, first fragment cache memory 502, follow-up fragment cache memory 503, common message queue buffer memory 504 and fragment message formation buffer memory 505;
Said recognition unit 501; Be used for from the message common message of identification and the fragment message that receive; And common message is distributed in the said common message queue buffer memory 504, first burst is saved in the said first fragment cache memory 502, follow-up burst is saved in the said follow-up fragment cache memory 503;
Said first fragment cache memory 502; Be used for the first burst that its inside deposits in is carried out timing scan; First burst and all follow-up bursts related with it are distributed in the said fragment message formation buffer memory 505 in order, and first burst and the corresponding follow-up burst thereof aging to needs wear out;
Said follow-up fragment cache memory 503 is used for the follow-up burst that its inside deposits in is carried out timing scan, and follow-up burst and the corresponding first burst thereof aging to needs wear out;
Said common message queue buffer memory 504 is used to preserve common message;
Said fragment message formation buffer memory 505 is used to preserve fragment message.
This system carries out buffer memory and timing scan to fragment message, realizes the order output of fragment message, and in time wearing out needs aging burst, and through providing first fragment cache memory and follow-up fragment cache memory to avoid fragment message taking the original buffer memory of system.
Fig. 6 is the sketch map of another fragment message treatment system of providing of embodiments of the invention six; It is the same with embodiment four; Comprise: recognition unit 601, first fragment cache memory 602, follow-up fragment cache memory 603, common message queue buffer memory 604 and fragment message formation buffer memory 605 comprise: scheduling unit 606 in addition;
Said scheduling unit 606 is used for the common message of common message queue buffer memory 604 and the fragment message in the fragment message formation buffer memory 605 are dispatched, and generates a row message queue.
Present embodiment is exported a row message queue through common message queue and fragment message formation are dispatched, for the forwarding or the processing of subsequent packet are provided convenience.
In sum; There is following advantage in the embodiment of the invention: through first burst in the fragment message and follow-up burst are carried out the processing of buffer memory and timing scan respectively; First burst and all corresponding follow-up bursts of said complete message are distributed in the fragment message formation in order; Guarantee the order output of fragment message, alleviate the burden that packet out-ordering causes to system; Need not to set up and inquiry burst conversational list, improve system effectiveness; Can control the forwarding of first burst through the situation of follow-up burst, effectively take precautions against fragment message and attack; The in time aging burst that need wear out; Through first fragment cache memory and follow-up fragment cache memory storage fragment message is provided, avoid fragment message to take the original buffer memory of system, save system resource.
The above is merely several embodiments of the present invention, and those skilled in the art can carry out various changes or modification to the present invention according to the disclosed content of application documents and not break away from the spirit and scope of the present invention.