utils

package
v0.0.0-...-465a192 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PCAPLog

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

PCAPLog is a collection of PCAPReceivedPackets

func NewPCAPLog

func NewPCAPLog() *PCAPLog

Returns an instantiated PCAPLog

func (*PCAPLog) Print

func (pl *PCAPLog) Print()

prints current statistics for the pcap logger

func (*PCAPLog) ReceivedPcap

func (pl *PCAPLog) ReceivedPcap(ID uint32, clientID uint16, frag bool, tsSent uint64, tsExperimentStart uint64, dataLen uint32)

should be called with the received pcap packet

type PCAPReceivedPacket

type PCAPReceivedPacket struct {
	ID uint32

	ReceivedAt      uint64
	SentAt          uint64
	Delay           uint64
	DataLen         uint32
	IsFinalFragment bool
	// contains filtered or unexported fields
}

PCAPReceivedPacket represents a PCAP that was transmitted through Prifi and received at the relay

type Packet

type Packet struct {
	ID                        uint32
	MsSinceBeginningOfCapture uint64 //milliseconds since beginning of capture
	Header                    []byte
	RealLength                int
}

Packet is an ID(Packet number), TimeSent in microsecond, and some Data

func ParsePCAP

func ParsePCAP(path string, maxPayloadLength int, clientID uint16) ([]Packet, error)

Parses a .pcap file, and returns all valid packets. A packet is (ID, TimeSent [milliseconds], Data)

func ParsePKTS

func ParsePKTS(path string, maxPayloadLength int, clientID uint16) ([]Packet, error)

Parses a .pkts file (homemade format with [timestamp, bytes, npackets], and returns all valid packets. A packet is (ID, TimeSent [milliseconds], Data)

type StateMachine

type StateMachine struct {
	sync.Mutex
	// contains filtered or unexported fields
}

is used to asset that an entity is in a given state

func (*StateMachine) AssertState

func (s *StateMachine) AssertState(state string) bool

asserts (and returns true/false) that the state is the one given. Fails if the given state is invalid

func (*StateMachine) AssertStateOrState

func (s *StateMachine) AssertStateOrState(state1 string, state2 string) bool

asserts (and returns true/false) that the state is the one given. Fails if the given state is invalid

func (*StateMachine) ChangeState

func (s *StateMachine) ChangeState(newState string)

changes state if it is valid

func (*StateMachine) Init

func (s *StateMachine) Init(states []string, logInfo, logErr func(interface{}))

creates a StateMachine with two logging functions. The initial state will be states[0]

func (*StateMachine) SetEntity

func (s *StateMachine) SetEntity(e string)

sets the entity used in printing the log messages

func (*StateMachine) State

func (s *StateMachine) State() string

returns the current state

Jump to

Keyboard shortcuts

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