bdp_estimator.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H
20 #define GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H
21 
23 
24 #include <inttypes.h>
25 
27 #include <grpc/support/log.h>
28 #include <grpc/support/time.h>
29 
32 
34 
35 namespace grpc_core {
36 
37 class BdpEstimator {
38  public:
39  explicit BdpEstimator(const char* name);
41 
42  int64_t EstimateBdp() const { return estimate_; }
43  double EstimateBandwidth() const { return bw_est_; }
44 
45  void AddIncomingBytes(int64_t num_bytes) { accumulator_ += num_bytes; }
46 
47  // Schedule a ping: call in response to receiving a true from
48  // grpc_bdp_estimator_add_incoming_bytes once a ping has been scheduled by a
49  // transport (but not necessarily started)
50  void SchedulePing() {
52  gpr_log(GPR_INFO, "bdp[%s]:sched acc=%" PRId64 " est=%" PRId64, name_,
54  }
57  accumulator_ = 0;
58  }
59 
60  // Start a ping: call after calling grpc_bdp_estimator_schedule_ping and
61  // once
62  // the ping is on the wire
63  void StartPing() {
65  gpr_log(GPR_INFO, "bdp[%s]:start acc=%" PRId64 " est=%" PRId64, name_,
67  }
71  }
72 
73  // Completes a previously started ping, returns when to schedule the next one
75 
77 
78  private:
80 
84  // when was the current ping started?
88  double bw_est_;
89  const char* name_;
90 };
91 
92 } // namespace grpc_core
93 
94 #endif /* GRPC_CORE_LIB_TRANSPORT_BDP_ESTIMATOR_H */
trace.h
GPR_INFO
#define GPR_INFO
Definition: include/grpc/impl/codegen/log.h:56
log.h
grpc_core::BdpEstimator::accumulator
int64_t accumulator()
Definition: bdp_estimator.h:76
grpc_core::BdpEstimator::PingState::STARTED
@ STARTED
grpc_core::BdpEstimator::PingState
PingState
Definition: bdp_estimator.h:79
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::Timestamp
Definition: src/core/lib/gprpp/time.h:62
grpc_core::BdpEstimator::estimate_
int64_t estimate_
Definition: bdp_estimator.h:83
grpc_core::BdpEstimator::EstimateBdp
int64_t EstimateBdp() const
Definition: bdp_estimator.h:42
setup.name
name
Definition: setup.py:542
time.h
grpc_core::BdpEstimator::name_
const char * name_
Definition: bdp_estimator.h:89
GRPC_TRACE_FLAG_ENABLED
#define GRPC_TRACE_FLAG_ENABLED(f)
Definition: debug/trace.h:114
grpc_core::BdpEstimator::ping_start_time_
gpr_timespec ping_start_time_
Definition: bdp_estimator.h:85
grpc_core::BdpEstimator::PingState::SCHEDULED
@ SCHEDULED
grpc_core::BdpEstimator::BdpEstimator
BdpEstimator(const char *name)
Definition: bdp_estimator.cc:34
grpc_core::BdpEstimator::EstimateBandwidth
double EstimateBandwidth() const
Definition: bdp_estimator.h:43
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_core::BdpEstimator::StartPing
void StartPing()
Definition: bdp_estimator.h:63
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
grpc_core::BdpEstimator::SchedulePing
void SchedulePing()
Definition: bdp_estimator.h:50
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
time.h
GPR_CLOCK_MONOTONIC
@ GPR_CLOCK_MONOTONIC
Definition: gpr_types.h:36
grpc_core::BdpEstimator::bw_est_
double bw_est_
Definition: bdp_estimator.h:88
grpc_core::BdpEstimator::stable_estimate_count_
int stable_estimate_count_
Definition: bdp_estimator.h:87
gpr_now
GPRAPI gpr_timespec gpr_now(gpr_clock_type clock)
gpr_types.h
grpc_core::TraceFlag
Definition: debug/trace.h:63
grpc_core::BdpEstimator::PingState::UNSCHEDULED
@ UNSCHEDULED
grpc_core::BdpEstimator::ping_state_
PingState ping_state_
Definition: bdp_estimator.h:81
grpc_core::BdpEstimator::accumulator_
int64_t accumulator_
Definition: bdp_estimator.h:82
grpc_core::BdpEstimator::CompletePing
Timestamp CompletePing()
Definition: bdp_estimator.cc:44
grpc_core::BdpEstimator::inter_ping_delay_
Duration inter_ping_delay_
Definition: bdp_estimator.h:86
grpc_bdp_estimator_trace
grpc_core::TraceFlag grpc_bdp_estimator_trace
grpc_core::BdpEstimator::AddIncomingBytes
void AddIncomingBytes(int64_t num_bytes)
Definition: bdp_estimator.h:45
gpr_timespec
Definition: gpr_types.h:50
grpc_core::Duration
Definition: src/core/lib/gprpp/time.h:122
grpc_core::BdpEstimator
Definition: bdp_estimator.h:37
grpc_core::BdpEstimator::~BdpEstimator
~BdpEstimator()
Definition: bdp_estimator.h:40
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 02:58:36