Skip to content

Commit 8269526

Browse files
committed
++
1 parent 72f3565 commit 8269526

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+1456
-401
lines changed

new-process-api/process/basicPlus/src/basicPlus.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
* @brief Plugin for parsing basicplus traffic.
44
* @author Jiri Havranek <[email protected]>
55
* @author Pavel Siska <[email protected]>
6+
* @author Damir Zainullin <[email protected]>
67
* @date 2025
78
*
8-
* Copyright (c) 2025 CESNET
9+
* Provides a plugin that extracts basic IP and TCP fields from packets,
10+
* stores them in per-flow plugin data, and exposes fields via FieldManager.
911
*
10-
* SPDX-License-Identifier: BSD-3-Clause
12+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
1113
*/
1214

1315
#include "basicPlus.hpp"

new-process-api/process/basicPlus/src/basicPlus.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
* @brief Plugin for parsing basicplus traffic.
44
* @author Jiri Havranek <[email protected]>
55
* @author Pavel Siska <[email protected]>
6+
* @author Damir Zainullin <[email protected]>
67
* @date 2025
78
*
8-
* Copyright (c) 2025 CESNET
9+
* Provides a plugin that extracts basic IP and TCP fields from packets,
10+
* stores them in per-flow plugin data, and exposes fields via FieldManager.
911
*
10-
* SPDX-License-Identifier: BSD-3-Clause
12+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
1113
*/
1214

1315
#pragma once
@@ -27,8 +29,6 @@ namespace ipxp {
2729
/**
2830
* @class BasicPlusPlugin
2931
* @brief A plugin for collecting basic statistics about the flow: IP TTL, flags, TCP window, options, MSS and SYN length.
30-
*
31-
* @note Duplicate and empty packets can be optionally skipped.
3232
*/
3333
class BasicPlusPlugin : public ProcessPlugin {
3434
public:

new-process-api/process/basicPlus/src/basicPlusData.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @file
3+
* @brief Export data of basicplus plugin.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <directionalField.hpp>

new-process-api/process/basicPlus/src/basicPlusFields.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @file
3+
* @brief Export fields of basicplus plugin.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <cstddef>

new-process-api/process/bstats/src/burst.hpp

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @file
3+
* @brief Burst structure for packet statistics.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <sys/time.h>
@@ -7,17 +16,26 @@
716
namespace ipxp
817
{
918

19+
/**
20+
* @struct Burst
21+
* @brief Structure representing one packet burst. Contains packets, bytes which belong to that burst with begin and end timestamps.
22+
*/
1023
struct Burst {
11-
1224
constexpr static uint64_t MAX_INTERPACKET_TIMEDIFF = 1'000'000;
1325

1426
std::reference_wrapper<uint32_t> packets;
1527
std::reference_wrapper<uint32_t> bytes;
1628
std::reference_wrapper<uint64_t> start;
1729
std::reference_wrapper<uint64_t> end;
1830

19-
constexpr inline
20-
bool belongs(const uint64_t& time) const noexcept
31+
/**
32+
* @brief Checks if the given timestamp belongs to the burst.
33+
*
34+
* @param time The timestamp to check.
35+
* @return true if the timestamp belongs to the burst, false otherwise.
36+
*/
37+
constexpr
38+
bool belongs(const uint64_t time) const noexcept
2139
{
2240
return time - end < MAX_INTERPACKET_TIMEDIFF;
2341
}

new-process-api/process/bstats/src/burstStats.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/**
22
* @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>
55
* @author Pavel Siska <[email protected]>
6+
* @author Damir Zainullin <[email protected]>
67
* @date 2025
78
*
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.
1113
*/
1214

1315
#include "burstStats.hpp"
@@ -167,11 +169,6 @@ PluginDataMemoryLayout BurstStatsPlugin::getDataMemoryLayout() const noexcept
167169
};
168170
}
169171

170-
std::string BurstStatsPlugin::getName() const noexcept
171-
{
172-
return burstStatsPluginManifest.name;
173-
}
174-
175172
static const PluginRegistrar<BurstStatsPlugin, PluginFactory<ProcessPlugin, const std::string&, FieldManager&>>
176173
burstStatsRegistrar(burstStatsPluginManifest);
177174

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
/**
22
* @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>
55
* @author Pavel Siska <[email protected]>
6+
* @author Damir Zainullin <[email protected]>
67
* @date 2025
78
*
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.
1113
*/
1214

1315
#pragma once
@@ -23,31 +25,76 @@
2325

2426
namespace ipxp {
2527

28+
/**
29+
* @class BurstStatsPlugin
30+
* @brief A plugin for collecting packet burst statistics.
31+
*/
2632
class BurstStatsPlugin : public ProcessPlugin {
2733
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+
*/
2841
BurstStatsPlugin(const std::string& params, FieldManager& manager);
2942

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+
*/
3053
PluginInitResult onInit(const FlowContext& flowContext, void* pluginContext) override;
3154

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+
*/
3264
PluginUpdateResult onUpdate(const FlowContext& flowContext, void* pluginContext) override;
3365

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+
*/
3477
PluginExportResult onExport(const FlowRecord& flowRecord, void* pluginContext) override;
3578

79+
/**
80+
* @brief Cleans up and destroys `BurstStatsData`.
81+
* @param pluginContext Pointer to `BurstStatsData`.
82+
*/
3683
void onDestroy(void* pluginContext) override;
3784

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+
*/
4089
PluginDataMemoryLayout getDataMemoryLayout() const noexcept override;
4190

42-
4391
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.
4593

4694
void updateBursts(Burst& burst, FlowRecord& flowRecord, const Packet& packet) noexcept;
4795
void makeAllFieldsUnavailable(FlowRecord& flowRecord) noexcept;
4896

4997
FieldHandlers<BurstStatsFields> m_fieldHandlers;
50-
5198
};
5299

53100
} // namespace ipxp

new-process-api/process/bstats/src/burstStatsData.hpp

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/**
2+
* @file
3+
* @brief Export data of bstats plugin.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <array>
@@ -10,8 +19,13 @@
1019
namespace ipxp
1120
{
1221

13-
struct BurstStatsData {
14-
private:
22+
/**
23+
* @class BurstStatsData
24+
* @brief Class representing flow burst statistics.
25+
*
26+
* Contains packets, bytes and begin and end timestamps for each burst.
27+
*/
28+
class BurstStatsData {
1529
static constexpr std::size_t MAX_BURST_COUNT = 15;
1630

1731
DirectionalField<boost::container::static_vector<uint32_t, MAX_BURST_COUNT>> packets;
@@ -21,28 +35,57 @@ struct BurstStatsData {
2135

2236
public:
2337

38+
/**
39+
* @brief Returns a span over the packets for the given direction.
40+
*
41+
* @param direction The direction for which to retrieve the packet span.
42+
* @return A span over the packets.
43+
*/
2444
std::span<const uint32_t> getPackets(const Direction direction) const noexcept
2545
{
2646
return {packets[direction].data(), static_cast<std::size_t>(packets[direction].size())};
2747
}
2848

49+
/**
50+
* @brief Returns a span over the bytes for the given direction.
51+
*
52+
* @param direction The direction for which to retrieve the byte span.
53+
* @return A span over the bytes.
54+
*/
2955
std::span<const uint32_t> getBytes(const Direction direction) const noexcept
3056
{
3157
return std::span<const uint32_t>(bytes[direction].data(), static_cast<std::size_t>(bytes[direction].size()));
3258
}
3359

60+
/**
61+
* @brief Returns a span over the start timestamps for the given direction.
62+
*
63+
* @param direction The direction for which to retrieve the start timestamps span.
64+
* @return A span over the start timestamps.
65+
*/
3466
std::span<const uint64_t> getStartTimestamps(const Direction direction) const noexcept
3567
{
3668
return std::span<const uint64_t>(start[direction].data(), static_cast<std::size_t>(start[direction].size()));
3769
}
3870

71+
/**
72+
* @brief Returns a span over the end timestamps for the given direction.
73+
*
74+
* @param direction The direction for which to retrieve the end timestamps span.
75+
* @return A span over the end timestamps.
76+
*/
3977
std::span<const uint64_t> getEndTimestamps(const Direction direction) const noexcept
4078
{
4179
return std::span<const uint64_t>(&*end[direction].begin(), static_cast<std::size_t>(end[direction].size()));
4280
}
4381

44-
inline
45-
std::optional<Burst> back(const Direction direction) noexcept
82+
/**
83+
* @brief Returns a view to the last observed burst.
84+
*
85+
* @param direction The direction for which to retrieve the last observed burst.
86+
* @return A view to the last observed burst, or std::nullopt if no burst were added.
87+
*/
88+
inline std::optional<Burst> back(const Direction direction) noexcept
4689
{
4790
if (packets[direction].empty()) {
4891
return std::nullopt;
@@ -55,10 +98,15 @@ struct BurstStatsData {
5598
});
5699
}
57100

58-
inline
59-
std::optional<Burst> push(const Direction direction) noexcept
101+
/**
102+
* @brief Adds new burst and returns it.
103+
*
104+
* @param direction The direction for which to add a burst.
105+
* @return A view to the newly added burst, or std::nullopt if the storage is full.
106+
*/
107+
inline std::optional<Burst> push(const Direction direction) noexcept
60108
{
61-
if (packets[direction].size() == packets[direction].max_size()) {
109+
if (packets[direction].size() == packets[direction].capacity()) {
62110
return std::nullopt;
63111
}
64112

@@ -69,8 +117,6 @@ struct BurstStatsData {
69117

70118
return back(direction);
71119
}
72-
73-
74120
};
75121

76122
} // namespace ipxp

new-process-api/process/bstats/src/burstStatsFields.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
1+
/**
2+
* @file
3+
* @brief Export fields of bstats plugin.
4+
* @author Damir Zainullin <[email protected]>
5+
* @date 2025
6+
*
7+
* @copyright Copyright (c) 2025 CESNET, z.s.p.o.
8+
*/
9+
110
#pragma once
211

312
#include <cstddef>
413

514
namespace ipxp
615
{
716

17+
/**
18+
* @enum BurstStatsFields
19+
* @brief Enumerates the fields exported by the BurstStats plugin.
20+
*
21+
* These enum values are used to index field handlers for this plugin.
22+
*/
823
enum class BurstStatsFields : std::size_t {
924
SBI_BRST_PACKETS = 0,
1025
SBI_BRST_BYTES,

0 commit comments

Comments
 (0)