-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathround_trip_counter.h
More file actions
40 lines (35 loc) · 918 Bytes
/
Copy pathround_trip_counter.h
File metadata and controls
40 lines (35 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef BBR_ROUDN_TRIP_COUNTER_H_
#define BBR_ROUDN_TRIP_COUNTER_H_
#include <cstddef>
#include <cstdint>
namespace bbr
{
class RoundTripCounter
{
public:
void on_pkt_sent(uint64_t seq_no) {
last_sent_packet_no_ = seq_no;
}
// Return whether a round trip has just completed.
bool on_pkt_acked(uint64_t acked_seq_no) {
if (acked_seq_no > end_of_round_trip_) {
round_trip_count_++;
end_of_round_trip_ = last_sent_packet_no_;
return true;
}
return false;
}
uint64_t count() {
return round_trip_count_;
}
void restart() {
end_of_round_trip_ = last_sent_packet_no_;
}
private:
uint64_t round_trip_count_ = 0;
uint64_t last_sent_packet_no_ = std::numeric_limits<uint64_t>::max();
// The last sent packet number of the current round trip.
uint64_t end_of_round_trip_ = 0;
};
}
#endif