Managing Flows Using NTAPI

Stateful Flow Management

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

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.


Page-1 Rectangle Application Application Can Host buffer Sheet.77 Host buffer Document Document.7 Document.8 Flow status record Flow status record Ellipse RX thread RX thread Can.88 Sheet.89 Sheet.90 RX network stream RX network stream Ellipse.101 Flow thread Flow thread Sheet.102 Flow learn queue Flow learn queue 15 ruled column.106 Dynamic connector Dynamic connector.109 Dynamic connector.110 Sheet.111 NT_NetRxGetNextPacket NT_NetRxGetNextPacket Sheet.112 NT_FlowWrite NT_FlowStatusRead NT_FlowRead NT_FlowWriteNT_FlowStatusReadNT_FlowRead Can.117 Host buffer Sheet.118 Host buffer Ellipse.119 RX thread RX thread Can.120 Sheet.121 Sheet.122 Network stream Network stream Dynamic connector.123 Dynamic connector.124 Sheet.125 NT_NetRxGetNextPacket NT_NetRxGetNextPacket Can.126 Sheet.127 Sheet.128 RX network stream RX network stream Dynamic connector.129 Dynamic connector.130 Sheet.131 NT_NetRxGetNextPacket NT_NetRxGetNextPacket Can.132 Host buffer Sheet.133 Host buffer Ellipse.134 RX thread RX thread Can.135 Sheet.136 Sheet.137 RX network stream RX network stream Dynamic connector.138 Dynamic connector.139 Sheet.140 NT_NetRxGetNextPacket NT_NetRxGetNextPacket Can.141 Sheet.142 Sheet.143 Flow stream Flow stream Dynamic connector.144 Dynamic connector.145 Document.151 Document.152 Document.153 Flow info record Flow info record Dynamic connector.155 Dynamic connector.158 15 ruled column

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.