|
1 | 1 | /** |
2 | 2 | * @file |
3 | | - * @brief Plugin for parsing basicplus traffic. |
4 | | - * @author Jiri Havranek <havranek@cesnet.cz> |
| 3 | + * @brief Plugin for parsing bstats traffic. |
| 4 | + * @author Karel Hynek <[email protected].cz> |
5 | 5 | * @author Pavel Siska <[email protected]> |
| 6 | + * @author Damir Zainullin <[email protected]> |
6 | 7 | * @date 2025 |
7 | 8 | * |
8 | | - * Copyright (c) 2025 CESNET |
9 | | - * |
10 | | - * SPDX-License-Identifier: BSD-3-Clause |
| 9 | + * Provides a plugin that extracts packet burst statistics of flows, |
| 10 | + * stores them in per-flow plugin data, and exposes fields via FieldManager. |
| 11 | + * |
| 12 | + * @copyright Copyright (c) 2025 CESNET, z.s.p.o. |
11 | 13 | */ |
12 | 14 |
|
13 | 15 | #pragma once |
|
23 | 25 |
|
24 | 26 | namespace ipxp { |
25 | 27 |
|
| 28 | +/** |
| 29 | + * @class BurstStatsPlugin |
| 30 | + * @brief A plugin for collecting packet burst statistics. |
| 31 | + */ |
26 | 32 | class BurstStatsPlugin : public ProcessPlugin { |
27 | 33 | public: |
| 34 | + |
| 35 | + /** |
| 36 | + * @brief Constructs the BurstStats plugin. |
| 37 | + * |
| 38 | + * @param parameters Plugin parameters as a string (currently unused). |
| 39 | + * @param fieldManager Reference to the FieldManager for field registration. |
| 40 | + */ |
28 | 41 | BurstStatsPlugin(const std::string& params, FieldManager& manager); |
29 | 42 |
|
| 43 | + /** |
| 44 | + * @brief Initializes plugin data for a new flow. |
| 45 | + * |
| 46 | + * Constructs `BurstStatsData` in `pluginContext` and initializes it with |
| 47 | + * burst containing initial packet. |
| 48 | + * |
| 49 | + * @param flowContext Contextual information about the flow to fill new record. |
| 50 | + * @param pluginContext Pointer to pre-allocated memory to create record. |
| 51 | + * @return Result of the initialization process. |
| 52 | + */ |
30 | 53 | PluginInitResult onInit(const FlowContext& flowContext, void* pluginContext) override; |
31 | 54 |
|
| 55 | + /** |
| 56 | + * @brief Updates plugin data with values from new packet. |
| 57 | + * |
| 58 | + * Inserts new packet into `BurstStatsData`. |
| 59 | + * |
| 60 | + * @param flowContext Contextual information about the flow to be updated. |
| 61 | + * @param pluginContext Pointer to `BurstStatsData`. |
| 62 | + * @return Result of the update, may not require new packets if burst storage is full. |
| 63 | + */ |
32 | 64 | PluginUpdateResult onUpdate(const FlowContext& flowContext, void* pluginContext) override; |
33 | 65 |
|
| 66 | + /** |
| 67 | + * @brief Prepare the export data. |
| 68 | + * |
| 69 | + * Removes record if it is too short. |
| 70 | + * Sets all fields as available otherwise. |
| 71 | + * |
| 72 | + * @param flowRecord The flow record containing aggregated flow data. |
| 73 | + * @param pluginContext Pointer to `BurstStatsData`. |
| 74 | + * @return RemovePlugin if packet count is less than `MINIMAL_PACKETS_COUNT`, |
| 75 | + * else no action is required. |
| 76 | + */ |
34 | 77 | PluginExportResult onExport(const FlowRecord& flowRecord, void* pluginContext) override; |
35 | 78 |
|
| 79 | + /** |
| 80 | + * @brief Cleans up and destroys `BurstStatsData`. |
| 81 | + * @param pluginContext Pointer to `BurstStatsData`. |
| 82 | + */ |
36 | 83 | void onDestroy(void* pluginContext) override; |
37 | 84 |
|
38 | | - std::string getName() const noexcept override; |
39 | | - |
| 85 | + /** |
| 86 | + * @brief Provides the memory layout of `BurstStatsData`. |
| 87 | + * @return Memory layout description for the plugin data. |
| 88 | + */ |
40 | 89 | PluginDataMemoryLayout getDataMemoryLayout() const noexcept override; |
41 | 90 |
|
42 | | - |
43 | 91 | private: |
44 | | - constexpr static std::size_t MINIMAL_PACKETS_COUNT = 3; |
| 92 | + constexpr static std::size_t MINIMAL_PACKETS_COUNT = 3; ///< Minimal number of packets to consider the flow valid. |
45 | 93 |
|
46 | 94 | void updateBursts(Burst& burst, FlowRecord& flowRecord, const Packet& packet) noexcept; |
47 | 95 | void makeAllFieldsUnavailable(FlowRecord& flowRecord) noexcept; |
48 | 96 |
|
49 | 97 | FieldHandlers<BurstStatsFields> m_fieldHandlers; |
50 | | - |
51 | 98 | }; |
52 | 99 |
|
53 | 100 | } // namespace ipxp |
0 commit comments