udt

package
v0.0.0-...-3520cae Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DialUDT

func DialUDT(network string, laddr string, raddr *net.UDPAddr, isStream bool) (net.Conn, error)

DialUDT establishes an outbound UDT connection using the supplied net, laddr and raddr. See function net.DialUDP for a description of net, laddr and raddr.

func DialUDTContext

func DialUDTContext(ctx context.Context, network string, laddr string, raddr *net.UDPAddr, isStream bool) (net.Conn, error)

DialUDTContext establishes an outbound UDT connection using the supplied net, laddr and raddr. See function net.DialUDP for a description of net, laddr and raddr.

func ListenUDT

func ListenUDT(network string, addr string) (net.Listener, error)

ListenUDT listens for incoming UDT connections addressed to the local address laddr. See function net.ListenUDP for a description of net and laddr.

func ListenUDTContext

func ListenUDTContext(ctx context.Context, network string, addr string) (net.Listener, error)

ListenUDTContext listens for incoming UDT connections addressed to the local address laddr. See function net.ListenUDP for a description of net and laddr.

func RendezvousUDT

func RendezvousUDT(network string, laddr string, raddr *net.UDPAddr, isStream bool) (net.Conn, error)

RendezvousUDT establishes an outbound UDT connection using the supplied net, laddr and raddr. See function net.DialUDP for a description of net, laddr and raddr.

func RendezvousUDTContext

func RendezvousUDTContext(ctx context.Context, network string, laddr string, raddr *net.UDPAddr, isStream bool) (net.Conn, error)

RendezvousUDTContext establishes an outbound UDT connection using the supplied net, laddr and raddr. See function net.DialUDP for a description of net, laddr and raddr.

Types

type Config

type Config struct {
	CanAcceptDgram     bool          // can this listener accept datagrams?
	CanAcceptStream    bool          // can this listener accept streams?
	ListenReplayWindow time.Duration // length of time to wait for repeated incoming connections
	MaxPacketSize      uint          // Upper limit on maximum packet size (0 = unlimited)
	MaxBandwidth       uint64        // Maximum bandwidth to take with this connection (in bytes/sec, 0 = unlimited)
	LingerTime         time.Duration // time to wait for retransmit requests after connection shutdown
	MaxFlowWinSize     uint          // maximum number of unacknowledged packets to permit (minimum 32)

	CanAccept           func(hsPacket *packet.HandshakePacket, from *net.UDPAddr) error // can this listener accept this connection?
	CongestionForSocket func(sock *udtSocket) CongestionControl                         // create or otherwise return the CongestionControl for this socket
}

Config controls behavior of sockets created with it

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig constructs a Config with default values

func (*Config) Dial

func (c *Config) Dial(ctx context.Context, network string, laddr string, raddr *net.UDPAddr, isStream bool) (net.Conn, error)

Dial establishes an outbound UDT connection using the supplied net, laddr and raddr. See function net.DialUDP for a description of net, laddr and raddr.

func (*Config) Listen

func (c *Config) Listen(ctx context.Context, network string, addr string) (net.Listener, error)

Listen listens for incoming UDT connections addressed to the local address laddr. See function net.ListenUDP for a description of net and laddr.

func (*Config) Rendezvous

func (c *Config) Rendezvous(ctx context.Context, network string, laddr string, raddr *net.UDPAddr, isStream bool) (net.Conn, error)

Rendezvous establishes an outbound UDT connection using the supplied net, laddr and raddr. See function net.DialUDP for a description of net, laddr and raddr.

type CongestionControl

type CongestionControl interface {
	// Init to be called (only) at the start of a UDT connection.
	Init(CongestionControlParms)

	// Close to be called when a UDT connection is closed.
	Close(CongestionControlParms)

	// OnACK to be called when an ACK packet is received
	OnACK(CongestionControlParms, packet.PacketID)

	// OnNAK to be called when a loss report is received
	OnNAK(CongestionControlParms, []packet.PacketID)

	// OnTimeout to be called when a timeout event occurs
	OnTimeout(CongestionControlParms)

	// OnPktSent to be called when data is sent
	OnPktSent(CongestionControlParms, packet.Packet)

	// OnPktRecv to be called when data is received
	OnPktRecv(CongestionControlParms, packet.DataPacket)

	// OnCustomMsg to process a user-defined packet
	OnCustomMsg(CongestionControlParms, packet.UserDefControlPacket)
}

CongestionControl controls how timing is handled and UDT connections tuned

type CongestionControlParms

type CongestionControlParms interface {
	// GetSndCurrSeqNo is the most recently sent packet ID
	GetSndCurrSeqNo() packet.PacketID

	// SetCongestionWindowSize sets the size of the congestion window (in packets)
	SetCongestionWindowSize(uint)

	// GetCongestionWindowSize gets the size of the congestion window (in packets)
	GetCongestionWindowSize() uint

	// GetPacketSendPeriod gets the current delay between sending packets
	GetPacketSendPeriod() time.Duration

	// SetPacketSendPeriod sets the current delay between sending packets
	SetPacketSendPeriod(time.Duration)

	// GetMaxFlowWindow is the largest number of unacknowledged packets we can receive (in packets)
	GetMaxFlowWindow() uint

	// GetReceiveRates is the current calculated receive rate and bandwidth (in packets/sec)
	GetReceiveRates() (recvSpeed, bandwidth uint)

	// GetRTT is the current calculated roundtrip time between peers
	GetRTT() time.Duration

	// GetMSS is the largest packet size we can currently send (in bytes)
	GetMSS() uint

	// SetACKPerid sets the time between ACKs sent to the peer
	SetACKPeriod(time.Duration)

	// SetACKInterval sets the number of packets sent to the peer before sending an ACK
	SetACKInterval(uint)

	// SetRTOPeriod overrides the default EXP timeout calculations waiting for data from the peer
	SetRTOPeriod(time.Duration)
}

CongestionControlParms permits a CongestionControl implementation to interface with the UDT socket

type NativeCongestionControl

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

NativeCongestionControl implements the default congestion control logic for UDP

func (NativeCongestionControl) Close

Close to be called when a UDT connection is closed.

func (NativeCongestionControl) Init

Init to be called (only) at the start of a UDT connection.

func (NativeCongestionControl) OnACK

OnACK to be called when an ACK packet is received

func (NativeCongestionControl) OnCustomMsg

OnCustomMsg to process a user-defined packet

func (NativeCongestionControl) OnNAK

func (ncc NativeCongestionControl) OnNAK(parms CongestionControlParms, losslist []packet.PacketID)

OnNAK to be called when a loss report is received

func (NativeCongestionControl) OnPktRecv

OnPktRecv to be called when a data is received

func (NativeCongestionControl) OnPktSent

func (ncc NativeCongestionControl) OnPktSent(parms CongestionControlParms, pkt packet.Packet)

OnPktSent to be called when data is sent

func (NativeCongestionControl) OnTimeout

func (ncc NativeCongestionControl) OnTimeout(parms CongestionControlParms)

OnTimeout to be called when a timeout event occurs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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