throughput

package module
v0.0.0-...-59c0ad3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 15 Imported by: 0

README

throughput

I'm working on this to test some network throughput stuff. There's a receiver and sender that proxy in/out data for measurement purposes. There's also included lag scripts for making lag happen at the OS level.

Issues, pull requests, and support currently ignored. MIT license.

Running

  • Client is expected to send to 1235 and listen on 1234
  • Server is expected to send to 1234 and listen on 1235
  • Must use -j > 2 for make to run in parallel SERVER_CMD="server bin + args" CLIENT_CMD="client bin + args" make -j2 benchmark

Make it lag (macos/bsd)

BANDIWDTH="2000Mbit/s" DELAY="10" PLR=".9" make start-lag

Make it stop laging (macos/bsd)

make stop-lag

Linux

Investigating dropped UDP packets

You may be easily dropping packets so check net.core.rmem_max and maybe do sudo sysctl -w net.core.rmem_max=2048000000.

You can check out https://github.com/nhorman/dropwatch and then use sudo dropwatch -l kas followed by start which is easier to work with then netstat as described below.

macOS

Investigating dropped UDP packets

If you're experiencing this, definitely turn on trace logging PION_LOG_TRACE=all to see if anything in the pion stack is dropping packets. If you want to know if any packets dropped at the OS level, run: netstat -s | grep "dropped due to full socket buffers" before and after to calculate how many packets were dropped.

You may want to check sysctl net.inet.udp.recvspace and increase the size if you want to make drops happen at the OS level or avoid them (sysctl -w net.inet.udp.recvspace=999999)

Usage of named pipes

Due to hard-coded limits in macOS, the size of a named pipe is 8192 which on an M1 Max will limit you to a max throughput of ~1GiB/s. A good way to find this limit is to open a named pipe in non blocking mode and write to it until it fails. Writing to it with blocking is a fool's errand because it'll block until someone else reads the bytes, no matter the size (seen in testing). For more info, see https://stackoverflow.com/questions/78444600/why-is-a-fifo-pipe-on-macos-8x-slower-than-an-anonymous-pipe

Documentation

Index

Constants

View Source
const (
	ServerPort = 1234
	ClientPort = 1235

	ServerAddr = "127.0.0.1:1234"
	ClientAddr = "127.0.0.1:1235"
)

Variables

View Source
var (
	ServerUDPAddr = &net.UDPAddr{Port: 1234}
	ClientUDPAddr = &net.UDPAddr{Port: 1235}
)

Functions

func MustInputPipe

func MustInputPipe() io.ReadCloser

func MustOutputPipe

func MustOutputPipe() io.WriteCloser

func ProcessClient

func ProcessClient(createClientConn func() (io.ReadWriteCloser, error))

func ProcessServer

func ProcessServer(createServerConn func() (io.ReadCloser, error))

func ResolveFile

func ResolveFile(fn string) string

func TestPacketThroughput

func TestPacketThroughput(t *testing.T, makeReaderWriterPair func(t *testing.T) (io.ReadCloser, io.WriteCloser, error))

Types

type ConnCloserWrapper

type ConnCloserWrapper struct {
	net.Conn
	CloseFunc func() error
}

func (ConnCloserWrapper) Close

func (c ConnCloserWrapper) Close() error

type MultiSlogHandler

type MultiSlogHandler struct {
	Handlers []slog.Handler
}

func (MultiSlogHandler) Enabled

func (h MultiSlogHandler) Enabled(ctx context.Context, level slog.Level) bool

func (MultiSlogHandler) Handle

func (h MultiSlogHandler) Handle(ctx context.Context, record slog.Record) error

func (MultiSlogHandler) WithAttrs

func (h MultiSlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (MultiSlogHandler) WithGroup

func (h MultiSlogHandler) WithGroup(name string) slog.Handler

type PairedUDPWriter

type PairedUDPWriter struct {
	Conn   transport.UDPConn
	ToAddr net.Addr
}

func (PairedUDPWriter) Close

func (w PairedUDPWriter) Close() error

func (PairedUDPWriter) Write

func (w PairedUDPWriter) Write(p []byte) (n int, err error)

type SCTPStreamConnWrapper

type SCTPStreamConnWrapper struct {
	*sctp.Stream
}

func (SCTPStreamConnWrapper) LocalAddr

func (s SCTPStreamConnWrapper) LocalAddr() net.Addr

func (SCTPStreamConnWrapper) RemoteAddr

func (s SCTPStreamConnWrapper) RemoteAddr() net.Addr

func (SCTPStreamConnWrapper) SetDeadline

func (s SCTPStreamConnWrapper) SetDeadline(time.Time) error

func (SCTPStreamConnWrapper) SetReadDeadline

func (s SCTPStreamConnWrapper) SetReadDeadline(time.Time) error

func (SCTPStreamConnWrapper) SetWriteDeadline

func (s SCTPStreamConnWrapper) SetWriteDeadline(time.Time) error

type Stats

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

func (Stats) String

func (s Stats) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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