Managing Flows Using NTAPI

Stateful Flow Management

Platform
Napatech SmartNIC
Content Type
User Guide
Capture Software Version
Link™ Capture Software 12.10

Flow learning is done using NTAPI in the application. This describes how to handle flows with API examples.

Flow management application architecture

The application can handle received frames in multiple threads as the SmartNIC can distribute flows to a maximum of 128 host buffers. The frames belonging to the same flow are delivered to the same host buffer. If a received frame is unknown (missed), the application adds the flow to the flow table (flow learning). When the application handles RX frames and flow learning in the same thread, the flow-learning rate may not be able to keep up with the RX rate. This results in dropped packets. It is therefore recommended to handle RX frames and flow learning in separate threads using a queue as illustrated in the following figure.


It is recommended to handle RX frames and flow learning in separate threads using a queue as the flow-learning rate can be slower than the RX rate. It is also advisable that reading flow status records and flow info records is handled in the same flow thread as a stream is not thread-safe.

Refer to the code example /opt/napatech3/examples/flow/flow_learn_span_example.cpp which shows how to implement a queue to handle RX traffic and flow learning in separate threads.
Note: A stream is not thread-safe. It is therefore advisable that reading flow status records and reading flow info records are handled in the same thread which originally learned the flows as shown in the figure. If the same stream is used by multiple threads however, it must be mutex-protected in the application.
Note: Up to 256 flow streams per system are supported. Flow learning can be done in multiple threads as it is allowed to open multiple flow streams per SmartNIC.

Code examples

Code examples for the flow management are available in the package. They are placed in the /opt/napatech3/examples/flow directory.