common

package
v0.0.0-...-518e166 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package common providers common OTG flow helper functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(fn hdrsFunc, bpfFn bpfFunc, match matchFunc, reporter *Reporter) lwotg.FlowGeneratorFn

Handler creates a new flow generator function based on the header and match function provided.

func NewCounters

func NewCounters() *counters

func OverrideHandleCreator

func OverrideHandleCreator(pc HandleCreator)

OverrideHandleCreator sets a custom implementation of the handle creator.

func Ports

func Ports(flow *otg.Flow, intfs []*lwotg.OTGIntf) (tx string, rx string, err error)

Ports returns the transmit and receive ports in terms of the physical interfaces of the underlying system for a flow.

func Rate

func Rate(flow *otg.Flow, hdrs []gopacket.SerializableLayer) (uint64, error)

Rate returns the number of packets per second that should be sent for the flow to meet the specified rate. The specified headers are used where packet size calculations are required.

It returns a default rate of 1000 packets per second per the OTG specification if there is no rate specified.

TODO(robjs): support specifications other than simple PPS.

Types

type HandleCreator

type HandleCreator interface {
	CreateHandle(name string) (Port, error)
}

HandleCreator is an interface for creating handles.

type Port

type Port interface {
	gopacket.PacketDataSource
	// WritePacketData writes the frame to the port.
	WritePacketData(data []byte) error
	// Close closes the port.
	Close()
	// LinkType specifies the layer at which packet written to the port are processed.
	LinkType() layers.LinkType
	// SetBPFFilter sets a Berkeley Packet Filtering (BPF) filter for the port.
	// When specified, only packets matching the BPF filter are read from the port.
	SetBPFFilter(string) error
}

Port is interface for reading and writing to a port.

type Reporter

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

Reporter encapsulates multiple named flows.

func NewReporter

func NewReporter() *Reporter

NewReporter returns a new flow reporter.

func (*Reporter) AddFlow

func (r *Reporter) AddFlow(name string, fc *counters)

AddFlow adds the supplied flow, fc, as the entry at name in the map. It overwrites existing entries.

func (*Reporter) Flow

func (r *Reporter) Flow(name string) *counters

Flow returns the counters for the flow with the specified name.

func (*Reporter) Telemetry

func (r *Reporter) Telemetry(updateFn gnmit.UpdateFn, target string)

Jump to

Keyboard shortcuts

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