Summary of the invention
The technical problem to be solved in the present invention is the method for not adding up tree topology change frequency and time in prior art in order to overcome, the defect that user cannot perception topological structure changes, a kind of variation statistical method and device of tree topology are provided, can add up change frequency and the stable duration of the last tree topology of tree topology, the maintenance after being convenient to tree topology and breaking down.
The present invention solves above-mentioned technical problem by following technical proposals: a kind of variation statistical method of tree topology, it is the variable of the first numerical value or second value that each Node configuration of described tree topology has a value, in the time that being the first numerical value, the value of described variable represents that described tree topology changes, in the time that being second value, the value of described variable represents that described tree topology does not change, its feature is, one initial value is set is zero change frequency, described variation statistical method comprises the steps:
S
1, one time interval of time delay;
S
2, detect that in whole described variablees, whether to have the value of at least one variable be described the first numerical value, if perform step S
3, again perform step if not S
1;
S
3, described change frequency value add one, and then execution step S
1.
Tree topology does not change and refers to that whole described variablees is second value, in the time there is the first numerical value in whole variablees of tree topology, represent that topological structure changes, be that the process that the first numerical value is second value for the first time to the value of the variable changing is that a tree topology changes from the variable-value of tree topology, in described variation statistical method, step S
1refer to just carry out once at set intervals described detection, step S
2in represent by two kinds of values of variable whether described tree topology changes, change at step S if detect
3the middle change frequency by the described tree topology of definition adds one, then reach behind regular time interval, carry out on detection once, if detect tree topology do not change reach behind regular time interval, carry out on detection once, described number of times can be shown to intuitively user through respective handling after being added up again on some equipment, make user perceive the variation of topological structure, the while is also for the maintenance of topological structure provides a kind of method.Can utilize existing techniques in realizing for how to detect the variation of described variable and how to be shown to user, whether changing method can start a timer for RSTP for example to detect described variable, and define the numerical value in variable tcWhile recording timing device, acting as of this timer: in the time that the tcWhile of timer is non-vanishing, comprise change in topology information at the RSTP BPDUs sending to timer, the value that is variable described in corresponding the present invention is the first numerical value; In the time that the tcWhile of timer is zero, represent that RSTP BPDUs does not comprise change in topology information, the value that is variable described in corresponding the present invention is second value, described topological structure transmits change in topology information by RSTP BPDUs, the specific implementation of this detection and demonstration is not the main improvements place of the present invention to prior art, omits and does not state therefore other are detected to the method for described variable change and the specific implementation of demonstration at this.
Preferably, the flag that a value is the first ident value or the second ident value is set, the initial value of this flag is described the second ident value, step S
2comprise S
21and S
22:
S
21, detect that in whole described variablees, whether to have the value of at least one variable be described the first numerical value, if perform step S
22, be the second ident value by described flag assignment if not, and then execution step S
1;
S
22, judge whether the value of described flag is the first ident value, if again perform step S
1, perform step if not S
3;
Step S
3for: the value of described change frequency adds one, is the first ident value by described flag assignment, and then execution step S
1.
Because between twice adjacent detection be free interval, in the time that the degree of depth of tree topology is larger, the duration of change in topology likely can be greater than the described time interval, after being added up for fear of a change in topology, while detection, this time change in topology does not complete and is again repeated statistics next time, defines a flag.Described the first ident value represents that the described change in topology detecting has counted in described number of times, described the second ident value represent that the described change in topology detecting is not also added up or described topological structure in unchanged stable state.When having detected that described the first numerical value is that described topological structure is while changing, described flag is that the second ident value just adds one by the value of described change frequency, at this moment the change in topology this time detecting is added up, flag assignment is the first ident value so, then reach behind regular time interval, carry out on detection once.In the time detecting that all described variablees are second value, the variation that means topological structure has finished and in an indeclinable stable state, has been at this moment the second ident value by flag assignment.
Preferably, an initial value be set be zero maintenance duration, step S
21for: detect that in whole described variablees, whether to have the value of at least one variable be described the first numerical value, if the value of described maintenance duration is made zero, then performs step S after exporting described maintenance duration
22, be the second ident value by described flag assignment if not, be described maintenance duration by described maintenance duration assignment value and described time interval sum and then execution step S
1.
Definition maintenance duration represents to detect that changing described tree topology has before kept the stable of how many durations.When having detected that described the first numerical value is that topological structure is while changing, value after the output of described maintenance duration or record is made zero, the maintenance duration that is at this moment output or records represent to detect change in topology before topological structure kept the stable of how many durations.In the time detecting that topological structure does not change, the value that described maintenance duration assignment is described maintenance duration adds the described time interval.
Preferably, the span in the described time interval is 0.5 second to 2 seconds.The different values in the time interval are in order to add up more accurately described number of times and described maintenance duration, when the degree of depth of tree topology hour, the duration that a change in topology occurs may be very short, in order to prevent, in the time interval, fast-changing situation has occurred twice, will get in the time interval and littlely can add up more accurately change in topology.
Preferably, the described time interval is 1 second.From cost, considering with statistical accuracy, 1 second is the good time interval value of effect.
The present invention also provides a kind of variation statistic device of tree topology, it is the variable of the first numerical value or second value that each Node configuration of described tree topology has a value, in the time that being the first numerical value, the value of described variable represents that described tree topology changes, in the time that being second value, the value of described variable represents that described tree topology does not change, its feature is, it is zero change frequency that described variation statistic device is provided with an initial value, described variation statistic device comprises a timing device, a checkout gear and a counting module
Described timing device for calling described checkout gear after one time interval of time delay;
Described checkout gear is described the first numerical value for detection of the value that whether has at least one variable in whole described variablees, if call described counting module, calls if not described timing device;
Described counting module, for the value of described change frequency is added to one, then calls described timing device.
A kind of in described tree topology is the topological structure in passive optical-fiber network, for example, generated a tree topology being made up of optical switch, optical fiber and user terminal by RSTP.
Preferably, described variation statistic device also comprises an identity device and a judge module, and described variation statistic device is provided with the flag that a value is the first ident value or the second ident value, and the initial value of described flag is described the second ident value;
Described checkout gear is described the first numerical value for detection of the value that whether has at least one variable in whole described variablees, if call described judge module, call if not described identity device described flag assignment is the second ident value, then calls described timing device;
Described judge module is for judging whether the value of described flag is the first ident value, if call described timing device, calls if not described counting module;
Described counting module is for adding one by the value of described change frequency, and calling described identity device is the first ident value by described flag assignment, then calls described timing device.
Preferably, it is zero maintenance duration that described variation statistic device is provided with an initial value, described variation statistic device comprises a time set, described checkout gear is used for: detect whole described variablees whether having the value of at least one variable is described the first numerical value, call described time set after described maintenance duration the value of described maintenance duration is made zero if export, then call described judge module, calling if not described identity device is the second ident value by described flag assignment, value and described time interval sum that to call described time set be described maintenance duration by described maintenance duration assignment, then call described timing device.
Each above-mentioned functional module and device all can be realized in conjunction with existing software programming means under existing hardware condition, therefore their specific implementation are not repeated.
Preferably, the span in the described time interval is 0.5 second to 2 seconds.
Preferably, the described time interval is 1 second.
Positive progressive effect of the present invention is: the present invention can add up change frequency and the stable duration of the last tree topology of tree topology, the maintenance after being convenient to tree topology and breaking down.
Embodiment
Provide preferred embodiment of the present invention below in conjunction with accompanying drawing, to describe technical scheme of the present invention in detail.
Embodiment 1
In the present embodiment, referring to Fig. 1, it is the variable of the first numerical value or second value that each Node configuration of described tree topology has a value, in the time that being the first numerical value, the value of described variable represents that described tree topology changes, in the time that being second value, the value of described variable represents that described tree topology does not change, one initial value be set be zero change frequency, the flag that one value is the first ident value or the second ident value is set, the initial value of this flag is described the second ident value, and described variation statistical method comprises the steps:
Step 100, time delay 0.5 second.
Step 101, detect that in whole described variablees, whether to have the value of at least one variable be described the first numerical value, if perform step 103, perform step 102 if not.
Step 102, be the second ident value by described flag assignment, and then execution step 100.
Step 103, judge whether the value of described flag is the first ident value, if again perform step 100, performs step 104 if not.
The value of step 104, described change frequency adds one, is the first ident value by described flag assignment, and then execution step 100.
The flag relating in the middle of above-mentioned steps is preferably a kind of, and flag can prevent that the change in topology detecting is repeated statistics.Can just can not count more accurately described number of times by described flag and set the described time interval according to the degree of depth of topological structure, the one that 0.5 second is the time interval is preferred, the frequency of less detection of the time interval is higher, coordinates flag can count more accurately described number of times.
Referring to Fig. 2, corresponding the present invention also provides a kind of variation statistic device 1 of tree topology, and described variation statistic device 1 comprises a timing device 11, a checkout gear 12, a counting module 13, an identity device 14 and a judge module 15.
Described timing device 11 is for calling described checkout gear 12 after 0.5 second in time delay; Described checkout gear 12 is described the first numerical value for detection of the value that whether has at least one variable in whole described variablees, if call described judge module 15, call if not described identity device 14 described flag assignment is the second ident value, then calls described timing device 11; Whether described judge module 15 is the first ident value for the value that judges described flag, if call described timing device 11, calls if not described counting module 13; Described counting module 13 is for adding one by the value of described change frequency, and calling described identity device 14 is the first ident value by described flag assignment, then calls described timing device 11.
Identity device 14 in the middle of described variation statistic device 1 is preferably a kind of, identity device 14 can prevent that the change in topology detecting is repeated statistics, can just can not count described number of times by described identity device 14 more accurately and set the described time interval according to the degree of depth of topological structure.
Embodiment 2
Referring to Fig. 3, the present embodiment is on the basis of embodiment 1, and the time interval of time delay is 2 seconds, an initial value is set is zero maintenance duration, and step 101 replaces with step 1011 and step 1012,
Step 1011, detect that in whole described variablees, whether to have the value of at least one variable be described the first numerical value, if perform step 1012, perform step 1021 if not.
Step 1012, the value of described maintenance duration is made zero, then performs step 103 after exporting described maintenance duration.
Step 102 replaces with:
Step 1021, by described flag assignment be the second ident value, being described maintenance duration by described maintenance duration assignment, value adds 2 seconds and then execution step 100.
Above-mentioned steps provides again described tree topology before a kind of change detected to keep the stable statistical method of how many durations.
Accordingly, on the basis of the variation statistic device of embodiment 1, the time interval of time delay is 2 seconds, one initial value be set be zero maintenance duration, described variation statistic device comprises a time set, described checkout gear is used for: detect whole described variablees whether having the value of at least one variable is described the first numerical value, call described time set after described maintenance duration the value of described maintenance duration is made zero if export, then call described judge module, calling if not described identity device is the second ident value by described flag assignment, the value that to call described time set be described maintenance duration by described maintenance duration assignment adds 2 seconds, then call described timing device.
The one that 2 seconds is the time interval is preferred, and the frequency of larger detection of the time interval is lower.Detect frequency low benefit and be that to take the resource of described variation statistic device less.
Embodiment 3
The difference of the present embodiment and embodiment 2 is, the time interval of time delay in embodiment 2 was become to 1 second from 2 seconds, it within 1 second, is the good time interval value of effect, from cost, consider with use value, the too high detection of frequency may take or waste resource, according to the degree of depth of at present conventional topological structure, it within 1 second, is execution mode preferably.
Although more than described the specific embodiment of the present invention, it will be understood by those of skill in the art that these only illustrate, protection scope of the present invention is limited by appended claims.Those skilled in the art is not deviating under the prerequisite of principle of the present invention and essence, can make various changes or modifications to these execution modes, but these changes and amendment all fall into protection scope of the present invention.