summaryrefslogtreecommitdiffstats
path: root/net/quic/quic_multipath_received_packet_manager.h
blob: dba9244134d53e8a73974e839afa365ec0b2f199 (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
76
77
78
79
// Copyright (c) 2015 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.

// A connection level received packet manager which manages multiple per path
// received packet managers.

#ifndef NET_QUIC_QUIC_MULTIPATH_RECEIVED_PACKET_MANAGER_H_
#define NET_QUIC_QUIC_MULTIPATH_RECEIVED_PACKET_MANAGER_H_

#include <unordered_map>
#include <vector>

#include "net/quic/quic_protocol.h"
#include "net/quic/quic_received_packet_manager.h"

namespace net {

namespace test {
class QuicMultipathReceivedPacketManagerPeer;
}  // namespace test

class NET_EXPORT_PRIVATE QuicMultipathReceivedPacketManager {
 public:
  typedef std::unordered_map<QuicPathId, QuicReceivedPacketManager*>
      MultipathReceivedPacketManagerMap;

  explicit QuicMultipathReceivedPacketManager(QuicConnectionStats* stats);
  ~QuicMultipathReceivedPacketManager();

  // Called when a new path with |path_id| is created.
  void OnPathCreated(QuicPathId path_id, QuicConnectionStats* stats);

  // Called when path with |path_id| is closed.
  void OnPathClosed(QuicPathId path_id);

  // Records packet receipt information on path with |path_id|.
  void RecordPacketReceived(QuicPathId path_id,
                            QuicByteCount bytes,
                            const QuicPacketHeader& header,
                            QuicTime receipt_time);

  // Called when packet with |packet_number| is revived on path with |path_id|.
  void RecordPacketRevived(QuicPathId path_id, QuicPacketNumber packet_number);

  // Checks whether |packet_number| is missing on path with |path_id|.
  bool IsMissing(QuicPathId path_id, QuicPacketNumber packet_number);

  // Checks if we're still waiting for the packet with |packet_number| on path
  // with |path_id|.
  bool IsAwaitingPacket(QuicPathId path_id, QuicPacketNumber packet_number);

  // If |force_all_paths| is false, populates ack information for paths whose
  // ack has been updated since UpdateReceivedPacketInfo was called last time.
  // Otherwise, populates ack for all paths.
  void UpdateReceivedPacketInfo(std::vector<QuicAckFrame>* ack_frames,
                                QuicTime approximate_now,
                                bool force_all_paths);

  // Updates internal state based on stop_waiting frames for corresponding path.
  void UpdatePacketInformationSentByPeer(
      const std::vector<QuicStopWaitingFrame>& stop_waitings);

  // Returns true when there are new missing packets to be reported within 3
  // packets of the largest observed on path with |path_id|.
  bool HasNewMissingPackets(QuicPathId path_id) const;

  QuicPacketNumber GetPeerLeastPacketAwaitingAck(QuicPathId path_id);

 private:
  friend class test::QuicMultipathReceivedPacketManagerPeer;

  // Map mapping path id to path received packet manager.
  MultipathReceivedPacketManagerMap path_managers_;
};

}  // namespace net

#endif  // NET_QUIC_QUIC_MULTIPATH_RECEIVED_PACKET_MANAGER_H_