pathhealth

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package pathhealth monitors paths to different ASes. Call Monitor.Register() to start monitoring paths to a remote AS using a chosen path policy. The call returns a registration object which can be used to obtain the best path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultPathWatcherFactory

type DefaultPathWatcherFactory struct {
	// LocalIA is the ID of the local AS.
	LocalIA addr.IA
	// LocalIP is the IP address of the local host.
	LocalIP netip.Addr
	// RevocationHandler is the revocation handler.
	RevocationHandler snet.RevocationHandler
	// ConnFactory is used to create probe connections.
	ConnFactory ProbeConnFactory
	// Probeinterval defines the interval at which probes are sent. If it is not
	// set a default is used.
	ProbeInterval time.Duration
	// ProbesSent keeps track of how many path probes have been sent per remote
	// AS.
	ProbesSent func(remote addr.IA) metrics.Counter
	// ProbesReceived keeps track of how many path probes have been received per
	// remote AS.
	ProbesReceived func(remote addr.IA) metrics.Counter
	// ProbesSendErrors keeps track of how many time sending probes failed per
	// remote.
	ProbesSendErrors func(remote addr.IA) metrics.Counter

	SCMPErrors             metrics.Counter
	SCIONPacketConnMetrics snet.SCIONPacketConnMetrics
}

DefaultPathWatcherFactory creates PathWatchers.

func (*DefaultPathWatcherFactory) New

func (f *DefaultPathWatcherFactory) New(
	ctx context.Context,
	remote addr.IA,
	path snet.Path,
	id uint16,
) (PathWatcher, error)

New creates a PathWatcher that monitors a specific path.

type DefaultRemoteWatcherFactory

type DefaultRemoteWatcherFactory struct {
	// Router is used to find paths to remote ASes.
	Router interface {
		AllRoutes(ctx context.Context, dst addr.IA) ([]snet.Path, error)
	}
	// PathWatcherFactory is used to construct PathWatchers.
	PathWatcherFactory PathWatcherFactory
	// PathUpdateInterval specified how often the paths are retrieved from the
	// daemon. If not specified a default is used.
	PathUpdateInterval time.Duration
	// PathFetchTimeout is the timeout for the path fetch operation. If not set
	// a default value is used.
	PathFetchTimeout time.Duration
	// PathsMonitored is a gauge counting the number of paths currently
	// monitored to a remote AS.
	PathsMonitored func(remote addr.IA) metrics.Gauge
}

DefaultRemoteWatcherFactory is a default factory for creating RemoteWatchers.

func (*DefaultRemoteWatcherFactory) New

New creates an RemoteWatcher that keeps track of all the paths for a given remote, and spawns/kills PathWatchers appropriately.

type FilteringPathSelector

type FilteringPathSelector struct {
	// PathPolicy is used to determine which paths are eligible and which are not.
	PathPolicy PathPolicy
	// RevocationStore keeps track of the revocations.
	RevocationStore
	// PathCount is the max number of paths to return to the user. Defaults to 1.
	PathCount int
}

FilteringPathSelector selects the best paths from a filtered set of paths.

func (*FilteringPathSelector) Select

func (f *FilteringPathSelector) Select(selectables []Selectable, current FingerprintSet) Selection

Select selects the best paths.

type FingerprintSet

type FingerprintSet map[snet.PathFingerprint]struct{}

FingerprintSet is a set of path fingerprints.

type MemoryRevocationStore

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

MemoryRevocationStore holds a list of current revocations. It can be used to determine whether a path goes through interfaces which are revoked.

func (*MemoryRevocationStore) AddRevocation

func (s *MemoryRevocationStore) AddRevocation(ctx context.Context, rev *path_mgmt.RevInfo)

AddRevocation adds the revocation to the list of currently active revocations.

func (*MemoryRevocationStore) Cleanup

func (s *MemoryRevocationStore) Cleanup(ctx context.Context)

Cleanup removes all expired revocations.

func (*MemoryRevocationStore) IsRevoked

func (s *MemoryRevocationStore) IsRevoked(path snet.Path) bool

IsRevoked returns true if there is at least one revoked interface on the path.

type Monitor

type Monitor struct {
	// RemoteWatcherFactory creates a RemoteWatcher for the specified remote.
	RemoteWatcherFactory RemoteWatcherFactory
	// contains filtered or unexported fields
}

func (*Monitor) Register

func (m *Monitor) Register(remote addr.IA, selector PathSelector) *Registration

Register starts monitoring given AS under the specified selector.

type PathInfo

type PathInfo []PathInfoEntry

PathInfo contains debug info about onging path monitoring.

type PathInfoEntry

type PathInfoEntry struct {
	Path         string
	Rejected     bool
	RejectReason string
	Current      bool
	Revoked      bool
}

type PathPolicy

type PathPolicy interface {
	Filter(paths []snet.Path) []snet.Path
}

PathPolicy filters the set of paths.

type PathSelector

type PathSelector interface {
	Select(selectable []Selectable, current FingerprintSet) Selection
}

PathSelector selects the best paths from all the available path watchers.

type PathWatcher

type PathWatcher interface {
	// Run runs the path watcher until the context is cancelled.
	Run(context.Context)
	// UpdatePath changes a path to be monitored. While actual path, as in
	// "sequence of SCION interfaces", must never change for a single
	// PathWatcher object, some elements of the path structure (e.g. expiration)
	// do change and should be updated accordingly.
	UpdatePath(path snet.Path)
	// Path returns a fresh copy of the monitored path.
	Path() snet.Path
	// State returns the state of the monitored path.
	State() State
}

PathWatcher monitors a specific path.

type PathWatcherFactory

type PathWatcherFactory interface {
	New(ctx context.Context, remote addr.IA, path snet.Path, id uint16) (PathWatcher, error)
}

PathWatcherFactory constructs a PathWatcher.

type ProbeConnFactory

type ProbeConnFactory interface {
	New(context.Context) (net.PacketConn, error)
}

ProbeConnFactory is used to construct net.PacketConn objects for sending and receiving probes.

type Registration

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

Registration represents a single remote IA monitoring registration

func (*Registration) Close

func (r *Registration) Close()

Close cancels the registration.

func (*Registration) Get

func (r *Registration) Get() Selection

Get returns your own copy of the best available path.

type RemoteWatcher

type RemoteWatcher interface {
	Run(context.Context)
	PathWatchers() []PathWatcher
}

type RemoteWatcherFactory

type RemoteWatcherFactory interface {
	New(remote addr.IA) RemoteWatcher
}

RemoteWatcherFactory creates RemoteWatchers.

type RevocationStore

type RevocationStore interface {
	// AddRevocation adds a revocation.
	AddRevocation(ctx context.Context, rev *path_mgmt.RevInfo)
	// IsRevoked returns true if there is at least one revoked interface on the path.
	IsRevoked(path snet.Path) bool
	// Cleanup removes all expired revocations.
	Cleanup(ctx context.Context)
}

RevocationStore keeps track of revocations.

type Selectable

type Selectable interface {
	Path() snet.Path
	State() State
}

Selectable is a subset of the PathWatcher that is used for path selection.

type Selection

type Selection struct {
	// Path is the list of selected paths. The list is sorted from best to worst
	// according to the scoring function used by the selector.
	Paths []snet.Path
	// PathInfo provides more info about why the path was selected.
	PathInfo PathInfo
	// PathsAlive is the number of active paths available.
	PathsAlive int
	// PathsDead is the number of dead paths.
	PathsDead int
	// PathsRejected is the number of paths that are rejected by the policy.
	PathsRejected int
}

Selection contains the set of selected paths with metadata.

type State

type State struct {
	// IsAlive indicates that the path is currently alive.
	IsAlive bool
	// IsExpired indicates that the path is expired. IsExpired == true implies IsAlive == false but
	// not vice versa.
	IsExpired bool
}

State is the path state used during selection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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