@@ -15,6 +15,7 @@ to the compiler.
15
15
16
16
For example, to install C-libmemif system-wide into the standard
17
17
locations, execute:
18
+
18
19
```
19
20
$ git clone https://gerrit.fd.io/r/vpp
20
21
$ cd vpp/extras/libmemif
@@ -30,6 +31,7 @@ Package **libmemif** is not part of the **GoVPP** core and as such it is
30
31
not included in the [ make build] ( ../../Makefile ) target.
31
32
Instead, it has its own target in the [ top-level Makefile] ( ../../Makefile )
32
33
used to build the attached examples with the adapter:
34
+
33
35
```
34
36
$ make extras
35
37
```
@@ -61,6 +63,7 @@ structure representing the underlying memif interface.
61
63
62
64
Callbacks are optional and can be shared across multiple memif instances.
63
65
Available callbacks are:
66
+
64
67
1 . ** OnConnect** : called when the connection is established.
65
68
By the time the callback is called, the Rx/Tx queues are initialized
66
69
and ready for data transmission. Interrupt channels are also
@@ -105,7 +108,7 @@ Do not touch memif after it was closed, let garbage collector to remove
105
108
the ` Memif ` instance. In the end, ` Cleanup() ` will also ensure that all
106
109
active memif interfaces are closed before the cleanup finalizes.
107
110
108
- To use libmemif with ` google/gopacket ` , simply call ` Memif .NewPacketHandle()`
111
+ To use libmemif with ` google/gopacket ` , simply call ` libmemif .NewPacketHandle()`
109
112
to create ` google/gopacket/PacketDataSource ` from memif queue. After this you
110
113
can use gopacket API to read from ` MemifPacketHandle ` as normal. You can pass
111
114
optional ` rxCount ` when creating the packet handle and then when reading data,
@@ -121,46 +124,48 @@ The examples can be found in the subdirectory [examples](./examples).
121
124
122
125
#### Raw data (libmemif <-> libmemif)
123
126
124
- * raw-data * is a basic example showing how to create a memif interface,
127
+ _ raw-data _ is a basic example showing how to create a memif interface,
125
128
handle events through callbacks and perform Rx/Tx of raw data. Before
126
129
handling an actual packet it is important to understand the skeleton
127
130
of libmemif-based applications.
128
131
129
132
Since VPP expects proper packet data, it is not very useful to connect
130
- * raw-data * example with VPP, even though it will work, since all
133
+ _ raw-data _ example with VPP, even though it will work, since all
131
134
the received data will get dropped on the VPP side.
132
135
133
136
To create a connection of two raw-data instances, start two processes
134
137
concurrently in an arbitrary order:
135
- - * master* memif:
136
- ```
137
- $ cd extras/libmemif/examples/raw-data
138
- $ ./raw-data
139
- ```
140
- - * slave* memif:
141
- ```
142
- $ cd extras/libmemif/examples/raw-data
143
- $ ./raw-data --slave
144
- ```
138
+
139
+ - _ master_ memif:
140
+ ```
141
+ $ cd extras/libmemif/examples/raw-data
142
+ $ ./raw-data
143
+ ```
144
+ - _ slave_ memif:
145
+ ```
146
+ $ cd extras/libmemif/examples/raw-data
147
+ $ ./raw-data --slave
148
+ ```
145
149
146
150
Every 3 seconds both sides send 3 raw-data packets to the opposite end
147
151
through each of the 3 queues. The received packets are printed to stdout.
148
152
149
- Stop an instance of * raw-data * with an interrupt signal (^C).
153
+ Stop an instance of _ raw-data _ with an interrupt signal (^C).
150
154
151
155
#### Jumbo Frames Raw data (libmemif <-> libmemif)
152
156
153
- * jumbo-frames * is simple example how to send larger and larger jumbo
154
- packets with libmemif adapter. This is simple copy of * raw-data * but with
157
+ _ jumbo-frames _ is simple example how to send larger and larger jumbo
158
+ packets with libmemif adapter. This is simple copy of _ raw-data _ but with
155
159
sending larger packets, so for more information read its code and documentation.
156
160
157
161
#### ICMP Responder
158
162
159
- * icmp-responder * is a simple example showing how to answer APR and ICMP
163
+ _ icmp-responder _ is a simple example showing how to answer APR and ICMP
160
164
echo requests through a memif interface. Package ` google/gopacket ` is
161
165
used to decode and construct packets.
162
166
163
167
The appropriate VPP configuration for the opposite memif is:
168
+
164
169
```
165
170
vpp$ create memif socket id 1 filename /tmp/icmp-responder-example
166
171
vpp$ create interface memif id 1 socket-id 1 slave secret secret no-zero-copy
@@ -169,22 +174,25 @@ vpp$ set int ip address memif1/1 192.168.1.2/24
169
174
```
170
175
171
176
To start the example, simply type:
177
+
172
178
```
173
179
root$ ./icmp-responder
174
180
```
175
181
176
- * icmp-responder * needs to be run as root so that it can access the socket
182
+ _ icmp-responder _ needs to be run as root so that it can access the socket
177
183
created by VPP.
178
184
179
185
Normally, the memif interface is in the master mode. Pass CLI flag ` --slave `
180
186
to create memif in the slave mode:
187
+
181
188
```
182
189
root$ ./icmp-responder --slave
183
190
```
184
191
185
192
Don't forget to put the opposite memif into the master mode in that case.
186
193
187
194
To verify the connection, run:
195
+
188
196
```
189
197
vpp$ ping 192.168.1.1
190
198
64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=.6974 ms
@@ -197,20 +205,22 @@ vpp$ sh ip arp
197
205
Time IP4 Flags Ethernet Interface
198
206
68.5648 192.168.1.1 D aa:aa:aa:aa:aa:aa memif0/1
199
207
```
200
- * Note* : it is expected that the first ping is shown as lost.
201
- It was actually converted to an ARP request. This is a VPP
202
- specific feature common to all interface types.
208
+
209
+ _ Note_ : it is expected that the first ping is shown as lost.
210
+ It was actually converted to an ARP request. This is a VPP
211
+ specific feature common to all interface types.
203
212
204
213
Stop the example with an interrupt signal (^C).
205
214
206
215
#### GoPacket ICMP Responder
207
216
208
- * gopacket * is a simple example showing how to answer APR and ICMP echo
217
+ _ gopacket _ is a simple example showing how to answer APR and ICMP echo
209
218
requests through a memif interface. This example is mostly identical
210
219
to icmp-responder example, but it is using MemifPacketHandle API to
211
220
read and write packets using gopacket API.
212
221
213
222
The appropriate VPP configuration for the opposite memif is:
223
+
214
224
```
215
225
vpp$ create memif socket id 1 filename /tmp/gopacket-example
216
226
vpp$ create interface memif id 1 socket-id 1 slave secret secret no-zero-copy
@@ -219,6 +229,7 @@ vpp$ set int ip address memif1/1 192.168.1.2/24
219
229
```
220
230
221
231
To start the example, simply type:
232
+
222
233
```
223
234
root$ ./gopacket
224
235
```
@@ -228,13 +239,15 @@ created by VPP.
228
239
229
240
Normally, the memif interface is in the master mode. Pass CLI flag "--slave"
230
241
to create memif in the slave mode:
242
+
231
243
```
232
244
root$ ./gopacket --slave
233
245
```
234
246
235
247
Don't forget to put the opposite memif into the master mode in that case.
236
248
237
249
To verify the connection, run:
250
+
238
251
```
239
252
vpp$ ping 192.168.1.1
240
253
64 bytes from 192.168.1.1: icmp_seq=2 ttl=255 time=.6974 ms
@@ -248,8 +261,8 @@ Time IP4 Flags Ethernet Interface
248
261
68.5648 192.168.1.1 D aa:aa:aa:aa:aa:aa memif0/1
249
262
```
250
263
251
- * Note * : it is expected that the first ping is shown as lost.
252
- It was actually converted to an ARP request. This is a VPP
253
- specific feature common to all interface types.
264
+ _ Note _ : it is expected that the first ping is shown as lost.
265
+ It was actually converted to an ARP request. This is a VPP
266
+ specific feature common to all interface types.
254
267
255
268
Stop the example with an interrupt signal (^C).
0 commit comments