segment

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package segment wraps the vendored control-plane protobuf path segment messages in CION-owned domain types: parsing path-construction beacons, creating and signing AS entries, computing hop-field MACs, and building data-plane paths from registered segments.

Index

Constants

View Source
const (
	// HopExpTime is the expiration time of created hop fields: a hop expires
	// (1+HopExpTime) hop-field units after the segment timestamp — six hours.
	HopExpTime uint8 = 63

	// MTU is the intra-AS MTU advertised in created AS entries (draft Section
	// 2.2.2.2; a fixed default, like the reference implementation's).
	MTU uint32 = 1500
)

Variables

This section is empty.

Functions

func Compose

func Compose(parts ...*scion.Decoded) (*scion.Decoded, error)

Compose concatenates segment paths into one end-to-end data-plane path: up (reversed), core, and down segments in travel order. The result starts at the first part's current position.

func EdgeDelay added in v0.0.10

func EdgeDelay(up, down *ASEntry) (time.Duration, bool)

EdgeDelay returns the declared one-way delay of the link between two consecutive entries, from up's egress interface to down's ingress interface, whichever direction travel runs: the higher of the two ends' declarations where both declare, false where neither does — an undeclared edge is unknown, not free.

Types

type ASEntry

type ASEntry struct {
	// IA is the ISD-AS of the AS that created this entry.
	IA addr.IA
	// Next is the ISD-AS of the downstream AS the beacon is forwarded to;
	// zero on a terminating entry (Section 3.1.1).
	Next addr.IA
	// IngressMTU is the MTU of the ingress interface in beaconing direction.
	IngressMTU uint32
	// Hop is the data-plane hop field of this entry.
	Hop path.HopField
	// Latency holds the one-way delays the entry's signed extension declares
	// (the StaticInfoExtension the drafts name for segment latency), keyed by
	// the declaring ISD-AS and interface. Each AS attests its own links
	// alone; nil when the entry declares none.
	Latency map[LinkID]time.Duration
	// Signed is the raw signed component, the input to signature
	// verification.
	Signed *cryptopb.SignedMessage
}

ASEntry is one decoded AS entry: the signed body's fields together with the raw signed component they were extracted from.

type EntryOptions

type EntryOptions struct {
	// Next is the ISD-AS of the neighbor the beacon is propagated to; zero
	// terminates the segment (Section 3.1.1).
	Next addr.IA
	// IngressIfID is the interface the beacon entered this AS on; zero on
	// the originating core.
	IngressIfID uint16
	// EgressIfID is the interface the beacon leaves on; zero on a
	// terminating entry.
	EgressIfID uint16
	// EgressLatency is the egress link's declared one-way delay, carried in
	// the signed extension the drafts define — the node's latest measured
	// echo round trip halved. Zero declares nothing: a link without a sample
	// declares none.
	EgressLatency time.Duration
}

EntryOptions describes the AS entry to append to the segment.

type Info

type Info struct {
	Timestamp time.Time
	ID        uint16
}

Info is the decoded segment information (Section 2.2.1): the creation timestamp set by the originating core, and the 16-bit segment identifier seeding the hop-field MAC chain.

type LinkID

type LinkID struct {
	// IA is the ISD-AS of the interface's end.
	IA addr.IA
	// IfID is the interface ID at that end.
	IfID uint16
}

LinkID identifies one link by an ISD-AS and one of its interface IDs — either end names the link — the identity interface-down signals name and composed paths' link sets carry.

type PCB

type PCB struct {
	// PB is the wire form; it is mutated by AppendEntry.
	PB *cppb.PathSegment
	// Info is the decoded segment information.
	Info Info
	// Entries are the decoded AS entries, in construction direction.
	Entries []ASEntry
}

PCB is a parsed path-construction beacon or path segment: the wire message with its segment information and AS entries decoded (control plane draft, Section 2.2).

func NewPCB

func NewPCB(now time.Time) (*PCB, error)

NewPCB creates a fresh beacon's wire form: new segment information with a cryptographically random 16-bit segment ID and the creation timestamp (Section 2.2.1). The caller appends the originating core's AS entry.

func PCBWithID

func PCBWithID(now time.Time, id uint16) (*PCB, error)

PCBWithID creates a fresh beacon's wire form with the given segment ID.

func ParsePCB

func ParsePCB(pb *cppb.PathSegment) (*PCB, error)

ParsePCB decodes the wire message's segment information and AS entries.

func (*PCB) AppendEntry

func (p *PCB) AppendEntry(
	ctx context.Context,
	ia addr.IA,
	opts EntryOptions,
	macFactory func() hash.Hash,
	signer Signer,
) error

AppendEntry appends this AS's signed entry to the segment and MACs the hop field with the data-plane forwarding key — the same MAC algorithm the processor verifies — chaining the segment ID through the existing hops (dataplane draft, Section 4.1).

func (*PCB) AppendRouteHop

func (p *PCB) AppendRouteHop(
	ia addr.IA,
	opts EntryOptions,
	macFactory func() hash.Hash,
) (path.HopField, error)

AppendRouteHop appends this AS's hop field to the segment without signing an entry: the enrollment route built from an unverified beacon, whose reversed path needs the node's own hop to leave its router. The appended entry carries no signature — it is a route, never a stored, propagated, or registered segment.

func (*PCB) AssociatedData

func (p *PCB) AssociatedData(i int) [][]byte

AssociatedData returns the signature input association for entry i (Section 2.2.2.6): the segment information followed by the signed component and signature of every previous entry.

func (*PCB) Clone

func (p *PCB) Clone() (*PCB, error)

Clone returns a deep copy of the segment's current state, for extending one candidate into several propagated or terminated segments.

func (*PCB) ContainsIA

func (p *PCB) ContainsIA(ia addr.IA) bool

ContainsIA reports whether any entry names the given ISD-AS.

func (*PCB) Expiration

func (p *PCB) Expiration() time.Time

Expiration returns the earliest absolute hop expiration of the segment (Section 2.2.2.5): each hop expires its ExpTime units after the segment timestamp.

func (*PCB) FirstIA

func (p *PCB) FirstIA() addr.IA

FirstIA returns the ISD-AS of the first entry, the segment's originator.

func (*PCB) ForwardPath

func (p *PCB) ForwardPath() *scion.Decoded

ForwardPath returns the data-plane path in construction direction: originator to terminator, hop fields as beaconed.

func (*PCB) ForwardPathFrom

func (p *PCB) ForwardPathFrom(i int) (*scion.Decoded, error)

ForwardPathFrom returns the data-plane path in construction direction beginning mid-segment at entry i: the hop fields of entries i onward, the segment ID chained through the entries the travel skips — the state at position i, the same arithmetic ReversePath performs for the terminator. A hop field's MAC depends on the hops before it in construction direction, never on the hops after it, so starting past the skipped entries verifies unchanged. The result carries at least two hop fields, the minimum the data plane accepts of a segment without the peering flag.

func (*PCB) ID

func (p *PCB) ID() uint16

ID returns the segment's identifier.

func (*PCB) IndexOfIA

func (p *PCB) IndexOfIA(ia addr.IA) int

IndexOfIA returns the index of the first entry naming the given ISD-AS, or -1 when none does.

func (*PCB) LastIA

func (p *PCB) LastIA() addr.IA

LastIA returns the ISD-AS of the last entry.

func (*PCB) ReversePath

func (p *PCB) ReversePath() *scion.Decoded

ReversePath returns the data-plane path against construction direction: terminator to originator, hop fields reversed, and the segment ID chained through every hop but the terminator's own — the value the info field holds when a packet starts at this end (dataplane draft, Section 4.1).

func (*PCB) ReversePathTo

func (p *PCB) ReversePathTo(m int) (*scion.Decoded, error)

ReversePathTo returns the data-plane path against construction direction ending mid-segment at entry m: reversed travel starts at the terminator whatever the ending, so the info field is ReversePath's own — its chained state covers entries 0 to n-2 independent of m — and the hop fields run from the terminator down to m. Removing trailing hops changes no state a kept router reads. The result carries at least two hop fields, the minimum the data plane accepts of a segment without the peering flag.

func (*PCB) RouteKey added in v0.0.10

func (p *PCB) RouteKey() string

RouteKey encodes the route the entries cross: each entry's ISD-AS and its ingress and egress interface IDs in construction order. Every origination of one route shares the key, each drawing a fresh segment ID and timestamp over the same links.

func (*PCB) Timestamp

func (p *PCB) Timestamp() time.Time

Timestamp returns the segment's creation timestamp.

type Signer

type Signer interface {
	Sign(ctx context.Context, msg []byte, associatedData ...[]byte) (*cryptopb.SignedMessage, error)
}

Signer signs an AS entry body with its associated data (draft Section 2.2.2.6); trust.Engine and trust.Signer satisfy it.

Jump to

Keyboard shortcuts

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