beaconing

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Overview

Package beaconing implements tasks and handlers related to beacon propagation and registration.

Handler

Call NewHandler to create a beacon handler that implements infra.Handler. The handler validates the received beacon and verifies all signatures. If successful, the beacon is added to the beacon store.

Originator

The originator should only be instantiated by core beacon servers. It periodically creates fresh beacons and propagates them on all core and child links. In case the task is run before a full period has passed, beacons are originated on all interfaces that have last been originated on more than one period ago.

Registrar

The registrar is a periodic task to register segments with the appropriate path server. Core and Up segments are registered with the local path server. Down segments are registered with the originating core AS. In case the task is run before a full period has passed, segments are only registered, if there has not been a successful registration in the last period.

Propagator

The propagator is a periodic task to propagate beacons to the appropriate neighboring ASes. In a core AS, the beacons are propagated to the neighbors on all core link, unless they will create an AS loop. In a non-core AS, the beacons are propagated to the neighbors on all child links. In case the task is run before a full period has passed, beacons are propagated on all interfaces that have last been propagated on more than one period ago.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BeaconInserter

type BeaconInserter interface {
	PreFilter(beacon beacon.Beacon) error
	InsertBeacon(ctx context.Context, beacon beacon.Beacon) (beacon.InsertStats, error)
}

BeaconInserter inserts beacons into the beacon store.

type BeaconProvider

type BeaconProvider interface {
	BeaconsToPropagate(ctx context.Context) (<-chan beacon.BeaconOrErr, error)
}

BeaconProvider provides beacons to send to neighboring ASes.

type BeaconSender added in v0.6.0

type BeaconSender interface {
	Send(ctx context.Context, beacon *seg.PathSegment, dst addr.IA,
		egress common.IFIDType, nextHop *net.UDPAddr) error
}

BeaconSender sends the beacon on the provided interface.

type DefaultExtender added in v0.6.0

type DefaultExtender struct {
	// IA is the local IA
	IA addr.IA
	// Signer is used to sign path segments.
	Signer seg.Signer
	// MAC is used to calculate the hop field MAC.
	MAC func() hash.Hash
	// Intfs holds all interfaces in the AS.
	Intfs *ifstate.Interfaces
	// MTU is the MTU value set in the AS entries.
	MTU uint16
	// GetMaxExpTime returns the maximum relative expiration time.
	MaxExpTime func() uint8
	// Task contains an identifier specific to the task that uses the extender.
	Task string
	// StaticInfo contains the configuration used for the StaticInfo Extension.
	StaticInfo func() *StaticInfoCfg
}

DefaultExtender extends provided path segments with entries for the local AS.

func (*DefaultExtender) Extend added in v0.6.0

func (s *DefaultExtender) Extend(ctx context.Context, pseg *seg.PathSegment,
	ingress, egress common.IFIDType, peers []common.IFIDType) error

Extend extends the beacon with hop fields of the old format.

type Extender added in v0.6.0

type Extender interface {
	// Extend extends the path segment. The zero value for ingress indicates
	// that the created AS entry is the initial entry in a path. The zero value
	// for egress indicates that the created AS entry is the last entry in the
	// path, and the beacon is terminated.
	Extend(ctx context.Context, seg *seg.PathSegment, ingress, egress common.IFIDType,
		peers []common.IFIDType) error
}

Extender extends path segments.

type Handler added in v0.6.0

type Handler struct {
	LocalIA    addr.IA
	Inserter   BeaconInserter
	Verifier   infra.Verifier
	Interfaces *ifstate.Interfaces

	BeaconsHandled metrics.Counter
}

Handler handles beacons.

func (Handler) HandleBeacon added in v0.6.0

func (h Handler) HandleBeacon(ctx context.Context, b beacon.Beacon, peer *snet.UDPAddr) error

HandleBeacon handles a baeacon received from peer.

type InterfaceBandwidths added in v0.6.0

type InterfaceBandwidths struct {
	Inter uint64                     `json:"Inter"`
	Intra map[common.IFIDType]uint64 `json:"Intra"`
}

type InterfaceGeodata added in v0.6.0

type InterfaceGeodata struct {
	Longitude float32 `json:"Longitude"`
	Latitude  float32 `json:"Latitude"`
	Address   string  `json:"Address"`
}

type InterfaceHops added in v0.6.0

type InterfaceHops struct {
	Intra map[common.IFIDType]uint32 `json:"Intra"`
}

type InterfaceLatencies added in v0.6.0

type InterfaceLatencies struct {
	Inter util.DurWrap                     `json:"Inter"`
	Intra map[common.IFIDType]util.DurWrap `json:"Intra"`
}

type LinkType added in v0.6.0

type LinkType staticinfo.LinkType

func (*LinkType) MarshalText added in v0.6.0

func (l *LinkType) MarshalText() ([]byte, error)

func (*LinkType) UnmarshalText added in v0.6.0

func (l *LinkType) UnmarshalText(text []byte) error

type LocalWriter added in v0.6.0

type LocalWriter struct {
	// InternalErrors counts errors that happened before being able to send a
	// segment to a remote. This can for example be during the termination of
	// the segment. If the counter is nil errors are not counted.
	InternalErrors metrics.Counter
	// Registered counts the amount of registered segments. A label is used to
	// indicate the status of the registration.
	Registered metrics.Counter
	// Type is the type of segment that is handled by this writer.
	Type seg.Type
	// Store is used to store the terminated segments.
	Store SegmentStore
	// Extender is used to terminate the beacon.
	Extender Extender
	// Intfs gives access to the interfaces this CS beacons over.
	Intfs *ifstate.Interfaces
}

LocalWriter can be used to write segments in the SegmentStore.

func (*LocalWriter) Write added in v0.6.0

func (r *LocalWriter) Write(ctx context.Context, segments <-chan beacon.BeaconOrErr,
	peers []common.IFIDType) (WriteStats, error)

Write terminates the segments and registers them in the SegmentStore.

type Originator

type Originator struct {
	Extender     Extender
	BeaconSender BeaconSender
	IA           addr.IA
	Signer       seg.Signer
	Intfs        *ifstate.Interfaces

	Originated metrics.Counter

	// Tick is mutable.
	Tick Tick
}

Originator originates beacons. It should only be used by core ASes.

func (*Originator) Name

func (o *Originator) Name() string

Name returns the tasks name.

func (*Originator) Run

func (o *Originator) Run(ctx context.Context)

Run originates core and downstream beacons.

type Pather added in v0.6.0

type Pather interface {
	GetPath(svc addr.HostSVC, ps *seg.PathSegment) (*snet.SVCAddr, error)
}

Pather computes the remote address with a path based on the provided segment.

type Propagator

type Propagator struct {
	Extender     Extender
	BeaconSender BeaconSender
	Provider     BeaconProvider
	IA           addr.IA
	Signer       seg.Signer
	Intfs        *ifstate.Interfaces
	Core         bool
	AllowIsdLoop bool

	Propagated     metrics.Counter
	InternalErrors metrics.Counter

	// Tick is mutable.
	Tick Tick
}

Propagator forwards beacons to neighboring ASes. In a core AS, the beacons are propagated to neighbors on core links. In a non-core AS, the beacons are forwarded on child links. Selection of the beacons is handled by the beacon provider, the propagator only filters AS loops.

func (*Propagator) Name

func (p *Propagator) Name() string

Name returns the tasks name.

func (*Propagator) Run

func (p *Propagator) Run(ctx context.Context)

Run propagates beacons provided by the beacon provider on all active target interfaces. In a core beacon server, core interfaces are the target interfaces. In a non-core beacon server, child interfaces are the target interfaces.

type RPC added in v0.6.0

type RPC interface {
	RegisterSegment(ctx context.Context, meta seg.Meta, remote net.Addr) error
}

RPC registers the path segment with the remote.

type RemoteWriter added in v0.6.0

type RemoteWriter struct {
	// InternalErrors counts errors that happened before being able to send a
	// segment to a remote. This can be during terminating the segment, looking
	// up the remote etc. If the counter is nil errors are not counted.
	InternalErrors metrics.Counter
	// Registered counts the amount of registered segments. A label is used to
	// indicate the status of the registration.
	Registered metrics.Counter
	// Intfs gives access to the interfaces this CS beacons over.
	Intfs *ifstate.Interfaces
	// Extender is used to terminate the beacon.
	Extender Extender
	// Type is the type of segment that is handled by this writer.
	Type seg.Type
	// RPC is used to send the segment to a remote.
	RPC RPC
	// Pather is used to find paths to a remote.
	Pather Pather
}

RemoteWriter writes segments via an RPC to the source AS of a segment.

func (*RemoteWriter) Write added in v0.6.0

func (r *RemoteWriter) Write(ctx context.Context, segments <-chan beacon.BeaconOrErr,
	peers []common.IFIDType) (WriteStats, error)

Write writes the segment at the source AS of the segment.

type SegmentProvider

type SegmentProvider interface {
	// SegmentsToRegister returns the segments that should be registered for the
	// given segment type. The returned channel must not be nil if the returned
	// error is nil.
	SegmentsToRegister(ctx context.Context, segType seg.Type) (
		<-chan beacon.BeaconOrErr, error)
}

SegmentProvider provides segments to register for the specified type.

type SegmentStore

type SegmentStore interface {
	StoreSegs(context.Context, []*seghandler.SegWithHP) (seghandler.SegStats, error)
}

SegmentStore stores segments in the path database.

type StaticInfoCfg added in v0.6.0

type StaticInfoCfg struct {
	Latency   map[common.IFIDType]InterfaceLatencies  `json:"Latency"`
	Bandwidth map[common.IFIDType]InterfaceBandwidths `json:"Bandwidth"`
	LinkType  map[common.IFIDType]LinkType            `json:"LinkType"`
	Geo       map[common.IFIDType]InterfaceGeodata    `json:"Geo"`
	Hops      map[common.IFIDType]InterfaceHops       `json:"Hops"`
	Note      string                                  `json:"Note"`
}

StaticInfoCfg is used to parse data from config.json.

func ParseStaticInfoCfg added in v0.6.0

func ParseStaticInfoCfg(file string) (*StaticInfoCfg, error)

ParseStaticInfoCfg parses data from a config file into a StaticInfoCfg struct.

func (StaticInfoCfg) Generate added in v0.6.0

func (cfg StaticInfoCfg) Generate(intfs *ifstate.Interfaces,
	ingress, egress common.IFIDType) *staticinfo.Extension

Generate creates a StaticInfoExtn struct and populates it with data extracted from the configuration.

type Tick added in v0.6.0

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

Tick keeps track whether the period has passed compared to the last time.

If the Tick's clock has never been set, its value is the default Go time.Time.

func NewTick added in v0.6.0

func NewTick(period time.Duration) Tick

func (*Tick) Now added in v0.6.0

func (t *Tick) Now() time.Time

func (*Tick) Overdue added in v0.6.0

func (t *Tick) Overdue(timestamp time.Time) bool

Overdue returns true if the Tick's period has elapsed since timestamp in the past up to the Tick's Now time.

func (*Tick) Passed added in v0.6.0

func (t *Tick) Passed() bool

Passed returns true if the Tick's period has elapsed since the last UpdateLast call up to the Tick's Now time.

func (*Tick) Period added in v0.6.0

func (t *Tick) Period() time.Duration

func (*Tick) SetNow added in v0.6.0

func (t *Tick) SetNow(now time.Time)

func (*Tick) UpdateLast added in v0.6.0

func (t *Tick) UpdateLast()

UpdateLast updates the last time to the current time, if the period has passed since last.

type WriteScheduler added in v0.6.0

type WriteScheduler struct {
	// Provider is used to query for segments.
	Provider SegmentProvider
	// Intfs gives access to the interfaces this CS beacons over.
	Intfs *ifstate.Interfaces
	// Type is the type of segments that should be queried from the Provider.
	Type seg.Type
	// Write is used to write the segments once the scheduling determines it is
	// time to write.
	Writer Writer

	// Tick is mutable. It's used to determine when to call write.
	Tick Tick
	// contains filtered or unexported fields
}

WriteScheduler is used to periodically write path segments at the configured writer.

func (*WriteScheduler) Name added in v0.6.0

func (r *WriteScheduler) Name() string

Name returns the tasks name.

func (*WriteScheduler) Run added in v0.6.0

func (r *WriteScheduler) Run(ctx context.Context)

Run writes path segments using the configured writer.

type WriteStats added in v0.6.0

type WriteStats struct {
	// Count is the number of successfully written segments.
	Count int
	// StartIAs lists the AS.
	StartIAs map[addr.IA]struct{}
}

WriteStats provides statistics about segment writing.

type Writer added in v0.6.0

type Writer interface {
	// Write must consume the segments channel until it's closed by the caller.
	// The provided channel is always non-nil. Peers indicate the peering
	// interface IDs of the local IA. The returned statistics should provide
	// insights about how many segments have been successfully written. The
	// method should return an error if the writing did fail.
	Write(ctx context.Context, segments <-chan beacon.BeaconOrErr,
		peers []common.IFIDType) (WriteStats, error)
}

Writer writes segments.

Directories

Path Synopsis
Package mock_beaconing is a generated GoMock package.
Package mock_beaconing is a generated GoMock package.

Jump to

Keyboard shortcuts

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