Summary of the invention
The embodiment of the invention provides a kind of method and apparatus of conversation aging, can automatically identify long the connection, and the long ageing time that connects is set, and improves operating efficiency.
On the one hand, the embodiment of the invention provides a kind of method of conversation aging, comprising:
In conversational list, add aging sign through the session after wearing out for the first time;
The second time is carried out in the session of carrying described aging sign wears out;
Obtain the characterisitic parameter of data flow in the described second time in the ageing process, and compare with described preset property parameter of carrying the session of aging sign;
If the characterisitic parameter of described data flow is identical with the preset property parameter of described session, then obtain the type of described data flow;
When the type of described data flow is non-connecting during message, determine that described session is long connection session, the ageing time of removing aging sign and described long connection session is set to preset value.
On the other hand, the embodiment of the invention provides a kind of device of conversation aging, comprising:
Add module, be used for adding aging sign at conversational list through the session after wearing out for the first time;
Aging module is used for that the second time is carried out in the session of carrying described aging sign and wears out;
Comparing module, be used for described second time ageing process obtain the characterisitic parameter of data flow, and compare with described preset property parameter of carrying the session of aging sign;
Acquisition module when the characterisitic parameter that is used for comparison result when described comparing module and is data flow is identical with the preset property parameter of session, obtains the type of described data flow;
First processing module, be used for when type that described acquisition module obtains data flow be non-connecting during message, determine that described session is long connection session, the ageing time of removing aging sign and described long connection session is set to preset value.
Compared with prior art, the embodiment of the invention has the following advantages:
The method that provides by the embodiment of the invention, in the conversational list of the aging session that finishes for the first time, add aging sign, the long second time of time is carried out in the session of carrying described aging sign wears out, obtain the characterisitic parameter of data flow in the ageing process in the second time, and compare with the preset property parameter of the session of carrying aging sign, if the characterisitic parameter of data flow is identical with the preset property parameter of described session, then obtain the type of this data flow, when the type of data flow is non-connecting during message, determine that this session is long connection session, the ageing time of removing aging sign so and growing connection session is set to preset value.The present invention program connects by automatically identification is long, and ageing time is set, and is connected and the scheme of manual configuration length connect hours is compared with User Recognition in the prior art is long, has improved operating efficiency.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the invention, the technical scheme in the embodiment of the invention is clearly and completely described, 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 belong to the scope of protection of the invention not making the every other embodiment that is obtained under the creative work prerequisite.
The embodiment of the invention provides a kind of method and apparatus of conversation aging, can identify long connection session preferably.
The method and apparatus of the conversation aging that the embodiment of the invention is provided below in conjunction with the drawings and specific embodiments is elaborated.
According to existing technology, for fear of being reclaimed by resource,, be the very long ageing time of this long connection session setting again by manually identifying long connection session earlier through the long connection session after for the first time aging, guarantee that with this long connection session finishes business and transmit.The method that goes out long connection session by manual identified is complicated like this, so the method that provides of the embodiment of the invention adds aging sign and carry out second time and wear out in through the session after aging for the first time, and does not directly reclaim resource.The method of a kind of conversation aging that the embodiment of the invention provides as shown in Figure 1, comprising:
Step 101, the first time wear out when finishing, and add aging the sign in the conversational list of session.
Because the capacity limit of internal memory, wherein Yun Hang number of sessions has certain upper limit, and session is too much, take resource can cause setting up new session after for a long time, is unfavorable for the transmission of data service.Therefore concept of ageing has been proposed, aging is to reclaim a kind of mechanism that session takies resource: when session is set up, for an ageing time is set in this session, when the starting point of this ageing time is finished for this session foundation, the life period of this session of scanning that system is real-time, when the life period of this session surpassed the ageing time of setting, system reclaimed the resource that this session takies.
The method that the embodiment of the invention provides, by the real-time life period of obtaining session, and with the first time that is provided with aging ageing time make comparisons, it is aging to know whether this session is carrying out one-level.When the life period of session is not less than aging for the first time ageing time, judge aging for the first time the end, in the conversational list of session, add aging sign this moment, identify this session with this and enter aging for the second time.
Step 102, that the second time is carried out in the session of carrying described aging sign is aging, and this aging for the second time time is greater than the aging for the first time time.
Prior art is carried out in the aging for the first time process session, and after data traffic transmission was finished in the common session connection of normal operation, though do not surpass ageing time, the resource that takies also can be recovered; And long connection session is reclaimed by resource after carrying out wearing out the first time according to the ageing time of common session, can the traffic affecting normal transmission.Therefore the method that provides of the embodiment of the invention, during to aging end for the first time, the session of not finishing data traffic transmission is not carried out resource and is reclaimed, and adds aging sign, and it is aging long second time to carry out ageing time.The ageing time value can be set up on their own by the user for the second time.
Step 103, obtain the characterisitic parameter of data flow in the ageing process in the described second time, and compare with described preset property parameter of carrying the session of aging sign.Generally speaking, a data flow has the preset property parameter of difference and other data flow, as five-tuple, and also has the characterisitic parameter that is different from other sessions in the conversational list of session.A data flow is made up of a plurality of messages, and these messages have identical characteristic (as five-tuple); When needs send to a certain receiving terminal with this data flow, need set up session according to these identical characteristics, therefore when if the characterisitic parameter of the preset property parameter of session and data flow is identical, illustrate that this session and data flow mate, and the business of this session transmissions is not finished as yet.
Step 104, if the characterisitic parameter of described data flow is identical with the preset property parameter of described session, then obtain the type of described data flow.
Step 105, when the type of described data flow is non-connecting during message, determine that described session is long connection session, the ageing time of removing aging sign and described long connection session is set to preset value.Concrete, after the type identification by data flow goes out long connection session, remove aging sign, the ageing time of long connection session is set to reasonably ageing time, proceeds aging for the third time.After this aging for the third time ageing time finishes,, in the conversational list of this session, add aging sign, proceed to wear out if session remains unfulfilled professional transmission.Reclaimed by resource in the session that do not hit by data flow in the ageing time second time.This is the value of aging ageing time for the third time, can determine according to the analysis data to long connection session of preserving, and for example when the data traffic of long connection session is A, the ageing time value is made as B.
By above-mentioned steps, it is aging that second time carried out in the session of carrying aging sign, and go out long the connection by obtaining the type identification of hitting the data flow of session in the ageing time in the second time, do not need the long connection of manual identified thus.
May be before not finishing professional transmission for common session, because causing to connect, abnormal cause interrupts, TCP (Transmission Control Protocol just, transmission control protocol) connects not by the termination message FIN or the message RST that resets, confirmation message ACK just disconnects and connecting, and the transmission of the business of this session can't be finished like this; For long connection session,, can't finish professional transmission in the ageing time in the first time because aging for the first time ageing time is shorter.And the session of above-mentioned two kinds of situations all needs to be retained, and realizes normal professional transmission with this.In order to identify long connection session, realize normal professional transmission, the embodiment of the invention provides a kind of method of conversation aging, as shown in Figure 2, comprising:
Step 201, the first time wear out when finishing, and are that aging the sign added in session;
Wherein, by the real-time life period of obtaining session, and with the first time that is provided with aging ageing time make comparisons, it is aging to know whether this session is carrying out one-level.When the life period of session is not less than aging for the first time ageing time, judge aging for the first time the end, during to aging end for the first time, do not finish the session of data traffic transmission and do not carry out the resource recovery, in the conversational list of session, add aging sign this moment, identify this session with this and enter aging for the second time.
Step 202, the connection session that has aging sign is carried out second time wear out; This aging for the second time ageing time should satisfy the needs of long connection session, so aging for the second time ageing time setting is longer, can be 1 day.
Step 203, obtain the characterisitic parameter of data flow and compare with the preset property parameter in the conversational list of the session of carrying aging sign.Data flow has five-tuple unique identification (host-host protocol, source address, source port number, destination address and destination slogan), and this five-tuple unique identification can be thought the characterisitic parameter of data flow, when characterisitic parameter is identical, and execution in step 204.If in aging for the second time ageing time, never data flow is identical with the preset property parameter of session, and then the shared resource of this session is recovered.
Step 204, detect the type of this data flow; If this data flow is a TCP SYN message, execution in step 205; Otherwise, execution in step 206.
Step 205, the aging TCP that identifies and rebulid this session of removal connect.
Concrete, when the session of carrying aging sign was the common session of aborted, this session can only be identical with the message characterisitic parameter that belongs to TCP SYN type, because the not only professional transmission of the common session of aborted is interrupted, and session connection also is disconnected.TCP connection initialization procedure is called the transmission of three-way handshake (three-way handshake): A connection originating end and indicates that the tcp data bag that the SYN position is arranged to destination, is used for consultation parameter, and initialization connects; The B destination uses SYN/ACK to show the connection parameter of oneself and confirms the connection parameter of originating end; After the C originating end is received SYN/ACK, use ACK to confirm that destination connects parameter.This shows that the TCP that has only TCP SYN message just can rebulid the common session of this aborted connects.
Step 206, the aging sign of removal and ageing time are set to preset value.
Because after long connection session is worn out for the first time, professional transmission is connected with TCP still and exists, therefore, when data flow is not TCP SYN message, can think that the session of this aborted is long connection session, because the professional transmission time of long connection session is longer, so this preset value can be 1 day or longer time.
In carrying out aging for the second time process, can also detect the quantity of the session of carrying aging sign, has certain upper limit because carry the quantity of the session of aging sign, can cause Session Resources other normal discharge that influences in short supply when surpassing this upper limit, when the quantity of the session of carrying aging sign during greater than default threshold value, send warning information, and shorten aging for the second time ageing time, the session of aging sign is carried in accelerated ageing.
Can automatically identify long connection session by above-mentioned steps, and the common session that aborted TCP is connected rebulids the TCP connection.Can make the session of aborted continue to finish professional transmission thus.
After identifying long connection session by above-mentioned steps, can also analyze summary to the characteristic of long connection session, and will preserve and analyze data, for example can extract purpose IP address or source IP address or the agreement and the port information of long connection session, to the information of extracting analyze, statistics etc., drawing some characteristic informations thus, be that the TCP of X.X.X.X connects as destination address is that the long possibility that connects is very big.Above-mentioned characteristic information can be used for discerning better long connection session; Also can be used for optimizing aging for the second time mechanism, as the less session of long connection possibility of wearing out earlier.
When the ageing time that step 206 is mentioned in the foregoing description is set to preset value, can determine this preset value according to the analysis data of preserving (changing) as long connection traffic.Concrete, can change the situation of predicting long connection session according to long connection traffic, the dynamic thus aging ageing time value second time that changes long connection session.As shown in table 1, define a flow grade, a corresponding respectively range of flow and long connection session ageing time preset value.If present flow rate is very big, belong to flow grade A, illustrate that current long connection session quantity is more, its situation is better, and the longer the better for corresponding ageing time, and the ageing time preset value is a higher value; If belong to flow grade B, illustrate that long connection session quantity is general, corresponding ageing time preset value is arranged to medium value; And be in flow grade C, and then explanation length connection session negligible amounts, the ageing time preset value just is set to smaller value so.
Table 1
Flow grade |
Range of flow (unit: M/20m) |
Ageing time |
A |
N3-N4 |
X1 |
B |
N2-N3 |
X2 |
C |
N1-N2 |
X3 |
The method that the embodiment of the invention provides, the second time is carried out in the session of carrying aging sign wears out, when the preset property parameter of the data flow that receives is planted the preset property parameter of session that carrying aging sign when identical therewith, can identify the type of session according to the type (TCP SYN message or non-TCP SYN message) of this data flow, thereby handle accordingly.And after identifying long connection session, can also analyze and sum up and preserve the long characteristic that connects, thereby can better recognition length connect.
Be the method that realizes that the embodiment of the invention provides, the embodiment of the invention also provides a kind of device of conversation aging, as described in Figure 3, comprising:
Add module 301, when being used for aging for the first time the end, in the conversational list of session, add aging sign;
Aging module 302 is used for that the second time is carried out in the session of carrying described aging sign and wears out;
Comparing module 303, be used for described second time ageing process obtain the characterisitic parameter of data flow, and compare with described preset property parameter of carrying the session of aging sign;
Acquisition module 304 when the characterisitic parameter that is used for comparison result when described comparing module 303 and is data flow is identical with the preset property parameter of session, obtains the type of described data flow;
First processing module 305, be used for when type that described acquisition module 304 obtains data flow be non-connecting during message, determine that described session is long connection session, the ageing time of removing aging sign and described long connection session is set to preset value.
Said apparatus comprises:
Second processing module 306, the type that is used for obtaining data flow when described acquisition module determine that described session is the common connection session that aborted connects when connecting message, remove the aging sign of described session, rebulid the connection of described session.
Wherein, comparing module 303 comprises:
Obtain submodule 3031, be used to obtain the characterisitic parameter of described data flow;
Comparer module 3032 is used for described submodule 3031 characterisitic parameter that obtains and the session preset property parameter of carrying aging sign obtained compared.
Said apparatus also comprises:
Characteristic information acquisition module 307 is used to obtain the characteristic information of the long connection session after described first processing module 305 is handled;
Analysis module 308 is used to analyze and preserve the characteristic information that described characteristic information acquisition module 307 obtains.
Said apparatus also comprises:
Quantity detection module 309 is used to detect described quantity of carrying the session of aging sign;
Accelerated ageing module 310, the quantity that is used for detecting session that carrying aging sign when described quantity detection module 309 shorten aging for the second time ageing time during greater than threshold value.
Method and apparatus by the embodiment of the invention provides can identify long connection session dynamically, and can carry out signature analysis to long connection session, and long connection session can be better monitored and be managed in Information Statistics.The quantity of the session of aging sign is carried in control, reduces because the risk that session too much brings.
The present invention program connects by automatically identification is long, and ageing time is set, and is connected and the scheme of manual configuration length connect hours is compared with User Recognition in the prior art is long, has improved operating efficiency.
Through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by hardware, also can realize by the mode that software adds necessary general hardware platform.Based on such understanding, technical scheme of the present invention can embody with the form of software product, it (can be CD-ROM that this software product can be stored in a non-volatile memory medium, USB flash disk, portable hard drive etc.) in, comprise some instructions with so that computer equipment (can be personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
More than disclosed only be several specific embodiment of the present invention, still, the present invention is not limited thereto, any those skilled in the art can think variation all should fall into protection scope of the present invention.