route/vendor/github.com/lucas-clemente/quic-go/internal/protocol/protocol.go

88 lines
2.8 KiB
Go
Raw Normal View History

2017-12-12 02:51:45 +00:00
package protocol
2018-01-03 19:19:49 +00:00
import (
"fmt"
)
2017-12-12 02:51:45 +00:00
// A PacketNumber in QUIC
type PacketNumber uint64
// PacketNumberLen is the length of the packet number in bytes
type PacketNumberLen uint8
const (
// PacketNumberLenInvalid is the default value and not a valid length for a packet number
PacketNumberLenInvalid PacketNumberLen = 0
// PacketNumberLen1 is a packet number length of 1 byte
PacketNumberLen1 PacketNumberLen = 1
// PacketNumberLen2 is a packet number length of 2 bytes
PacketNumberLen2 PacketNumberLen = 2
// PacketNumberLen4 is a packet number length of 4 bytes
PacketNumberLen4 PacketNumberLen = 4
// PacketNumberLen6 is a packet number length of 6 bytes
PacketNumberLen6 PacketNumberLen = 6
)
2018-01-03 19:19:49 +00:00
// The PacketType is the Long Header Type (only used for the IETF draft header format)
type PacketType uint8
const (
// PacketTypeInitial is the packet type of a Initial packet
PacketTypeInitial PacketType = 2
// PacketTypeRetry is the packet type of a Retry packet
PacketTypeRetry PacketType = 3
// PacketTypeHandshake is the packet type of a Cleartext packet
PacketTypeHandshake PacketType = 4
// PacketType0RTT is the packet type of a 0-RTT packet
PacketType0RTT PacketType = 5
)
func (t PacketType) String() string {
switch t {
case PacketTypeInitial:
return "Initial"
case PacketTypeRetry:
return "Retry"
case PacketTypeHandshake:
return "Handshake"
case PacketType0RTT:
return "0-RTT Protected"
default:
return fmt.Sprintf("unknown packet type: %d", t)
}
}
2017-12-12 02:51:45 +00:00
// A ConnectionID in QUIC
type ConnectionID uint64
// A StreamID in QUIC
2018-01-03 19:19:49 +00:00
type StreamID uint64
2017-12-12 02:51:45 +00:00
// A ByteCount in QUIC
type ByteCount uint64
// MaxByteCount is the maximum value of a ByteCount
2018-01-03 19:19:49 +00:00
const MaxByteCount = ByteCount(1<<62 - 1)
2017-12-12 02:51:45 +00:00
// MaxReceivePacketSize maximum packet size of any QUIC packet, based on
// ethernet's max size, minus the IP and UDP headers. IPv6 has a 40 byte header,
// UDP adds an additional 8 bytes. This is a total overhead of 48 bytes.
// Ethernet's max packet size is 1500 bytes, 1500 - 48 = 1452.
const MaxReceivePacketSize ByteCount = 1452
// DefaultTCPMSS is the default maximum packet size used in the Linux TCP implementation.
// Used in QUIC for congestion window computations in bytes.
const DefaultTCPMSS ByteCount = 1460
2018-01-03 19:19:49 +00:00
// MinClientHelloSize is the minimum size the server expects an inchoate CHLO to have (in gQUIC)
const MinClientHelloSize = 1024
2017-12-12 02:51:45 +00:00
2018-01-03 19:19:49 +00:00
// MinInitialPacketSize is the minimum size an Initial packet (in IETF QUIC) is requried to have.
const MinInitialPacketSize = 1200
2017-12-12 02:51:45 +00:00
// MaxClientHellos is the maximum number of times we'll send a client hello
// The value 3 accounts for:
// * one failure due to an incorrect or missing source-address token
// * one failure due the server's certificate chain being unavailible and the server being unwilling to send it without a valid source-address token
const MaxClientHellos = 3