1 .. _libmemif_example_setup_doc:
6 VPP-memif master icmp_responder slave
7 -------------------------------------
9 Libmemif example app(s) use memif default socket file:
10 ``/run/vpp/memif.sock``.
12 Run VPP and icmpr-epoll example (default example when running in
15 Other examples work similar to icmpr-epoll. Brief explanation can be
16 found in :ref:`libmemif_examples_doc` .
22 DBGvpp# create interface memif id 0 master
23 DBGvpp# set int state memif0/0 up
24 DBGvpp# set int ip address memif0/0 192.168.1.1/24
32 Memif in slave mode will try to connect every 2 seconds. If connection
33 establishment is successful, a message will show.
37 INFO: memif connected!
41 Error messages like “unmatched interface id” are printed only in
44 Check connected status. Use show command in icmpr-epoll:
50 ==============================
52 interface ip: 192.168.1.2
53 interface name: memif_connection
54 app name: ICMP_Responder
55 remote interface name: memif0/0
56 remote app name: VPP 17.10-rc0~132-g62f9cdd
61 socket filename: /run/vpp/memif.sock
74 Use sh memif command in VPP:
80 remote-name "ICMP_Responder"
81 remote-interface "memif_connection"
82 id 0 mode ethernet file /run/vpp/memif.sock
83 flags admin-up connected
84 listener-fd 12 conn-fd 13
85 num-s2m-rings 1 num-m2s-rings 1 buffer-size 0
86 master-to-slave ring 0:
87 region 0 offset 32896 ring-size 1024 int-fd 16
88 head 0 tail 0 flags 0x0000 interrupts 0
89 master-to-slave ring 0:
90 region 0 offset 0 ring-size 1024 int-fd 15
91 head 0 tail 0 flags 0x0001 interrupts 0
93 Send ping from VPP to icmpr-epoll:
97 DBGvpp# ping 192.168.1.2
98 64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=.1888 ms
99 64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=.1985 ms
100 64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=.1813 ms
101 64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=.1929 ms
103 Statistics: 5 sent, 4 received, 20% packet loss
105 multiple queues VPP-memif slave icmp_responder master
106 -----------------------------------------------------
108 Run icmpr-epoll as in previous example setup. Run VPP with startup conf,
109 enabling 2 worker threads. Example startup.conf:
127 DBGvpp# create memif id 0 slave rx-queues 2 tx-queues 2
128 DBGvpp# set int state memif0/0 up
129 DBGvpp# set int ip address memif0/0 192.168.1.1/24
137 When connection is established a message will print:
141 INFO: memif connected!
145 Error messages like “unmatched interface id” are printed only in
148 Check connected status. Use show command in icmpr-epoll:
154 ==============================
156 interface ip: 192.168.1.2
157 interface name: memif_connection
158 app name: ICMP_Responder
159 remote interface name: memif0/0
160 remote app name: VPP 17.10-rc0~132-g62f9cdd
165 socket filename: /run/vpp/memif.sock
184 Use sh memif command in VPP:
190 remote-name "ICMP_Responder"
191 remote-interface "memif_connection"
192 id 0 mode ethernet file /run/vpp/memif.sock
193 flags admin-up slave connected
194 listener-fd -1 conn-fd 12
195 num-s2m-rings 2 num-m2s-rings 2 buffer-size 2048
196 slave-to-master ring 0:
197 region 0 offset 0 ring-size 1024 int-fd 14
198 head 0 tail 0 flags 0x0000 interrupts 0
199 slave-to-master ring 1:
200 region 0 offset 32896 ring-size 1024 int-fd 15
201 head 0 tail 0 flags 0x0000 interrupts 0
202 slave-to-master ring 0:
203 region 0 offset 65792 ring-size 1024 int-fd 16
204 head 0 tail 0 flags 0x0001 interrupts 0
205 slave-to-master ring 1:
206 region 0 offset 98688 ring-size 1024 int-fd 17
207 head 0 tail 0 flags 0x0001 interrupts 0
209 Send ping from VPP to icmpr-epoll:
213 DBGvpp# ping 192.168.1.2
214 64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=.1439 ms
215 64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=.2184 ms
216 64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=.1458 ms
217 64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=.1687 ms
219 Statistics: 5 sent, 4 received, 20% packet loss
221 icmp_responder master icmp_responder slave
222 ------------------------------------------
224 This setup creates connection between two applications using
225 libmemif. Traffic functionality is the same as when connection to
226 VPP. App can receive ARP/ICMP request and transmit response.
228 Run two instances of icmpr-epoll example. > If not running in container,
229 make sure folder /run/vpp/ exists before creating memif master. Instance
230 1 will be in master mode, instance 2 in slave mode. instance 1:
242 In 2 seconds, both instances should print connected! message:
246 INFO: memif connected!
248 Check peer interface names using show command.