The content of the invention
The technical problem to be solved in the present invention is to overcome in the prior art without statistics tree topology change time
Number and the method for time, user can not perceive the defects of topological structure changes, there is provided a kind of change of tree topology
Statistical method and device, can count tree topology change frequency and the last tree topology it is stable when
It is long, be easy to tree topology break down after maintenance.
The present invention is that solve above-mentioned technical problem by following technical proposals:A kind of change statistics of tree topology
Method, each node of the tree topology is provided with a value as the first numerical value or the variable of second value, when described
The value of variable represents that the tree topology changes when being the first numerical value, when the value of the variable is second value
When represent that the tree topology does not change, its feature is, set an initial value be zero change frequency, it is described change system
Meter method comprises the following steps:
S1, delay one time interval;
S2, whether detection all has the value of an at least variable in the variables is first numerical value, if then performing
Step S3If step S is otherwise performed again1;
S3, the change frequency value add one, then perform step S again1。
Tree topology, which does not change, refers to that whole variables is second value, when the whole of tree topology
When occurring the first numerical value in variable, represent that topological structure changes, be first from the variable-value of tree topology
The value of numerical value to the variable to change is that the process of second value is a tree topology change for the first time, in institute
State in change statistical method, step S1Finger just carries out once the detection, step S at regular intervals2In by two kinds of variable
Value represents whether the tree topology changes, in step S if detecting to change3It is middle by described in definition
The change frequency of tree topology adds one, and detection next time is then carried out after fixed time interval is reached, if detection
Tree topology does not change, carries out detection next time after fixed time interval is reached, the number counted after again
User can be visually indicated in some equipment by respective handling, user is perceived the change of topological structure, simultaneously
Also the maintenance for topological structure provides a kind of method.For how to detect the change of the variable and how to be shown to user can
To be realized using prior art, such as detect the variable whether changing method can be RSTP and start a timer, and it is fixed
Numerical value in an adopted variable tcWhile recording timer, the timer are act as:When the tcWhile of timer is not zero
When, change in topology information is included in the RSTP BPDUs sent to timer, the value for being corresponding heretofore described variable is
First numerical value;When the tcWhile of timer is zero, represent that RSTP BPDUs do not include change in topology information, be this corresponding hair
The value of variable described in bright is second value, and the topological structure transmits change in topology information, this inspection by RSTP BPDUs
Survey and the specific implementation of display and non-invention are to where the main improvements of prior art, therefore other are examined at this
Survey the method for the variable change and the specific implementation of display is omitted and do not stated.
It is preferred that setting the flag that a value is the first ident value or the second ident value, the initial value of the flag is
Second ident value, step S2Including S21And S22:
S21, whether detection all has the value of an at least variable in the variables is first numerical value, if then performing
Step S22If the flag otherwise is entered as into the second ident value, step S is then performed again1;
S22, the value that judges the flag whether be the first ident value, if then performing step S again1If otherwise hold
Row step S3;
Step S3For:The value of the change frequency adds one, the flag is entered as into the first ident value, then again
Perform step S1。
Because being having time interval between detection adjacent twice, when the depth of tree topology is larger, topology becomes
The duration of change is possible to that the time interval can be more than, after one time change in topology is counted, when detecting next time this
One time change in topology is not completed and repeatedly counted again, defines a flag.First ident value represents to detect
The change in topology counted in the number, second ident value represents the change in topology detected also not
Counted or the topological structure is in unchanged stable state.When having detected the i.e. described topological structure of first numerical value
When changing, the flag is that the value of the change frequency is just added one by the second ident value, is at this moment this time detected
Change in topology is counted, then flag is entered as the first ident value, is then carried out after fixed time interval is reached next
Secondary detection.When it is second value to detect all variables, it is meant that the change of topological structure be over and
State in an indeclinable stabilization, flag is at this moment entered as the second ident value.
It is preferred that the holding duration that an initial value is zero, step S are set21For:Detection all whether have in the variables to
The value of a few variable is first numerical value, if returning the value of the holding duration after then exporting the holding duration
Zero and then execution step S22If the flag is otherwise entered as the second ident value, the holding duration is entered as it is described
The value of duration is kept to perform step S with the time interval sum and then again1。
Definition keeps duration to represent to detect the stabilization that change foregoing description tree topology maintains how many duration.
When having detected first numerical value i.e. topological structure changing, by value after the holding duration output or record
Zero, the holding duration for being at this moment output or recording represent to detect topological structure maintains how many duration before change in topology
It is stable.When detecting that topological structure does not change, the value for keeping duration to be entered as the holding duration adds the time
Interval.
It is preferred that the span of the time interval is 0.5 second to 2 seconds.The different values of time interval are in order to more
The number and the holding duration are accurately counted, when the depth of tree topology is smaller, a change in topology occurs
Duration may be very short, in order to prevent taking time interval there occurs fast-changing situation twice in a time interval
It is small more accurately to count change in topology.
It is preferred that the time interval is 1 second.Consider from cost and on statistical accuracy, 1 second when being that effect is preferable
Between be spaced value.
The present invention also provides a kind of change statistic device of tree topology, each node of the tree topology
A value is provided with as the first numerical value or the variable of second value, the tree is represented when the value of the variable is the first numerical value
Shape topological structure changes, and represents that the tree topology does not change when the value of the variable is second value, its
Feature is that the change statistic device is provided with the change frequency that an initial value is zero, and the change statistic device includes one
Timing means, a detection means and a counting module,
The timing means is used to call the detection means after the time interval that is delayed;
The detection means is used to detect the value for whether having an at least variable in all variables and counted for described first
Value, if then calling the counting module, if otherwise calling the timing means;
The counting module is used to the value of the change frequency adding one, then calls the timing means.
A kind of in the tree topology is the topological structure in passive optical-fiber network, such as is generated by RSTP
One tree topology being made up of optical switch, optical fiber and user terminal.
It is preferred that the change statistic device also includes an identity device and a judge module, the change statistics dress
Install and be equipped with flag of the value for the first ident value or the second ident value, the initial value of the flag is the described second mark
Knowledge value;
The detection means is used to detect the value for whether having an at least variable in all variables and counted for described first
Value, if then calling the judge module, if otherwise call the identity device by the flag be entered as the second ident value,
Then the timing means is called;
The judge module is used to judge whether the value of the flag is the first ident value, if then call it is described fixed
When device, if otherwise calling the counting module;
The counting module is used to the value of the change frequency adding one, calls the identity device by the flag
The first ident value is entered as, then calls the timing means.
It is preferred that the change statistic device is provided with the holding duration that an initial value is zero, the change statistic device
Including a time set, the detection means is used for:The value for whether having an at least variable in the whole variables of detection is institute
The first numerical value is stated, if call the time set that the value of the holding duration is zeroed after then exporting the holding duration,
Then the judge module is called, if otherwise calling the identity device that the flag is entered as into the second ident value, called
The holding duration is entered as the value and the time interval sum and then calling of the holding duration by the time set
The timing means.
Above-mentioned each functional module and device can combine existing software programming hand under existing hardware condition
Duan Shixian, therefore their specific implementation is not repeated.
It is preferred that the span of the time interval is 0.5 second to 2 seconds.
It is preferred that the time interval is 1 second.
The positive effect of the present invention is:The present invention can count tree topology change frequency and recently
The stable duration of tree topology, be easy to tree topology break down after maintenance.
Embodiment 1
In the present embodiment, referring to Fig. 1, it is the first numerical value that each node of the tree topology, which is provided with a value,
Or the variable of second value, represent that the tree topology is changing when the value of the variable is the first numerical value, when
The value of the variable represents that the tree topology does not change when being second value, sets the change time that an initial value is zero
Number, the flag that a value is the first ident value or the second ident value is set, and the initial value of the flag is the described second mark
Value, the change statistical method comprise the following steps:
Step 100, delay 0.5 second.
The value for whether having an at least variable in step 101, the whole variables of detection is first numerical value, if then
Step 103 is performed, if otherwise performing step 102.
Step 102, the flag is entered as the second ident value, then performs step 100 again.
Whether step 103, the value for judging the flag are the first ident value, if then performing step 100 again, if
Otherwise step 104 is performed.
Step 104, the value of the change frequency add one, the flag are entered as into the first ident value, then again
Perform step 100.
The flag being related among above-mentioned steps is a kind of preferred, and the change in topology that flag can prevent from detecting is weighed
Multiple statistics.And the time interval is set according to the depth of topological structure can not can be with more accurate by the flag
Count the number, be within 0.5 second one kind of time interval preferably, the frequency of the smaller detection of time interval is higher, coordinates mark
Know potential energy and enough more accurately count the number.
Referring to Fig. 2, the corresponding present invention also provides a kind of change statistic device 1 of tree topology, the change system
Counter device 1 includes a timing means 11, a detection means 12, a counting module 13, an identity device 14 and a judge module
15。
The timing means 11 is used to call the detection means 12 after being delayed 0.5 second;The detection means 12 is used for
The value for whether having an at least variable in the whole variables of detection is first numerical value, if then calling the judge module
15, if otherwise calling the identity device 14 that the flag is entered as into the second ident value and then calls the timing means
11;The judge module 15 is used to judge whether the value of the flag to be the first ident value, if then calling the timing
Device 11, if otherwise calling the counting module 13;The counting module 13 is used to the value of the change frequency adding one, adjusts
The flag is entered as the first ident value with the identity device 14, then calls the timing means 11.
Identity device 14 among the change statistic device 1 is a kind of preferred, and identity device 14 can prevent from detecting
Change in topology repeatedly counted, and the time interval is set according to the depth of topological structure can not be by the mark
Device 14 can count the number with accurate.
Embodiment 2
Referring to Fig. 3, for the present embodiment on the basis of embodiment 1, the time interval of delay is 2 seconds, and one initial value of setting is
Zero holding duration, step 101 replace with step 1011 and step 1012,
The value for whether having an at least variable in step 1011, the whole variables of detection is first numerical value, if
Step 1012 is then performed, if otherwise performing step 1021.
The value of the holding duration is zeroed and then performed step 103 after step 1012, the output holding duration.
Step 102 replaces with:
Step 1021, when the flag is entered as the second ident value, the holding duration is entered as into the holding
Long value adds 2 seconds and then performed again step 100.
Above-mentioned steps provide a kind of stabilization for detecting change foregoing description tree topology and maintaining how many duration again
Statistical method.
Accordingly, on the basis of the change statistic device of embodiment 1, the time interval of delay is 2 seconds, and setting one is initial
The holding duration that value is zero, the change statistic device include a time set, and the detection means is used for:Detect described in whole
It is first numerical value whether to have the value of an at least variable in variable, if calling the meter after then exporting the holding duration
When device the value of the holding duration is zeroed and then calls the judge module, if otherwise calling the identity device will
The flag is entered as the second ident value, calls the time set that the holding duration is entered as into the holding duration
Value adds 2 seconds and then calls the timing means.
2 seconds are a kind of preferred of time interval, and the frequency of the bigger detection of time interval is lower.Detecting the low benefit of frequency is
The resource for taking the change statistic device is less.