endpoint

package
v0.0.0-...-c2e30b8 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: NIST-PD-fallback Imports: 10 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 (
	ErrExpire = errors.New("Interest expired")
)

Error conditions.

View Source
var (
	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 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 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) func() time.Duration

IntervalIterable implements RetxPolicy.

type RetxPolicy

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

RetxPolicy represents an Interest retransmission policy.

Jump to

Keyboard shortcuts

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