trudp

package
v0.0.0-...-2e4d9bc Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package trudp is the Teonet relable udp processing package.

Index

Constants

View Source
const (
	DATA     = iota //(0x0)
	ACK             //(0x1)
	RESET           //(0x2)
	ACKReset        //(0x3)
	PING            //(0x4)
	ACKPing         //(0x5)
)

Packet type

View Source
const (

	/**
	 * Initialize TR-UDP event
	 * @param td Pointer to trudpData
	 */
	EvInitialize = iota

	/**
	 * Destroy TR-UDP event
	 * @param td Pointer to trudpData
	 */
	EvDestroy

	/**
	 * TR-UDP channel disconnected event
	 * @param data NULL
	 * @param data_length 0
	 * @param user_data NULL
	 */
	EvConnected

	/**
	 * TR-UDP channel disconnected event
	 * @param data Last packet received
	 * @param data_length 0
	 * @param user_data NULL
	 */
	EvDisconnected

	/**
	 * Got TR-UDP reset packet
	 * @param data NULL
	 * @param data_length 0
	 * @param user_data NULL
	 */
	EvGotReset

	/**
	 * Send TR-UDP reset packet
	 * @param data Pointer to uint32_t send id or NULL if received id = 0
	 * @param data_length Size of uint32_t or 0
	 * @param user_data NULL
	 */
	EvSendReset

	/**
	 * Got ACK to reset command
	 * @param data NULL
	 * @param data_length 0
	 * @param user_data NULL
	 */
	EvGotAckReset

	/**
	 * Got ACK to ping command
	 * @param data Pointer to ping data (usually it is a string)
	 * @param data_length Length of data
	 * @param user_data NULL
	 */
	EvGotAckPing

	/**
	 * Got PING command
	 * @param data Pointer to ping data (usually it is a string)
	 * @param data_length Length of data
	 * @param user_data NULL
	 */
	EvGotPing

	/**
	 * Got ACK command
	 * @param data Pointer to ACK packet
	 * @param data_length Length of data
	 * @param user_data NULL
	 */
	EvGotAck

	/**
	 * Got DATA
	 * @param data Pointer to data
	 * @param data_length Length of data
	 * @param user_data NULL
	 */
	EvGotData
	EvGotDataNotrudp

	/**
	 * Process received data
	 * @param tcd Pointer to trudpData
	 * @param data Pointer to receive buffer
	 * @param data_length Receive buffer length
	 * @param user_data NULL
	 */
	EvProcessReceived

	/** Process received not TR-UDP data
	 * @param tcd Pointer to trudpData
	 * @param data Pointer to receive buffer
	 * @param data_length Receive buffer length
	 * @param user_data NULL
	 */
	EvProcessReceivedNoTrudp

	EvResetLocal
)

Enumeration of Trudp events

View Source
const (

	// DefaultQueueSize is size of send and receive queue
	DefaultQueueSize = 256 // 96

)
View Source
const USESYSCALL = false

USESYSCALL flag select udp libray or syscall (may be syscall will be deprekated bekause library wotk good)

View Source
const Version = "3.0.0"

Version is srudp version

Variables

View Source
var MODULE = teokeys.Color(teokeys.ANSICyan, "(trudp)")

MODULE trudp packet name in logs

Functions

func BenchmarkSyscallUDP

func BenchmarkSyscallUDP()

BenchmarkSyscallUDP test function to connect to UDP with syscall packet

Types

type ChannelData

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

ChannelData is the TRUDP channel data structure

func (*ChannelData) AllowSendTestMsg

func (tcd *ChannelData) AllowSendTestMsg(sendTestMsgF bool)

AllowSendTestMsg set sendTestMsgF flag to send test message by interval

func (*ChannelData) Close

func (tcd *ChannelData) Close() (err error)

Close close trudp channel

func (*ChannelData) Connected

func (tcd *ChannelData) Connected() bool

Connected return channel is connected flag

func (*ChannelData) GetAddr

func (tcd *ChannelData) GetAddr() *net.UDPAddr

GetAddr return trudp channel address

func (*ChannelData) GetCh

func (tcd *ChannelData) GetCh() int

GetCh return trudp channel

func (*ChannelData) GetKey

func (tcd *ChannelData) GetKey() string

GetKey return trudp channel key

func (*ChannelData) GetTriptime

func (tcd *ChannelData) GetTriptime() (float32, float32)

GetTriptime return trudp channel triptime

func (*ChannelData) ID

func (tcd *ChannelData) ID() (currentID uint32)

ID return new packe id

func (*ChannelData) TripTime

func (tcd *ChannelData) TripTime() float32

TripTime return current triptime (ms)

func (*ChannelData) Write

func (tcd *ChannelData) Write(data []byte) (n int, err error)

Write send data to remote host

func (*ChannelData) WriteNowait

func (tcd *ChannelData) WriteNowait(data []byte, cb func()) (n int, err error)

WriteNowait send data to remote host in no wait mode and got result in callback

func (*ChannelData) WriteUnsafe

func (tcd *ChannelData) WriteUnsafe(data []byte) (int, error)

WriteUnsafe send data to remote host by UDP

type EventData

type EventData struct {
	Tcd   *ChannelData
	Event int
	Data  []byte
}

EventData used as structure in sendEvent function

type RealTimeSpeed

type RealTimeSpeed struct {
	SpeedPacSec int // Speed in pacets/second
	// contains filtered or unexported fields
}

RealTimeSpeed type to calculate real time speed

func (*RealTimeSpeed) Calculate

func (realTime *RealTimeSpeed) Calculate(length int)

Calculate function calculate real time packets speed in pac/sec and mb/sec

type TRUDP

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

TRUDP connection strucure

func Init

func Init(port *int) (trudp *TRUDP)

Init start trudp connection

func (*TRUDP) AllowEvents

func (trudp *TRUDP) AllowEvents(events uint32)

AllowEvents set allow events flags

func (*TRUDP) ChanEvent

func (trudp *TRUDP) ChanEvent() <-chan *EventData

ChanEvent return channel to read trudp events

func (*TRUDP) ChanEventClosed

func (trudp *TRUDP) ChanEventClosed()

ChanEventClosed signalling that event channel reader routine sucessfully closed

func (*TRUDP) Close

func (trudp *TRUDP) Close()

Close closes trudp connection and channelRead

func (*TRUDP) Connect

func (trudp *TRUDP) Connect(rhost string, rport int)

Connect to remote host by UDP

func (*TRUDP) ConnectChannel

func (trudp *TRUDP) ConnectChannel(rhost string, rport int, ch int) (tcd *ChannelData)

ConnectChannel to remote host by UDP

func (*TRUDP) GetAddr

func (trudp *TRUDP) GetAddr() (ip string, port int)

GetAddr return IP and Port of local address

func (*TRUDP) Run

func (trudp *TRUDP) Run()

Run waits some data received from UDP port and procces it

func (*TRUDP) Running

func (trudp *TRUDP) Running() bool

Running return true if TRUDP is running now

func (*TRUDP) SetDefaultQueueSize

func (trudp *TRUDP) SetDefaultQueueSize(defaultQueueSize int)

SetDefaultQueueSize set maximum send and receive queues size

func (*TRUDP) SetShowStatistic

func (trudp *TRUDP) SetShowStatistic(showStatF bool)

SetShowStatistic set showStatF to show trudp statistic window

func (*TRUDP) ShowStatistic

func (trudp *TRUDP) ShowStatistic() bool

ShowStatistic get showStatF

func (*TRUDP) Timestamp

func (trudp *TRUDP) Timestamp() uint32

Timestamp return current 32 bit timestamp in thousands of milliseconds

Jump to

Keyboard shortcuts

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