tnet

package
Version: v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: Apache-2.0, MIT Imports: 16 Imported by: 23

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ZeroLocalTCPAddress, _ = ma.NewMultiaddr("/ip4/127.0.0.1/tcp/0")

ZeroLocalTCPAddress is the "zero" tcp local multiaddr. This means:

/ip4/127.0.0.1/tcp/0

Functions

func FindNetworkLimit

func FindNetworkLimit(testFunc NetworkTestFunc) (int, error)

FindNetworkLimit benchmarks a function to analyze CPU and network relationship

func ParallelismSlowdown

func ParallelismSlowdown(testFunc NetworkTestFunc, kbps int, l time.Duration) (slowdown float64, err error)

ParallelismSlowdown tracks how much overhead is incurred on a ntework bound function when parallelism contentention in increased.

func RandLocalTCPAddress

func RandLocalTCPAddress() ma.Multiaddr

RandLocalTCPAddress returns a random multiaddr. it suppresses errors for nice composability-- do check the address isn't nil.

NOTE: for real network tests, use ZeroLocalTCPAddress so the kernel assigns an unused TCP port. otherwise you may get clashes. This function remains here so that p2p/net/mock (which does not touch the real network) can assign different addresses to peers.

Types

type Identity

type Identity interface {
	Address() ma.Multiaddr
	ID() peer.ID
	PrivateKey() ci.PrivKey
	PublicKey() ci.PubKey
}

func NewIdentity

func NewIdentity(ID peer.ID, addr ma.Multiaddr, privk ci.PrivKey, pubk ci.PubKey) Identity

NewIdentity constructs a new identity object with specific parameters

func RandIdentity

func RandIdentity() (Identity, error)

func RandIdentityOrFatal

func RandIdentityOrFatal(t *testing.T) Identity

type LatencyConfig

type LatencyConfig struct {
	BlockstoreLatency time.Duration
	NetworkLatency    time.Duration
	RoutingLatency    time.Duration
}

func (LatencyConfig) AllInstantaneous

func (c LatencyConfig) AllInstantaneous() LatencyConfig

func (LatencyConfig) Blockstore7200RPM

func (c LatencyConfig) Blockstore7200RPM() LatencyConfig

func (LatencyConfig) BlockstoreFastSSD2014

func (c LatencyConfig) BlockstoreFastSSD2014() LatencyConfig

func (LatencyConfig) BlockstoreSlowSSD2014

func (c LatencyConfig) BlockstoreSlowSSD2014() LatencyConfig

func (LatencyConfig) NetworkIntraDatacenter2014

func (c LatencyConfig) NetworkIntraDatacenter2014() LatencyConfig

func (LatencyConfig) NetworkNYtoSF

func (c LatencyConfig) NetworkNYtoSF() LatencyConfig

func (LatencyConfig) RoutingSlow

func (c LatencyConfig) RoutingSlow() LatencyConfig

type NetworkTestFunc

type NetworkTestFunc func(b *testing.B, n1, n2 net.Conn)

NetworkTestFunc is a benchmark function under test by `FindNetworkLimit`

type PeerNetParams

type PeerNetParams struct {
	ID      peer.ID
	PrivKey ci.PrivKey
	PubKey  ci.PubKey
	Addr    ma.Multiaddr
}

PeerNetParams is a struct to bundle together the four things you need to run a connection with a peer: id, 2keys, and addr.

func RandPeerNetParams

func RandPeerNetParams() (*PeerNetParams, error)

func RandPeerNetParamsOrFatal

func RandPeerNetParamsOrFatal(t *testing.T) PeerNetParams

type WriteTrackedConn

type WriteTrackedConn struct {
	net.Conn
	WriteCount atomic.Uint32
}

WriteTrackedConn provides a wrapper for tracking how many write calls are made to a network connection.

func ConnectionForNetwork

func ConnectionForNetwork(n *latency.Network) (n1, n2 *WriteTrackedConn, err error)

ConnectionForNetwork generates a pair of network connections with a specified latency.

func (*WriteTrackedConn) Write

func (c *WriteTrackedConn) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to