The method and device that in a kind of DPI system, Data Concurrent reports
Technical field
The present invention relates to DPI (Deep Packet Inspection, deep-packet detection) technology neck
Territory, is specifically related to the method and device that in a kind of DPI system, Data Concurrent reports.
Background technology
DPI technology is a kind of flow detection based on application layer and control technology, when IP data
Bag, TCP (Transmission Control Protocol, transmission control protocol) or UDP (User
Datagram Protocol, UDP) data stream is by band based on DPI technology
During wide management system, this system is come OSI seven layers by the content of deep reading IP payload package
Application layer message in agreement is recombinated, thus obtains the content of whole application program, then
According to the management strategy of system definition, flow carried out shaping operation, and by multiple detection skill
Art, carries out data extraction, data traffic analysis, user behavior analysis and visitor to bag and stream information
Family customized information collection etc..
Be in similar with anti-virus software system of bandwidth management system based on DPI technology
In: the application type that can identify is necessary for known to system;With the BT (Bit known to user
Torrent, bit stream) as a example by, the protocol characteristic word of its Handshake is " BitTorrent
Protocol”.In order to ensure application type known to system identification, Anti-Virus backstage needs
One huge anti-virus signature database, bandwidth management system based on DPI technology also to be safeguarded
One application property data base.When flow is through bandwidth management system, and bandwidth management system will
Application message after unpacking and backstage property data base are compared to determine application type.
But, when there being new application to occur, the application property data base on backstage needs novel
Application possesses identification and control ability.Existing bandwidth management system based on DPI technology reports
During data, using the mode of " reported data successively ", it is inefficient that data send, and
Total duration that data send is longer, and then makes the hydraulic performance decline of bandwidth management system, server
Load bigger.
Summary of the invention
For defect present in prior art, present invention solves the technical problem that into: provide one
Planting the method and device that in DPI system, Data Concurrent reports, the present invention not only increases DPI
Report performance, it is achieved data efficient concurrently reports, and improves the performance of big data parsing,
Reduce the load of server.
For reaching object above, the side that in the DPI system that the present invention provides, Data Concurrent reports
Method, the method comprises the following steps:
A:DPI system start-up, initializes and reports reporting number of threads and reporting team of thread pool
Row length, forwards step B to;
B: report in thread pool all reports thread to enter waiting state, when reporting task
When adding Excelsior queue, idle in task distribution Excelsior thread pool report line by reporting
Journey, forwards step C to;
C: according to reporting the type of service of task, selects corresponding TCP file to connect descriptor
List, forwards step D to;
D: judge TCP file to connect in descriptor list and there is effective descriptor, select institute
State effective descriptor, forward step E to;
E: call send function from effective descriptor, carries out tcp data transmission;Look into
See return value value of send function: if value is the length sending packet, then TCP
Data are transmitted, and forward step B to and wait that other tasks trigger;If value is less than 0, then
Tcp data bust this, forwards step F to after adding 1 by transmission fail count count_fail,
If value is more than 0 and is less than the length sending packet, then tcp data transmission is not fully complete,
Forward step G to;
F: judge that count_fail, whether less than server number of units, if so, effectively retouches described
State after the conventional mark of symbol is set to down state-1 and forward step C to, otherwise forward step B to;
G: judge that value whether less than single DPI maximum transmitted byte number, the most then sends out
Send obstruction, transmission is blocked after counting count_block adds 1 and forward step H to, otherwise continue
Perform step E;
H: judge that count_block, whether less than positive integer N, if so, re-executes step E;
Step C is forwarded to after otherwise the conventional mark of described effective descriptor being set to blocked state 2.
On the basis of technique scheme, if TCP file connects descriptor row in step D
Table do not exists effective descriptor, then sends state according to history, select suitable descriptor,
And be set to its conventional mark after 1 preserve to corresponding TCP file connection descriptor list,
Re-execute step C.
On the basis of technique scheme, described in step D, send state according to history,
Preserve to correspondence after selecting suitable descriptor and its conventional mark being set to upstate 1
The idiographic flow that TCP file connects in descriptor list is:
D01: in definition DPI system, the ip of server is x, and the port y used by server is
Ipxy, y select according to the type of service of reporting service, every kind of corresponding different clothes of type of service
Business device port, each ipxy unique correspondence one respectively records what front 2 report cycles sent
Total duration ipxy.duration [2], each report cycle is 5min;Ipxy.duration [0] is corresponding
In first 10 minutes report cycles of current time, TCP sends shared total duration,
In the corresponding first 5 minutes report cycles of current time of ipxy.duration [1], TCP sends shared total
Duration;The initial value of ipxy.duration [0] and ipxy.duration [1] is 0;
D02: respectively each ipxy carried in current reporting service is created TCP and connect,
Socket is stored in the descriptor that each ipxy connects;
D03: calculating the transmission scoring ipxyscore of each ipxy, computing formula is:
Ipxyscore=ipxy.duration [0] α+ipxy.duration [1] β;Alpha+beta in above-mentioned formula
=1;
D04: judge that all of ipxyscore is the most identical, if so, selects ipxy.duration [1]
The server ip of minima, otherwise selects minima ipxyscore_min in all of ipxyscore
Server ip;
D05: determine that the server ipx and port y of selection are this destination address sent,
The descriptor that the ipxy of selection connects is set to 1, at the beginning of the descriptor that other ipxy connect is set to
After beginning state 0, preserve to corresponding TCP file connection descriptor list.
On the basis of technique scheme, after step E carries out tcp data transmission, need
Ipxy.duration [0] and ipxy.duration [1] is updated according to the report cycle of transmission.
On the basis of technique scheme, D selects the concrete stream of described effective descriptor
Cheng Wei: judge that TCP file connects in descriptor list whether to exist and conventional be masked as 1 retouch
State symbol:
If so, select TCP file connect in descriptor first conventional be masked as 1 description
Symbol;Otherwise judge whether the connection descriptor list of TCP file exists to commonly use to be masked as 0
Descriptor:
If so, select TCP file connect in descriptor first conventional be masked as 0 description
Its conventional mark is also set to 1 by symbol, forwards step E to;Otherwise judge that TCP file connects to retouch
State whether symbol list exists and commonly use the descriptor being masked as 2:
If so, select TCP file connect in descriptor first conventional be masked as 2 description
Its conventional mark is also set to 1 by symbol, forwards step E to;Otherwise determine that TCP file connects to retouch
State in symbol list and there is not effective descriptor.
On the basis of technique scheme, step B determines and reports task to add Excelsior
The flow process of queue is: judges that whether the queue that reports reporting thread is empty, does not goes up
Report task joins and reports queue, now continues executing with step B, otherwise reports task to add
To reporting queue.
On the basis of technique scheme, judge described in step D that TCP file connects and retouch
State and symbol list exists the flow process of effective descriptor be: judge TCP file connection descriptor
Whether list is empty and TCP file connects the conventional of descriptor list All Files descriptor
Mark is not the most 1, the most then do not exist in TCP file connection descriptor list and effectively retouch
Stating symbol, otherwise there is effective descriptor in connecting descriptor list in TCP file.
The device that in the DPI system based on said method that the present invention provides, Data Concurrent reports,
This device includes DPI system initialization module, reports task allocating module, descriptor list choosing
Select module, effective descriptor determination module, tcp data transport module, fail count judgement mould
Block, obstruction determination module and obstruction counting determination module;
DPI system initialization module is used for: control DPI system start-up, initializes and reports thread
Reporting number of threads and reporting queue length of pond, reports to reporting task allocating module to send and appoints
Business distribution signal;
Report task allocating module for: receive report task distribution signal after, control report line
The all of Cheng Chizhong report thread to enter waiting state, add Excelsior queue when reporting task
Time, idle in task distribution Excelsior thread pool report thread, to descriptor list by reporting
Select module to send descriptor list and select signal;
Descriptor list selection module is used for: after receiving descriptor list selection signal, according to upper
The type of service of report task, selects corresponding TCP file to connect descriptor list, to effectively
Descriptor determination module sends effective descriptor and judges signal;
Effectively descriptor determination module is used for: after receiving effective descriptor judgement signal, it is judged that
TCP file connects in descriptor list and there is effective descriptor, if so, to tcp data
Transport module sends tcp data transmission signal;Otherwise send state according to history, select to close
Its conventional mark is also set to after 1 the TCP file connection preserved to corresponding by suitable descriptor
In descriptor list, again send descriptor list to descriptor list selection module and select letter
Number;
Tcp data transport module is used for: after receiving tcp data transmission signal, from effectively
Descriptor calls send function, carries out tcp data transmission;Check the return of send function
Value value: if value is the length sending packet, then tcp data is transmitted, to
Reporting task allocating module to send reports task to distribute signal;If value is less than 0, then TCP
Data transmission fails, judges mould to fail count after adding 1 by transmission fail count count_fail
Block sends fail count and judges signal, if value more than 0 and is less than the length sending packet,
Then tcp data transmission is not fully complete, and sends obstruction judgement signal to blocking determination module;
Fail count determination module is used for: judge whether count_fail is less than server number of units,
If so, the conventional mark of described effective descriptor is set to after down state-1 to descriptor
List selection module sends descriptor list and selects signal, otherwise to reporting task allocating module to send out
Serve report task distribution signal;
Block determination module to be used for: after receiving obstruction judgement signal, it is judged that whether value is less than
Single DPI maximum transmitted byte number, the most then send obstruction, and transmission is blocked counting
Count_block sends obstruction counting judgement signal to obstruction counting determination module after adding 1, no
Then continue to send tcp data transmission signal to tcp data transport module;
Block counting determination module to be used for: judge whether count_block is less than positive integer N,
The most again tcp data transmission signal is sent to tcp data transport module;Otherwise by institute
State after the conventional mark of effective descriptor is set to blocked state 2 and select mould to descriptor list
Block sends descriptor list and selects signal.
Compared with prior art, it is an advantage of the current invention that:
With the mode of employing " reported data successively " in prior art, present invention incorporates DPI
Process big data, multiple services demand, it is provided that one Data Concurrent in DPI system reports
Method and device.The method employing multi-service classification reports, multi-thread concurrent reports, file
Descriptor transmission state mechanism and balanced multi-server load design, not only increase DPI
Report performance, it is achieved data efficient concurrently reports, and improves the performance of big data parsing,
Reduce the load of server.
Accompanying drawing explanation
Fig. 1 is the flow process of the method that Data Concurrent reports in the DPI system in the embodiment of the present invention
Figure;
Fig. 2 is the signal of the device that Data Concurrent reports in the DPI system in the embodiment of the present invention
Flow to schematic diagram.
Detailed description of the invention
Below in conjunction with drawings and Examples, the present invention is described in further detail.
Side shown in Figure 1, that in the DPI system in the embodiment of the present invention, Data Concurrent reports
Method, comprises the following steps:
S101:DPI system boot, in system, each initiation of services, completes according to business configuration
(completing the Policy receipt storage work such as reporting policy, business entrance etc. is pending for initial work
Data mode);Initialize according to configuration (business reports scale and physical equipment disposal ability)
Report reporting number of threads and reporting queue length etc. of thread pool, forward S102 to.
S102: report in thread pool all reports thread to enter waiting state, it is judged that report line
Whether the queue that reports of journey is empty, does not the most report task to add Excelsior queue, continues
Continuous execution S102, otherwise reports task to add Excelsior queue, and task will be reported to distribute extremely
Report in thread pool and idle to report thread, forward S103 to.
S103: according to reporting the type of service of task, select corresponding TCP (Transmission
Control Protocol, transmission control protocol) file connection descriptor list, forward S104 to.
S104: judge TCP file connects in descriptor list whether there is effective descriptor,
If so, forward S106 to, otherwise forward S105 to.
S104 judging, TCP file connects in descriptor list whether there is effective descriptor
Idiographic flow be: whether judge that TCP file connects descriptor list is empty and TCP literary composition
It is not the most 1 (upstate) that part connects the conventional mark of descriptor list All Files descriptor,
The most then there is not effective descriptor, otherwise TCP in connecting descriptor list in TCP file
File connects in descriptor list and there is effective descriptor.
S105: send state according to history, select suitable descriptor and commonly used mark
It is set to after 1 preserve and connects in descriptor list to corresponding TCP file, re-execute S103.
S106: select TCP file to connect effective descriptor in descriptor list, forward to
S107。
Whether the idiographic flow of S106 is: judge that TCP file connects in descriptor list and exist
Conventional be masked as 1 descriptor:
If so, select TCP file connect in descriptor first conventional be masked as 1 description
Symbol;Otherwise judge whether the connection descriptor list of TCP file exists to commonly use to be masked as 0 (just
Beginning state) descriptor:
If so, select TCP file connect in descriptor first conventional be masked as 0 description
Its conventional mark is also set to 1 by symbol, forwards S107 to;Otherwise judge that TCP file connects to retouch
State and whether symbol list exist the conventional descriptor being masked as 2 (blocked states):
If so, select TCP file connect in descriptor first conventional be masked as 2 description
Its conventional mark is also set to 1 by symbol, forwards S107 to;Otherwise forward S105 to.
S107: take out socket from effective descriptor and call send function, carry out TCP
Data are transmitted, and forward S108 to.
S108: check return value value of send function: if value is to send packet
Length, then tcp data is transmitted, and forwards S102 to and waits that other tasks trigger;If value
Less than 0 (such as-1 ,-2 etc.), then tcp data bust this, fail count will be sent
Count_fail forwards S109 to after adding 1, if value is more than 0 and less than the length sending packet
Degree, then tcp data transmission is not fully complete, and forwards S110 to.
S109: judge that count_fail is whether less than server number of units (server in the present embodiment
Number of units is 3), if so, the conventional mark of descriptor effective in S107 being set to-1 (can not
By state) after forward S103 to, otherwise forward S102 to.
S110: judge that whether value is less than single DPI maximum transmitted byte number (such as 4 1024
Byte), the most then send obstruction, transmission is blocked after counting count_block adds 1 and forward to
S111, otherwise shows data volume the to be sent transmitting capacity more than DPI, needs to send out several times
Send, continue executing with S107.
S111: judge whether (N is positive integer to count_block, its concrete numerical value less than N
Empirically determined according to test, in the present embodiment, N is defined as 3, shows what tcp data transmitted
Server load is heavier, needs load balancing), if so, re-execute S107;Otherwise by S107
In the conventional mark of effective descriptor be set to 2 after forward S103 to.
The idiographic flow of S105 is:
S105a: in definition DPI system, the ip of server is x, the port y used by server
For ipxy, (y selects according to the type of service of reporting service, and every kind of type of service is corresponding different
Service-Port), it is (false that each ipxy unique correspondence one respectively records front 2 report cycles
If each report cycle is 5min) total duration ipxy.duration [2] of sending,
In the corresponding first 10 minutes report cycles of current time of ipxy.duration [0], TCP sends shared
Total duration, in the corresponding first 5 minutes report cycles of current time of ipxy.duration [1], TCP sends
Shared total duration.The initial value of ipxy.duration [0] and ipxy.duration [1] is 0.
S105b: respectively each ipxy carried in current reporting service is created TCP and connect,
Socket is stored in the descriptor that each ipxy connects.
S105c: calculating the transmission scoring ipxyscore of each ipxy, computing formula is:
Ipxyscore=ipxy.duration [0] α+ipxy.duration [1] β;α in above-mentioned formula+
β=1, the ratio for different user α and β there may be difference, converges by saving certain
Platform test, obtaining best practices value α convergence is 0.3, and β convergence is 0.7.
S105d: judge that all of ipxyscore is the most identical, if so, selects ipxy.duration [1]
The server ip of minima, otherwise selects minima ipxyscore_min in all of ipxyscore
Server ip.
S105e: determine that the server ipx and port y of selection are this destination address sent,
The descriptor that the ipxy of selection connects is set to 1, and the descriptor that other ipxy connect is set to 0
After, preserve to corresponding TCP file connection descriptor list.
The present embodiment reporting service includes that general class reports TASK1 and flux and flow direction class to report
TASK2, TASK1 corresponding ports 1, TASK2 corresponding ports 2, number of servers is 3,
Ip is respectively ip1, ip2 and ip3.Ip1 and port 1, ip2 and port 1 and ip3 and end
The ipxyscore, respectively ip11score, ip21score and ip31score of mouth 1.This enforcement
When example implements S105, when reporting service is TASK1 and TASK1, ip11score is
Minima, therefore, the server ip selected in s105d is 1.
On this basis, after S107 carries out tcp data transmission, need upper according to transmit
The report cycle updates ipxy.duration [0] and ipxy.duration [1].
Shown in Figure 2, number in the DPI system based on said method in the embodiment of the present invention
According to the device concurrently reported, this device includes DPI system initialization module, reports task to distribute
Module, descriptor list selection module, effective descriptor determination module, tcp data transmission mould
Block, fail count determination module, obstruction determination module and obstruction counting determination module;
DPI system initialization module is used for: control DPI system start-up, initializes and reports thread
Reporting number of threads and reporting queue length of pond, reports to reporting task allocating module to send and appoints
Business distribution signal;
Report task allocating module for: receive report task distribution signal after, control report line
The all of Cheng Chizhong report thread to enter waiting state, add Excelsior queue when reporting task
Time, idle in task distribution Excelsior thread pool report thread, to descriptor list by reporting
Select module to send descriptor list and select signal;
Descriptor list selection module is used for: after receiving descriptor list selection signal, according to upper
The type of service of report task, selects corresponding TCP file to connect descriptor list, to effectively
Descriptor determination module sends effective descriptor and judges signal;
Effectively descriptor determination module is used for: after receiving effective descriptor judgement signal, it is judged that
TCP file connects in descriptor list and there is effective descriptor, if so, to tcp data
Transport module sends tcp data transmission signal;Otherwise send state according to history, select to close
Its conventional mark is also set to after 1 the TCP file connection preserved to corresponding by suitable descriptor
In descriptor list, again send descriptor list to descriptor list selection module and select letter
Number;
Tcp data transport module is used for: after receiving tcp data transmission signal, from effectively
Descriptor calls send function, carries out tcp data transmission;Check the return of send function
Value value: if value is the length sending packet, then tcp data is transmitted, to
Reporting task allocating module to send reports task to distribute signal;If value is less than 0, then TCP
Data transmission fails, judges mould to fail count after adding 1 by transmission fail count count_fail
Block sends fail count and judges signal, if value more than 0 and is less than the length sending packet,
Then tcp data transmission is not fully complete, and sends obstruction judgement signal to blocking determination module;
Fail count determination module is used for: judge whether count_fail is less than server number of units,
If so, the conventional mark of described effective descriptor is set to after down state-1 to descriptor
List selection module sends descriptor list and selects signal, otherwise to reporting task allocating module to send out
Serve report task distribution signal;
Block determination module to be used for: after receiving obstruction judgement signal, it is judged that whether value is less than
Single DPI maximum transmitted byte number, the most then send obstruction, and transmission is blocked counting
Count_block sends obstruction counting judgement signal to obstruction counting determination module after adding 1, no
Then continue to send tcp data transmission signal to tcp data transport module;
Block counting determination module to be used for: judge whether count_block is less than positive integer N,
The most again tcp data transmission signal is sent to tcp data transport module;Otherwise by institute
State after the conventional mark of effective descriptor is set to blocked state 2 and select mould to descriptor list
Block sends descriptor list and selects signal.
The present invention is not limited to above-mentioned embodiment, for those skilled in the art
For, under the premise without departing from the principles of the invention, it is also possible to make some improvements and modifications,
Within these improvements and modifications are also considered as protection scope of the present invention.This specification is not made in detail
The content described belongs to prior art known to professional and technical personnel in the field.