statsprint

package
v0.1.0-alpha.7 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MulanPSL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package statsprint 提供与 iperf3 UDP 周期表相近的终端定宽输出。

Index

Constants

View Source
const (
	RoleDirWidth   = 12
	TimeWidth      = 12
	TransferWidth  = 13
	BitrateWidth   = 17
	JitterWidth    = 12
	LostTotalWidth = 20
)

列宽度常量

View Source
const (
	DirectionUL    = "UL"  // 上行
	DirectionDL    = "DL"  // 下行
	DirectionTotal = "SUM" // 总计
)

Direction 流量方向

View Source
const (
	RoleClient = "CLIENT" // 客户端
	RoleServer = "SERVER" // 服务端
)

Role 角色标识

Variables

This section is empty.

Functions

func FormatJitter

func FormatJitter(ms float64, ok bool) string

FormatJitter 返回抖动列字符串;无样本时为 " N/A "。

func FormatLostTotal

func FormatLostTotal(lost, total int64) string

FormatLostTotal 格式化为 iperf 风格 "lost/total (pct%)";total==0 时百分比为 0。

func FormatUDPRow

func FormatUDPRow(r UDPRow) string

FormatUDPRow 生成一行定宽输出(不含换行)。

func MeanInterArrivalJitterMs

func MeanInterArrivalJitterMs(arrivalNs []int64, expectedSpacingNs int64) (ms float64, ok bool)

MeanInterArrivalJitterMs 根据本端入站包到达时间戳(纳秒,单调递增)与理论包间隔(纳秒)计算平均绝对到达偏差,单位毫秒。 样本不足(少于 2 个到达)时返回 ok=false。

func WriteUDPRow

func WriteUDPRow(w io.Writer, r UDPRow) error

WriteUDPRow 写入一行周期统计(含换行)。

func WriteUDPTableHeader

func WriteUDPTableHeader(w io.Writer) error

WriteUDPTableHeader 写入 iperf3 UDP 风格表头(含 Jitter、Lost/Total)。

Types

type UDPRow

type UDPRow struct {
	Role             string
	Direction        string
	IntervalStartSec float64
	IntervalEndSec   float64
	TransferBytes    uint64
	IntervalSeconds  float64
	JitterMs         float64
	JitterOk         bool
	Lost, Total      int64
}

UDPRow 单行周期统计([角色:方向] + 五列语义)。

Source Files

  • statsprint.go

Jump to

Keyboard shortcuts

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