flowmatch_example_flowstat.cpp Source File

Reference Documentation

Platform
Napatech SmartNIC
Content Type
Reference Information
Capture Software Version
Link™ Capture Software 12.15
Napatech Software Suite: examples/flowmatch/flowmatch_example_flowstat.cpp Source File
flowmatch_example_flowstat.cpp
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2025 Napatech A/S. All Rights Reserved.
4  *
5  * 1. Copying, modification, and distribution of this file, or executable
6  * versions of this file, is governed by the terms of the Napatech Software
7  * license agreement under which this file was made available. If you do not
8  * agree to the terms of the license do not install, copy, access or
9  * otherwise use this file.
10  *
11  * 2. Under the Napatech Software license agreement you are granted a
12  * limited, non-exclusive, non-assignable, copyright license to copy, modify
13  * and distribute this file in conjunction with Napatech SmartNIC's and
14  * similar hardware manufactured or supplied by Napatech A/S.
15  *
16  * 3. The full Napatech Software License Agreement is included in this
17  * distribution, please see "NA-0009 Software License Agreement.pdf"
18  *
19  * 4. Redistributions of source code must retain this copyright notice,
20  * list of conditions and the following disclaimer.
21  *
22  * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTIES, EXPRESS OR
23  * IMPLIED, AND NAPATECH DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING ANY
24  * IMPLIED WARRANTY OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, OR OF
25  * FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT NOT PROHIBITED BY
26  * APPLICABLE LAW, IN NO EVENT SHALL NAPATECH BE LIABLE FOR PERSONAL INJURY,
27  * OR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES WHATSOEVER,
28  * INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, CORRUPTION OR
29  * LOSS OF DATA, FAILURE TO TRANSMIT OR RECEIVE ANY DATA OR INFORMATION,
30  * BUSINESS INTERRUPTION OR ANY OTHER COMMERCIAL DAMAGES OR LOSSES, ARISING
31  * OUT OF OR RELATED TO YOUR USE OR INABILITY TO USE NAPATECH SOFTWARE OR
32  * SERVICES OR ANY THIRD PARTY SOFTWARE OR APPLICATIONS IN CONJUNCTION WITH
33  * THE NAPATECH SOFTWARE OR SERVICES, HOWEVER CAUSED, REGARDLESS OF THE THEORY
34  * OF LIABILITY (CONTRACT, TORT OR OTHERWISE) AND EVEN IF NAPATECH HAS BEEN
35  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW
36  * THE EXCLUSION OR LIMITATION OF LIABILITY FOR PERSONAL INJURY, OR OF
37  * INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY TO YOU.
38  *
39  *
40 
41  */
42 
43 // Include this in order to access the Napatech API
44 #include <nt.h>
45 
46 #include <iostream>
47 
49 
51 
53 {
54  int status;
55  NtStatistics_t hStat;
56 
57  // Open the stat stream.
58  status = NT_StatOpen(&hStatStream, "Learn_example_flowstats");
59  handleErrorStatus(status, "NT_StatOpen() failed");
60 
61  // Read the statistics counters in order to clear them.
63  hStat.u.flowData_v0.clear = 1; // Clear statistics
65  status = NT_StatRead(hStatStream, &hStat);
66  handleErrorStatus(status, "NT_StatRead() failed");
67 }
68 
70 {
71  int status;
72  NtStatistics_t hStat;
73 
74  // Read the statistics counters
76  hStat.u.flowData_v0.clear = 0; // Don't clear statistics
78  status = NT_StatRead(hStatStream, &hStat);
79  handleErrorStatus(status, "NT_StatRead() failed");
80 
81  std::cout << "Statistic from stat stream:" << std::endl
82  << " Learn:" << std::endl
83  << " Done: " << hStat.u.flowData_v0.learnDone << std::endl
84  << " Ignore: " << hStat.u.flowData_v0.learnIgnore << std::endl
85  << " Fail: " << hStat.u.flowData_v0.learnFail << std::endl
86  << " Unlearn:" << std::endl
87  << " Done: " << hStat.u.flowData_v0.unlearnDone << std::endl
88  << " Ignore: " << hStat.u.flowData_v0.unlearnIgnore << std::endl
89  << " Automatic Unlearn:" << std::endl
90  << " Done: " << hStat.u.flowData_v0.automaticUnlearnDone << std::endl
91  << " Ignore: " << hStat.u.flowData_v0.automaticUnlearnIgnore << std::endl
92  << " Fail: " << hStat.u.flowData_v0.automaticUnlearnFail << std::endl
93  << " Timeout Unlearn:" << std::endl
94  << " Done: " << hStat.u.flowData_v0.timeoutUnlearnDone << std::endl
95  << " DMA:" << std::endl
96  << " Write: " << hStat.u.flowData_v0.dmaWriteRecords << std::endl
97  << " Info Read: " << hStat.u.flowData_v0.dmaReadInfoRecords << std::endl
98  << " Info Drop: " << hStat.u.flowData_v0.dmaDroppedInfoRecords << std::endl
99  << " Stat Read: " << hStat.u.flowData_v0.dmaReadStatRecords << std::endl
100  << " Stat Drop: " << hStat.u.flowData_v0.dmaDroppedStatRecords << std::endl;
101 
102  // Close the stat stream.
103  status = NT_StatClose(hStatStream);
104  handleErrorStatus(status, "NT_StatClose() failed");
105 }