socketface

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/iface/socketface

This package implements a face using socket as transport.

socketFace type represents a socket face. See face creation "socket face" section for locator syntax.

Generic Implementation

This package accepts any Go net.Conn instance, which could be either stream-oriented or datagram-oriented. It reuses the functionality implemented in socketransport package. That includes receiving and sending packets, and redialing failed stream-oriented sockets.

RX logic is implemented in rxConns type. Each face has a goroutine that reads one packet at a time from the sockettransport.Transport into the dataroom of a DPDK mbuf. Upon successfully receiving a packet, the mbuf is enqueued to a ring buffer, which is shared among all socket faces. The RxLoop thread calls C SocketRxConns_RxBurst function to dequeue from this ring buffer.

TX logic is implemented in go_SocketFace_TxBurst function. The TxLoop thread may call this function to write a packet to the sockettransport.Transport. Since this is a synchronous call, the TxLoop thread could get blocked if the socket buffer is full.

UDP Specialization

This package offers a specialized implementation when the net.Conn is identified to be a UDP socket. Receiving and sending packets are implemented in C.

RX logic is implemented in rxEpoll type. It maintains an epoll instance that waits for any of the socket file descriptors of all socket faces to become readable or have an error. The RxLoop thread calls SocketRxEpoll_RxBurst function, which checks for epoll events. Upon notified by epoll, packets are received from the socket into mbufs via recvmmsg syscall, and any socket errors are ignored.

TX logic is implemented in SocketFace_DgramTxBurst function, which transmits the packet via sendmmsg syscall.

Documentation

Overview

Package socketface implements UDP/TCP socket faces using Go net.Conn type.

Index

Constants

This section is empty.

Variables

View Source
var (
	GqlRxConnsType *graphql.Object
	GqlRxEpollType *graphql.Object
)

GraphQL types.

Functions

func New

func New(loc Locator) (iface.Face, error)

New creates a socket face.

func Wrap

func Wrap(transport sockettransport.Transport, cfg Config) (iface.Face, error)

Wrap wraps a sockettransport.Transport to a socket face.

Types

type Config

type Config struct {
	iface.Config

	// sockettransport.Config fields.
	// See ndn-dpdk/ndn/sockettransport package for their semantics and defaults.
	RedialBackoffInitial nnduration.Milliseconds `json:"redialBackoffInitial,omitempty"`
	RedialBackoffMaximum nnduration.Milliseconds `json:"redialBackoffMaximum,omitempty"`
}

Config contains socket face configuration.

type GlobalConfig

type GlobalConfig struct {
	// Socket chooses a NUMA socket to create RX/TX threads for socket faces.
	// Default is the first NUMA socket.
	// If the specified NUMA socket does not exist, it uses the default.
	Socket eal.NumaSocket `json:"socket"`

	// RxConns configures net.Conn RX implementation.
	RxConns struct {
		// RingCapacity is the capacity of a ring buffer for packets that are received from net.Conn
		// but have not been picked up by C code.
		RingCapacity int `json:"ringCapacity"`
	} `json:"rxConns"`

	// RxEpoll configures epoll RX implementation, available for UDP sockets only.
	// If this is disabled, UDP sockets will use net.Conn RX implementation.
	RxEpoll struct {
		Disabled bool `json:"disabled"`
	} `json:"rxEpoll"`

	// TxSyscall configures syscall TX implementation, available for UDP sockets only.
	// If this is disabled, UDP sockets will use net.Conn TX implementation.
	TxSyscall struct {
		Disabled bool `json:"disabled"`
	} `json:"txSyscall"`
}

GlobalConfig contains global options applied to all socket faces.

func (GlobalConfig) Apply

func (cfg GlobalConfig) Apply()

type Locator

type Locator struct {
	*Config
	Network string `json:"scheme"`
	Local   string `json:"local,omitempty"`
	Remote  string `json:"remote"`
}

Locator describes network and addresses of a socket.

func (Locator) CreateFace

func (loc Locator) CreateFace() (iface.Face, error)

CreateFace creates a face from this Locator.

func (Locator) Scheme

func (loc Locator) Scheme() string

Scheme returns the protocol.

func (Locator) Validate

func (loc Locator) Validate() error

Validate checks the addresses.

func (Locator) WithSchemeField

func (Locator) WithSchemeField()

WithSchemeField implements iface.locatorWithSchemeField interface.

Jump to

Keyboard shortcuts

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