quic

package module
v0.0.0-...-cf13cda Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2015 License: MIT Imports: 5 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	PaddingFrame         = 0x0
	ResetStreamFrame     = 0x1
	ConnectionCloseFrame = 0x2
	GoAwayFrame          = 0x3
	WindowUpdateFrame    = 0x4
	BlockedFrame         = 0x5
	StopWaitingFrame     = 0x6
	PingFrame            = 0x7

	StreamFrame                 = 0x80
	AckFrameMask                = 0xC0
	AckFrame                    = 0x40
	CongestionFeedbackFrameMask = 0xE0
	CongestionFeedbackFrame     = 0x20
)

Frame Types

View Source
const (
	StreamIDMask = 0x03
	OffsetMask   = 0x1C
	DataLenMask  = 0x20
	FinMask      = 0x40
)

Constants for FrameStream

View Source
const (
	SequenceNumberDeltaLenMask           = 0x03
	LargestObservedSequenceNumberLenMask = 0xC
)

Constants for FrameAck

View Source
const (
	// QuicVersion - LSB 0x1 has value 1 iff the packet contains a Quic Version.  This bit must be set by a client in all packets until confirmation from a server arrives agreeing to the proposed version is received by the client.  A server indicates agreement on a version by sending packets without setting this bit.
	QuicVersion = 0x1
	// PublicReset - Bit at location, 0x2, is set to indicate that the packet is a Public Reset packet.
	PublicReset = 0x2
	// DataPacket is the bitmask for a data packet. If version and public reset aren't set.
	DataPacket = 0x3

	// ConnIDBitMask - Pair of bits, included in 0xC, together indicate the size of the connection ID that is present in the packet, but should be set to set to 0xC in all packets until agreeably negotiated to a different value, for a given direction (e.g., client may request fewer bytes of the connection id be presented).  Within this 2 bit mask:
	ConnIDBitMask = 0xC
	ConnID8Bytes  = 0xC
	ConnID4Bytes  = 0x8
	ConnID1Byte   = 0x4
	ConnIDOmmited = 0x0

	// SequenceNumberBitMask - Pair of bits included in 0x30 indicate the number of low-order-bytes of the packet sequence number that are present in each packet.  Within this 2 bit mask:
	SequenceNumberBitMask = 0x30
	SequenceNumber6Bytes  = 0x30
	SequenceNumber4Bytes  = 0x20
	SequenceNumber2Bytes  = 0x10
	SequenceNumber1Byte   = 0x00
)

Public Flags

View Source
const (
	// FlagEntropy - for data packets, signifies that this packet contains the 1 bit of entropy, for fec packets, contains the xor of the entropy of protected packets.
	FlagEntropy = 0x01
	// FlagFECGroup - indicates whether the fec byte is present.
	FlagFECGroup = 0x02
	// FlagFEC - signifies that this packet represents an FEC packet.
	FlagFEC = 0x04
)

Private Flags

Variables

This section is empty.

Functions

func FloatToUFloat16

func FloatToUFloat16(a float64) []byte

FloatToUFloat16 converts a float64 into a 16 bit unsigned float with 11 explicit bits of mantissa and 5 bits of explicit exponent byte array.

Types

type Frame

type Frame interface {
	ToBuf() ([]byte, error)
}

Frame is an interface for the varying frames

type FrameAck

type FrameAck struct {
	ReceivedEntropy                           byte
	LargestObserved, LargestObservedDeltaTime uint64
}

FrameAck represents a AckFrame

func (FrameAck) ToBuf

func (f FrameAck) ToBuf() ([]byte, error)

ToBuf serializes a frame into a byte array

type FrameBlocked

type FrameBlocked struct {
	StreamID uint64
}

FrameBlocked represents a BlockedFrame

func (FrameBlocked) ToBuf

func (f FrameBlocked) ToBuf() ([]byte, error)

ToBuf serializes a FrameBlocked into a byte array

type FrameCongestionFeedback

type FrameCongestionFeedback struct {
}

FrameCongestionFeedback represents a CongestionFeedbackFrame

func (FrameCongestionFeedback) ToBuf

func (f FrameCongestionFeedback) ToBuf() ([]byte, error)

ToBuf serializes a FrameCongestionFeedback into a byte array

type FrameConnectionClose

type FrameConnectionClose struct {
	ErrorCode uint64
	Reason    string
}

FrameConnectionClose represents a ConnectionCloseFrame

func (FrameConnectionClose) ToBuf

func (f FrameConnectionClose) ToBuf() ([]byte, error)

ToBuf serializes a FrameConnectionClose into a byte array

type FrameGoAway

type FrameGoAway struct {
	ErrorCode, LastGoodStreamID uint64
	Reason                      string
}

FrameGoAway represents a GoAwayFrame

func (FrameGoAway) ToBuf

func (f FrameGoAway) ToBuf() ([]byte, error)

ToBuf serializes a FrameGoAway into a byte array

type FramePadding

type FramePadding struct {
}

FramePadding represents a PaddingFrame

func (FramePadding) ToBuf

func (f FramePadding) ToBuf() ([]byte, error)

ToBuf serializes a FramePadding into a byte array

type FramePing

type FramePing struct {
}

FramePing represents a PingFrame

func (FramePing) ToBuf

func (f FramePing) ToBuf() ([]byte, error)

ToBuf serializes a FramePing into a byte array

type FrameResetStream

type FrameResetStream struct {
	StreamID, ErrorCode uint64
}

FrameResetStream represents a ResetStreamFrame

func (FrameResetStream) ToBuf

func (f FrameResetStream) ToBuf() ([]byte, error)

ToBuf serializes a frame into a byte array

type FrameStopWaiting

type FrameStopWaiting struct {
	SentEntropy       byte
	LeastUnackedDelta uint64
}

FrameStopWaiting represents a StopWaitingFrame

func (FrameStopWaiting) ToBuf

func (f FrameStopWaiting) ToBuf() ([]byte, error)

ToBuf serializes a frame into a byte array TODO Variable length delta

type FrameStream

type FrameStream struct {
	StreamID, Offset, DataLen uint64
	Fin                       bool
	Data                      string
}

FrameStream represents a StreamFrame

func (FrameStream) ToBuf

func (f FrameStream) ToBuf() ([]byte, error)

ToBuf serializes a frame into a byte array TODO: Implement variable length StreamID and optional data length

type FrameWindowUpdate

type FrameWindowUpdate struct {
	StreamID, ByteOffset uint64
}

FrameWindowUpdate represents a WindowUpdateFrame

func (FrameWindowUpdate) ToBuf

func (f FrameWindowUpdate) ToBuf() ([]byte, error)

ToBuf serializes a frame into a byte array

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

Listener represents a QUIC connection

func Listen

func Listen(port int) (*Listener, error)

Listen to a specific address

func (*Listener) Close

func (l *Listener) Close()

Close closes the QUIC Listener

func (*Listener) Handle

func (l *Listener) Handle()

Handle is an internal goroutine that handles input.

type Packet

type Packet struct {
	PublicFlags                         byte
	ConnID, QuicVersion, SequenceNumber uint64
	PrivateFlags                        byte
	FECGroupNumber                      uint64
	Type                                byte
	Frames                              []Frame
}

Packet represents a packet

func ParsePacket

func ParsePacket(buf []byte) (*Packet, error)

ParsePacket parses a byte array and returns the corresponding packet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL