|
1 | 1 | /** |
2 | 2 | * @file |
3 | | - * @brief Plugin for parsing basicplus traffic. |
4 | | - * @author Jiri Havranek <havranek@cesnet.cz> |
| 3 | + * @brief Plugin for parsing phists 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 creates histograms based on packet sizes and inter-arrival times, |
| 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 PacketHistogramPlugin |
| 30 | + * @brief A plugin for collecting and exporting packet histogram statistics. |
| 31 | + * |
| 32 | + * Empty packets can optionally be omitted from statistics. |
| 33 | + */ |
26 | 34 | class PacketHistogramPlugin : public ProcessPlugin { |
27 | 35 | public: |
| 36 | + |
| 37 | + /** |
| 38 | + * @brief Constructs the PacketHistogram plugin. |
| 39 | + * |
| 40 | + * @param parameters Plugin parameters as a string (currently unused). |
| 41 | + * @param fieldManager Reference to the FieldManager for field registration. |
| 42 | + */ |
28 | 43 | PacketHistogramPlugin(const std::string& params, FieldManager& manager); |
29 | 44 |
|
| 45 | + /** |
| 46 | + * @brief Initializes plugin data for a new flow. |
| 47 | + * |
| 48 | + * Constructs `PacketHistogramData` in `pluginContext` and initializes histograms |
| 49 | + * with values from the first packet. |
| 50 | + * |
| 51 | + * @param flowContext Contextual information about the flow to fill new record. |
| 52 | + * @param pluginContext Pointer to pre-allocated memory to create record. |
| 53 | + * @return Result of the initialization process, always requires new packets. |
| 54 | + */ |
30 | 55 | PluginInitResult onInit(const FlowContext& flowContext, void* pluginContext) override; |
31 | 56 |
|
| 57 | + /** |
| 58 | + * @brief Updates plugin data with values from new packet. |
| 59 | + * |
| 60 | + * Updates histograms of `PacketHistogramData` with length and inter-arrival time. |
| 61 | + * |
| 62 | + * @param flowContext Contextual information about the flow to be updated. |
| 63 | + * @param pluginContext Pointer to `PacketHistogramData`. |
| 64 | + * @return Result of the update, always requires new packets. |
| 65 | + */ |
32 | 66 | PluginUpdateResult onUpdate(const FlowContext& flowContext, void* pluginContext) override; |
33 | 67 |
|
| 68 | + /** |
| 69 | + * @brief Prepare the export data. |
| 70 | + * |
| 71 | + * Removes record if it seems to be TCP scan. |
| 72 | + * Sets all fields as available otherwise. |
| 73 | + * |
| 74 | + * @param flowRecord The flow record containing aggregated flow data. |
| 75 | + * @param pluginContext Pointer to `PacketHistogramData`. |
| 76 | + * @return Remove plugin if it is TCP scan. |
| 77 | + */ |
34 | 78 | PluginExportResult onExport(const FlowRecord& flowRecord, void* pluginContext) override; |
35 | 79 |
|
| 80 | + /** |
| 81 | + * @brief Cleans up and destroys `PacketHistogramData`. |
| 82 | + * @param pluginContext Pointer to `PacketHistogramData`. |
| 83 | + */ |
36 | 84 | void onDestroy(void* pluginContext) override; |
37 | 85 |
|
38 | | - std::string getName() const noexcept override; |
39 | | - |
| 86 | + /** |
| 87 | + * @brief Provides the memory layout of `PacketHistogramData`. |
| 88 | + * @return Memory layout description for the plugin data. |
| 89 | + */ |
40 | 90 | PluginDataMemoryLayout getDataMemoryLayout() const noexcept override; |
41 | 91 |
|
42 | 92 | private: |
43 | 93 | void updateExportData( |
44 | 94 | const std::size_t realPacketLength, const uint64_t packetTimestamp, const Direction direction, PacketHistogramData& pluginData) noexcept; |
45 | 95 |
|
| 96 | + bool m_countEmptyPackets{false}; |
| 97 | + |
46 | 98 | FieldHandlers<PacketHistogramFields> m_fieldHandlers; |
47 | 99 | }; |
48 | 100 |
|
|
0 commit comments