1 ## Example setup {#libmemif_example_setup_doc}
3 #### VPP-memif master icmp_responder slave
5 > Libmemif example app(s) use memif default socket file: `/run/vpp/memif.sock`.
7 Run VPP and icmpr-epoll example (default example when running in container).
9 > Other examples work similar to icmpr-epoll. Brief explanation can be found in @ref libmemif_examples_doc .
13 DBGvpp# create interface memif id 0 master
14 DBGvpp# set int state memif0/0 up
15 DBGvpp# set int ip address memif0/0 192.168.1.1/24
21 Memif in slave mode will try to connect every 2 seconds. If connection establishment is successful, a message will show.
23 INFO: memif connected!
25 > Error messages like "unmatched interface id" are printed only in debug mode.
27 Check connected status.
28 Use show command in icmpr-epoll:
32 ==============================
34 interface ip: 192.168.1.2
35 interface name: memif_connection
36 app name: ICMP_Responder
37 remote interface name: memif0/0
38 remote app name: VPP 17.10-rc0~132-g62f9cdd
43 socket filename: /run/vpp/memif.sock
57 Use sh memif command in VPP:
61 remote-name "ICMP_Responder"
62 remote-interface "memif_connection"
63 id 0 mode ethernet file /run/vpp/memif.sock
64 flags admin-up connected
65 listener-fd 12 conn-fd 13
66 num-s2m-rings 1 num-m2s-rings 1 buffer-size 0
67 master-to-slave ring 0:
68 region 0 offset 32896 ring-size 1024 int-fd 16
69 head 0 tail 0 flags 0x0000 interrupts 0
70 master-to-slave ring 0:
71 region 0 offset 0 ring-size 1024 int-fd 15
72 head 0 tail 0 flags 0x0001 interrupts 0
75 Send ping from VPP to icmpr-epoll:
77 DBGvpp# ping 192.168.1.2
78 64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=.1888 ms
79 64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=.1985 ms
80 64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=.1813 ms
81 64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=.1929 ms
83 Statistics: 5 sent, 4 received, 20% packet loss
85 #### multiple queues VPP-memif slave icmp_responder master
87 Run icmpr-epoll as in previous example setup.
88 Run VPP with startup conf, enabling 2 worker threads.
103 DBGvpp# create memif id 0 slave rx-queues 2 tx-queues 2
104 DBGvpp# set int state memif0/0 up
105 DBGvpp# set int ip address memif0/0 192.168.1.1/24
111 When connection is established a message will print:
113 INFO: memif connected!
115 > Error messages like "unmatched interface id" are printed only in debug mode.
117 Check connected status.
118 Use show command in icmpr-epoll:
122 ==============================
124 interface ip: 192.168.1.2
125 interface name: memif_connection
126 app name: ICMP_Responder
127 remote interface name: memif0/0
128 remote app name: VPP 17.10-rc0~132-g62f9cdd
133 socket filename: /run/vpp/memif.sock
153 Use sh memif command in VPP:
157 remote-name "ICMP_Responder"
158 remote-interface "memif_connection"
159 id 0 mode ethernet file /run/vpp/memif.sock
160 flags admin-up slave connected
161 listener-fd -1 conn-fd 12
162 num-s2m-rings 2 num-m2s-rings 2 buffer-size 2048
163 slave-to-master ring 0:
164 region 0 offset 0 ring-size 1024 int-fd 14
165 head 0 tail 0 flags 0x0000 interrupts 0
166 slave-to-master ring 1:
167 region 0 offset 32896 ring-size 1024 int-fd 15
168 head 0 tail 0 flags 0x0000 interrupts 0
169 slave-to-master ring 0:
170 region 0 offset 65792 ring-size 1024 int-fd 16
171 head 0 tail 0 flags 0x0001 interrupts 0
172 slave-to-master ring 1:
173 region 0 offset 98688 ring-size 1024 int-fd 17
174 head 0 tail 0 flags 0x0001 interrupts 0
177 Send ping from VPP to icmpr-epoll:
179 DBGvpp# ping 192.168.1.2
180 64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=.1439 ms
181 64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=.2184 ms
182 64 bytes from 192.168.1.2: icmp_seq=4 ttl=64 time=.1458 ms
183 64 bytes from 192.168.1.2: icmp_seq=5 ttl=64 time=.1687 ms
185 Statistics: 5 sent, 4 received, 20% packet loss
188 #### icmp_responder master icmp_responder slave
190 > This setup creates connection between two applications using libmemif. Traffic functionality is the same as when connection to VPP. App can receive ARP/ICMP request and transmit response.
192 Run two instances of icmpr-epoll example.
193 > If not running in container, make sure folder /run/vpp/ exists before creating memif master.
194 Instance 1 will be in master mode, instance 2 in slave mode.
203 In 2 seconds, both instances should print connected! message:
205 INFO: memif connected!
207 Check peer interface names using show command.