tgconsumer

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: 27 Imported by: 0

README

ndn-dpdk/app/tgconsumer

This package is the traffic generator consumer. It may act as a ndnping client. It requires two threads, running TgcTx_Run and TgcRx_Run functions.

The consumer sends Interests and receives Data or Nacks. It supports multiple configurable patterns:

  • probability of selecting this pattern relative to other patterns
  • Name prefix
  • CanBePrefix flag
  • MustBeFresh flag
  • InterestLifetime value
  • HopLimit value
  • implicit digest
  • relative sequence number

The consumer randomly selects a pattern and creates an Interest with the pattern settings. The Interest name ends with a sequence number, which is a 64-bit integer encoded in binary format and native endianness. Strictly speaking, this encoding violates the ndnping protocol, which requires the sequence number to be encoded in ASCII. However, the current C++ ndnpingserver implementation can respond to such Interests.

The consumer maintains Interest, Data, Nack counters and collects Data round-trip time for each pattern.

Implicit Digest

The consumer can generate Interests whose name contains an implicit digest component. This is achieved by locally constructing a Data packet according to a Data template, and then computing its implicit digest. Due to its performance overhead, patterns using this feature should be assigned lower weights.

When this feature is being used, the consumer contains a DPDK crypto device, and each pattern uses a queue pair. Data packets for each pattern are prepared in bursts and enqueued into the crypto device submission queue. Every time a pattern is selected, the consumer dequeues a Data packet from the crypto device completion queue, takes its computed implicit digest to construct an Interest, and then discards the Data packet. In the rare case that the crypto device completion queue fails to return a Data packet, the consumer may randomly select another traffic pattern to use.

For the producer to create Data packets that can satisfy those Interests, the producer's pattern should have a reply definition that has the same Data template. Name suffix cannot be used in the Data template.

Relative Sequence Number

Normally, each traffic pattern in the consumer has an independent sequence number that is incremented by one every time the pattern is selected. If the seqNumOffset option is set to a non-zero value, the traffic pattern would instead use a relative sequence number.

Suppose the seqNumOffset option is specified on traffic pattern i, every time pattern i is selected:

  1. The consumer reads the last sequence number of pattern i-1.
  2. This sequence number is subtracted by the seqNumOffset of pattern i.
  3. In the unlikely case that the computed sequence number same as the last sequence number of pattern i (i.e. pattern i-1 has not been selected between two consecutive selections of pattern i), the sequence number is incremented by one.

This feature enables the consumer to generate Interests that can potentially be satisfied by cached Data in a forwarder, if the seqNumOffset setting is appropriate for the cache capacity and network latency.

Limitations of this feature:

  • seqNumOffset cannot be specified on the first pattern.
  • seqNumOffset cannot be specified together with implicit digest.
  • Even if pattern i-1 has implicit digest, Interests from pattern i will not have implicit digest.
  • To reduce the probability of incremented sequence number (step 3) that reduces the effectiveness of generating cache hits, pattern i should be assigned a lower weight than pattern i-1.

PIT token usage

The consumer encodes the following information in the PIT token field:

  • when the Interest was sent,
  • which pattern created the Interest,
  • a "run number", so that replies to Interests from previous executions are not considered.

Having the above information inside the packet eliminates the need for a pending Interest table, allowing the consumer to operate more efficiently. However, the consumer cannot detect network faults, such as unsolicited replies, duplicate replies, mismatched implicit digests.

Documentation

Overview

Package tgconsumer implements a traffic generator consumer.

Index

Constants

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

	// MaxSumWeight is maximum sum of weights among traffic patterns.
	MaxSumWeight = 8192

	// DigestLowWatermark is the number of remaining Data packets in the crypto device before enqueuing a new burst.
	DigestLowWatermark = 16

	// DigestBurstSize is the number of Data packets to enqueue into crypto device.
	DigestBurstSize = 64
)

Variables

View Source
var (
	GqlPatternInput        *graphql.InputObject
	GqlConfigInput         *graphql.InputObject
	GqlPatternCountersType *graphql.Object
	GqlCountersType        *graphql.Object
	GqlConsumerType        *gqlserver.NodeType[*Consumer]
)

GraphQL types.

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

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

Functions

This section is empty.

Types

type Config

type Config struct {
	RxQueue iface.PktQueueConfig `json:"rxQueue,omitempty"`

	// Interval defines average Interest interval.
	// TX thread transmits Interests in bursts, so the specified interval will be converted to
	// a burst interval with equivalent traffic amount.
	// Default is 1ms.
	Interval nnduration.Nanoseconds `json:"interval"`

	// Patterns defines traffic patterns.
	// It must contain between 1 and MaxPatterns entries.
	Patterns []Pattern `json:"patterns"`
	// contains filtered or unexported fields
}

Config describes consumer configuration.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate applies defaults and validates the configuration.

type Consumer

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

Consumer represents a traffic generator consumer instance.

func New

func New(face iface.Face, cfg Config) (c *Consumer, e error)

New creates a Consumer.

func (*Consumer) ClearCounters

func (c *Consumer) ClearCounters()

ClearCounters clears counters. Both RX and TX threads should be stopped before calling this, otherwise race conditions may occur.

func (*Consumer) Close

func (c *Consumer) Close() error

Close closes the consumer.

func (*Consumer) ConnectRxQueues

func (c *Consumer) ConnectRxQueues(demuxD, demuxN *iface.InputDemux)

ConnectRxQueues connects Data+Nack InputDemux to RxQueues.

func (*Consumer) Counters

func (c *Consumer) Counters() (cnt Counters)

Counters retrieves counters.

func (Consumer) Face

func (c Consumer) Face() iface.Face

Face returns the associated face.

func (Consumer) Interval

func (c Consumer) Interval() time.Duration

Interval returns average Interest interval.

func (*Consumer) Launch

func (c *Consumer) Launch()

Launch launches RX and TX threads.

func (Consumer) Patterns

func (c Consumer) Patterns() []Pattern

Patterns returns traffic patterns.

func (*Consumer) Stop

func (c *Consumer) Stop() error

Stop stops RX and TX threads.

func (*Consumer) StopDelay

func (c *Consumer) StopDelay(delay time.Duration) error

StopDelay stops the TX thread, sleep for the specified duration, then stops the RX thread.

func (Consumer) Workers

func (c Consumer) Workers() []ealthread.ThreadWithRole

Workers returns worker threads.

type Counters

type Counters struct {
	PacketCounters
	NAllocError uint64               `json:"nAllocError"`
	Rtt         runningstat.Snapshot `json:"rtt" gqldesc:"RTT in nanoseconds."`
	PerPattern  []PatternCounters    `json:"perPattern"`
}

Counters contains consumer counters.

func (Counters) String

func (cnt Counters) String() string

type PacketCounters

type PacketCounters struct {
	NInterests uint64 `json:"nInterests"`
	NData      uint64 `json:"nData"`
	NNacks     uint64 `json:"nNacks"`
}

PacketCounters is a group of network layer packet counters.

func (PacketCounters) DataRatio

func (cnt PacketCounters) DataRatio() float64

DataRatio returns NData/NInterests.

func (PacketCounters) NackRatio

func (cnt PacketCounters) NackRatio() float64

NackRatio returns NNacks/NInterests.

func (PacketCounters) String

func (cnt PacketCounters) String() string

type Pattern

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

	ndni.InterestTemplateConfig

	// If specified, append implicit digest to Interest name.
	// For Data to satisfy Interests, the producer pattern must reply with the same DataGenConfig.
	Digest *ndni.DataGenConfig `json:"digest,omitempty"`

	// If non-zero, request cached Data. This must appear after a pattern without SeqNumOffset.
	// The consumer derives sequence number by subtracting SeqNumOffset from the previous pattern's
	// sequence number. Sufficient CS capacity is necessary for Data to actually come from CS.
	SeqNumOffset int `json:"seqNumOffset,omitempty"`
}

Pattern configures how the consumer generates a sequence of Interests.

type PatternCounters

type PatternCounters struct {
	PacketCounters
	Rtt runningstat.Snapshot `json:"rtt" gqldesc:"RTT in nanoseconds."`
}

PatternCounters contains per-pattern counters.

func (PatternCounters) String

func (cnt PatternCounters) String() string

Jump to

Keyboard shortcuts

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