bitswap

package
v0.0.0-...-8b9b725 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2019 License: MIT, MIT Imports: 19 Imported by: 8

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(testutil.Identity) bsnet.BitSwapNetwork

	HasPeer(peer.ID) bool
}

func RateLimitedVirtualNetwork

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

func StreamNet

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

func VirtualNetwork

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

type RateLimitGenerator

type RateLimitGenerator interface {
	NextRateLimit() float64
}

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