udt

package module
v0.0.0-...-9d61372 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2018 License: BSD-3-Clause Imports: 13 Imported by: 2

README

go-udtwrapper

go-udtwrapper is a cgo wrapper around the main C++ UDT implementation.

This repository is the fork of the original getlantern/go-udtwrapper. Several other forks are merged together here. Mainly it is based on jbenet/go-udtwrapper, mixed up with fffw/go-udtwrapper and Syncbak-Git/go-udtwrapper. Original authors have been preserved for all imported commits, though some commits were modified due to rebase and some commits were omitted.

Usage

Tools:

  • udtcat - netcat using the udt pkg
  • benchmark - benchmark for comparison of tcp and udt streams

Try:

(cd udtcat; go build; ./test_simple.sh)
Supported Platforms
ARCH/OS Linux Mac OSX Windows
x86/i386 ? ? ?
x86-64/amd64 YES ? YES*

*Golang doesn't support SEH exception handling(https://github.com/golang/go/issues/12516). Use mingw-w64 with sjlj handling and without pthread wrapper under windows.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// UDP_RCVBUF_SIZE is the default UDP_RCVBUF size.
	UDP_RCVBUF_SIZE = uint32(20971520) // 20MB

	// UDT_SNDTIMEO is the udt_send() timeout in milliseconds
	// note this doesnt change the interface, we use it as a poor polling
	UDT_SNDTIMEO_MS = C.int(UDT_ASYNC_TIMEOUT)

	// UDT_RCVTIMEO is the udt_recv() timeout in milliseconds
	// note this doesnt change the interface, we use it as a poor polling
	UDT_RCVTIMEO_MS = C.int(UDT_ASYNC_TIMEOUT)

	// UDT_ASYNC_TIMEOUT (in ms)
	UDT_ASYNC_TIMEOUT = 40
)

rebind this here for type safety

Functions

func Dial

func Dial(network, address string) (c net.Conn, err error)

Dial connects to the remote address raddr on the network net, which must be "udt", "udt4", or "udt6". If laddr is not nil, it is used as the local address for the connection.

func Listen

func Listen(network, address string) (net.Listener, error)

Listen listens for incoming UDT packets addressed to the local address laddr. Net must be "udt", "udt4", or "udt6". If laddr has a port of 0, ListenUDT will choose an available port. The LocalAddr method of the returned UDTConn can be used to discover the port. The returned connection's ReadFrom and WriteTo methods can be used to receive and send UDT packets with per-packet addressing.

Types

type Dialer

type Dialer struct {
	LocalAddr net.Addr
}

func (*Dialer) Dial

func (d *Dialer) Dial(network, address string) (c net.Conn, err error)

Dial connects to the remote address raddr on the network net, which must be "udt", "udt4", or "udt6".

func (*Dialer) DialUDT

func (d *Dialer) DialUDT(network string, raddr *UDTAddr) (*UDTConn, error)

DialUDT connects to the remote address raddr on the network net, which must be "udt", "udt4", or "udt6".

type PerfMonData

type PerfMonData struct {
	// global measurements
	MsTimeStamp        int64 // time since the UDT entity is started, in milliseconds
	PktSentTotal       int64 // total number of sent data packets, including retransmissions
	PktRecvTotal       int64 // total number of received packets
	PktSndLossTotal    int   // total number of lost packets (sender side)
	PktRcvLossTotal    int   // total number of lost packets (receiver side)
	PktRetransTotal    int   // total number of retransmitted packets
	PktSentACKTotal    int   // total number of sent ACK packets
	PktRecvACKTotal    int   // total number of received ACK packets
	PktSentNAKTotal    int   // total number of sent NAK packets
	PktRecvNAKTotal    int   // total number of received NAK packets
	UsSndDurationTotal int64 // total time duration when UDT is sending data (idle time exclusive)

	// local measurements
	PktSent       int64   // number of sent data packets, including retransmissions
	PktRecv       int64   // number of received packets
	PktSndLoss    int     // number of lost packets (sender side)
	PktRcvLoss    int     // number of lost packets (receiver side)
	PktRetrans    int     // number of retransmitted packets
	PktSentACK    int     // number of sent ACK packets
	PktRecvACK    int     // number of received ACK packets
	PktSentNAK    int     // number of sent NAK packets
	PktRecvNAK    int     // number of received NAK packets
	MbpsSendRate  float64 // sending rate in Mb/s
	MbpsRecvRate  float64 // receiving rate in Mb/s
	UsSndDuration int64   // busy sending time (i.e., idle time exclusive)

	// instant measurements
	UsPktSndPeriod      float64 // packet sending period, in microseconds
	PktFlowWindow       int     // flow window size, in number of packets
	PktCongestionWindow int     // congestion window size, in number of packets
	PktFlightSize       int     // number of packets on flight
	MsRTT               float64 // RTT, in milliseconds
	MbpsBandwidth       float64 // estimated bandwidth, in Mb/s
	ByteAvailSndBuf     int     // available UDT sender buffer size
	ByteAvailRcvBuf     int     // available UDT receiver buffer size
}

type UDTAddr

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

func ResolveUDTAddr

func ResolveUDTAddr(n, addr string) (*UDTAddr, error)

func WrapUDPAddr

func WrapUDPAddr(ua *net.UDPAddr) *UDTAddr

func (*UDTAddr) AF

func (a *UDTAddr) AF() int

AF returns UDTAddr's AF (Address Family)

func (*UDTAddr) IPPROTO

func (a *UDTAddr) IPPROTO() int

IPPROTO returns UDTAddr's IPPROTO (IPPROTO_UDP)

func (*UDTAddr) Network

func (a *UDTAddr) Network() string

func (*UDTAddr) String

func (a *UDTAddr) String() string

func (*UDTAddr) UDPAddr

func (a *UDTAddr) UDPAddr() *net.UDPAddr

type UDTConn

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

UDTConn is the implementation of the Conn and PacketConn interfaces for UDT network connections.

func DialUDT

func DialUDT(net string, laddr, raddr *UDTAddr) (*UDTConn, error)

DialUDT connects to the remote address raddr on the network net, which must be "udt", "udt4", or "udt6". If laddr is not nil, it is used as the local address for the connection.

func (UDTConn) Close

func (fd UDTConn) Close() error

func (UDTConn) LocalAddr

func (fd UDTConn) LocalAddr() net.Addr

func (UDTConn) PerfMon

func (fd UDTConn) PerfMon(clear bool) (*PerfMonData, error)

func (UDTConn) Read

func (fd UDTConn) Read(buf []byte) (int, error)

func (UDTConn) RemoteAddr

func (fd UDTConn) RemoteAddr() net.Addr

func (UDTConn) SetDeadline

func (fd UDTConn) SetDeadline(t time.Time) error

func (UDTConn) SetReadDeadline

func (fd UDTConn) SetReadDeadline(t time.Time) error

func (UDTConn) SetRendezvous

func (fd UDTConn) SetRendezvous(value bool) error

func (UDTConn) SetWriteDeadline

func (fd UDTConn) SetWriteDeadline(t time.Time) error

func (UDTConn) Write

func (fd UDTConn) Write(buf []byte) (writecnt int, err error)

type UDTListener

type UDTListener struct {
	net.Listener
	// contains filtered or unexported fields
}

UDTListener is a network listener for UDT.

func ListenUDT

func ListenUDT(network string, laddr *UDTAddr) (*UDTListener, error)

ListenUDT listens for incoming UDT packets addressed to the local address laddr. Net must be "udt", "udt4", or "udt6". If laddr has a port of 0, ListenUDT will choose an available port. The LocalAddr method of the returned UDTConn can be used to discover the port. The returned connection's ReadFrom and WriteTo methods can be used to receive and send UDT packets with per-packet addressing.

func (*UDTListener) Accept

func (l *UDTListener) Accept() (c net.Conn, err error)

func (*UDTListener) Addr

func (l *UDTListener) Addr() net.Addr

func (*UDTListener) Close

func (l *UDTListener) Close() error

Directories

Path Synopsis
package udtcat provides an implementation of netcat using the go-udtwrapper package.
package udtcat provides an implementation of netcat using the go-udtwrapper package.

Jump to

Keyboard shortcuts

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