message

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package message implements wrappers for sending and receiving messages with sequence numbers and timestamps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NetworkBytesToUint64

func NetworkBytesToUint64(bytes []byte) uint64

NetworkBytesToUint64 converts up to first 8 bytes of input slice to a uint64.

func Uint64ToNetworkBytes

func Uint64ToNetworkBytes(val uint64) []byte

Uint64ToNetworkBytes converts a 64bit unsigned integer to an 8-byte slice. in network byte order.

Types

type FlowState

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

FlowState maintains the state of flow on both the src and dst sides.

func (*FlowState) CreateMessage

func (fs *FlowState) CreateMessage(ts time.Time, payload []byte, maxLen int) ([]byte, uint64, error)

CreateMessage creates a message for the flow and returns byte array representation of the message and sequence number used on success. TODO: add Message.CreateMessage() fn and use it in FlowState.CreateMessage.

func (*FlowState) NextSeq

func (fs *FlowState) NextSeq() uint64

NextSeq returns the next sequence number that will be used.

func (*FlowState) SetSeq

func (fs *FlowState) SetSeq(nextSeq uint64)

SetSeq sets internal state such that the next message will contain nextSeq.

func (*FlowState) WithdrawMessage

func (fs *FlowState) WithdrawMessage(seq uint64) bool

WithdrawMessage tries to update internal state that message with "seq" was not sent. If no new packet was sent in parallel, then sequence number is decremented, and the function returns true. Otherwise, it is a no-op and the function returns false.

type FlowStateMap

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

FlowStateMap is a container to hold all flows with a mutex to safely add new flows.

func NewFlowStateMap

func NewFlowStateMap() *FlowStateMap

NewFlowStateMap returns a new FlowStateMap variable.

func (*FlowStateMap) FlowState

func (fm *FlowStateMap) FlowState(src, srcPort, dst string) *FlowState

FlowState returns the flow state for the node, creating a new one if necessary.

type Message

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

Message is a wrapper struct for the message protobuf that provides functions to access the most commonly accessed fields.

func NewMessage

func NewMessage(msgBytes []byte) (*Message, error)

NewMessage parses a byte array into a message.

func (*Message) Dst

func (m *Message) Dst() string

Dst returns the dst node name.

func (*Message) Payload

func (m *Message) Payload() []byte

Payload returns the payload in the UDP message.

func (*Message) ProcessOneWay

func (m *Message) ProcessOneWay(fsm *FlowStateMap, rxTS time.Time) *Results

ProcessOneWay processes a one-way message on the receiving end. It updates FlowState for the sender seq|msgTS|rxTS and returns a Results object with metrics derived from the message.

func (*Message) Seq

func (m *Message) Seq() uint64

Seq returns the sequence number.

func (*Message) Src

func (m *Message) Src() string

Src returns the src node name.

func (*Message) SrcPort

func (m *Message) SrcPort() string

SrcPort returns the src port.

func (*Message) SrcTS

func (m *Message) SrcTS() time.Time

SrcTS returns the timestamp for the source.

type Results

type Results struct {
	FS *FlowState

	Success   bool
	LostCount int
	Delayed   bool
	Dup       bool

	// Delta of rxTS and src timestamp in message.
	Latency time.Duration

	// Inter-packet delay for one-way-packets = delta_recv_ts - delta_send_ts.
	// delta_send_ts = sender_ts_for_seq - sender_ts_for_seq+1 (send_ts is in msg)
	// delta_recv_ts = rcvr_ts_for_seq - rcvr_ts_for_seq+1 (ts at msg recv).
	InterPktDelay time.Duration
}

Results captures the result of sequence number analysis after processing the latest message.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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