This is the documentation for the 20.02 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 master and the other endpoint will be a
slave. A single socket may only be associated with one role type.
Creating a memif Socket¶
interface memif socket command requires an identifier number and a
filename, both of which must be unique to this socket. The full form of the
interface memif socket id <id> filename <socket-filename>
In this command, 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 master or slave interfaces, but not both. A socket can have more than one master, or it can have more than one slave.
Creating a memif interface¶
interface memif interface <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 command enters
config-memif mode, where the following commands are
- socket-id <id>
The socket ID for the associated memif socket created previously. This value is required.
- 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
masterand this is the most common role for TNSR. The following modes and options are available:
Master role. The master does not expose its memory to the slave peer.
- slave [(rx-queues|tx-queues) <num-queues>]
Slave role. Allocates and shares memory with the master to transfer data. When operating in slave 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.
After creating the interface, it will be available in TNSR. The name of this
interface is composed of the socket ID and the interface ID:
memif<socket id>/<interface id>.
First, create a socket with an ID of
23, using a socket file of
tnsr(config)# interface memif socket id 23 filename /tmp/memif23.sock
Next, run commands to create a memif interface with an interface ID of
taking on the role
master on the socket created previously:
tnsr(config)# interface memif interface 100 tnsr(config-memif)# socket-id 23 tnsr(config-memif)# role master 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 memif id: 100 Memif name: memif23/100 Interface: memif23/100 Role: master Mode: ethernet MAC address: 02:fe:8c:e5:ce:06 Socket id: 23 Ring size: 0 Buffer size: 0 Admin up: false Link up: false