CN107332732A - A kind of method of sampling of message flow, device and routing device - Google Patents

A kind of method of sampling of message flow, device and routing device Download PDF

Info

Publication number
CN107332732A
CN107332732A CN201710495409.9A CN201710495409A CN107332732A CN 107332732 A CN107332732 A CN 107332732A CN 201710495409 A CN201710495409 A CN 201710495409A CN 107332732 A CN107332732 A CN 107332732A
Authority
CN
China
Prior art keywords
read
message
mark
statistical variable
sampling period
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201710495409.9A
Other languages
Chinese (zh)
Inventor
孙琳洋
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Maipu Communication Technology Co Ltd
Original Assignee
Maipu Communication 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 Maipu Communication Technology Co Ltd filed Critical Maipu Communication Technology Co Ltd
Priority to CN201710495409.9A priority Critical patent/CN107332732A/en
Publication of CN107332732A publication Critical patent/CN107332732A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0876Network utilisation, e.g. volume of load or congestion level
    • H04L43/0888Throughput
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • H04L43/0876Network utilisation, e.g. volume of load or congestion level
    • H04L43/0894Packet rate
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/38Flow based routing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/70Admission control; Resource allocation
    • H04L47/82Miscellaneous aspects
    • H04L47/822Collecting or measuring resource availability data

Landscapes

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

Abstract

The embodiment of the present invention provides a kind of method of sampling of message flow, device and routing device, it is related to communication technical field, the problem of solution static statistics method used in the prior art can not know the situation of change of the message flow in the working time on network interface.This method includes:The message received by network interface is read in circulation, and records the message number that success is read every time, in the case where having read to be masked as the first mark, and the message number read according to each success updates statistical variable, and statistical variable is used for the number for reflecting that message is cumulative;When reaching in each sampling period, mark will be read and be set to the second mark, and read statistical variable, mark will have been read after running through and has been set to the first mark, the reception condition of message in the sampling period is exported according to the statistical variable read.The present invention is used for the statistics of message flow.

Description

A kind of method of sampling of message flow, device and routing device
Technical field
The present invention relates to communication technical field, more particularly to a kind of method of sampling of message flow, device and routing device.
Background technology
With the development of Internet technology, network has become a part, the network data of magnanimity necessary to daily life Requirement to the data throughout of network communication equipment is also stricter.Router is set as important necessary in communication network It is standby, the reliability of the data communication of network where the performance of its data transmit-receive is directly determined, to the business carried in network Normal operation serve support and limitation effect.
In the prior art, the message flow on a certain network interface of router is made typically by the mode of static statistics Statistics, i.e., carry out simply adding up to the message received on network interface.In can only so reflecting router operationally Total message reception amount, and the situation of change of the upward message flow of recipient can not be reflected, so that in route Some FAQs appeared in device are that can not analyze concrete reason according to total message reception amount in the working time. For example, for the common packet loss problem of router, above-mentioned static statistics mode can only determine network interface institute during operation The sum of the packet loss of statistics, it is impossible to as according to judge Network Packet Loss the reason for be due to the number networks exceed interface institute The performance of the network chip used, or software layer processing speed cause very much buffer to deplete the packet loss of appearance slowly.
Therefore, it is necessary to enter Mobile state description to the message flow on the network interface of routing device, satisfied the need so as to provide The data analyzed by the service behaviour of equipment and the working condition of software layer, are the technical problems of current urgent need to resolve.
The content of the invention
Embodiments of the invention provide a kind of method of sampling of message flow, device and routing device, solve prior art Employed in static statistics method the problem of can not know the situation of change of message flow in the working time on network interface.
To reach above-mentioned purpose, embodiments of the invention are adopted the following technical scheme that:
The first aspect of the embodiment of the present invention there is provided a kind of routing device, including:
Network interface, for receiving message;
From core, the thread created from core, which is used to circulate, to be read and the report from the reception of core corresponding network interface Text, and the message number that success is read every time is recorded, in the case where having read to be masked as the first mark, according to successfully reading every time Message number update statistical variable, the statistical variable is used for the number for reflecting that message is cumulative;Forwarding is additionally operable to by the net The message of network interface;
The thread created on main core, the main core is used for when reaching in each sampling period, and the mark of having read is set to Second mark, and the statistical variable is read, the mark of having read is set to first mark after running through, read according to described The statistical variable got exports the reception condition of message in the sampling period.
The second aspect of the embodiment of the present invention includes there is provided a kind of method of sampling of message flow, methods described:
The message received by network interface is read in circulation, and records the message number that success is read every time, is reading mark In the case of for the first mark, the message number read according to each success updates statistical variable, and the statistical variable is used for anti- Reflect the cumulative number of message;
When reaching in each sampling period, the mark of having read is set to the second mark, and reads the statistical variable, The mark of having read is set to first mark after running through, exported according to the statistical variable read in the sampling period The reception condition of message.
There is provided a kind of sampling apparatus of message flow for the third aspect of the embodiment of the present invention, it is characterised in that described device Including:
Read module, reads the message received by network interface, and record the message number that success is read every time for circulating Mesh;
Update module, in the case where having read to be masked as the first mark, according to the message number of each success reading Statistical variable is updated, the statistical variable is used for the number for reflecting that message is cumulative;
Processing module, for when reaching in each sampling period, the mark of having read being set into the second mark, and read institute Statistical variable is stated, the mark of having read is set to first mark after running through;
Output module, the statistical variable for being read according to exports the reception condition of message in the sampling period.
The method of sampling, device and the routing device of message flow provided in an embodiment of the present invention, are read by net by circulating The message of network interface, and record the message number that success is read every time, in the case where having read to be masked as the first mark, root The message number read according to each success updates statistical variable, and the statistical variable is used for the number for reflecting that message is cumulative;Each When sampling period reaches, mark will have been read and be set to the second mark, and read statistical variable, mark will have been read after running through and has been set to the One mark, the reception condition of message in the sampling period is exported according to the statistical variable read.
The mode for the static statistics taken compared to prior art be only capable of obtaining router operationally in it is total By when reaching in each sampling period, reading statistical variable in message reception amount, this programme, the statistics read according to this becomes Amount exports the reception condition of message in the sampling period, so obtain routing device operationally in each sampling period Bag asks reception condition, so that the situation of the dynamic change of message flow is obtained, for some problems appeared in routing device Positioning and message flow analysis have good directive function.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing There is the accompanying drawing used required in technology description to be briefly described, it should be apparent that, drawings in the following description are only this Some embodiments of invention, for those of ordinary skill in the art, without having to pay creative labor, may be used also To obtain other accompanying drawings according to these accompanying drawings.
Fig. 1 is a kind of method flow diagram of the method for sampling of message flow provided in an embodiment of the present invention;
Fig. 2 is a kind of structural representation of the sampling apparatus of message flow provided in an embodiment of the present invention;
Fig. 3 is a kind of block schematic illustration of routing device provided in an embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made Embodiment, belongs to the scope of protection of the invention.
For the ease of clearly describing the technical scheme of the embodiment of the present invention, in an embodiment of the present invention, employ " the One ", the printed words such as " second " make a distinction to function or the essentially identical identical entry of effect or similar item, and those skilled in the art can To understand that the printed words such as " first ", " second " are not defined to quantity and execution order.
The routing device referred in the embodiment of the present invention, polycaryon processor used in the routing device includes a main core With multiple from core (being referred to as forwarding core).The main core is responsible for the related business of operation processing message forwarding.Mainly born from core Duty is forwarded the message of reception, it is ensured that the message that software processing can be currently to carry on quick obtaining network interface.
Based on the content of above-mentioned routing device, the embodiment of the present invention provides a kind of method of sampling of message flow, such as Fig. 1 Shown, this method includes:
101st, the message received by network interface is read in circulation, and records the message number that success is read every time, is being read In the case of being masked as the first mark, statistical variable is updated according to the message number that each success is read.
Wherein, above-mentioned statistical variable is used for the number for reflecting that message is cumulative.
Exemplary, the executive agent in above-mentioned steps 101 can be from core or in the thread set up from core.
It is preferred that, in order to embody the basis in the variation tendency of message number in the sampling period, above-mentioned step 101 The message number that success is read every time, which updates statistical variable, to be included:
A1, according to every time success read message number residing for message number interval, by counting messages structure with the report The corresponding statistical variable increase preset constant of literary number interval.
Wherein, above-mentioned counting messages structure includes statistical variable corresponding with each message number interval.
Optionally, count for convenience, above-mentioned preset constant is the numerical value more than or equal to 0.
It is further preferred that above-mentioned counting messages structure arranges for each statistical variable in array, and array according to it The message number interval that order is corresponding in turn to is continuous.
Exemplary, if above-mentioned message number interval is 4,4 statistical variables are included in array, and according to array Put in order respectively a, b, c and d, then corresponding message number interval be:[0-1/4*L1]、(1/4*L1-1/2*L1)、 [1/2*L1-3/4*L1] and (3/4*L1-L1], wherein:L1 represents BD ring maximum lengths.Corresponding above-mentioned step A1 is specific For:The message number interval residing for message number read according to each success, by system corresponding with the message number interval in array Count variable increase preset constant.If for example, certain message number interval once succeeded residing for the message number read is [0-1/4* L1], then the numerical value of the statistical variable a in array increases preset constant;If the report succeeded residing for the message number read next time Literary number interval is (1/4*L1-1/2*L1), then the numerical value increase of the statistical variable b in array and last time identical preset constant.
102nd, when reaching in each sampling period, mark will have been read and be set to the second mark, and read statistical variable, run through Mark will have been read afterwards and has been set to the first mark, and the reception condition of message in the sampling period is exported according to the statistical variable read.
Exemplary, the executive agent of above-mentioned steps 102 can be main core or the thread set up in main core.
Exemplary, the above-mentioned sampling period is flowTime, and the flowTime is configurable in operation.Specifically , staff or technical staff can configure the flowTime as needed, for example, the sampling period can for 10S or 1S etc..
Exemplary, the above-mentioned mark of reading can be represented with " 0 " " 1 ", if specifically, this, which has read mark, is equal to 1, walking In rapid 101 statistical variable is updated from core or from the message number that the thread in core is read according to each success;If this has read mark Equal to 0, then the thread in the main core or main core in step 102 reads the numerical value of each statistical variable in array, will after running through ReadFlag is set to 1.Then, the thread in main core or main core, and execution is circulated always from core or from the thread in core.When So, when reaching in the sampling period, the thread in main core or main core can will read mark and be set to 0.Certainly, above-mentioned 0 and 1 are only A kind of example, in actual applications, can also be represented, do not limit here, the present embodiment is for side using other marks Just with being illustrated exemplified by 0 and 1.
Optionally, in order to prevent from the loss of data in internal memory occur after power-off according to reading in the problem of, above-mentioned steps 102 To statistical variable export the reception condition of message in the sampling period, including:
The statistical variable that B1, basis are read exports the reception condition of message in the sampling period into caching.
By above-mentioned step 102a content, the reception condition of message is exported into caching, so that after power-off Data corresponding to the reception condition of the message will not lose, while being also convenient for the later stage by these data to know network interface And the information such as working condition of whole routing device.
Exemplary, the reception of message in the sampling period is exported in above-mentioned steps 102 according to the statistical variable read Situation, including:
102a, the statistical variable that the statistical variable in the n-th cycle read is subtracted to the N-1 cycle, are sampled The message number received in cycle.
102b, the message number for exporting reception in the sampling period.
Optionally, it is set to the first mark mark will have been read after the step of reading statistical variable in above-mentioned steps 102 The step of before, this method also includes:
C1, statistical variable reset.
Based on above-mentioned step C1 content, sampling week is exported according to the statistical variable read in above-mentioned steps 102 The reception condition of message in phase, including:Message in the sampling period is directly exported according to the numerical value of the statistical variable read Reception condition, i.e., need not do any calculation process, directly export the reception condition of message in the sampling period.
The method of sampling of message flow provided in an embodiment of the present invention, the report received by network interface is read by circulating Text, and the message number that success is read every time is recorded, in the case where having read to be masked as the first mark, according to successfully reading every time Message number update statistical variable, the statistical variable is used for the number for reflecting that message is cumulative;When reaching in each sampling period, Mark will have been read and be set to the second mark, and read statistical variable, mark will have been read after running through and has been set to the first mark, according to reading To statistical variable export the reception condition of message in the sampling period.
The mode for the static statistics taken compared to prior art be only capable of obtaining router operationally in it is total By when reaching in each sampling period, reading statistical variable in message reception amount, this programme, the statistics read according to this becomes Amount exports the reception condition of message in the sampling period, so obtain routing device operationally in each sampling period Bag asks reception condition, so that the situation of the dynamic change of message flow is obtained, for some problems appeared in routing device Positioning and message flow analysis have good directive function.
The associated description in the embodiment of the method for sampling based on the corresponding message flows of Fig. 1 is implemented to the present invention below A kind of sampling apparatus for message flow that example is provided is introduced.The technology art related to above-described embodiment in following examples The explanation of language, concept etc. is referred to the above embodiments, repeats no more here.
The embodiment of the present invention provides a kind of sampling apparatus of message flow, as shown in Fig. 2 the device 2 includes:Read module 21st, update module 22, processing module 23 and output module 24, wherein:
Read module 21, reads the message received by network interface, and record the message that success is read every time for circulating Number.
Update module 22, in the case where having read to be masked as the first mark, according to the message number of each success reading Mesh updates statistical variable, and statistical variable is used for the number for reflecting that message is cumulative.
Processing module 23, for when reaching in each sampling period, mark will have been read and be set to the second mark, and read statistics Variable, after running through will read mark is set to the first mark.
Output module 24, the reception condition for exporting message in the sampling period according to the statistical variable read.
Exemplary, in order to embody the variation tendency of message number in the sampling period, above-mentioned update module 22 exists When the message number read according to each success updates statistical variable, specifically for:
The message number interval residing for message number read according to each success, by counting messages structure with the message number Interval corresponding statistical variable increase preset constant.
Wherein, above-mentioned counting messages structure includes statistical variable corresponding with each message number interval.
Optionally, count for convenience, above-mentioned preset constant is the numerical value more than or equal to 0.
It is further preferred that above-mentioned counting messages structure arranges for each statistical variable in array, and array according to it The message number interval that order is corresponding in turn to is continuous.
Optionally, in order to prevent power-off after there is the loss of data in internal memory the problem of, above-mentioned output module 24 is specific For:
The reception condition of message in the sampling period is exported into caching according to the statistical variable read.
The reception condition of message is exported into caching by above-mentioned output module 24, so that the message after power-off Reception condition corresponding to data will not lose, network interface is known by these data and whole while being also convenient for the later stage The information such as the working condition of individual routing device.
It is exemplary, above-mentioned output module 24 specifically for:
The statistical variable in the n-th cycle read is subtracted to the statistical variable in the N-1 cycle, obtained in the sampling period The message number of reception.
Export the message number received in the sampling period.
Optionally, as shown in Fig. 2 the device 2 also includes:Dump block 25, wherein:
Dump block 25, for above-mentioned statistical variable to be reset.
The mode for the static statistics taken compared to prior art be only capable of obtaining router operationally in it is total By when reaching in each sampling period, reading statistical variable in message reception amount, this programme, the statistics read according to this becomes Amount exports the reception condition of message in the sampling period, so obtain routing device operationally in each sampling period Bag asks reception condition, so that the situation of the dynamic change of message flow is obtained, for some problems appeared in routing device Positioning and message flow analysis have good directive function.
The associated description in the embodiment of the method for sampling based on the corresponding message flows of Fig. 1 is implemented to the present invention below A kind of routing device that example is provided is introduced.The technical term related to above-described embodiment, concept etc. in following examples Illustrate to be referred to the above embodiments, repeat no more here.
The embodiment of the present invention provides a kind of routing device, and the routing device includes:
Network interface, for receiving message.
From core, the thread that should be created from core is used to circulating the message read by with being received from the corresponding network interface of core, And the message number that success is read every time is recorded, in the case where having read to be masked as the first mark, read according to each success Message number updates statistical variable, and statistical variable is used for the number for reflecting that message is cumulative;Forwarding is additionally operable to by the network interface The message of reception.
The thread created on main core, the main core is used for when reaching in each sampling period, will read mark and has been set to the second mark Know, and read statistical variable, the mark of having read is set to the first mark after running through, exported according to the statistical variable read The reception condition of message in the sampling period.
Exemplary, above-mentioned network interface is additionally operable to the message carry by reception on BD rings.
Specifically, receiving chip comprising message in above-mentioned network interface, the message receives chip and hangs the message of reception It is loaded on BD rings.
Based on above-mentioned content, the above-mentioned thread created from core specifically for:
Message is read in circulation from BD rings, and records the message number that success is read every time, is reading to be masked as the first mark In the case of knowledge, the message number read according to each success updates statistical variable, and the statistical variable is used to reflect that message adds up Number;Forward the message received by network interface.
It is preferred that, being created on above-mentioned main core has first thread and the second thread.Wherein:
The first thread is used for when reaching in each sampling period, will read mark and has been set to the second mark, and has read statistics Variable, after running through will read mark is set to the first mark.
Second thread is used for the reception condition that message in the sampling period is exported according to the statistical variable read.
Wherein, above-mentioned first thread and the second cross-thread are synchronized by mutex amount flowSem, the second thread Block waiting signal amount flowSem, release semaphore flowSem, the second thread ability root after first thread reads statistical variable The reception condition of message in the sampling period is exported according to the statistical variable read.
It is preferred that, in order to embody the variation tendency of message number in the sampling period, the above-mentioned line created from core Journey according to every time success read message number update statistical variable when, specifically for:
The message number interval residing for message number read according to each success, by counting messages structure with the message number Interval corresponding statistical variable increase preset constant.
Wherein, above-mentioned counting messages structure includes statistical variable corresponding with each message number interval.
Optionally, count for convenience, above-mentioned preset constant is the numerical value more than or equal to 0.
It is further preferred that above-mentioned counting messages structure arranges for each statistical variable in array, and array according to it The message number interval that order is corresponding in turn to is continuous.
Exemplary, if above-mentioned message number interval is 4,4 statistical variables are included in array, and according to array Put in order respectively a, b, c and d, then corresponding message number interval can be:[0-1/4*L1]、(1/4*L1-1/2* L1), [1/2*L1-3/4*L1] and (3/4*L1-L1], wherein:L1 represents BD ring maximum lengths.Corresponding above-mentioned step A1 Specially:The message number interval residing for message number read according to each success, will be corresponding with the message number interval in array Statistical variable increase preset constant.If for example, certain message number interval once succeeded residing for the message number read is [0-1/ 4*L1], then the numerical value of the statistical variable a in array increases preset constant;If succeed residing for the message number read next time Message number interval is (1/4*L1-1/2*L1), then the numerical value increase of the statistical variable b in array and last time identical are default normal Number.
Exemplary, the thread created on above-mentioned main core exports sampling week in the statistical variable read according to In phase during the reception condition of message, also particularly useful for:
The statistical variable in the n-th cycle read is subtracted to the statistical variable in the N-1 cycle, obtained in the sampling period The reception condition of message.
Export the reception condition of message in the sampling period.
Optionally, the thread created on above-mentioned main core is additionally operable to:Statistical variable is reset.When the thread created on main core When statistical variable is reset, the thread created on main core directly exports sampling week according to the numerical value to statistical variable of reading The reception condition of message in phase.
Routing device provided in an embodiment of the present invention, is read by corresponding with from core by the thread loops created from core The message that network interface is received, and the message number that success is read every time is recorded, in the case where having read to be masked as the first mark, The message number read according to each success updates statistical variable, and statistical variable is used for the number for reflecting that message is cumulative;It is additionally operable to Forward the message received by the network interface.By the thread that is created on the main core when reaching in each sampling period, by Read mark and be set to the second mark, and read statistical variable, the mark of having read is set to the first mark after running through, according to reading To statistical variable export the reception condition of message in the sampling period.
The mode for the static statistics taken compared to prior art be only capable of obtaining router operationally in it is total The thread created on main core in message reception amount, this programme is by when reaching in each sampling period, reading statistical variable, root The reception condition of message in the sampling period is exported according to the statistical variable read, and then between obtaining routing device operationally Bag in each interior sampling period asks reception condition, so that the situation of the dynamic change of message flow is obtained, for routing device Appeared in some problems positioning and message flow analysis have good directive function.
Below by the framework based on the polycaryon processor in router, explained with specific content and illustrate above-mentioned retouched The content for the routing device stated, detailed content refers to the content of following components:
(a) one is created in the framework based on the polycaryon processor in above-mentioned router, the embodiment of the present invention on main core Individual thread flowCtrl, the thread is responsible for periodically reading each from the reception condition of core message within the sampling period, false If the sampling period is flowTime, the sampling period is can configure in running.Another thread is created in main core FlowProcess, thread flowProcess all are counted according to what is obtained in each cycle from the message flow of core Calculate, it is possible to depict message in continuous time and receive the situation of change of flow, and statistical result is preserved into Flash, use In purposes such as flow analyses, wherein:Carried out between thread flowCtrl and flowProcess by mutex amount flowSem It is synchronous, thread flowProcess obstruction waiting signal amount flowSem, release signal after thread flowCtrl reads sampled value FlowSem is measured, thread flowProcess proceeds by message flow calculating.
(b) in the framework based on the polycaryon processor in above-mentioned router, the embodiment of the present invention at each from core A thread flowRecv is created, the thread is responsible for circulation and reads message from BD rings, the message of reception is handled and turned Hair.Meanwhile, thread flowRecv can record the successful message number read from BD rings each time, and storage is arrived for being somebody's turn to do from core The message of foundation is received in statistical framework flowSum, and the thread flowCtrl on main core is read out and analyzed.
(c) chip is received based on the message used in the network interface in routing device, to the BD rings described in (b), Message receives chip and the message of reception can be mounted on BD rings.Assuming that the BD rings maximum length is L1, on current BD rings The message number of carrying is L2.As L2=L1, if software does not read message from BD rings, subsequent packet will be dropped.
(d) based on the BD ring lengths described in (c), it is assumed that the message number that each software can successfully be read from BD rings For L3, then L3≤L2≤L1.It is [0-1/4*L1], (1/4*L1-1/2*L1), [1/2*L1- that message is received into number interval division 3/4*L1]、(3/4*L1-L1].Message number L3 according to reading every time falls in different interval number of times, it is possible to reflect one The size variation situation of message flow in the individual sampling period.
(e) for described in (b) message receive statistical framework flowSum [], the structure for each is from core, Can be the array that a length is M, M size receives the number of a number interval for above-mentioned middle message.Pass through mark ReadFlag realizes main core thread flowCtrl and from nothings of the core thread flowRecv to statistical framework flowSum [] Lock is accessed, it is to avoid reduction forwarding performance.
Specifically, circulating the message for reading and being received by the network interface of routing device from core thread flowRecv, and remember The record message number that success is read every time, when readFlag is equal to 1, array is updated according to the message number that each success is read In each statistical variable.
ReadFlag is set to 0, and read each in array by main core thread flowCtrl when reaching in each sampling period The numerical value of individual statistical variable, 1 is set to after running through by readFlag.Then from core thread flowRecv according to the readFlag It is worth for 1, is updated each statistical variable in array, circulates always, until terminates.
(f) from core in the message number L3 after BD rings read message, indicated every time according to readFlag and this reads Interval distribution, the corresponding element in statistical framework flowSum [] is added up.
(g) when the cycle flowTime that principal epipolar line journey flowCtrl samples is reached, traversal reads the system of each forwarding core Count structure flowSum.After principal epipolar line journey flowCtrl completes the statistical framework flowSum [] of all forwarding cores reading, release Discharge signal amount flowSem, sampled value is handled by thread flowProcess.And again wait for sampling period flowTime arrival.
(h), can be with by the setting to principal epipolar line journey flowCtrl sampling period flowTime and readFlag mark Dynamic is turned off or on from the traffic sampling on core, realizes the purpose opened on demand.For example, by the above-mentioned sampling period FlowTime is set to infinitely great, and readFlag is set to 0, and because readFlag not work from core for 0, the sampling period is nothing The arrival less than the sampling period such as poor ambassador winner core can not also work, and thus close the function of flow collection and processing.
According to the description of (a)-(h) contents above, with one for core, framework is as shown in Figure 3 for of the invention realizing.Base Circulated in the block schematic illustration of the routing device shown in Fig. 3, this programme by the thread flowRecv created from core from BD Message is read on ring, and records the message number that success is read every time, in the case where having read to be masked as the first mark, according to every The message number that secondary success is read updates statistical variable, and the statistical variable is used for the number for reflecting that message is cumulative.Created on main core Thread flowCtrl when reaching in each sampling period, mark will have been read and be set to the second mark, and read statistical variable, read Mark will have been read after complete and has been set to the first mark;The thread flowProcess created on main core is defeated according to the statistical variable read Go out the reception condition of message in the sampling period.The reception condition of message in each sampling period can be so obtained, so as to To obtain trend of the message number with time dynamic.
It should be noted that above-mentioned is only to illustrate process of the embodiment of the present invention by taking BD ring reception patterns as an example, this In be not defined.And the message flow method of sampling that this programme is provided can also be applied in the mode that other receive message.
Through the above description of the embodiments, it is apparent to those skilled in the art that, for description It is convenient and succinct, can as needed will be upper only with the division progress of above-mentioned each functional module for example, in practical application State function distribution to be completed by different functional modules, i.e., the internal structure of device is divided into different functional modules, to complete All or part of function described above.The specific work process of the system, apparatus, and unit of foregoing description, before may be referred to The corresponding process in embodiment of the method is stated, be will not be repeated here.
, can in several embodiments provided herein, it should be understood that the sampling apparatus of disclosed message flow To realize by another way.For example, the embodiment of device described above is only schematical, for example, the module Or the division of unit, only a kind of division of logic function, there can be other dividing mode when actually realizing, such as multiple lists Member or component can combine or be desirably integrated into another system, or some features can be ignored, or not perform.It is another, Shown or discussed coupling or direct-coupling or communication connection each other can be by some interfaces, device or unit INDIRECT COUPLING or communication connection, can be electrical, machinery or other forms.
The unit illustrated as separating component can be or may not be it is physically separate, it is aobvious as unit The part shown can be or may not be physical location, you can with positioned at a place, or can also be distributed to multiple On NE.Some or all of unit therein can be selected to realize the mesh of this embodiment scheme according to the actual needs 's.
In addition, each functional unit in each embodiment of the invention can be integrated in a processing unit, can also That unit is individually physically present, can also two or more units it is integrated in a unit.Above-mentioned integrated list Member can both be realized in the form of hardware, it would however also be possible to employ the form of SFU software functional unit is realized.
If the integrated unit is realized using in the form of SFU software functional unit and as independent production marketing or used When, it can be stored in a computer read/write memory medium.Understood based on such, technical scheme is substantially The part contributed in other words to prior art or all or part of the technical scheme can be in the form of software products Embody, the computer software product is stored in a storage medium, including some instructions are to cause a computer Equipment (can be personal computer, server, or network equipment etc.) or processor (processor) perform the present invention each The all or part of step of embodiment methods described.And foregoing storage medium includes:USB flash disk, mobile hard disk, read-only storage (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disc or CD Etc. it is various can be with the medium of store program codes.
The foregoing is only a specific embodiment of the invention, but protection scope of the present invention is not limited thereto, any Those familiar with the art the invention discloses technical scope in, change or replacement can be readily occurred in, should all be contained Cover within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.

Claims (12)

1. a kind of routing device, it is characterised in that including:
Network interface, for receiving message;
From core, the thread created from core be used to circulate read by with the report received from the corresponding network interface of core Text, and the message number that success is read every time is recorded, in the case where having read to be masked as the first mark, according to successfully reading every time Message number update statistical variable, the statistical variable is used for the number for reflecting that message is cumulative;Forwarding is additionally operable to by the net The message of network interface;
The thread created on main core, the main core is used for when reaching in each sampling period, and the mark of having read is set into second Mark, and the statistical variable is read, the mark of having read is set to first mark after running through, read according to described Statistical variable export the reception condition of message in the sampling period.
2. routing device according to claim 1, it is characterised in that
The network interface is additionally operable to the message carry by reception on BD rings;
The thread created from core specifically for:
Message is read in circulation from the BD rings, and records the message number that success is read every time, is reading to be masked as the first mark In the case of knowledge, the message number read according to each success updates statistical variable, and the statistical variable is used to reflect that message tires out Plus number;Forward the message received by the network interface.
3. routing device according to claim 1, it is characterised in that
Being created on the main core has first thread and the second thread;
The first thread is used for when reaching in each sampling period, the mark of having read is set into the second mark, and read institute Statistical variable is stated, the mark of having read is set to first mark after running through;
Second thread is used for the reception condition that the statistical variable that reads according to exports message in the sampling period;
The first thread and second cross-thread are synchronous by mutex amount.
4. routing device according to claim 1, it is characterised in that the thread created from core according to every time into When the message number that work(is read updates statistical variable, specifically for:
The message number interval residing for message number read according to each success, by counting messages structure with the message number interval Corresponding statistical variable increases preset constant;The counting messages structure becomes comprising statistics corresponding with each message number interval Amount.
5. routing device according to claim 4, it is characterised in that the counting messages structure is array, and the number The statistical variable of each in the group message number interval being corresponding in turn to that put in order according to it is continuous.
6. routing device according to claim 1, it is characterised in that the thread created on the main core is additionally operable to:By institute State statistical variable clearing.
7. a kind of method of sampling of message flow, it is characterised in that methods described includes:
The message that is received by network interface is read in circulation, and records the message number that success is read every time, is reading to be masked as the In the case of one mark, the message number read according to each success updates statistical variable, and the statistical variable, which is used to reflect, to be reported The cumulative number of text;
When reaching in each sampling period, the mark of having read is set to the second mark, and reads the statistical variable, is being run through The mark of having read is set to first mark afterwards, message in the sampling period is exported according to the statistical variable read Reception condition.
8. method according to claim 7, it is characterised in that the successful message number read updates system to the basis every time Meter variable includes:
The message number interval residing for message number read according to each success, by counting messages structure with the message number interval Corresponding statistical variable increases preset constant;The counting messages structure becomes comprising statistics corresponding with each message number interval Amount.
9. method according to claim 8, it is characterised in that the counting messages structure is in array, and the array Each statistical variable message number interval being corresponding in turn to that put in order according to it is continuous.
10. method according to claim 7, it is characterised in that the statistical variable output read described in the basis should The reception condition of message includes in sampling period:
The reception condition of message in the sampling period is exported into caching according to the statistical variable read.
11. method according to claim 7, it is characterised in that after the step of reading the statistical variable, by institute State before having read the step of mark is set to first mark, methods described also includes:The statistical variable is reset.
12. a kind of sampling apparatus of message flow, it is characterised in that described device includes:
Read module, reads the message received by network interface, and record the message number that success is read every time for circulating;
Update module, in the case where having read to be masked as the first mark, being updated according to the message number that each success is read Statistical variable, the statistical variable is used for the number for reflecting that message is cumulative;
Processing module, for when reaching in each sampling period, the mark of having read being set into the second mark, and read the system Variable is counted, the mark of having read is set to first mark after running through;
Output module, the statistical variable for being read according to exports the reception condition of message in the sampling period.
CN201710495409.9A 2017-06-26 2017-06-26 A kind of method of sampling of message flow, device and routing device Pending CN107332732A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710495409.9A CN107332732A (en) 2017-06-26 2017-06-26 A kind of method of sampling of message flow, device and routing device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710495409.9A CN107332732A (en) 2017-06-26 2017-06-26 A kind of method of sampling of message flow, device and routing device

Publications (1)

Publication Number Publication Date
CN107332732A true CN107332732A (en) 2017-11-07

Family

ID=60197065

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710495409.9A Pending CN107332732A (en) 2017-06-26 2017-06-26 A kind of method of sampling of message flow, device and routing device

Country Status (1)

Country Link
CN (1) CN107332732A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108616399A (en) * 2018-05-09 2018-10-02 北京神州绿盟信息安全科技股份有限公司 A kind of message statistical method and device
CN111464385A (en) * 2020-03-30 2020-07-28 北京信而泰科技股份有限公司 Second counting type statistical method and device
CN112702275A (en) * 2020-12-29 2021-04-23 迈普通信技术股份有限公司 Method, device, network equipment and computer storage medium based on packet-by-packet forwarding
CN113726591A (en) * 2021-07-28 2021-11-30 中盈优创资讯科技有限公司 Secondary sampling method suitable for NetFlow message distribution

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1477823A (en) * 2003-07-31 2004-02-25 CPU message flow control method of distributed exchange router system
CN101645834A (en) * 2009-08-28 2010-02-10 北京星网锐捷网络技术有限公司 Ethernet flow control method, device and network device
CN101719850A (en) * 2009-11-04 2010-06-02 中兴通讯股份有限公司 Device and method for carrying out statistics on Ethernet packet loss rate as well as message switching device
CN102710374A (en) * 2012-05-28 2012-10-03 天津大学 Speed control method in wireless streaming media transmission
CN103312566A (en) * 2013-06-28 2013-09-18 盛科网络(苏州)有限公司 Message port congestion detection method and device
CN106131083A (en) * 2016-08-30 2016-11-16 迈普通信技术股份有限公司 A kind of attack message detection and take precautions against method and switch
WO2017054738A1 (en) * 2015-09-30 2017-04-06 Huawei Technologies Co., Ltd. Method and apparatus for supporting service function chaining in a communication network

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1477823A (en) * 2003-07-31 2004-02-25 CPU message flow control method of distributed exchange router system
CN101645834A (en) * 2009-08-28 2010-02-10 北京星网锐捷网络技术有限公司 Ethernet flow control method, device and network device
CN101719850A (en) * 2009-11-04 2010-06-02 中兴通讯股份有限公司 Device and method for carrying out statistics on Ethernet packet loss rate as well as message switching device
CN102710374A (en) * 2012-05-28 2012-10-03 天津大学 Speed control method in wireless streaming media transmission
CN103312566A (en) * 2013-06-28 2013-09-18 盛科网络(苏州)有限公司 Message port congestion detection method and device
WO2017054738A1 (en) * 2015-09-30 2017-04-06 Huawei Technologies Co., Ltd. Method and apparatus for supporting service function chaining in a communication network
CN106131083A (en) * 2016-08-30 2016-11-16 迈普通信技术股份有限公司 A kind of attack message detection and take precautions against method and switch

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108616399A (en) * 2018-05-09 2018-10-02 北京神州绿盟信息安全科技股份有限公司 A kind of message statistical method and device
CN108616399B (en) * 2018-05-09 2021-02-12 北京神州绿盟信息安全科技股份有限公司 Message statistical method and device
CN111464385A (en) * 2020-03-30 2020-07-28 北京信而泰科技股份有限公司 Second counting type statistical method and device
CN112702275A (en) * 2020-12-29 2021-04-23 迈普通信技术股份有限公司 Method, device, network equipment and computer storage medium based on packet-by-packet forwarding
CN113726591A (en) * 2021-07-28 2021-11-30 中盈优创资讯科技有限公司 Secondary sampling method suitable for NetFlow message distribution
CN113726591B (en) * 2021-07-28 2023-02-21 中盈优创资讯科技有限公司 Secondary sampling method suitable for NetFlow message distribution

Similar Documents

Publication Publication Date Title
CN107332732A (en) A kind of method of sampling of message flow, device and routing device
CN109343965A (en) Resource adjusting method, device, cloud platform and server
CN102662988B (en) Method for filtering redundant data of RFID middleware
CN103399781B (en) Cloud Server and virtual machine management method thereof
CN109345200A (en) Automatic auditing method and device, computer readable storage medium based on high-volume report
CN106484709A (en) A kind of auditing method of daily record data and audit device
CN107092641A (en) Determination methods and device, the method and apparatus of shop search of shop business status
CN110175165A (en) Transaction account checking method, device, computer equipment and storage medium
CN105989163A (en) Data real-time processing method and system
CN104869155A (en) Data auditing method and device
CN109933315A (en) A kind of patterned transaction processing system and method
CN109669690A (en) Vocational work stream generating method, device, equipment and computer readable storage medium
CN108647727A (en) Unbalanced data classification lack sampling method, apparatus, equipment and medium
CN107392582A (en) The implementation method and device of resource transfers, the implementation method of bank settlement and device
CN106959898A (en) Reduce method, device and the mobile terminal of EMS memory occupation
CN102034163A (en) Method and system for managing asset information of telecommunication equipment
CN110334081A (en) The cleaning method and device of mass data
CN108985067A (en) Content processing method and device based on automation backtracking
CN103077080A (en) Method and device for acquiring parallel program performance data based on high performance platform
CN101060683B (en) Warning information generation method and device for communication system
CN113472681A (en) Flow rate limiting method and device
CN101661429A (en) Storage method of statistical information and device thereof
CN110515693A (en) A kind of method and system that the virtual machine based on rack perception is extending transversely
CN108287760A (en) Terminal equipment control method and device, terminal device and computer readable storage medium
CN107908710A (en) A kind of file reception management method, device, terminal device and storage medium

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20171107

RJ01 Rejection of invention patent application after publication