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

Side by Side Diff: net/quic/quic_packet_generator.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « net/quic/quic_packet_generator.h ('k') | net/quic/quic_packet_generator_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/quic_packet_generator.h" 5 #include "net/quic/quic_packet_generator.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "net/quic/quic_fec_group.h" 9 #include "net/quic/quic_fec_group.h"
10 #include "net/quic/quic_utils.h" 10 #include "net/quic/quic_utils.h"
11 11
12 using base::StringPiece; 12 using base::StringPiece;
13 13
14 namespace net { 14 namespace net {
15 15
16 namespace { 16 namespace {
17 17
18 // We want to put some space between a protected packet and the FEC packet to 18 // We want to put some space between a protected packet and the FEC packet to
19 // avoid losing them both within the same loss episode. On the other hand, 19 // avoid losing them both within the same loss episode. On the other hand,
20 // we expect to be able to recover from any loss in about an RTT. 20 // we expect to be able to recover from any loss in about an RTT.
21 // We resolve this tradeoff by sending an FEC packet atmost half an RTT, 21 // We resolve this tradeoff by sending an FEC packet atmost half an RTT,
22 // or equivalently, half a cwnd, after the first protected packet. Since we 22 // or equivalently, half the max number of in-flight packets, the first
23 // don't want to delay an FEC packet past half an RTT, we set the max FEC 23 // protected packet. Since we don't want to delay an FEC packet past half an
24 // group size to be half the current congestion window. 24 // RTT, we set the max FEC group size to be half the current congestion window.
25 const float kCongestionWindowMultiplierForFecGroupSize = 0.5; 25 const float kMaxPacketsInFlightMultiplierForFecGroupSize = 0.5;
26 26
27 } // namespace 27 } // namespace
28 28
29 class QuicAckNotifier; 29 class QuicAckNotifier;
30 30
31 QuicPacketGenerator::QuicPacketGenerator(QuicConnectionId connection_id, 31 QuicPacketGenerator::QuicPacketGenerator(QuicConnectionId connection_id,
32 QuicFramer* framer, 32 QuicFramer* framer,
33 QuicRandom* random_generator, 33 QuicRandom* random_generator,
34 DelegateInterface* delegate) 34 DelegateInterface* delegate)
35 : delegate_(delegate), 35 : delegate_(delegate),
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 case PING_FRAME: 78 case PING_FRAME:
79 delete it->ping_frame; 79 delete it->ping_frame;
80 break; 80 break;
81 case NUM_FRAME_TYPES: 81 case NUM_FRAME_TYPES:
82 DCHECK(false) << "Cannot delete type: " << it->type; 82 DCHECK(false) << "Cannot delete type: " << it->type;
83 } 83 }
84 } 84 }
85 } 85 }
86 86
87 void QuicPacketGenerator::OnCongestionWindowChange( 87 void QuicPacketGenerator::OnCongestionWindowChange(
88 QuicByteCount congestion_window) { 88 QuicPacketCount max_packets_in_flight) {
89 packet_creator_.set_max_packets_per_fec_group( 89 packet_creator_.set_max_packets_per_fec_group(
90 static_cast<size_t>(kCongestionWindowMultiplierForFecGroupSize * 90 static_cast<size_t>(kMaxPacketsInFlightMultiplierForFecGroupSize *
91 congestion_window / kDefaultTCPMSS)); 91 max_packets_in_flight));
92 } 92 }
93 93
94 void QuicPacketGenerator::SetShouldSendAck(bool also_send_feedback, 94 void QuicPacketGenerator::SetShouldSendAck(bool also_send_feedback,
95 bool also_send_stop_waiting) { 95 bool also_send_stop_waiting) {
96 should_send_ack_ = true; 96 should_send_ack_ = true;
97 should_send_feedback_ = also_send_feedback; 97 should_send_feedback_ = also_send_feedback;
98 should_send_stop_waiting_ = also_send_stop_waiting; 98 should_send_stop_waiting_ = also_send_stop_waiting;
99 SendQueuedFrames(false); 99 SendQueuedFrames(false);
100 } 100 }
101 101
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 } 371 }
372 372
373 SerializedPacket QuicPacketGenerator::ReserializeAllFrames( 373 SerializedPacket QuicPacketGenerator::ReserializeAllFrames(
374 const QuicFrames& frames, 374 const QuicFrames& frames,
375 QuicSequenceNumberLength original_length) { 375 QuicSequenceNumberLength original_length) {
376 return packet_creator_.ReserializeAllFrames(frames, original_length); 376 return packet_creator_.ReserializeAllFrames(frames, original_length);
377 } 377 }
378 378
379 void QuicPacketGenerator::UpdateSequenceNumberLength( 379 void QuicPacketGenerator::UpdateSequenceNumberLength(
380 QuicPacketSequenceNumber least_packet_awaited_by_peer, 380 QuicPacketSequenceNumber least_packet_awaited_by_peer,
381 QuicByteCount congestion_window) { 381 QuicPacketCount max_packets_in_flight) {
382 return packet_creator_.UpdateSequenceNumberLength( 382 return packet_creator_.UpdateSequenceNumberLength(
383 least_packet_awaited_by_peer, congestion_window); 383 least_packet_awaited_by_peer, max_packets_in_flight);
384 } 384 }
385 385
386 void QuicPacketGenerator::SetConnectionIdLength(uint32 length) { 386 void QuicPacketGenerator::SetConnectionIdLength(uint32 length) {
387 if (length == 0) { 387 if (length == 0) {
388 packet_creator_.set_connection_id_length(PACKET_0BYTE_CONNECTION_ID); 388 packet_creator_.set_connection_id_length(PACKET_0BYTE_CONNECTION_ID);
389 } else if (length == 1) { 389 } else if (length == 1) {
390 packet_creator_.set_connection_id_length(PACKET_1BYTE_CONNECTION_ID); 390 packet_creator_.set_connection_id_length(PACKET_1BYTE_CONNECTION_ID);
391 } else if (length <= 4) { 391 } else if (length <= 4) {
392 packet_creator_.set_connection_id_length(PACKET_4BYTE_CONNECTION_ID); 392 packet_creator_.set_connection_id_length(PACKET_4BYTE_CONNECTION_ID);
393 } else { 393 } else {
394 packet_creator_.set_connection_id_length(PACKET_8BYTE_CONNECTION_ID); 394 packet_creator_.set_connection_id_length(PACKET_8BYTE_CONNECTION_ID);
395 } 395 }
396 } 396 }
397 397
398 398
399 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) { 399 void QuicPacketGenerator::set_encryption_level(EncryptionLevel level) {
400 packet_creator_.set_encryption_level(level); 400 packet_creator_.set_encryption_level(level);
401 } 401 }
402 402
403 } // namespace net 403 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_packet_generator.h ('k') | net/quic/quic_packet_generator_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698