Summary of the invention
For above problem, the invention provides a kind of method that the network bandwidth detects, automatically carry out the detection of the network bandwidth, and being applied in the middle of Flow Control, load balancing the Bandwidth Dynamic of detection, greatly improve the accuracy of detection bandwidth, improve Flow Control and load balancing effect.
The method that the network bandwidth of the present invention detects, comprising:
A. use default bandwidth to download predetermined data volume from the website of testing the speed, according to the business of the size of described data volume and corresponding downloading duration, obtain initial bandwidth;
B. load balancing module and Flow Control module are applied to described initial bandwidth in control, realize load balancing and Flow Control function;
C. record the data traffic at least 1 time current 1 second, according to described data traffic, obtain current bandwidth average and the current maximum bandwidth of each record, the current bandwidth average of each time is averaging and obtains existing bandwidth, the current maximum bandwidth of each time is averaging and obtains current maximum bandwidth average;
D. described existing bandwidth and current maximum bandwidth average value of averaging are calculated, if the existing bandwidth of poor > of described mean value and existing bandwidth 10%, described mean value is carried out to bandwidth replacement as existing bandwidth;
E. the time that interval is set carries out to carry out bandwidth from b step cycle and detects in real time.
When configuration of routers by specifying testing the speed of network address, according to the actual situation of obtaining data, calculate the bandwidth of initial outer net, in the use procedure of successive router, regularly externally guipure is wide samples, according to average bandwidth situation and the lasting peak condition used, constantly test bandwidth is detected, adjust the most realistic bandwidth numerical value router is configured in real time, greatly improve thus the accuracy of detection bandwidth, improve Flow Control and load balancing effect.
Preferably, the data traffic in step c in recording occurring continuously 5 times current 1 second, and according to this data volume of 5 times, calculate current bandwidth average and the current maximum bandwidth of each record.More accurate from the more values that finally obtain of probability angle sampled value, but take into account efficiency simultaneously, every execution is this step once, preferably carries out 5 samplings.
Preferably, step c enters steps d again after repeating 5 times.
Preferably, by the existing bandwidth described in the current bandwidth mean value computation step c of nearest 10 times; By the current maximum bandwidth average described in the current maximum bandwidth calculation procedure c of nearest 10 times, to obtain existing bandwidth and current maximum bandwidth average more accurately.
Further, because actual bandwidth peak and standard peak value have certain difference, therefore according to sample variance, the maximum bandwidth average described in steps d is compensated, so that the more realistic bandwidth value of result.
Preferably, the setting-up time described in step e is 300 seconds, at interval of each step that repeats a inventive method for 300 seconds, current outer net bandwidth is detected in real time, realizes dynamic-configuration.
Method of the present invention, solved outer net bandwidth in the environment of dynamic change, the problem of client's inconvenience configuration router, and by automatically carrying out the detection of the network bandwidth, by being applied in the middle of Flow Control, load balancing of the Bandwidth Dynamic detecting, greatly improve the accuracy of detection bandwidth, improve Flow Control and load balancing effect.
Below in conjunction with the embodiment by accompanying drawing illustrated embodiment, foregoing of the present invention is described in further detail again.But this should be interpreted as to the scope of the above-mentioned theme of the present invention only limits to following example.Without departing from the idea case in the present invention described above, various replacements or the change according to ordinary skill knowledge and customary means, made, all should comprise within the scope of the invention.
Embodiment
The method that the network bandwidth of the present invention detects as shown in Figure 1, comprising:
A. work as device start, after initialization network has connected, forbid that intranet data connects to avoid data to disturb.Use the 10M(million of acquiescence) bandwidth downloads predetermined data volume from the website of testing the speed, and according to the business of the size of described data volume and corresponding downloading duration T, obtains initial bandwidth B
0, i.e. initial bandwidth B
0(bit/s)=downloading data amount M(bit)/downloading duration T(s), duration T=downloads end time T2-and downloads initial time T1;
B. load balancing module and Flow Control module are by described initial bandwidth B
0be applied in control, realize load balancing and Flow Control function;
C. the data traffic in recording occurring continuously 5 times current 1 second, is designated as respectively M1, M2, M3, M4, M5, and calculates current bandwidth average B according to this data volume of 5 times
n(bit/s)=(M1+M2+M3+M4+M5)/5, and current maximum bandwidth BM
n=Max (M1, M2, M3, M4, M5).Repeat after 5 times, by the current bandwidth average B of nearest 10 times
nbe averaging and obtain existing bandwidth, then by the current maximum bandwidth BM of nearest 10 times
nbe averaging and obtain current maximum bandwidth average.Current maximum bandwidth average BM=Average{BMn-
0, BMn-
1, BMn-
2, BMn-
3, BMn-
4, BMn-
5, BMn-
6, BMn-
7, BMn-
8, BMn-
9.Once, the value of subscript n increases progressively 1 to every record, and records this calculated value, as historical data;
D. according to sample variance, maximum bandwidth average BM is compensated: sample variance S=[(Bn-
0-X) ^2+ (Bn-
1-X) ^2....+ (Bn-
9-X) ^2]/(10-1), X represents sample average=(Bn-
0+ Bn-
1+ ...+Bn-
9)/10.Existing bandwidth and current maximum bandwidth average BM value of averaging are calculated, if 10% of the existing bandwidth of poor > of described mean value and existing bandwidth, the bandwidth value variable quantity of the bandwidth calculating and current system differs 10%, using described mean value as existing bandwidth B
0carry out bandwidth replacement;
E. interval is carried out to carry out bandwidth from b step cycle in 300 seconds and is detected in real time.