Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: net/quic/core/congestion_control/simulation/link.h

Issue 2323963002: Implement an event-based simulator for QuicConnection (Closed)
Patch Set: Adding missing files. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #ifndef NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_LINK_H_
2 #define NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_LINK_H_
3
4 #include <queue>
5 #include <utility>
6
7 #include "net/quic/core/congestion_control/simulation/actor.h"
8 #include "net/quic/core/congestion_control/simulation/port.h"
9 #include "net/quic/core/crypto/quic_random.h"
10
11 namespace net {
12 namespace simulation {
13
14 // A reliable simplex link between two endpoints with constrained bandwidth. A
15 // few microseconds of random delay are added for every packet to avoid
16 // synchronization issues.
17 class OneWayLink : public Actor, public ConstrainedPortInterface {
18 public:
19 OneWayLink(Simulator* simulator,
20 std::std::string name,
21 UnconstrainedPortInterface* sink,
22 QuicBandwidth bandwidth,
23 QuicTime::Delta propagation_delay);
24
25 void AcceptPacket(std::unique_ptr<Packet> packet) override;
26 QuicTime::Delta TimeUntilAvailable() override;
27 void Act() override;
28
29 inline QuicBandwidth bandwidth() const { return bandwidth_; }
30 inline QuicTime::Delta propagation_delay() const {
31 return propagation_delay_;
32 }
33
34 private:
35 struct QueuedPacket {
36 std::unique_ptr<Packet> packet;
37 QuicTime std::dequeue_time;
38
39 QueuedPacket(std::unique_ptr<Packet> packet, QuicTime std::dequeue_time);
40 };
41
42 // Schedule the next packet to be egressed out of the link if there are
43 // packets on the link.
44 void ScheduleNextPacketDeparture();
45
46 // Get the value of a random delay imposed on each packet in order to avoid
47 // artifical synchronization artifacts during the simulation.
48 QuicTime::Delta GetRandomDelay(QuicTime::Delta transfer_time);
49
50 UnconstrainedPortInterface* sink_;
51 std::queue<QueuedPacket> packets_in_transit_;
52
53 const QuicBandwidth bandwidth_;
54 const QuicTime::Delta propagation_delay_;
55
56 QuicTime next_write_at_;
57
58 DISALLOW_COPY_AND_ASSIGN(OneWayLink);
59 };
60
61 // A full-duplex link between two endpoints, functionally equivalent to two
62 // OneWayLink objects tied together.
63 class SymmetricLink {
64 public:
65 SymmetricLink(Simulator* simulator,
66 std::std::string name,
67 UnconstrainedPortInterface* sink_a,
68 UnconstrainedPortInterface* sink_b,
69 QuicBandwidth bandwidth,
70 QuicTime::Delta propagation_delay);
71 SymmetricLink(Endpoint* endpoint_a,
72 Endpoint* endpoint_b,
73 QuicBandwidth bandwidth,
74 QuicTime::Delta propagation_delay);
75
76 inline ConstrainedPortInterface* GetTxPortForA() { return &a_to_b_link_; }
77 inline ConstrainedPortInterface* GetTxPortForB() { return &b_to_a_link_; }
78
79 inline QuicBandwidth bandwidth() { return a_to_b_link_.bandwidth(); }
80 inline QuicTime::Delta propagation_delay() {
81 return a_to_b_link_.propagation_delay();
82 }
83
84 private:
85 OneWayLink a_to_b_link_;
86 OneWayLink b_to_a_link_;
87
88 DISALLOW_COPY_AND_ASSIGN(SymmetricLink);
89 };
90
91 } // namespace simulation
92 } // namespace net
93
94 #endif // NET_QUIC_CORE_CONGESTION_CONTROL_SIMULATION_LINK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698