endpoint

package
v0.0.0-...-6c4fd92 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: NIST-PD-fallback Imports: 11 Imported by: 7

Documentation

Overview

Package endpoint implements basic consumer and producer functionality.

Endpoint is the basic abstraction through which an application can communicate with the NDN network. It is similar to "client face" in other NDN libraries, with the enhancement that it handles these details automatically:

  • Outgoing packets are signed and incoming packets are verified, if keys are provided.
  • Outgoing Interests are transmitted periodically, if retransmission policy is specified.

Index

Constants

This section is empty.

Variables

View Source
var (
	//lint:ignore ST1005 'Interest' is a proper noun
	ErrExpire = errors.New("Interest expired")
)

Error conditions.

View Source
var (
	//lint:ignore ST1005 'Handler' is a field name
	ErrNoHandler = errors.New("Handler is missing")
)

Error conditions.

Functions

func Consume

func Consume(ctx context.Context, interest ndn.Interest, opts ConsumerOptions) (data *ndn.Data, e error)

Consume retrieves a single piece of Data.

func ReplyNack

func ReplyNack(reason uint8) error

ReplyNack causes the producer to return a Nack packet.

Types

type ConsumerOptions

type ConsumerOptions struct {
	// Fw specifies the L3 Forwarder.
	// Default is the default Forwarder.
	Fw l3.Forwarder

	// Retx specifies retransmission policy.
	// Default is disabling retransmission.
	Retx RetxPolicy

	// Verifier specifies a Data verifier.
	// Default is no verification.
	Verifier ndn.Verifier
}

ConsumerOptions contains arguments to Consume function.

type LFace

type LFace struct {
	FwFace l3.FwFace
	// contains filtered or unexported fields
}

LFace is a logical face between endpoint (consumer or producer) and internal forwarder.

func NewLFace

func NewLFace(fw l3.Forwarder) (face *LFace, e error)

NewLFace creates a logical face to an internal forwarder.

func (*LFace) Close

func (face *LFace) Close() error

Close closes the logical face.

func (*LFace) Rx

func (face *LFace) Rx() <-chan ndn.L3Packet

Rx returns a channel for receiving packets from internal forwarder.

func (*LFace) Send

func (face *LFace) Send(pkt *ndn.Packet) bool

Send attempts to send a packet to internal forwarder. Returns true if packet is queued, or false if packet is dropped.

func (*LFace) Tx

func (face *LFace) Tx() chan<- *ndn.Packet

Tx returns a channel for sending packets to internal forwarder.

type Producer

type Producer interface {
	io.Closer
}

Producer represents a running producer.

func Produce

func Produce(ctx context.Context, opts ProducerOptions) (Producer, error)

Produce starts a producer.

type ProducerHandler

type ProducerHandler func(ctx context.Context, interest ndn.Interest) (ndn.Data, error)

ProducerHandler is a producer handler function.

  • If it returns an error created with ReplyNack(), a Nack is sent in reply to the Interest.
  • If it returns a Data that satisfies the Interest, the Data is sent in reply to the Interest.
  • Otherwise, nothing is sent.

type ProducerOptions

type ProducerOptions struct {
	// Prefix is the name prefix of the producer.
	Prefix ndn.Name

	// NoAdvertise disables prefix announcement.
	// Default is announcing the prefix.
	NoAdvertise bool

	// Handler is a function to handle Interests under the prefix.
	// This may be invoked concurrently.
	Handler ProducerHandler

	// Fw specifies the L3 Forwarder.
	// Default is the default Forwarder.
	Fw l3.Forwarder

	// DataSigner automatically signs Data packets unless already signed.
	// Default is keeping the Null signature.
	DataSigner ndn.Signer
}

ProducerOptions contains arguments to Produce function.

type RetxIterable

type RetxIterable func() time.Duration

RetxIterable is a generator function for successive retransmission intervals. Returns zero to disallow further retransmissions.

type RetxOptions

type RetxOptions struct {
	// Limit is the maximum number of retransmissions, excluding initial Interest.
	// Default is 0, which disables retransmissions.
	Limit int

	// Interval is the initial retransmission interval.
	// Default is 50% of InterestLifetime.
	Interval time.Duration

	// Randomize causes retransmission interval to be randomized within [1-r, 1+r] range.
	// Suppose this is set to 0.1, an interval of 100ms would become [90ms, 110ms].
	// Default is 0.1. Set a negative value to disable randomization.
	Randomize float64

	// Backoff is the multiplication factor on the interval after each retransmission.
	// Valid range is [1.0, 2.0]. Default is 1.0.
	Backoff float64

	// Max is the maximum retransmission interval.
	// Default is 90% of InterestLifetime.
	Max time.Duration
}

RetxOptions specifies how to retransmit an Interest.

func (RetxOptions) IntervalIterable

func (retx RetxOptions) IntervalIterable(lifetime time.Duration) RetxIterable

IntervalIterable implements RetxPolicy interface.

type RetxPolicy

type RetxPolicy interface {
	IntervalIterable(lifetime time.Duration) RetxIterable
}

RetxPolicy represents an Interest retransmission policy.

Jump to

Keyboard shortcuts

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