bitswap

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2023 License: Apache-2.0, MIT Imports: 20 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InternetLatencyDelayGenerator

func InternetLatencyDelayGenerator(
	mediumDelay time.Duration,
	largeDelay time.Duration,
	percentMedium float64,
	percentLarge float64,
	std time.Duration,
	rng *rand.Rand,
) delay.Generator

InternetLatencyDelayGenerator generates three clusters of delays, typical of the type of peers you would encounter on the interenet. Given a base delay time T, the wait time generated will be either: 1. A normalized distribution around the base time 2. A normalized distribution around the base time plus a "medium" delay 3. A normalized distribution around the base time plus a "large" delay The size of the medium & large delays are determined when the generator is constructed, as well as the relative percentages with which delays fall into each of the three different clusters, and the standard deviation for the normalized distribution. This can be used to generate a number of scenarios typical of latency distribution among peers on the internet.

Types

type Network

type Network interface {
	Adapter(tnet.Identity, ...bsnet.NetOpt) bsnet.BitSwapNetwork

	HasPeer(peer.ID) bool
}

Network is an interface for generating bitswap network interfaces based on a test network.

func RateLimitedVirtualNetwork

func RateLimitedVirtualNetwork(rs mockrouting.Server, d delay.D, rateLimitGenerator RateLimitGenerator) Network

RateLimitedVirtualNetwork generates a testnet instance where nodes are rate limited in the upload/download speed.

func StreamNet

func StreamNet(ctx context.Context, net mockpeernet.Mocknet, rs mockrouting.Server) (Network, error)

StreamNet is a testnet that uses libp2p's MockNet

func VirtualNetwork

func VirtualNetwork(rs mockrouting.Server, d delay.D) Network

VirtualNetwork generates a new testnet instance - a fake network that is used to simulate sending messages.

type RateLimitGenerator

type RateLimitGenerator interface {
	NextRateLimit() float64
}

RateLimitGenerator is an interface for generating rate limits across peers

func FixedRateLimitGenerator

func FixedRateLimitGenerator(rateLimit float64) RateLimitGenerator

FixedRateLimitGenerator returns a rate limit generatoe that always generates the specified rate limit in bytes/sec.

func VariableRateLimitGenerator

func VariableRateLimitGenerator(rateLimit float64, std float64, rng *rand.Rand) RateLimitGenerator

VariableRateLimitGenerator makes rate limites that following a normal distribution.

Jump to

Keyboard shortcuts

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