| Index: net/quic/quic_protocol.h
|
| diff --git a/net/quic/quic_protocol.h b/net/quic/quic_protocol.h
|
| index 3d5f73e94a4a064db53ee3e2221bf547b3ba7274..689167c4ff368ff7b2c3f25aee0adfa0f11e96a5 100644
|
| --- a/net/quic/quic_protocol.h
|
| +++ b/net/quic/quic_protocol.h
|
| @@ -35,6 +35,7 @@ typedef uint64 QuicStreamOffset;
|
| typedef uint64 QuicPacketSequenceNumber;
|
| typedef QuicPacketSequenceNumber QuicFecGroupNumber;
|
| typedef uint64 QuicPublicResetNonceProof;
|
| +typedef uint8 QuicPacketEntropyHash;
|
|
|
| // TODO(rch): Consider Quic specific names for these constants.
|
| // Maximum size in bytes of a QUIC packet.
|
| @@ -105,8 +106,6 @@ const QuicStreamId kCryptoStreamId = 1;
|
| // Value which indicates this packet is not FEC protected.
|
| const uint8 kNoFecOffset = 0xFF;
|
|
|
| -typedef std::pair<QuicPacketSequenceNumber, QuicPacket*> PacketPair;
|
| -
|
| const int64 kDefaultTimeoutUs = 600000000; // 10 minutes.
|
|
|
| enum QuicFrameType {
|
| @@ -116,20 +115,23 @@ enum QuicFrameType {
|
| CONGESTION_FEEDBACK_FRAME,
|
| RST_STREAM_FRAME,
|
| CONNECTION_CLOSE_FRAME,
|
| + GOAWAY_FRAME,
|
| NUM_FRAME_TYPES
|
| };
|
|
|
| enum QuicPacketPublicFlags {
|
| PACKET_PUBLIC_FLAGS_NONE = 0,
|
| - PACKET_PUBLIC_FLAGS_VERSION = 1,
|
| - PACKET_PUBLIC_FLAGS_RST = 2, // Packet is a public reset packet.
|
| - PACKET_PUBLIC_FLAGS_MAX = 3 // Both bit set.
|
| + PACKET_PUBLIC_FLAGS_VERSION = 1 << 0,
|
| + PACKET_PUBLIC_FLAGS_RST = 1 << 1, // Packet is a public reset packet.
|
| + PACKET_PUBLIC_FLAGS_MAX = (1 << 2) - 1 // All bits set.
|
| };
|
|
|
| enum QuicPacketPrivateFlags {
|
| PACKET_PRIVATE_FLAGS_NONE = 0,
|
| - PACKET_PRIVATE_FLAGS_FEC = 1, // Payload is FEC as opposed to frames.
|
| - PACKET_PRIVATE_FLAGS_MAX = PACKET_PRIVATE_FLAGS_FEC
|
| + PACKET_PRIVATE_FLAGS_FEC = 1 << 0, // Payload is FEC as opposed to frames.
|
| + PACKET_PRIVATE_FLAGS_ENTROPY = 1 << 1,
|
| + PACKET_PRIVATE_FLAGS_FEC_ENTROPY = 1 << 2,
|
| + PACKET_PRIVATE_FLAGS_MAX = (1 << 3) - 1 // All bits set.
|
| };
|
|
|
| enum QuicVersion {
|
| @@ -161,6 +163,8 @@ enum QuicErrorCode {
|
| QUIC_INVALID_RST_STREAM_DATA,
|
| // Connection close data is malformed.
|
| QUIC_INVALID_CONNECTION_CLOSE_DATA,
|
| + // GoAway data is malformed.
|
| + QUIC_INVALID_GOAWAY_DATA,
|
| // Ack data is malformed.
|
| QUIC_INVALID_ACK_DATA,
|
| // There was an error decrypting.
|
| @@ -171,10 +175,8 @@ enum QuicErrorCode {
|
| QUIC_PACKET_TOO_LARGE,
|
| // Data was sent for a stream which did not exist.
|
| QUIC_PACKET_FOR_NONEXISTENT_STREAM,
|
| - // The client is going away (browser close, etc.)
|
| - QUIC_CLIENT_GOING_AWAY,
|
| - // The server is going away (restart etc.)
|
| - QUIC_SERVER_GOING_AWAY,
|
| + // The peer is going away. May be a client or server.
|
| + QUIC_PEER_GOING_AWAY,
|
| // A stream ID was invalid.
|
| QUIC_INVALID_STREAM_ID,
|
| // Too many streams already open.
|
| @@ -210,7 +212,8 @@ struct NET_EXPORT_PRIVATE QuicPacketPublicHeader {
|
| // Universal header. All QuicPacket headers will have a guid and public flags.
|
| // TODO(satyamshekhar): Support versioning as per Protocol Negotiation Doc.
|
| QuicGuid guid;
|
| - QuicPacketPublicFlags flags;
|
| + bool reset_flag;
|
| + bool version_flag;
|
| };
|
|
|
| // Header for Data or FEC packets.
|
| @@ -218,8 +221,15 @@ struct QuicPacketHeader {
|
| QuicPacketHeader() {}
|
| explicit QuicPacketHeader(const QuicPacketPublicHeader& header)
|
| : public_header(header) {}
|
| +
|
| + NET_EXPORT_PRIVATE friend std::ostream& operator<<(
|
| + std::ostream& os, const QuicPacketHeader& s);
|
| +
|
| QuicPacketPublicHeader public_header;
|
| - QuicPacketPrivateFlags private_flags;
|
| + bool fec_flag;
|
| + bool fec_entropy_flag;
|
| + bool entropy_flag;
|
| + QuicPacketEntropyHash entropy_hash;
|
| QuicPacketSequenceNumber packet_sequence_number;
|
| QuicFecGroupNumber fec_group;
|
| };
|
| @@ -252,7 +262,7 @@ struct NET_EXPORT_PRIVATE QuicStreamFrame {
|
|
|
| // TODO(ianswett): Re-evaluate the trade-offs of hash_set vs set when framing
|
| // is finalized.
|
| -typedef std::set<QuicPacketSequenceNumber> SequenceSet;
|
| +typedef std::set<QuicPacketSequenceNumber> SequenceNumberSet;
|
| // TODO(pwestin): Add a way to enforce the max size of this map.
|
| typedef std::map<QuicPacketSequenceNumber, QuicTime> TimeMap;
|
|
|
| @@ -262,16 +272,9 @@ struct NET_EXPORT_PRIVATE ReceivedPacketInfo {
|
| NET_EXPORT_PRIVATE friend std::ostream& operator<<(
|
| std::ostream& os, const ReceivedPacketInfo& s);
|
|
|
| - // Records a packet receipt.
|
| - void RecordReceived(QuicPacketSequenceNumber sequence_number);
|
| -
|
| - // True if the sequence number is greater than largest_observed or is listed
|
| - // as missing.
|
| - // Always returns false for sequence numbers less than least_unacked.
|
| - bool IsAwaitingPacket(QuicPacketSequenceNumber sequence_number) const;
|
| -
|
| - // Clears all missing packets less than |least_unacked|.
|
| - void ClearMissingBefore(QuicPacketSequenceNumber least_unacked);
|
| + // Entropy hash of all packets up to largest observed not including missing
|
| + // packets.
|
| + QuicPacketEntropyHash entropy_hash;
|
|
|
| // The highest packet sequence number we've observed from the peer.
|
| //
|
| @@ -283,16 +286,34 @@ struct NET_EXPORT_PRIVATE ReceivedPacketInfo {
|
| // list.
|
| QuicPacketSequenceNumber largest_observed;
|
|
|
| + // TODO(satyamshekhar): Can be optimized using an interval set like data
|
| + // structure.
|
| // The set of packets which we're expecting and have not received.
|
| - SequenceSet missing_packets;
|
| + SequenceNumberSet missing_packets;
|
| };
|
|
|
| +// True if the sequence number is greater than largest_observed or is listed
|
| +// as missing.
|
| +// Always returns false for sequence numbers less than least_unacked.
|
| +bool NET_EXPORT_PRIVATE IsAwaitingPacket(
|
| + const ReceivedPacketInfo& received_info,
|
| + QuicPacketSequenceNumber sequence_number);
|
| +
|
| +// Inserts missing packets between [lower, higher).
|
| +void NET_EXPORT_PRIVATE InsertMissingPacketsBetween(
|
| + ReceivedPacketInfo* received_info,
|
| + QuicPacketSequenceNumber lower,
|
| + QuicPacketSequenceNumber higher);
|
| +
|
| struct NET_EXPORT_PRIVATE SentPacketInfo {
|
| SentPacketInfo();
|
| ~SentPacketInfo();
|
| NET_EXPORT_PRIVATE friend std::ostream& operator<<(
|
| std::ostream& os, const SentPacketInfo& s);
|
|
|
| + // Entropy hash of all packets up to, but not including, the least unacked
|
| + // packet.
|
| + QuicPacketEntropyHash entropy_hash;
|
| // The lowest packet we've sent which is unacked, and we expect an ack for.
|
| QuicPacketSequenceNumber least_unacked;
|
| };
|
| @@ -356,14 +377,12 @@ struct NET_EXPORT_PRIVATE QuicCongestionFeedbackFrame {
|
|
|
| struct NET_EXPORT_PRIVATE QuicRstStreamFrame {
|
| QuicRstStreamFrame() {}
|
| - QuicRstStreamFrame(QuicStreamId stream_id, uint64 offset,
|
| - QuicErrorCode error_code)
|
| - : stream_id(stream_id), offset(offset), error_code(error_code) {
|
| + QuicRstStreamFrame(QuicStreamId stream_id, QuicErrorCode error_code)
|
| + : stream_id(stream_id), error_code(error_code) {
|
| DCHECK_LE(error_code, std::numeric_limits<uint8>::max());
|
| }
|
|
|
| QuicStreamId stream_id;
|
| - uint64 offset;
|
| QuicErrorCode error_code;
|
| std::string error_details;
|
| };
|
| @@ -374,6 +393,17 @@ struct NET_EXPORT_PRIVATE QuicConnectionCloseFrame {
|
| QuicAckFrame ack_frame;
|
| };
|
|
|
| +struct NET_EXPORT_PRIVATE QuicGoAwayFrame {
|
| + QuicGoAwayFrame() {}
|
| + QuicGoAwayFrame(QuicErrorCode error_code,
|
| + QuicStreamId last_good_stream_id,
|
| + const std::string& reason);
|
| +
|
| + QuicErrorCode error_code;
|
| + QuicStreamId last_good_stream_id;
|
| + std::string reason_phrase;
|
| +};
|
| +
|
| struct NET_EXPORT_PRIVATE QuicFrame {
|
| QuicFrame() {}
|
| explicit QuicFrame(QuicPaddingFrame* padding_frame)
|
| @@ -400,6 +430,10 @@ struct NET_EXPORT_PRIVATE QuicFrame {
|
| : type(CONNECTION_CLOSE_FRAME),
|
| connection_close_frame(frame) {
|
| }
|
| + explicit QuicFrame(QuicGoAwayFrame* frame)
|
| + : type(GOAWAY_FRAME),
|
| + goaway_frame(frame) {
|
| + }
|
|
|
| QuicFrameType type;
|
| union {
|
| @@ -409,6 +443,7 @@ struct NET_EXPORT_PRIVATE QuicFrame {
|
| QuicCongestionFeedbackFrame* congestion_feedback_frame;
|
| QuicRstStreamFrame* rst_stream_frame;
|
| QuicConnectionCloseFrame* connection_close_frame;
|
| + QuicGoAwayFrame* goaway_frame;
|
| };
|
| };
|
|
|
| @@ -464,8 +499,8 @@ class NET_EXPORT_PRIVATE QuicData {
|
| class NET_EXPORT_PRIVATE QuicPacket : public QuicData {
|
| public:
|
| static QuicPacket* NewDataPacket(char* buffer,
|
| - size_t length,
|
| - bool owns_buffer) {
|
| + size_t length,
|
| + bool owns_buffer) {
|
| return new QuicPacket(buffer, length, owns_buffer, false);
|
| }
|
|
|
| @@ -530,6 +565,43 @@ class NET_EXPORT_PRIVATE QuicEncryptedPacket : public QuicData {
|
| DISALLOW_COPY_AND_ASSIGN(QuicEncryptedPacket);
|
| };
|
|
|
| +class NET_EXPORT_PRIVATE RetransmittableFrames {
|
| + public:
|
| + RetransmittableFrames();
|
| + ~RetransmittableFrames();
|
| +
|
| + // Allocates a local copy of the referenced StringPiece has QuicStreamFrame
|
| + // use it.
|
| + // Takes ownership of |stream_frame|.
|
| + const QuicFrame& AddStreamFrame(QuicStreamFrame* stream_frame);
|
| + // Takes ownership of the frame inside |frame|.
|
| + const QuicFrame& AddNonStreamFrame(const QuicFrame& frame);
|
| + const QuicFrames& frames() const { return frames_; }
|
| +
|
| + private:
|
| + QuicFrames frames_;
|
| + // Data referenced by the StringPiece of a QuicStreamFrame.
|
| + std::vector<std::string*> stream_data_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(RetransmittableFrames);
|
| +};
|
| +
|
| +struct NET_EXPORT_PRIVATE SerializedPacket {
|
| + SerializedPacket(QuicPacketSequenceNumber sequence_number,
|
| + QuicPacket* packet,
|
| + QuicPacketEntropyHash entropy_hash,
|
| + RetransmittableFrames* retransmittable_frames)
|
| + : sequence_number(sequence_number),
|
| + packet(packet),
|
| + entropy_hash(entropy_hash),
|
| + retransmittable_frames(retransmittable_frames) { }
|
| +
|
| + QuicPacketSequenceNumber sequence_number;
|
| + QuicPacket* packet;
|
| + QuicPacketEntropyHash entropy_hash;
|
| + RetransmittableFrames* retransmittable_frames;
|
| +};
|
| +
|
| // A struct for functions which consume data payloads and fins.
|
| // The first member of the pair indicates bytes consumed.
|
| // The second member of the pair indicates if an incoming fin was consumed.
|
|
|