network

package
v0.0.0-...-a92cdc1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LinkStatus

type LinkStatus struct {

	// available bandwidth
	Bandwidth uint64
}

type Network

type Network interface {

	// Transfer models a transfer starting at time now of size
	// bytes from one location to another with a third parameter
	// to define what happens as a consequence of this transfer.
	// It returns a TransferEvent, which will execute the
	// consequence function at the time the transfer ends, and a
	// possible error if there's a problem with the transfer.
	StartTransfer(when, size uint64, from, to string, consequence func(time uint64) []event.Event) ([]event.Event, error)

	// Advances the network simulation up to time.  Returns the
	// earliest network events that concluded before that time,
	// the time they happened, or an error.
	Advance(time uint64) ([]TransferEvent, uint64, error)

	// Status returns a LinkStatus struct describing the current
	// condition of the link identified by the from, to ids
	Status(from, to string) (LinkStatus, error)

	AddConnection(from, to string, speed, delay uint64)
}

Network is meant to represent transfer of data between data centers.

type SimpleNetwork

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

SimpleNetwork models a naive approach to simulating a network.

func NewSimpleNetwork

func NewSimpleNetwork() SimpleNetwork

func (SimpleNetwork) AddConnection

func (network SimpleNetwork) AddConnection(from, to string, speed, delay uint64)

func (*SimpleNetwork) Advance

func (network *SimpleNetwork) Advance(time uint64) ([]TransferEvent, uint64, error)

func (*SimpleNetwork) StartTransfer

func (network *SimpleNetwork) StartTransfer(when, size uint64, from, to string, consequence func(time uint64) []event.Event) ([]event.Event, error)

func (*SimpleNetwork) Status

func (network *SimpleNetwork) Status(from, to string) (LinkStatus, error)

type TransferEvent

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

func (TransferEvent) Process

func (te TransferEvent) Process() []event.Event

func (TransferEvent) Time

func (te TransferEvent) Time() uint64

Jump to

Keyboard shortcuts

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