pcapfile

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package pcapfile loads an Ethernet capture into a form the transmit loop can replay without allocating.

It uses gopacket's pure-Go pcapgo reader, so Wireblast has no libpcap or cgo dependency and a static binary works anywhere.

The whole file is read and validated before the dataplane starts. A broken or unsupported capture should cost you an error message, never a bounced link and a half-started run.

Index

Constants

View Source
const (
	// MinFrame is the smallest thing that can be an Ethernet frame: two MAC
	// addresses and an EtherType.
	MinFrame = 14
	// MaxFrame is the largest frame that can be transmitted. It matches the
	// biggest UMEM frame Wireblast will configure.
	MaxFrame = 16384
	// MaxPackets bounds how many frames a capture may hold, so pointing
	// Wireblast at a capture with millions of tiny records fails politely
	// instead of exhausting the machine.
	MaxPackets = 2_000_000
)

Limits on what will be loaded.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

File is a loaded capture, ready to replay.

Frames live in one contiguous byte slice with an index alongside, so replay is a slice expression and a copy — no per-packet allocation, and the frames stay adjacent in memory for the cache's benefit.

func Load

func Load(path string) (*File, error)

Load reads and validates a capture file.

func (*File) Bytes

func (f *File) Bytes() int

Bytes is the total size of the loaded frames.

func (*File) Describe

func (f *File) Describe() string

Describe summarises the capture for the review screen and the dashboard.

func (*File) Frame

func (f *File) Frame(i int) ([]byte, time.Duration)

Frame returns the i-th frame and the gap the capture recorded before it. The returned slice aliases the backing store and must not be modified.

func (*File) Len

func (f *File) Len() int

Len is how many frames the capture holds.

func (*File) MaxLen

func (f *File) MaxLen() int

MaxLen is the largest frame in the capture, in bytes.

func (*File) MeanLen

func (f *File) MeanLen() int

MeanLen is the mean frame size, used as the rate limiter's estimate.

func (*File) MinLen

func (f *File) MinLen() int

MinLen is the smallest frame in the capture, in bytes.

func (*File) Span

func (f *File) Span() time.Duration

Span is the wall-clock duration the capture covers.

func (*File) Truncated

func (f *File) Truncated() int

Truncated is how many frames were cut short by the capture's snaplen. Those replay as the bytes that were actually captured, which is shorter than what the original host sent.

func (*File) Warnings

func (f *File) Warnings() []string

Warnings lists things about the capture the user should know before replaying it.

Jump to

Keyboard shortcuts

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