Documentation
¶
Index ¶
- Constants
- func ActiveProcs() map[string]int
- func BytesPerSecToMbps(bps float64) float64
- func Run(ctx context.Context, p *Progress, connections int, duration time.Duration)
- func RunMonitor(ctx context.Context, p *Progress, sampleInterval time.Duration)
- type Phase
- type ProcUse
- type Progress
- type Result
- type Sample
Constants ¶
const ( // DefaultConnections is the number of parallel streams used to saturate the link. DefaultConnections = 5 // DefaultDuration is how long each transfer phase (download / upload) runs. DefaultDuration = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func ActiveProcs ¶ added in v1.4.0
ActiveProcs returns processes that currently hold network connections, keyed by process name with the number of connections. It is best-effort and never errors: on unsupported platforms it returns an empty map. No elevated privileges are required — it only enumerates sockets, not their byte counts.
func BytesPerSecToMbps ¶
BytesPerSecToMbps converts a raw byte/sec rate into megabits per second.
func Run ¶
Run executes the full test: discover targets, download, upload, latency. It streams Phase transitions on p.Phases, Samples on p.Samples, and a final Result on p.Result. Always emits a Result (best-effort partials on cancel).
func RunMonitor ¶
RunMonitor is the real Bandwidth Monitor engine for Linux. It generates no traffic: it reads the kernel's per-interface byte counters from /sys/class/net/<iface>/statistics/{rx,tx}_bytes and derives the actual download / upload throughput of the whole PC from byte deltas between samples. It runs until ctx is cancelled.
Scope: every "up" interface except loopback (lo) is summed, so the numbers reflect total PC throughput (Wi-Fi, Ethernet, VPN, LAN, ...).
Types ¶
type Progress ¶
type Progress struct {
URLs []string // discovered target URLs (set once)
ServerName string // human-readable server/region label (set once)
Phases chan Phase // phase transitions
Samples chan Sample
Result chan Result
Err error
}
Progress is the live channel payload the UI consumes.