latency

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0, MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// None represents zero no-op latency model.
	None = none{}
)

Functions

This section is empty.

Types

type LogNormal

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

LogNormal represents a log normal latency distribution with a configurable mean latency. This latency model does not specialise based on host clock time nor participants.

func NewLogNormal

func NewLogNormal(seed int64, mean time.Duration) *LogNormal

NewLogNormal instantiates a new latency model of log normal latency distribution with the given mean. This model will always return zero if mean latency duration is less than or equal to zero.

func (*LogNormal) Sample

func (l *LogNormal) Sample(_ time.Time, from gpbft.ActorID, to gpbft.ActorID) time.Duration

Sample returns latency samples that correspond to the log normal distribution with the configured mean. The samples returned disregard time and participants, i.e. all the samples returned correspond to a fixed log normal distribution. Latency from one participant to another may be asymmetric and once generated remains constant for the lifetime of a simulation.

Note, when mean configured latency is not larger than zero the latency sample will always be zero.

type Model

type Model interface {
	// Sample returns an artificial latency at time t for communications from a
	// participant to another participant.
	//
	// See: gpbft.Host, gpbft.Clock.
	Sample(t time.Time, from, to gpbft.ActorID) time.Duration
}

Model represents a latency model of cross participant communication. The model offers the ability for implementation of varying latency across a simulation, as well as specialised latency across specific participants.

See LogNormal, Zipf, None.

type Modeler

type Modeler func() (Model, error)

Modeler instantiates a new latency Model.

type Zipf

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

Zipf represents a log normal latency distribution with a configurable max latency. This latency model does not specialise based on host clock time nor participants.

func NewZipf

func NewZipf(seed int64, s, v float64, max time.Duration) (*Zipf, error)

NewZipf instantiates a new latency model of ZipF latency distribution with the given max.

func (*Zipf) Sample

func (l *Zipf) Sample(_ time.Time, from gpbft.ActorID, to gpbft.ActorID) time.Duration

Sample returns latency samples that correspond to this ZipF numerical distribution. The samples returned disregard time and participants, i.e. the distribution does not vary over time nor for specific participants.

Jump to

Keyboard shortcuts

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