net

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HostIP

func HostIP(host string) string

HostIP looks up an IP for a hostname.

func IsReachable

func IsReachable(ctx context.Context, destNode string) bool

IsReachable returns the destNode is reachable with ping.

Types

type IPTables

type IPTables struct {
	Net
}

IPTables implements Net interface to simulate the network.

func (IPTables) Drop

func (IPTables) Drop(ctx context.Context, node string, srcNode string) error

Drop drops traffic from node.

func (IPTables) Fast

func (IPTables) Fast(ctx context.Context, node string) error

Fast removes packet loss and delays.

func (IPTables) Flaky

func (IPTables) Flaky(ctx context.Context, node string) error

Flaky introduces randomized packet loss.

func (IPTables) Heal

func (IPTables) Heal(ctx context.Context, node string) error

Heal ends all traffic drops and restores network to fast operations.

func (IPTables) Slow

func (IPTables) Slow(ctx context.Context, node string, opts SlowOptions) error

Slow delays the network packets with opetions.

type Net

type Net interface {
	// Drop runs on the node and drops traffic from srcNode.
	Drop(ctx context.Context, node string, srcNode string) error
	// Heal runs on the node and ends all traffic drops and restores network to fast operations.
	Heal(ctx context.Context, node string) error
	// Slow runs on the node and delays the network packets with options.
	Slow(ctx context.Context, node string, opts SlowOptions) error
	// Flaky runs on the node and introduces randomized packet loss.
	Flaky(ctx context.Context, node string) error
	// Fast runs on the node and removes packet loss and delays.
	Fast(ctx context.Context, node string) error
}

Net is used to control the network.

type Noop

type Noop struct {
	Net
}

Noop implements Net interface but does nothing.

func (Noop) Drop

func (Noop) Drop(ctx context.Context, node string, srcNode string) error

Drop drops traffic from node.

func (Noop) Fast

func (Noop) Fast(ctx context.Context, node string) error

Fast removes packet loss and delays.

func (Noop) Flaky

func (Noop) Flaky(ctx context.Context, node string) error

Flaky introduces randomized packet loss.

func (Noop) Heal

func (Noop) Heal(ctx context.Context, node string) error

Heal ends all traffic drops and restores network to fast operations.

func (Noop) Slow

func (Noop) Slow(ctx context.Context, node string, opts SlowOptions) error

Slow delays the network packets with opetions.

type SlowOptions

type SlowOptions struct {
	Mean         time.Duration
	Variance     time.Duration
	Distribution string
}

SlowOptions is used to delay the network packets.

func DefaultSlowOptions

func DefaultSlowOptions() SlowOptions

DefaultSlowOptions returns a default options.

Jump to

Keyboard shortcuts

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