fperf

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const CtrlHeaderLen = 12 //Byte
View Source
const FirstDataLen = 5
View Source
const RWBufferSize = 1048576

Variables

View Source
var TCPListener net.Listener

Functions

func StopTCPServe

func StopTCPServe() error

func TCPSendServe

func TCPSendServe(Addr string, duration time.Duration) error

func TCPSendServeWithContext

func TCPSendServeWithContext(ctx context.Context, Addr string, duration time.Duration) error

Types

type ConnType added in v0.1.3

type ConnType uint8
const (
	UnsetConn ConnType = iota
	TransConn
	CtrlConn
)

type CtrlHeader

type CtrlHeader struct {
	CtrlType      CtrlType
	Reserved      [7]byte
	PayloadLength uint32
	Data          []byte
}

func PacketFromReader

func PacketFromReader(r io.Reader) (*CtrlHeader, error)

func (*CtrlHeader) Pack

func (h *CtrlHeader) Pack() []byte

type CtrlType

type CtrlType uint8
const (
	CtrlType_Unknown CtrlType = iota
	START
	DATA
	FIN
	STAT
)

func ParseType

func ParseType(t uint8) CtrlType

func (*CtrlType) Uint8

func (t *CtrlType) Uint8() uint8

type Fperf

type Fperf struct {
	Conn         net.Conn
	CtrlConn     net.Conn
	TestDuration time.Duration
	Stat         *freconn.Stat
	PeerStat     *freconn.Stat
	Role         RoleType
	Finish       bool
}

func NewReceiver

func NewReceiver(conn, ctrlConn net.Conn) *Fperf

func NewSender

func NewSender(conn, ctrlConn net.Conn, duration time.Duration) *Fperf

func (*Fperf) GetPeerStat

func (f *Fperf) GetPeerStat() *freconn.Stat

func (*Fperf) GetStat

func (f *Fperf) GetStat() *freconn.Stat

func (*Fperf) RunReceiver

func (f *Fperf) RunReceiver() error

func (*Fperf) RunSender

func (f *Fperf) RunSender() error

type RoleType

type RoleType int
const (
	RoleType_Unknown RoleType = iota
	Sender
	Receiver
)

type TCPInfo added in v0.1.7

type TCPInfo struct {
	*tcpinfo.TCPInfo
}

func GetsockoptTCPInfo added in v0.1.7

func GetsockoptTCPInfo(tcpConn *net.TCPConn) (*TCPInfo, error)

type TcpPerfServer

type TcpPerfServer struct {
	Addr string
}

type TcpResult

type TcpResult struct {
	// TCP信息
	TCPInfo *TCPInfo
	// 发送的总数据量(bit)
	SendTotal uint64
	// 对端接收的总数据量(bit)
	RecvTotal uint64
	// 测试时间(second)
	Time int64
	// 重传量
	Retrans uint32
	Dura    time.Duration
}

func TCPClientRecv

func TCPClientRecv(serverAddr string, timeout time.Duration) (r *TcpResult, err error)

func TCPClientRecvCompatible

func TCPClientRecvCompatible(serverAddr string, timeout int32) (r *TcpResult, err error)

TCPClientRecvCompatible 测试TCP性能(客户端)

func (*TcpResult) Duration

func (t *TcpResult) Duration() int32

Duration 测试时长(second)

func (*TcpResult) Print

func (t *TcpResult) Print()

Print 打印测试的关键数据

func (*TcpResult) RTT

func (t *TcpResult) RTT() int32

RTT 单位ms

func (*TcpResult) RecvTotalBit

func (t *TcpResult) RecvTotalBit() int64

对端接收的总数据量(bit)

func (*TcpResult) RetransPercents

func (t *TcpResult) RetransPercents() float64

RetransPercents 重传率,若要以%表示需要额外*100

func (*TcpResult) SendTotalBit

func (t *TcpResult) SendTotalBit() int64

发送的总数据量(bit)

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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