summaryrefslogtreecommitdiff
path: root/chromium/net/third_party/quiche/src/quic/core/congestion_control/loss_detection_interface.h
blob: 77c8913e6aab26ba9716d0b0c0a9ddb86a8b38fb (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// The pure virtual class for send side loss detection algorithm.

#ifndef QUICHE_QUIC_CORE_CONGESTION_CONTROL_LOSS_DETECTION_INTERFACE_H_
#define QUICHE_QUIC_CORE_CONGESTION_CONTROL_LOSS_DETECTION_INTERFACE_H_

#include "quic/core/congestion_control/send_algorithm_interface.h"
#include "quic/core/quic_config.h"
#include "quic/core/quic_packets.h"
#include "quic/core/quic_time.h"
#include "quic/core/quic_types.h"
#include "quic/platform/api/quic_export.h"

namespace quic {

class QuicUnackedPacketMap;
class RttStats;

class QUIC_EXPORT_PRIVATE LossDetectionInterface {
 public:
  virtual ~LossDetectionInterface() {}

  virtual void SetFromConfig(const QuicConfig& config,
                             Perspective perspective) = 0;

  struct QUIC_NO_EXPORT DetectionStats {
    // Maximum sequence reordering observed in newly acked packets.
    QuicPacketCount sent_packets_max_sequence_reordering = 0;
    QuicPacketCount sent_packets_num_borderline_time_reorderings = 0;
    // Total detection response time for lost packets from this detection.
    // See QuicConnectionStats for the definition of detection response time.
    float total_loss_detection_response_time = 0.0;
  };

  // Called when a new ack arrives or the loss alarm fires.
  virtual DetectionStats DetectLosses(
      const QuicUnackedPacketMap& unacked_packets,
      QuicTime time,
      const RttStats& rtt_stats,
      QuicPacketNumber largest_newly_acked,
      const AckedPacketVector& packets_acked,
      LostPacketVector* packets_lost) = 0;

  // Get the time the LossDetectionAlgorithm wants to re-evaluate losses.
  // Returns QuicTime::Zero if no alarm needs to be set.
  virtual QuicTime GetLossTimeout() const = 0;

  // Called when |packet_number| was detected lost but gets acked later.
  virtual void SpuriousLossDetected(
      const QuicUnackedPacketMap& unacked_packets,
      const RttStats& rtt_stats,
      QuicTime ack_receive_time,
      QuicPacketNumber packet_number,
      QuicPacketNumber previous_largest_acked) = 0;

  virtual void OnConfigNegotiated() = 0;

  virtual void OnMinRttAvailable() = 0;

  virtual void OnUserAgentIdKnown() = 0;

  virtual void OnConnectionClosed() = 0;

  // Called when a reordering is detected by the loss algorithm, but _before_
  // the reordering_shift and reordering_threshold are consulted to see whether
  // it is a loss.
  virtual void OnReorderingDetected() = 0;
};

}  // namespace quic

#endif  // QUICHE_QUIC_CORE_CONGESTION_CONTROL_LOSS_DETECTION_INTERFACE_H_