Documentation ¶
Overview ¶
Package common providers common OTG flow helper functions.
Index ¶
- func Handler(fn hdrsFunc, bpfFn bpfFunc, match matchFunc, reporter *Reporter) lwotg.FlowGeneratorFn
- func NewCounters() *counters
- func OverrideHandleCreator(pc HandleCreator)
- func Ports(flow *otg.Flow, intfs []*lwotg.OTGIntf) (tx string, rx string, err error)
- func Rate(flow *otg.Flow, hdrs []gopacket.SerializableLayer) (uint64, error)
- type HandleCreator
- type Port
- type Reporter
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 ¶
Ports returns the transmit and receive ports in terms of the physical interfaces of the underlying system for a flow.
func Rate ¶
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 ¶
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 (*Reporter) AddFlow ¶
AddFlow adds the supplied flow, fc, as the entry at name in the map. It overwrites existing entries.