tgproducer

package
v0.0.0-...-1e60831 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: NIST-PD-fallback Imports: 20 Imported by: 0

README

ndn-dpdk/app/tgproducer

This package is the traffic generator producer. It may act as a ndnping server. It requires at least one thread, running the Tgp_Run function.

The producer responds to every Interest with Data or Nack. It supports multiple configurable patterns:

  • Name prefix
  • a list of possible reply definitions, each with a relative probability of being selected and one of:
    • Data template: Name suffix, FreshnessPeriod value, Content payload length
    • Nack reason
    • timeout/drop

Upon receiving an Interest, the producer finds a pattern whose name prefix is a prefix of the Interest name, and randomly picks a reply definition. It then creates a Data or Nack packet according to the selected reply, unless the latter specifies a "timeout". In case of a Data reply, the Data Name is the Interest name (except implicit digest) combined with the configured name suffix; if the name suffix is non-empty, the Interest needs to have the CanBePrefix flag. An Interest that does not match any pattern is dropped.

The producer maintains counters for the number of processed Interests under each pattern and reply definition, and a counter for non-matching Interests.

Documentation

Overview

Package tgproducer implements a traffic generator producer.

Index

Constants

View Source
const (
	// MaxPatterns is maximum number of traffic patterns.
	MaxPatterns = 128

	// MaxReplies is maximum number of replies per pattern.
	MaxReplies = 8

	// MaxSumWeight is maximum sum of weights among replies.
	MaxSumWeight = 256
)

Variables

View Source
var (
	ErrNoPattern       = errors.New("no pattern specified")
	ErrTooManyPatterns = fmt.Errorf("cannot add more than %d patterns", MaxPatterns)
	ErrPrefixTooLong   = fmt.Errorf("prefix cannot exceed %d octets", ndni.NameMaxLength)
	ErrTooManyReplies  = fmt.Errorf("cannot add more than %d replies", MaxReplies)
	ErrTooManyWeights  = fmt.Errorf("sum of weight cannot exceed %d", MaxSumWeight)
)

Error conditions.

View Source
var (
	GqlReplyInput          *graphql.InputObject
	GqlPatternInput        *graphql.InputObject
	GqlConfigInput         *graphql.InputObject
	GqlPatternCountersType *graphql.Object
	GqlCountersType        *graphql.Object
	GqlProducerType        *gqlserver.NodeType[*Producer]
)

GraphQL types.

View Source
var GqlRetrieveByFaceID func(id iface.ID) *Producer

GqlRetrieveByFaceID returns *Producer associated with a face. It is assigned during package tg initialization.

Functions

This section is empty.

Types

type Config

type Config struct {
	NThreads int                  `json:"nThreads,omitempty"` // number of threads, minimum/default is 1
	RxQueue  iface.PktQueueConfig `json:"rxQueue,omitempty"`
	Patterns []Pattern            `json:"patterns"`
	// contains filtered or unexported fields
}

Config describes producer configuration.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate applies defaults and validates the configuration.

type Counters

type Counters struct {
	PerPattern  []PatternCounters `json:"perPattern"`
	NInterests  uint64            `json:"nInterests"`
	NNoMatch    uint64            `json:"nNoMatch"`
	NAllocError uint64            `json:"nAllocError"`
}

Counters contains producer counters.

func (Counters) String

func (cnt Counters) String() string

type Pattern

type Pattern struct {
	Prefix  ndn.Name `json:"prefix"`
	Replies []Reply  `json:"replies"` // if empty, reply with Data FreshnessPeriod=1
}

Pattern configures how the producer replies to Interests under a name prefix.

type PatternCounters

type PatternCounters struct {
	NInterests uint64   `json:"nInterests"`
	PerReply   []uint64 `json:"perReply"`
}

PatternCounters contains per-pattern counters.

func (PatternCounters) String

func (cnt PatternCounters) String() string

type Producer

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

Producer represents a traffic generator producer instance.

func New

func New(face iface.Face, cfg Config) (p *Producer, e error)

New creates a Producer.

func (*Producer) Close

func (p *Producer) Close() error

Close closes the producer.

func (*Producer) ConnectRxQueues

func (p *Producer) ConnectRxQueues(demuxI *iface.InputDemux)

ConnectRxQueues connects Interest InputDemux to RxQueues.

func (Producer) Counters

func (p Producer) Counters() (cnt Counters)

Counters retrieves counters.

func (Producer) Face

func (p Producer) Face() iface.Face

Face returns the associated face.

func (*Producer) Launch

func (p *Producer) Launch()

Launch launches all workers.

func (Producer) Patterns

func (p Producer) Patterns() []Pattern

Patterns returns traffic patterns.

func (*Producer) Stop

func (p *Producer) Stop() error

Stop stops all workers.

func (Producer) Workers

func (p Producer) Workers() []ealthread.ThreadWithRole

Workers returns worker threads.

type Reply

type Reply struct {
	Weight int `json:"weight,omitempty"` // weight of random choice, minimum/default is 1

	ndni.DataGenConfig
	Nack    uint8 `json:"nack,omitempty"`    // if not NackNone, reply with Nack instead of Data
	Timeout bool  `json:"timeout,omitempty"` // if true, drop the Interest instead of sending Data
}

Reply configures how the producer replies to the Interest.

func (Reply) Kind

func (reply Reply) Kind() ReplyKind

Kind returns ReplyKind.

type ReplyKind

type ReplyKind int

ReplyKind indicates reply packet type.

const (
	ReplyData ReplyKind = iota
	ReplyNack
	ReplyTimeout
)

ReplyKind values.

Jump to

Keyboard shortcuts

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