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 ¶
NetworkBytesToUint64 converts up to first 8 bytes of input slice to a uint64.
func Uint64ToNetworkBytes ¶
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) SetSeq ¶
SetSeq sets internal state such that the next message will contain nextSeq.
func (*FlowState) WithdrawMessage ¶
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 ¶
NewMessage parses a byte array into a 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.
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.