Documentation ¶
Overview ¶
Package trudp is the Teonet relable udp processing package.
Index ¶
- Constants
- Variables
- func BenchmarkSyscallUDP()
- type ChannelData
- func (tcd *ChannelData) AllowSendTestMsg(sendTestMsgF bool)
- func (tcd *ChannelData) Close() (err error)
- func (tcd *ChannelData) Connected() bool
- func (tcd *ChannelData) GetAddr() *net.UDPAddr
- func (tcd *ChannelData) GetCh() int
- func (tcd *ChannelData) GetKey() string
- func (tcd *ChannelData) GetTriptime() (float32, float32)
- func (tcd *ChannelData) ID() (currentID uint32)
- func (tcd *ChannelData) TripTime() float32
- func (tcd *ChannelData) Write(data []byte) (n int, err error)
- func (tcd *ChannelData) WriteNowait(data []byte, cb func()) (n int, err error)
- func (tcd *ChannelData) WriteUnsafe(data []byte) (int, error)
- type EventData
- type RealTimeSpeed
- type TRUDP
- func (trudp *TRUDP) AllowEvents(events uint32)
- func (trudp *TRUDP) ChanEvent() <-chan *EventData
- func (trudp *TRUDP) ChanEventClosed()
- func (trudp *TRUDP) Close()
- func (trudp *TRUDP) Connect(rhost string, rport int)
- func (trudp *TRUDP) ConnectChannel(rhost string, rport int, ch int) (tcd *ChannelData)
- func (trudp *TRUDP) GetAddr() (ip string, port int)
- func (trudp *TRUDP) Run()
- func (trudp *TRUDP) Running() bool
- func (trudp *TRUDP) SetDefaultQueueSize(defaultQueueSize int)
- func (trudp *TRUDP) SetShowStatistic(showStatF bool)
- func (trudp *TRUDP) ShowStatistic() bool
- func (trudp *TRUDP) Timestamp() uint32
Constants ¶
const ( DATA = iota //(0x0) ACK //(0x1) RESET //(0x2) ACKReset //(0x3) PING //(0x4) ACKPing //(0x5) )
Packet type
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
const ( // DefaultQueueSize is size of send and receive queue DefaultQueueSize = 256 // 96 )
const USESYSCALL = false
USESYSCALL flag select udp libray or syscall (may be syscall will be deprekated bekause library wotk good)
const Version = "3.0.0"
Version is srudp version
Variables ¶
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) 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) 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) 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 (*TRUDP) AllowEvents ¶
AllowEvents set allow events flags
func (*TRUDP) ChanEventClosed ¶
func (trudp *TRUDP) ChanEventClosed()
ChanEventClosed signalling that event channel reader routine sucessfully closed
func (*TRUDP) ConnectChannel ¶
func (trudp *TRUDP) ConnectChannel(rhost string, rport int, ch int) (tcd *ChannelData)
ConnectChannel to remote host by UDP
func (*TRUDP) Run ¶
func (trudp *TRUDP) Run()
Run waits some data received from UDP port and procces it
func (*TRUDP) SetDefaultQueueSize ¶
SetDefaultQueueSize set maximum send and receive queues size
func (*TRUDP) SetShowStatistic ¶
SetShowStatistic set showStatF to show trudp statistic window