Nathan Skrzypczak | 8acc5ee | 2021-10-12 14:00:25 +0200 | [diff] [blame] | 1 | .. _libmemif_examples_doc: |
| 2 | |
| 3 | Examples |
| 4 | ======== |
| 5 | |
| 6 | After build, root folder will contain scripts linking binary examples |
| 7 | with library (same name as example apps). These scripts can be executed |
| 8 | to run example apps without installing the library. Example apps |
| 9 | binaries can be found in *libs* folder. To run binaries directly, make |
| 10 | sure that libmemif library is installed. |
| 11 | |
| 12 | Run in container |
| 13 | ---------------- |
| 14 | |
| 15 | ``ligato/libmemif-sample-service`` image contains built and installed |
| 16 | libmemf. To run different examples, override docker CMD to start |
| 17 | container in bash: |
| 18 | |
| 19 | :: |
| 20 | |
| 21 | # docker run -it --entrypoint=/bin/bash -i --rm --name icmp-responder --hostname icmp-responder --privileged -v "/run/vpp/:/run/vpp/" ligato/libmemif-sample-service |
| 22 | |
| 23 | Current WORKDIR is set to root repository directory. Example apps can be |
| 24 | run from this directory (a script linking binary with library), or |
| 25 | browse to ``./.libs`` folder and execute binary directly. |
| 26 | |
| 27 | * ``extras/libmemif/examples/icmp_responder`` |
| 28 | |
| 29 | Simplest implementation. Event polling is handled by libmemif. |
| 30 | Single memif connection in slave mode is created (id 0). Use Ctrl + C to exit app. |
| 31 | Memif receive mode: interrupt. |
| 32 | |
| 33 | * ``extras/libmemif/examples/icmp_responder-epoll`` (run in container by default) |
| 34 | |
| 35 | Supports multiple connections and master mode. User can create/delete connections, set ip addresses, |
| 36 | print connection information. :ref:`libmemif_example_setup_doc` contains instructions on basic |
| 37 | connection use cases setups. Memif receive mode: interrupt. App provides functionality to disable |
| 38 | interrupts for specified queue/s for testing purposes. Polling mode is not implemented in this example. |
| 39 | |
| 40 | * ``extras/libmemif/examples/icmp_responder-mt`` |
| 41 | |
| 42 | Multi-thread example, very similar to icmpr-epoll. Packets are handled in threads assigned to specific queues. Slave mode only. Memif receive mode: polling (memif_rx_poll function), interrupt (memif_rx_interrupt function). Receive modes differ per queue. |