Add explicit |forceOnlineSignin| to user pod status
[chromium-blink-merge.git] / net / quic / congestion_control / inter_arrival_state_machine.h
blob829aa29938adb87739e2da1dd3fa21f95bdd9d8b
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // State machine for congestion control. The state is updated by calls from
6 // other modules as they detect events, or decide on taking specific actions.
7 // Events include things like packet loss, or growing delay, while decisions
8 // include decisions to increase or decrease bitrates.
9 // This class should be called for every event and decision made by the
10 // congestion control, this class will coalesce all calls relative to the
11 // smoothed RTT.
13 #ifndef NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_STATE_MACHINE_H_
14 #define NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_STATE_MACHINE_H_
16 #include "net/base/net_export.h"
17 #include "net/quic/quic_clock.h"
18 #include "net/quic/quic_time.h"
20 namespace net {
22 // State transition diagram.
24 // kInterArrivalStatePacketLoss
25 // |
26 // kInterArrivalStateStable
27 // |
28 // kInterArrivalStateDelay
29 // | |
30 // kInterArrivalStateCompetingFlow -> kInterArrivalStateCompetingTcpFLow
32 enum NET_EXPORT_PRIVATE InterArrivalState {
33 // We are on a network with a delay that is too small to be reliably detected,
34 // such as a local ethernet.
35 kInterArrivalStatePacketLoss = 1,
36 // We are on an underutilized network operating with low delay and low loss.
37 kInterArrivalStateStable = 2,
38 // We are on a network where we can detect delay changes and suffer only
39 // low loss. Nothing indicates that we are competing with another flow.
40 kInterArrivalStateDelay = 3,
41 // We are on a network where we can detect delay changes and suffer only
42 // low loss. We have indications that we are compete with another flow.
43 kInterArrivalStateCompetingFlow = 4,
44 // We are on a network where we can detect delay changes, however we suffer
45 // packet loss due to sharing the bottleneck link with another flow, which is
46 // most likely a TCP flow.
47 kInterArrivalStateCompetingTcpFLow = 5,
50 class NET_EXPORT_PRIVATE InterArrivalStateMachine {
51 public:
52 explicit InterArrivalStateMachine(const QuicClock* clock);
54 InterArrivalState GetInterArrivalState();
56 // Inter arrival congestion control decided to increase bitrate.
57 void IncreaseBitrateDecision();
59 // Inter arrival congestion control decided to decrease bitrate.
60 void DecreaseBitrateDecision();
62 // Estimated smoothed round trip time.
63 // This should be called whenever the smoothed RTT estimate is updated.
64 void set_rtt(QuicTime::Delta rtt);
66 // This method is called when a packet loss was reported.
67 bool PacketLossEvent();
69 // This method is called when we believe that packet transit delay is
70 // increasing, presumably due to a growing queue along the path.
71 bool IncreasingDelayEvent();
73 private:
74 const QuicClock* clock_;
75 InterArrivalState current_state_;
76 QuicTime::Delta smoothed_rtt_;
78 int decrease_event_count_;
79 QuicTime last_decrease_event_;
81 int increase_event_count_;
82 QuicTime last_increase_event_;
84 int loss_event_count_;
85 QuicTime last_loss_event_;
87 int delay_event_count_;
88 QuicTime last_delay_event_;
90 DISALLOW_COPY_AND_ASSIGN(InterArrivalStateMachine);
93 } // namespace net
94 #endif // NET_QUIC_CONGESTION_CONTROL_INTER_ARRIVAL_STATE_MACHINE_H_