flowmatch_example_flowstat.cpp Source File

Reference Documentation

Platform
Intel® PAC
Napatech SmartNIC
Content Type
Reference Information
Capture Software Version
Link™ Capture Software 12.10
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 2023 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 "NP-0405 Napatech Software license
18  * agreement.pdf"
19  *
20  * 4. Redistributions of source code must retain this copyright notice,
21  * list of conditions and the following disclaimer.
22  *
23  * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTIES, EXPRESS OR
24  * IMPLIED, AND NAPATECH DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING ANY
25  * IMPLIED WARRANTY OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, OR OF
26  * FITNESS FOR A PARTICULAR PURPOSE. TO THE EXTENT NOT PROHIBITED BY
27  * APPLICABLE LAW, IN NO EVENT SHALL NAPATECH BE LIABLE FOR PERSONAL INJURY,
28  * OR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES WHATSOEVER,
29  * INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, CORRUPTION OR
30  * LOSS OF DATA, FAILURE TO TRANSMIT OR RECEIVE ANY DATA OR INFORMATION,
31  * BUSINESS INTERRUPTION OR ANY OTHER COMMERCIAL DAMAGES OR LOSSES, ARISING
32  * OUT OF OR RELATED TO YOUR USE OR INABILITY TO USE NAPATECH SOFTWARE OR
33  * SERVICES OR ANY THIRD PARTY SOFTWARE OR APPLICATIONS IN CONJUNCTION WITH
34  * THE NAPATECH SOFTWARE OR SERVICES, HOWEVER CAUSED, REGARDLESS OF THE THEORY
35  * OF LIABILITY (CONTRACT, TORT OR OTHERWISE) AND EVEN IF NAPATECH HAS BEEN
36  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME JURISDICTIONS DO NOT ALLOW
37  * THE EXCLUSION OR LIMITATION OF LIABILITY FOR PERSONAL INJURY, OR OF
38  * INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS LIMITATION MAY NOT APPLY TO YOU.
39  *
40  *
41 
42  */
43 
44 // Include this in order to access the Napatech API
45 #include <nt.h>
46 
47 #include <iostream>
48 
50 
52 
54 {
55  int status;
56  NtStatistics_t hStat;
57 
58  // Open the stat stream.
59  status = NT_StatOpen(&hStatStream, "Learn_example_flowstats");
60  handleErrorStatus(status, "NT_StatOpen() failed");
61 
62  // Read the statistics counters in order to clear them.
64  hStat.u.flowData_v0.clear = 1; // Clear statistics
66  status = NT_StatRead(hStatStream, &hStat);
67  handleErrorStatus(status, "NT_StatRead() failed");
68 }
69 
71 {
72  int status;
73  NtStatistics_t hStat;
74 
75  // Read the statistics counters
77  hStat.u.flowData_v0.clear = 0; // Don't clear statistics
79  status = NT_StatRead(hStatStream, &hStat);
80  handleErrorStatus(status, "NT_StatRead() failed");
81 
82  std::cout << "Statistic from stat stream:" << std::endl
83  << " Learn:" << std::endl
84  << " Done: " << hStat.u.flowData_v0.learnDone << std::endl
85  << " Ignore: " << hStat.u.flowData_v0.learnIgnore << std::endl
86  << " Fail: " << hStat.u.flowData_v0.learnFail << std::endl
87  << " Unlearn:" << std::endl
88  << " Done: " << hStat.u.flowData_v0.unlearnDone << std::endl
89  << " Ignore: " << hStat.u.flowData_v0.unlearnIgnore << std::endl
90  << " Automatic Unlearn:" << std::endl
91  << " Done: " << hStat.u.flowData_v0.automaticUnlearnDone << std::endl
92  << " Ignore: " << hStat.u.flowData_v0.automaticUnlearnIgnore << std::endl
93  << " Fail: " << hStat.u.flowData_v0.automaticUnlearnFail << std::endl
94  << " Timeout Unlearn:" << std::endl
95  << " Done: " << hStat.u.flowData_v0.timeoutUnlearnDone << std::endl
96  << " DMA:" << std::endl
97  << " Write: " << hStat.u.flowData_v0.dmaWriteRecords << std::endl
98  << " Info Read: " << hStat.u.flowData_v0.dmaReadInfoRecords << std::endl
99  << " Info Drop: " << hStat.u.flowData_v0.dmaDroppedInfoRecords << std::endl
100  << " Stat Read: " << hStat.u.flowData_v0.dmaReadStatRecords << std::endl
101  << " Stat Drop: " << hStat.u.flowData_v0.dmaDroppedStatRecords << std::endl;
102 
103  // Close the stat stream.
104  status = NT_StatClose(hStatStream);
105  handleErrorStatus(status, "NT_StatClose() failed");
106 }