OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015 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. | |
4 | |
5 // A map manages packets which are transmitted across multiple paths. | |
6 // For example, a packet is originally transmitted on path 1 with packet number | |
7 // 1. Then this packet is retransmitted on path 2 with packet number 1. (1, 1) | |
8 // and (2, 1) are inserted into this map. Suppose (2, 1) is detected lost and | |
9 // gets retransmitted on path 2 with packet 2. (2, 2) will not be inserted | |
10 // because this transmission does not "across" path compared to (2, 1). | |
11 | |
12 #ifndef NET_QUIC_QUIC_MULTIPATH_TRANSMISSIONS_MAP_H_ | |
13 #define NET_QUIC_QUIC_MULTIPATH_TRANSMISSIONS_MAP_H_ | |
14 | |
15 #include <deque> | |
16 #include <unordered_map> | |
17 | |
18 #include "base/macros.h" | |
19 #include "net/quic/quic_protocol.h" | |
20 #include "net/quic/quic_utils.h" | |
21 | |
22 namespace net { | |
23 | |
24 typedef std::pair<QuicPathId, QuicPacketNumber> QuicPathIdPacketNumber; | |
25 | |
26 class NET_EXPORT_PRIVATE QuicMultipathTransmissionsMap { | |
27 public: | |
28 struct QuicPathIdPacketNumberHash { | |
29 size_t operator()(std::pair<QuicPathId, QuicPacketNumber> value) const { | |
30 return QuicUtils::PackPathIdAndPacketNumber(value.first, value.second); | |
31 } | |
32 }; | |
33 | |
34 typedef std::deque<QuicPathIdPacketNumber> MultipathTransmissionsList; | |
35 typedef std::unordered_map<QuicPathIdPacketNumber, | |
36 MultipathTransmissionsList*, | |
37 QuicPathIdPacketNumberHash> | |
38 MultipathTransmissionsMap; | |
39 | |
40 QuicMultipathTransmissionsMap(); | |
41 ~QuicMultipathTransmissionsMap(); | |
42 | |
43 // Called when a packet is retransmitted on a different path. Adds both | |
44 // |original_path_id_packet_number| (if not exists) and | |
45 // |path_id_packet_number| to |transmission_map_|. | |
46 void OnPacketRetransmittedOnDifferentPath( | |
47 QuicPathIdPacketNumber original_path_id_packet_number, | |
48 QuicPathIdPacketNumber path_id_packet_number); | |
49 | |
50 // Returns all multipath transmissions list if |path_id_packet_number| has | |
51 // been transmitted across multiple paths, nullptr otherwise. | |
52 const MultipathTransmissionsList* MaybeGetTransmissionsOnOtherPaths( | |
53 QuicPathIdPacketNumber path_id_packet_number) const; | |
54 | |
55 // Called after packet |path_id_packet_number| is received. | |
56 // If |path_id_packet_number| has been transmitted across multiple paths, | |
57 // clears all multipath transmissions list and removes each transmission from | |
58 // |transmission_map_|, does nothing otherwise. | |
59 void OnPacketHandled(QuicPathIdPacketNumber path_id_packet_number); | |
60 | |
61 private: | |
62 // Keys of the map are QuicPathIdPacketNumber, and values are pointers to | |
63 // lists of multipath transmissions of the same packet. For example, if a | |
64 // packet has been transmitted as (1, 1) and (2, 1), two entries are added | |
65 // to this map and both values point to the same list: {(1, 1), (2, 1)}. | |
66 // The MultipathTransmissionsList is owned by the transmission which is | |
67 // received first (on any path). | |
68 MultipathTransmissionsMap transmission_map_; | |
69 }; | |
70 | |
71 } // namespace net | |
72 | |
73 #endif // NET_QUIC_QUIC_MULTIPATH_TRANSMISSIONS_MAP_H_ | |
OLD | NEW |