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

Side by Side Diff: net/quic/quic_connection.h

Issue 1782143003: Remove FEC code from receive path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@115997404
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | net/quic/quic_connection.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 // The entity that handles framing writes for a Quic client or server. 5 // The entity that handles framing writes for a Quic client or server.
6 // Each QuicSession will have a connection associated with it. 6 // Each QuicSession will have a connection associated with it.
7 // 7 //
8 // On the server side, the Dispatcher handles the raw reads, and hands off 8 // On the server side, the Dispatcher handles the raw reads, and hands off
9 // packets via ProcessUdpPacket for framing and processing. 9 // packets via ProcessUdpPacket for framing and processing.
10 // 10 //
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "net/quic/quic_sent_packet_manager.h" 47 #include "net/quic/quic_sent_packet_manager.h"
48 #include "net/quic/quic_time.h" 48 #include "net/quic/quic_time.h"
49 #include "net/quic/quic_types.h" 49 #include "net/quic/quic_types.h"
50 50
51 namespace net { 51 namespace net {
52 52
53 class QuicClock; 53 class QuicClock;
54 class QuicConfig; 54 class QuicConfig;
55 class QuicConnection; 55 class QuicConnection;
56 class QuicEncrypter; 56 class QuicEncrypter;
57 class QuicFecGroup;
58 class QuicRandom; 57 class QuicRandom;
59 58
60 namespace test { 59 namespace test {
61 class PacketSavingConnection; 60 class PacketSavingConnection;
62 class QuicConnectionPeer; 61 class QuicConnectionPeer;
63 } // namespace test 62 } // namespace test
64 63
65 // The initial number of packets between MTU probes. After each attempt the 64 // The initial number of packets between MTU probes. After each attempt the
66 // number is doubled. 65 // number is doubled.
67 const QuicPacketCount kPacketsBetweenMtuProbesBase = 100; 66 const QuicPacketCount kPacketsBetweenMtuProbesBase = 100;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // Called when a PathCloseFrame has been parsed. 226 // Called when a PathCloseFrame has been parsed.
228 virtual void OnPathCloseFrame(const QuicPathCloseFrame& frame) {} 227 virtual void OnPathCloseFrame(const QuicPathCloseFrame& frame) {}
229 228
230 // Called when a public reset packet has been received. 229 // Called when a public reset packet has been received.
231 virtual void OnPublicResetPacket(const QuicPublicResetPacket& packet) {} 230 virtual void OnPublicResetPacket(const QuicPublicResetPacket& packet) {}
232 231
233 // Called when a version negotiation packet has been received. 232 // Called when a version negotiation packet has been received.
234 virtual void OnVersionNegotiationPacket( 233 virtual void OnVersionNegotiationPacket(
235 const QuicVersionNegotiationPacket& packet) {} 234 const QuicVersionNegotiationPacket& packet) {}
236 235
237 // Called after a packet has been successfully parsed which results
238 // in the revival of a packet via FEC.
239 virtual void OnRevivedPacket(const QuicPacketHeader& revived_header,
240 base::StringPiece payload) {}
241
242 // Called when the connection is closed. 236 // Called when the connection is closed.
243 virtual void OnConnectionClosed(QuicErrorCode error, 237 virtual void OnConnectionClosed(QuicErrorCode error,
244 ConnectionCloseSource source) {} 238 ConnectionCloseSource source) {}
245 239
246 // Called when the version negotiation is successful. 240 // Called when the version negotiation is successful.
247 virtual void OnSuccessfulVersionNegotiation(const QuicVersion& version) {} 241 virtual void OnSuccessfulVersionNegotiation(const QuicVersion& version) {}
248 242
249 // Called when a CachedNetworkParameters is sent to the client. 243 // Called when a CachedNetworkParameters is sent to the client.
250 virtual void OnSendConnectionState( 244 virtual void OnSendConnectionState(
251 const CachedNetworkParameters& cached_network_params) {} 245 const CachedNetworkParameters& cached_network_params) {}
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 377
384 // Sends a GOAWAY frame. Does nothing if a GOAWAY frame has already been sent. 378 // Sends a GOAWAY frame. Does nothing if a GOAWAY frame has already been sent.
385 virtual void SendGoAway(QuicErrorCode error, 379 virtual void SendGoAway(QuicErrorCode error,
386 QuicStreamId last_good_stream_id, 380 QuicStreamId last_good_stream_id,
387 const std::string& reason); 381 const std::string& reason);
388 382
389 // Returns statistics tracked for this connection. 383 // Returns statistics tracked for this connection.
390 const QuicConnectionStats& GetStats(); 384 const QuicConnectionStats& GetStats();
391 385
392 // Processes an incoming UDP packet (consisting of a QuicEncryptedPacket) from 386 // Processes an incoming UDP packet (consisting of a QuicEncryptedPacket) from
393 // the peer. If processing this packet permits a packet to be revived from 387 // the peer.
394 // its FEC group that packet will be revived and processed.
395 // In a client, the packet may be "stray" and have a different connection ID 388 // In a client, the packet may be "stray" and have a different connection ID
396 // than that of this connection. 389 // than that of this connection.
397 virtual void ProcessUdpPacket(const IPEndPoint& self_address, 390 virtual void ProcessUdpPacket(const IPEndPoint& self_address,
398 const IPEndPoint& peer_address, 391 const IPEndPoint& peer_address,
399 const QuicEncryptedPacket& packet); 392 const QuicEncryptedPacket& packet);
400 393
401 // QuicBlockedWriterInterface 394 // QuicBlockedWriterInterface
402 // Called when the underlying connection becomes writable to allow queued 395 // Called when the underlying connection becomes writable to allow queued
403 // writes to happen. 396 // writes to happen.
404 void OnCanWrite() override; 397 void OnCanWrite() override;
(...skipping 30 matching lines...) Expand all
435 return framer_.supported_versions(); 428 return framer_.supported_versions();
436 } 429 }
437 430
438 // From QuicFramerVisitorInterface 431 // From QuicFramerVisitorInterface
439 void OnError(QuicFramer* framer) override; 432 void OnError(QuicFramer* framer) override;
440 bool OnProtocolVersionMismatch(QuicVersion received_version) override; 433 bool OnProtocolVersionMismatch(QuicVersion received_version) override;
441 void OnPacket() override; 434 void OnPacket() override;
442 void OnPublicResetPacket(const QuicPublicResetPacket& packet) override; 435 void OnPublicResetPacket(const QuicPublicResetPacket& packet) override;
443 void OnVersionNegotiationPacket( 436 void OnVersionNegotiationPacket(
444 const QuicVersionNegotiationPacket& packet) override; 437 const QuicVersionNegotiationPacket& packet) override;
445 void OnRevivedPacket() override;
446 bool OnUnauthenticatedPublicHeader( 438 bool OnUnauthenticatedPublicHeader(
447 const QuicPacketPublicHeader& header) override; 439 const QuicPacketPublicHeader& header) override;
448 bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override; 440 bool OnUnauthenticatedHeader(const QuicPacketHeader& header) override;
449 void OnDecryptedPacket(EncryptionLevel level) override; 441 void OnDecryptedPacket(EncryptionLevel level) override;
450 bool OnPacketHeader(const QuicPacketHeader& header) override; 442 bool OnPacketHeader(const QuicPacketHeader& header) override;
451 void OnFecProtectedPayload(base::StringPiece payload) override;
452 bool OnStreamFrame(const QuicStreamFrame& frame) override; 443 bool OnStreamFrame(const QuicStreamFrame& frame) override;
453 bool OnAckFrame(const QuicAckFrame& frame) override; 444 bool OnAckFrame(const QuicAckFrame& frame) override;
454 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override; 445 bool OnStopWaitingFrame(const QuicStopWaitingFrame& frame) override;
455 bool OnPingFrame(const QuicPingFrame& frame) override; 446 bool OnPingFrame(const QuicPingFrame& frame) override;
456 bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override; 447 bool OnRstStreamFrame(const QuicRstStreamFrame& frame) override;
457 bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override; 448 bool OnConnectionCloseFrame(const QuicConnectionCloseFrame& frame) override;
458 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override; 449 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override;
459 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; 450 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override;
460 bool OnBlockedFrame(const QuicBlockedFrame& frame) override; 451 bool OnBlockedFrame(const QuicBlockedFrame& frame) override;
461 bool OnPathCloseFrame(const QuicPathCloseFrame& frame) override; 452 bool OnPathCloseFrame(const QuicPathCloseFrame& frame) override;
462 void OnFecData(base::StringPiece redundnancy) override;
463 void OnPacketComplete() override; 453 void OnPacketComplete() override;
464 454
465 // QuicPacketGenerator::DelegateInterface 455 // QuicPacketGenerator::DelegateInterface
466 bool ShouldGeneratePacket(HasRetransmittableData retransmittable, 456 bool ShouldGeneratePacket(HasRetransmittableData retransmittable,
467 IsHandshake handshake) override; 457 IsHandshake handshake) override;
468 void PopulateAckFrame(QuicAckFrame* ack) override; 458 void PopulateAckFrame(QuicAckFrame* ack) override;
469 void PopulateStopWaitingFrame(QuicStopWaitingFrame* stop_waiting) override; 459 void PopulateStopWaitingFrame(QuicStopWaitingFrame* stop_waiting) override;
470 460
471 // QuicPacketCreator::DelegateInterface 461 // QuicPacketCreator::DelegateInterface
472 void OnSerializedPacket(SerializedPacket* packet) override; 462 void OnSerializedPacket(SerializedPacket* packet) override;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 bool goaway_sent() const { return goaway_sent_; } 500 bool goaway_sent() const { return goaway_sent_; }
511 501
512 bool goaway_received() const { return goaway_received_; } 502 bool goaway_received() const { return goaway_received_; }
513 503
514 // Must only be called on client connections. 504 // Must only be called on client connections.
515 const QuicVersionVector& server_supported_versions() const { 505 const QuicVersionVector& server_supported_versions() const {
516 DCHECK_EQ(Perspective::IS_CLIENT, perspective_); 506 DCHECK_EQ(Perspective::IS_CLIENT, perspective_);
517 return server_supported_versions_; 507 return server_supported_versions_;
518 } 508 }
519 509
520 size_t NumFecGroups() const { return group_map_.size(); }
521
522 // Testing only. 510 // Testing only.
523 size_t NumQueuedPackets() const { return queued_packets_.size(); } 511 size_t NumQueuedPackets() const { return queued_packets_.size(); }
524 512
525 // Once called, any sent crypto packets to be saved as the 513 // Once called, any sent crypto packets to be saved as the
526 // termination packet, for use with stateless rejections. 514 // termination packet, for use with stateless rejections.
527 void EnableSavingCryptoPackets(); 515 void EnableSavingCryptoPackets();
528 516
529 // Returns true if the underlying UDP socket is writable, there is 517 // Returns true if the underlying UDP socket is writable, there is
530 // no queued data and the connection is not congestion-control 518 // no queued data and the connection is not congestion-control
531 // blocked. 519 // blocked.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 // sent immediately after receiving an ACK. 701 // sent immediately after receiving an ACK.
714 void set_defer_send_in_response_to_packets(bool defer) { 702 void set_defer_send_in_response_to_packets(bool defer) {
715 defer_send_in_response_to_packets_ = defer; 703 defer_send_in_response_to_packets_ = defer;
716 } 704 }
717 705
718 private: 706 private:
719 friend class test::QuicConnectionPeer; 707 friend class test::QuicConnectionPeer;
720 friend class test::PacketSavingConnection; 708 friend class test::PacketSavingConnection;
721 709
722 typedef std::list<SerializedPacket> QueuedPacketList; 710 typedef std::list<SerializedPacket> QueuedPacketList;
723 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap;
724 711
725 // Writes the given packet to socket, encrypted with packet's 712 // Writes the given packet to socket, encrypted with packet's
726 // encryption_level. Returns true on successful write, and false if the writer 713 // encryption_level. Returns true on successful write, and false if the writer
727 // was blocked and the write needs to be tried again. Notifies the 714 // was blocked and the write needs to be tried again. Notifies the
728 // SentPacketManager when the write is successful and sets 715 // SentPacketManager when the write is successful and sets
729 // retransmittable frames to nullptr. 716 // retransmittable frames to nullptr.
730 // Saves the connection close packet for later transmission, even if the 717 // Saves the connection close packet for later transmission, even if the
731 // writer is write blocked. 718 // writer is write blocked.
732 bool WritePacket(SerializedPacket* packet); 719 bool WritePacket(SerializedPacket* packet);
733 720
(...skipping 30 matching lines...) Expand all
764 // Returns true if the packet should be discarded and not sent. 751 // Returns true if the packet should be discarded and not sent.
765 bool ShouldDiscardPacket(const SerializedPacket& packet); 752 bool ShouldDiscardPacket(const SerializedPacket& packet);
766 753
767 // Queues |packet| in the hopes that it can be decrypted in the 754 // Queues |packet| in the hopes that it can be decrypted in the
768 // future, when a new key is installed. 755 // future, when a new key is installed.
769 void QueueUndecryptablePacket(const QuicEncryptedPacket& packet); 756 void QueueUndecryptablePacket(const QuicEncryptedPacket& packet);
770 757
771 // Attempts to process any queued undecryptable packets. 758 // Attempts to process any queued undecryptable packets.
772 void MaybeProcessUndecryptablePackets(); 759 void MaybeProcessUndecryptablePackets();
773 760
774 // If a packet can be revived from the current FEC group, then
775 // revive and process the packet.
776 void MaybeProcessRevivedPacket();
777
778 void ProcessAckFrame(const QuicAckFrame& incoming_ack); 761 void ProcessAckFrame(const QuicAckFrame& incoming_ack);
779 762
780 void ProcessStopWaitingFrame(const QuicStopWaitingFrame& stop_waiting); 763 void ProcessStopWaitingFrame(const QuicStopWaitingFrame& stop_waiting);
781 764
782 // Sends any packets which are a response to the last packet, including both 765 // Sends any packets which are a response to the last packet, including both
783 // acks and pending writes if an ack opened the congestion window. 766 // acks and pending writes if an ack opened the congestion window.
784 void MaybeSendInResponseToPacket(); 767 void MaybeSendInResponseToPacket();
785 768
786 // Queue an ack or set the ack alarm if needed. |was_missing| is true if 769 // Queue an ack or set the ack alarm if needed. |was_missing| is true if
787 // the most recently received packet was formerly missing. 770 // the most recently received packet was formerly missing.
788 void MaybeQueueAck(bool was_missing); 771 void MaybeQueueAck(bool was_missing);
789 772
790 // Gets the least unacked packet number, which is the next packet number 773 // Gets the least unacked packet number, which is the next packet number
791 // to be sent if there are no outstanding packets. 774 // to be sent if there are no outstanding packets.
792 QuicPacketNumber GetLeastUnacked() const; 775 QuicPacketNumber GetLeastUnacked() const;
793 776
794 // Get the FEC group associate with the last processed packet or nullptr, if
795 // the group has already been deleted.
796 QuicFecGroup* GetFecGroup();
797
798 // Closes any FEC groups protecting packets before |packet_number|.
799 void CloseFecGroupsBefore(QuicPacketNumber packet_number);
800
801 // Sets the timeout alarm to the appropriate value, if any. 777 // Sets the timeout alarm to the appropriate value, if any.
802 void SetTimeoutAlarm(); 778 void SetTimeoutAlarm();
803 779
804 // Sets the ping alarm to the appropriate value, if any. 780 // Sets the ping alarm to the appropriate value, if any.
805 void SetPingAlarm(); 781 void SetPingAlarm();
806 782
807 // Sets the retransmission alarm based on SentPacketManager. 783 // Sets the retransmission alarm based on SentPacketManager.
808 void SetRetransmissionAlarm(); 784 void SetRetransmissionAlarm();
809 785
810 // Sets the MTU discovery alarm if necessary. 786 // Sets the MTU discovery alarm if necessary.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
862 IPEndPoint peer_address_; 838 IPEndPoint peer_address_;
863 839
864 // Used to store latest peer IP address for IP address migration. 840 // Used to store latest peer IP address for IP address migration.
865 IPAddress migrating_peer_ip_; 841 IPAddress migrating_peer_ip_;
866 // Used to store latest peer port to possibly migrate to later. 842 // Used to store latest peer port to possibly migrate to later.
867 uint16_t migrating_peer_port_; 843 uint16_t migrating_peer_port_;
868 844
869 // True if the last packet has gotten far enough in the framer to be 845 // True if the last packet has gotten far enough in the framer to be
870 // decrypted. 846 // decrypted.
871 bool last_packet_decrypted_; 847 bool last_packet_decrypted_;
872 bool last_packet_revived_; // True if the last packet was revived from FEC.
873 QuicByteCount last_size_; // Size of the last received packet. 848 QuicByteCount last_size_; // Size of the last received packet.
874 EncryptionLevel last_decrypted_packet_level_; 849 EncryptionLevel last_decrypted_packet_level_;
875 QuicPacketHeader last_header_; 850 QuicPacketHeader last_header_;
876 QuicStopWaitingFrame last_stop_waiting_frame_; 851 QuicStopWaitingFrame last_stop_waiting_frame_;
877 bool should_last_packet_instigate_acks_; 852 bool should_last_packet_instigate_acks_;
878 853
879 // Track some peer state so we can do less bookkeeping 854 // Track some peer state so we can do less bookkeeping
880 // Largest sequence sent by the peer which had an ack frame (latest ack info). 855 // Largest sequence sent by the peer which had an ack frame (latest ack info).
881 QuicPacketNumber largest_seen_packet_with_ack_; 856 QuicPacketNumber largest_seen_packet_with_ack_;
882 857
(...skipping 24 matching lines...) Expand all
907 bool save_crypto_packets_as_termination_packets_; 882 bool save_crypto_packets_as_termination_packets_;
908 883
909 // Contains the connection close packets if the connection has been closed. 884 // Contains the connection close packets if the connection has been closed.
910 scoped_ptr<std::vector<QuicEncryptedPacket*>> termination_packets_; 885 scoped_ptr<std::vector<QuicEncryptedPacket*>> termination_packets_;
911 886
912 // When true, the connection does not send a close packet on idle timeout due 887 // When true, the connection does not send a close packet on idle timeout due
913 // to lack of network activity. 888 // to lack of network activity.
914 // This is particularly important on mobile, where connections are short. 889 // This is particularly important on mobile, where connections are short.
915 bool silent_close_enabled_; 890 bool silent_close_enabled_;
916 891
917 FecGroupMap group_map_;
918
919 QuicReceivedPacketManager received_packet_manager_; 892 QuicReceivedPacketManager received_packet_manager_;
920 QuicSentEntropyManager sent_entropy_manager_; 893 QuicSentEntropyManager sent_entropy_manager_;
921 894
922 // Indicates whether an ack should be sent the next time we try to write. 895 // Indicates whether an ack should be sent the next time we try to write.
923 bool ack_queued_; 896 bool ack_queued_;
924 // How many retransmittable packets have arrived without sending an ack. 897 // How many retransmittable packets have arrived without sending an ack.
925 QuicPacketCount num_retransmittable_packets_received_since_last_ack_sent_; 898 QuicPacketCount num_retransmittable_packets_received_since_last_ack_sent_;
926 // Whether there were missing packets in the last sent ack. 899 // Whether there were missing packets in the last sent ack.
927 bool last_ack_had_missing_packets_; 900 bool last_ack_had_missing_packets_;
928 // How many consecutive packets have arrived without sending an ack. 901 // How many consecutive packets have arrived without sending an ack.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 1033
1061 // If true, multipath is enabled for this connection. 1034 // If true, multipath is enabled for this connection.
1062 bool multipath_enabled_; 1035 bool multipath_enabled_;
1063 1036
1064 DISALLOW_COPY_AND_ASSIGN(QuicConnection); 1037 DISALLOW_COPY_AND_ASSIGN(QuicConnection);
1065 }; 1038 };
1066 1039
1067 } // namespace net 1040 } // namespace net
1068 1041
1069 #endif // NET_QUIC_QUIC_CONNECTION_H_ 1042 #endif // NET_QUIC_QUIC_CONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698