This is the documentation for the v21.03 version. Looking for the documentation of the latest version? Have a look here.
Shared Memory Packet Interfaces (memif)¶
A Shared Memory Packet Interface (memif) has two components: A socket and an
interface. A memif also requires a
most TNSR applications, it will be the server and the other endpoint will be a
client. A single socket may only be associated with one role type.
interface memif socket command has two forms, both of which are required
in most cases. The first creates an association between a socket ID and a
filename. The second creates a memif interface using a specific socket.
Creating a memif Socket¶
To create the socket-filename association, use:
interface memif socket
<socket-id> filename <socket-filename>.
An exception to this is socket
0 which is special and locked to
/run/vpp/memif.sock. It cannot be changed to another file. This entry is
always present and does not need to be manually configured.
When defining a filename for a socket, the available parameters are:
A required identifier unique to this memif instance. This is an integer in the range
The full path to a socket file used for establishing memif connections. A socket can be used for either server or client interfaces, but not both. A socket can have more than one server, or it can have more than one client.
Sockets cannot be edited or deleted if they are in use by a memif. To change or remove a socket, first remove the associated memif.
Creating a memif interface¶
interface memif socket <socket-id> interface <if-id> command
creates a memif object. This command requires its own interface identifier, and
it must be tied to the socket using the same ID from the previous command. This
results in a new TNSR interface named
The combination of socket ID and interface ID must be unique, but
multiple sockets may use the same interface ID. For example,
Each socket can only be used by a single memif.
This command enters
config-memif mode, where the following commands are
- buffer-size <size>
The size of the buffer allocated for each ring entry. Default
- mac-address <mac>
MAC address for the memif interface.
- mode <mode>
Sets the mode for the memif interface. Mode must be one of:
Ethernet (L2) mode.
ethernetmode is active and a
mac-addressis not set, TNSR will generate a random MAC for the interface.
IP (L3) mode.
Reserved for future use. Not yet implemented.
- ring-size <size>
Number of entries in receive and transmit rings. Value is
8..32and is used as a power of 2. Default value is
- role <role> [<options>]
Sets the role of the memif interface. The default role is
serverand this is the most common role for TNSR. The following modes and options are available:
Server role. The server does not expose its memory to the client peer.
- client [(rx-queues|tx-queues) <num-queues>]
Client role. Allocates and shares memory with the server to transfer data. When operating in client mode, the number of receive or transmit queues may be set as an option:
- rx-queues <n-rx-qs>
Number of receive queues. May be between
- tx-queues <n-tx-qs>
Number of transmit queues. May be between
- secret <sec-str>
A quoted secret string, up to 24 characters.
First, create a socket with an ID of
23, using a socket file of
tnsr(config)# interface memif socket 23 filename /tmp/memif23.sock
Next, run commands to create a memif interface with an interface ID of
taking on the role
server on the socket created previously:
tnsr(config)# interface memif socket 23 interface 100 tnsr(config-memif)# role server tnsr(config-memif)# exit
Now the interface will be available to TNSR. In this example with a socket ID of
23 and an interface ID of
100, the full interface name is
For a list of all current memif entries, along with their names and
configuration, use the
show interface memif command:
tnsr# show interface memif Socket Id Filename ---------- -------------------------------------------------- 0 /run/vpp/memif.sock 23 /tmp/memif23.sock memif23/100: Socket id: 23 Interface id: 100 Interface: memif23/100 Role: server Mode: ethernet MAC address: 02:fe:2d:e2:87:a8 Ring size: 0 Buffer size: 0 Admin up: false Link up: false