File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ BdpEstimator::BdpEstimator(absl::string_view name)
3737 stable_estimate_count_(0 ),
3838 ping_state_(PingState::UNSCHEDULED),
3939 bw_est_(0 ),
40+ seed_(0 ),
4041 name_(name) {}
4142
4243Timestamp BdpEstimator::CompletePing () {
@@ -63,7 +64,7 @@ Timestamp BdpEstimator::CompletePing() {
6364 if (stable_estimate_count_ >= 2 ) {
6465 // if the ping estimate is steady, slowly ramp down the probe time
6566 inter_ping_delay_ += Duration::Milliseconds (
66- 100 + static_cast <int >(rand ( ) * 100.0 / RAND_MAX));
67+ 100 + static_cast <int >(rand_r (&seed_ ) * 100.0 / RAND_MAX));
6768 }
6869 }
6970 if (start_inter_ping_delay != inter_ping_delay_) {
Original file line number Diff line number Diff line change @@ -65,6 +65,9 @@ class BdpEstimator {
6565 CHECK (ping_state_ == PingState::SCHEDULED);
6666 ping_state_ = PingState::STARTED;
6767 ping_start_time_ = gpr_now (GPR_CLOCK_MONOTONIC);
68+ if (!seed_) {
69+ seed_ = ping_start_time_.tv_nsec ;
70+ }
6871 }
6972
7073 // Completes a previously started ping, returns when to schedule the next one
@@ -83,6 +86,7 @@ class BdpEstimator {
8386 int stable_estimate_count_;
8487 PingState ping_state_;
8588 double bw_est_;
89+ unsigned int seed_;
8690 absl::string_view name_;
8791};
8892
You can’t perform that action at this time.
0 commit comments