Use this example to handle a statistics record of the flow manager.
Supported counters of the flow manager
The following counters are supported.
- Learn counters
- Done: Incremented when a flow is learned successfully.
- Ignore: Incremented when flow learning is ignored because the flow exists in the flow table.
- Fail: Incremented when flow learning fails.
- Unlearn counters
- Done: Incremented when a flow is unlearned successfully.
- Ignore: Incremented when flow unlearning fails because the flow does not exist in the flow table.
- Automatic unlearn counters
- Done: Incremented when a TCP flow is unlearned after the TCP session is terminated.
- Ignore: Incremented when a TCP flow was already unlearned after a TCP termination is detected.
- Fail: Incremented when unlearning of a TCP flow fails after the TCP session is terminated. The automatic unlearning operation may fail if too many TCP termination events occur within a short time interval.
- DMA counters
- Write: Incremented when a flow is learned/unlearned by the application.
- Info read: Incremented when a flow info record is read by the driver.
- Info drop: Incremented when a flow info record is dropped.
- Stat read: Incremented when a statistics record is read by the driver.
- Stat drop: Incremented when a statistics record is dropped.
Read flow statistics
A statistics stream can be used to access these flow counters. Statistics data can be
accessed using the NT_StatRead function with the
NtStatistics_s structure. The following code snippet shows how to open
a statistics stream, read flow statistics information including an example on how to display
the
information.
uint8_t adapterNo = 0; NtStatistics_t hStat; NtStatStream_t hStatStream; // Open the stat stream. status = NT_StatOpen(&hStatStream, "Read_flowstats_example"); if(status != NT_SUCCESS) { /* Handle error */ } // Read the statistics counters hStat.cmd = NT_STATISTICS_READ_CMD_FLOW_V1; hStat.u.flowData_v1.clear = 0; // Don't clear statistics hStat.u.flowData_v1.adapterNo = adapterNo; status = NT_StatRead(hStatStream, &hStat); if(status != NT_SUCCESS) { /* Handle error */ } std::cout << "Statistic from stat stream:" << std::endl << " Learn:" << std::endl << " Done: " << hStat.u.flowData_v1.learnDone << std::endl << " Ignore: " << hStat.u.flowData_v1.learnIgnore << std::endl << " Fail: " << hStat.u.flowData_v1.learnFail << std::endl << " Unlearn:" << std::endl << " Done: " << hStat.u.flowData_v1.unlearnDone << std::endl << " Ignore: " << hStat.u.flowData_v1.unlearnIgnore << std::endl << " Automatic Unlearn:" << std::endl << " Done: " << hStat.u.flowData_v1.automaticUnlearnDone << std::endl << " Ignore: " << hStat.u.flowData_v1.automaticUnlearnIgnore << std::endl << " Fail: " << hStat.u.flowData_v1.automaticUnlearnFail << std::endl << " Timeout Unlearn:" << std::endl << " Done: " << hStat.u.flowData_v1.timeoutUnlearnDone << std::endl << " DMA:" << std::endl << " Write: " << hStat.u.flowData_v1.dmaWriteRecords << std::endl << " Info Read: " << hStat.u.flowData_v1.dmaReadInfoRecords << std::endl << " Stat Read: " << hStat.u.flowData_v1.dmaReadStatRecords << std::endl; << " Current Flow Count: " << hStat.u.flowData_v1.currentFlowCount << std::endl;In the code snippet the NT_STATISTICS_READ_CMD_FLOW_V1 command is set to retrieve flow manager statistics. The returned data from NT_StatRead is SmartNIC-specific, so before the function is called, the SmartNIC number must be specified.
Note: By default a new statistics record is available every 500 ms. The
interval can be changed using the StatInterval parameter in the
/opt/napatech3/config/ntservice.ini file as shown in the following
example.
StatInterval = 100See DN-0449 for more information about the StatInterval parameter in the ntservice.ini file.
Note: Statistics of the flow manager can be monitored using the
monitoring tool.