Documentation
¶
Overview ¶
Package ping is CION's SCMP echo library. It holds the mechanics the node's echoes share: a conn that sends echo requests and delivers the replies to them; the requests awaiting their replies, each settled with its round trip or as lost after its wait; and the responder hosts the requests go to, resolved off the caller's loop. Its client, behind `cion ping`, rides a destination's lease, sends a count of requests, and reports per-reply RTT, the reply's path hops, and a loss summary. The responder that answers is the destination node's own, part of its core.
Index ¶
- func Resolve(ctx context.Context, conn *scion.Conn, dst addr.IA, path *spath.Decoded) (netip.Addr, error)
- type Config
- type Conn
- type Hosts
- func (h *Hosts) Adopt(r Resolution, now time.Time)
- func (h *Hosts) Ask(dst addr.IA, paths []*spath.Decoded, now time.Time)
- func (h *Hosts) Forget(dst addr.IA)
- func (h *Hosts) Host(dst addr.IA) (netip.Addr, bool)
- func (h *Hosts) Landed() <-chan Resolution
- func (h *Hosts) Resolve(ctx context.Context)
- func (h *Hosts) RetryAt(dst addr.IA) time.Time
- type Paths
- type Pending
- type Reply
- type ReplyStat
- type Report
- type Resolution
- type Resolver
- type Settled
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Resolve ¶
func Resolve(ctx context.Context, conn *scion.Conn, dst addr.IA, path *spath.Decoded) (netip.Addr, error)
Resolve resolves the responder host in dst over the path on the conn, which nothing else may read meanwhile: the drafts' service resolution of dst's control service, whose answer names the host the responder's socket is bound to. A nil path resolves over the one-hop path out of a link to dst.
Types ¶
type Config ¶
type Config struct {
// Conn is the pinger's socket; its port becomes the echo identifier the
// replies return to.
Conn *scion.Conn
// Paths leases the path to the destination.
Paths Paths
// Dst is the destination ISD-AS.
Dst addr.IA
// DstHost is the destination's underlay host address, which the
// responder's socket is bound to.
DstHost netip.Addr
// Count is the number of requests to send.
Count int
// Interval is the time between requests.
Interval time.Duration
// Wait bounds the wait for each reply before it counts as lost.
Wait time.Duration
// Ready bounds the wait for the network to serve before the counted
// run: the wait for the lease's first path is retried within it and
// uncounted warm-up requests leave until one is answered. Zero waits once
// and counts at once; a destination no path composes for, within the
// bound when set, is an error either way, never a hang.
Ready time.Duration
// Log receives a line per reply and the summary; nil discards them.
Log func(string, ...any)
}
Config configures one ping run.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn sends a caller's echo requests on a SCION conn and delivers the replies to them, which ReadReplies reads off the conn on a goroutine of the caller's.
func NewConn ¶
NewConn returns a Conn over the conn, which nothing else may read: a reply read elsewhere is lost to it.
func (*Conn) ReadReplies ¶
ReadReplies reads the conn until ctx ends, whose end moves the read deadline to the past, delivering each reply to the conn's own requests on Replies. It returns nil once ctx ended, or the read's failure.
type Hosts ¶
type Hosts struct {
// contains filtered or unexported fields
}
Hosts holds the responder hosts of the destinations a caller echoes, and resolves each one asked for off the caller's loop: that loop asks for hosts and adopts each resolution as it lands, and Resolve, which the caller runs on a goroutine of its own, resolves them one at a time. Every method but Resolve and Landed belongs to the caller's loop.
func NewHosts ¶
NewHosts returns a Hosts that holds no host, resolves by resolve, and spaces a failed resolution's retry by retry.
func (*Hosts) Adopt ¶
func (h *Hosts) Adopt(r Resolution, now time.Time)
Adopt adopts a resolution that landed: its host, or for its failure the spacing of the retry.
func (*Hosts) Ask ¶
Ask asks for the destination's host over the paths, tried in turn until one answers; the host held meanwhile stays. It asks nothing while a resolution of the destination is in flight, before a failed one's retry, or while the asks waiting fill the queue.
func (*Hosts) Landed ¶
func (h *Hosts) Landed() <-chan Resolution
Landed delivers each resolution as it lands, for the caller's loop to adopt.
type Pending ¶
type Pending[T any] struct { // contains filtered or unexported fields }
Pending holds a caller's echo requests awaiting their replies, each with the caller's value for it, and settles each by its reply, or as lost once it has waited its wait. One loop of the caller's calls it.
func NewPending ¶
NewPending returns a Pending whose requests each wait for their reply.
func (*Pending[T]) Answered ¶
Answered settles the request the reply answers; false for a reply no request awaits, as one that came after its request's wait.
func (*Pending[T]) Deadline ¶
Deadline returns when the wait of the request sent first among those awaiting their replies runs out; false while none awaits one.
type Reply ¶
Reply is one echo reply to a conn's own request: its sequence number, whether it came back marked, and when it arrived.
type ReplyStat ¶
type ReplyStat struct {
// Seq is the reply's sequence number.
Seq uint16
// RTT is the time from sending the request to reading the reply.
RTT time.Duration
// Hops is the number of hop fields of the reply's arrival path — the
// reversed road the reply came by; a one-hop arrival counts one hop.
Hops int
// Segments is the number of segments of the arrival path.
Segments int
}
ReplyStat is one matched reply.
type Report ¶
type Report struct {
// Sent is the number of requests sent.
Sent int
// Received is the number of requests answered.
Received int
// Replies holds one statistic per received reply.
Replies []ReplyStat
}
Report summarizes a ping run.
func Run ¶
Run sends Count echo requests at Interval, matching replies by identifier and sequence, each over the path the destination's lease holds then, and reports each counted reply to the lease as a delivery and each request it waited out as a loss; a router's interface-down signal ends a request's wait and reports nothing. Ready bounds the wait for a network still converging — the wait for the lease's first path retried within it, uncounted warm-up requests leaving until one is answered — so the counted run reports the network, not its bring-up. A destination no path composes for, within Ready when set, is an error, not a hang.
type Resolution ¶
Resolution is one resolution that landed: the destination, and its host or the failure that left it unresolved.