packet

package
v0.0.0-...-23397e3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PacketTypeName

func PacketTypeName(pt PacketType) string

PacketTypeName returns a name describing the specified packet type

Types

type Ack2Packet

type Ack2Packet struct {
	AckSeqNo uint32 // ACK sequence number
	// contains filtered or unexported fields
}

Ack2Packet is a UDT packet acknowledging receipt of an ACK packet

func (*Ack2Packet) PacketType

func (p *Ack2Packet) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*Ack2Packet) SendTime

func (h *Ack2Packet) SendTime() (ts uint32)

func (*Ack2Packet) SetHeader

func (h *Ack2Packet) SetHeader(destSockID uint32, ts uint32)

func (*Ack2Packet) SocketID

func (h *Ack2Packet) SocketID() (sockID uint32)

func (*Ack2Packet) WriteTo

func (p *Ack2Packet) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type AckPacket

type AckPacket struct {
	AckSeqNo  uint32   // ACK sequence number
	PktSeqHi  PacketID // The packet sequence number to which all the previous packets have been received (excluding)
	Rtt       uint32   // RTT (in microseconds)
	RttVar    uint32   // RTT variance
	BuffAvail uint32   // Available buffer size (in bytes)

	// the following data is optional (not sent more than SYN)
	IncludeLink bool
	PktRecvRate uint32 // Packets receiving rate (in number of packets per second)
	EstLinkCap  uint32 // Estimated link capacity (in number of packets per second)
	// contains filtered or unexported fields
}

AckPacket is a UDT packet acknowledging previously-received data packets and describing the state of the link

func (*AckPacket) PacketType

func (p *AckPacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*AckPacket) SendTime

func (h *AckPacket) SendTime() (ts uint32)

func (*AckPacket) SetHeader

func (h *AckPacket) SetHeader(destSockID uint32, ts uint32)

func (*AckPacket) SocketID

func (h *AckPacket) SocketID() (sockID uint32)

func (*AckPacket) WriteTo

func (p *AckPacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type CongestionPacket

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

CongestionPacket is a (deprecated) UDT packet notifying the peer of increased congestion

func (*CongestionPacket) PacketType

func (p *CongestionPacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*CongestionPacket) SendTime

func (h *CongestionPacket) SendTime() (ts uint32)

func (*CongestionPacket) SetHeader

func (h *CongestionPacket) SetHeader(destSockID uint32, ts uint32)

func (*CongestionPacket) SocketID

func (h *CongestionPacket) SocketID() (sockID uint32)

func (*CongestionPacket) WriteTo

func (p *CongestionPacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type ControlPacket

type ControlPacket interface {
	// socketId retrieves the socket id of a packet
	SocketID() (sockID uint32)

	// SendTime retrieves the timesamp of the packet
	SendTime() (ts uint32)

	WriteTo(buf []byte) (uint, error)

	SetHeader(destSockID uint32, ts uint32)

	PacketType() PacketType
	// contains filtered or unexported methods
}

ControlPacket represents a UDT control packet.

type DataPacket

type DataPacket struct {
	Seq PacketID // packet sequence number (top bit = 0)

	DstSockID uint32 // destination socket
	Data      []byte // payload
	// contains filtered or unexported fields
}

DataPacket is a UDT packet containing message data

func (*DataPacket) GetMessageData

func (dp *DataPacket) GetMessageData() (MessageBoundary, bool, uint32)

GetMessageData returns the message field for this data packet

func (*DataPacket) PacketType

func (dp *DataPacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*DataPacket) SendTime

func (dp *DataPacket) SendTime() (ts uint32)

SendTime sets the timestamp field for this data packet

func (*DataPacket) SetHeader

func (dp *DataPacket) SetHeader(destSockID uint32, ts uint32)

SetHeader sets the fields common to UDT data packets

func (*DataPacket) SetMessageData

func (dp *DataPacket) SetMessageData(boundary MessageBoundary, order bool, msg uint32)

SetMessageData sets the message field for this data packet

func (*DataPacket) SocketID

func (dp *DataPacket) SocketID() (sockID uint32)

SocketID sets the Socket ID for this data packet

func (*DataPacket) WriteTo

func (dp *DataPacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type ErrPacket

type ErrPacket struct {
	Errno uint32 // error code
	// contains filtered or unexported fields
}

ErrPacket is a (undocumented) UDT packet describing an out-of-band error code

func (*ErrPacket) PacketType

func (p *ErrPacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*ErrPacket) SendTime

func (h *ErrPacket) SendTime() (ts uint32)

func (*ErrPacket) SetHeader

func (h *ErrPacket) SetHeader(destSockID uint32, ts uint32)

func (*ErrPacket) SocketID

func (h *ErrPacket) SocketID() (sockID uint32)

func (*ErrPacket) WriteTo

func (p *ErrPacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type HandshakePacket

type HandshakePacket struct {
	UdtVer     uint32     // UDT version
	SockType   SocketType // Socket Type (1 = STREAM or 2 = DGRAM)
	InitPktSeq PacketID   // initial packet sequence number
	//MaxPktSize     uint32           // maximum packet size (including UDP/IP headers)
	MaxFlowWinSize uint32           // maximum flow window size
	ReqType        HandshakeReqType // connection type (regular(1), rendezvous(0), -1/-2 response)
	SockID         uint32           // socket ID
	// contains filtered or unexported fields
}

HandshakePacket is a UDT packet used to negotiate a new connection

func (*HandshakePacket) PacketType

func (p *HandshakePacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*HandshakePacket) SendTime

func (h *HandshakePacket) SendTime() (ts uint32)

func (*HandshakePacket) SetHeader

func (h *HandshakePacket) SetHeader(destSockID uint32, ts uint32)

func (*HandshakePacket) SocketID

func (h *HandshakePacket) SocketID() (sockID uint32)

func (*HandshakePacket) WriteTo

func (p *HandshakePacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type HandshakeReqType

type HandshakeReqType int32

HandshakeReqType describes the type of handshake packet

const (
	// HsRequest represents an attempt to establish a new connection
	HsRequest HandshakeReqType = 1
	//HsRendezvous represents an attempt to establish a new connection using mutual rendezvous packets
	HsRendezvous HandshakeReqType = 0
	//HsResponse is a response to a handshake request
	HsResponse HandshakeReqType = -1
	//HsResponse2 is an acknowledgement that a HsResponse was received
	HsResponse2 HandshakeReqType = -2
	//HsRefused notifies the peer of a connection refusal
	HsRefused HandshakeReqType = 1002
)

type KeepAlivePacket

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

KeepAlivePacket is a UDT packet used to keep a connection alive when no data is being sent

func (*KeepAlivePacket) PacketType

func (p *KeepAlivePacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*KeepAlivePacket) SendTime

func (h *KeepAlivePacket) SendTime() (ts uint32)

func (*KeepAlivePacket) SetHeader

func (h *KeepAlivePacket) SetHeader(destSockID uint32, ts uint32)

func (*KeepAlivePacket) SocketID

func (h *KeepAlivePacket) SocketID() (sockID uint32)

func (*KeepAlivePacket) WriteTo

func (p *KeepAlivePacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type MessageBoundary

type MessageBoundary uint8

MessageBoundary flags for where this packet falls within a message

const (
	// MbFirst is the first packet in a multi-packet message
	MbFirst MessageBoundary = 2
	// MbLast is the last packet in a multi-packet message
	MbLast MessageBoundary = 1
	// MbOnly is the only packet in this message
	MbOnly MessageBoundary = 3
	// MbMiddle is neither the first nor last packet in a multi-packet message
	MbMiddle MessageBoundary = 0
)

type MsgDropReqPacket

type MsgDropReqPacket struct {
	MsgID    uint32   // Message ID
	FirstSeq PacketID // First sequence number in the message
	LastSeq  PacketID // Last sequence number in the message
	// contains filtered or unexported fields
}

MsgDropReqPacket is a UDT packet notifying the peer of expired packets not worth trying to send

func (*MsgDropReqPacket) PacketType

func (p *MsgDropReqPacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*MsgDropReqPacket) SendTime

func (h *MsgDropReqPacket) SendTime() (ts uint32)

func (*MsgDropReqPacket) SetHeader

func (h *MsgDropReqPacket) SetHeader(destSockID uint32, ts uint32)

func (*MsgDropReqPacket) SocketID

func (h *MsgDropReqPacket) SocketID() (sockID uint32)

func (*MsgDropReqPacket) WriteTo

func (p *MsgDropReqPacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type NakPacket

type NakPacket struct {
	CmpLossInfo []uint32 // integer array of compressed loss information
	// contains filtered or unexported fields
}

NakPacket is a UDT packet notifying the peer of lost packets

func (*NakPacket) PacketType

func (p *NakPacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*NakPacket) SendTime

func (h *NakPacket) SendTime() (ts uint32)

func (*NakPacket) SetHeader

func (h *NakPacket) SetHeader(destSockID uint32, ts uint32)

func (*NakPacket) SocketID

func (h *NakPacket) SocketID() (sockID uint32)

func (*NakPacket) WriteTo

func (p *NakPacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type Packet

type Packet interface {
	// socketId retrieves the socket id of a packet
	SocketID() (sockID uint32)

	// SendTime retrieves the timesamp of the packet
	SendTime() (ts uint32)

	// WriteTo writes this packet to the provided buffer, returning the length of the packet
	WriteTo(buf []byte) (uint, error)

	SetHeader(destSockID uint32, ts uint32)

	PacketType() PacketType
	// contains filtered or unexported methods
}

Packet represents a UDT packet

func DecodePacket

func DecodePacket(data []byte) (p Packet, err error)

DecodePacket takes the contents of a UDP packet and decodes it into a UDT packet

type PacketID

type PacketID struct {
	Seq uint32
}

PacketID represents a UDT packet ID sequence

func RandomPacketSequence

func RandomPacketSequence() PacketID

RandomPacketSequence returns a random packet sequence

func (PacketID) Add

func (p PacketID) Add(off int32) PacketID

Add returns a packet ID after adding the specified offset

func (PacketID) BlindDiff

func (p PacketID) BlindDiff(rhs PacketID) int32

BlindDiff attempts to return the difference after subtracting the argument from itself

func (*PacketID) Decr

func (p *PacketID) Decr()

Decr decrements this packet ID

func (*PacketID) Incr

func (p *PacketID) Incr()

Incr increments this packet ID

func (PacketID) IsBigger

func (p PacketID) IsBigger(other PacketID) bool

IsBigger checks if the current packet sequence is bigger than the parameter

func (PacketID) IsBiggerEqual

func (p PacketID) IsBiggerEqual(other PacketID) bool

IsBiggerEqual checks if the current packet sequence is bigger or equal than the parameter

func (PacketID) IsLess

func (p PacketID) IsLess(other PacketID) bool

IsLess checks if the current packet sequence is less than the parameter

func (PacketID) IsLessEqual

func (p PacketID) IsLessEqual(other PacketID) bool

IsLessEqual checks if the current packet sequence is less or equal than the parameter

type PacketType

type PacketType uint16

PacketType describes the type of UDP packet we're dealing with

type ShutdownPacket

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

ShutdownPacket is a UDT packet notifying the peer of connection shutdown

func (*ShutdownPacket) PacketType

func (p *ShutdownPacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*ShutdownPacket) SendTime

func (h *ShutdownPacket) SendTime() (ts uint32)

func (*ShutdownPacket) SetHeader

func (h *ShutdownPacket) SetHeader(destSockID uint32, ts uint32)

func (*ShutdownPacket) SocketID

func (h *ShutdownPacket) SocketID() (sockID uint32)

func (*ShutdownPacket) WriteTo

func (p *ShutdownPacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

type SocketType

type SocketType uint16

SocketType describes the kind of socket this is (i.e. streaming vs message)

const (
	// TypeSTREAM describes a reliable streaming protocol (e.g. TCP)
	TypeSTREAM SocketType = 1
	// TypeDGRAM describes a partially-reliable messaging protocol
	TypeDGRAM SocketType = 2
)

type UserDefControlPacket

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

UserDefControlPacket is a UDT user-defined packet

func (*UserDefControlPacket) PacketType

func (p *UserDefControlPacket) PacketType() PacketType

PacketType returns the packetType associated with this packet

func (*UserDefControlPacket) SendTime

func (h *UserDefControlPacket) SendTime() (ts uint32)

func (*UserDefControlPacket) SetHeader

func (h *UserDefControlPacket) SetHeader(destSockID uint32, ts uint32)

func (*UserDefControlPacket) SocketID

func (h *UserDefControlPacket) SocketID() (sockID uint32)

func (*UserDefControlPacket) WriteTo

func (p *UserDefControlPacket) WriteTo(buf []byte) (uint, error)

WriteTo writes this packet to the provided buffer, returning the length of the packet

Jump to

Keyboard shortcuts

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