From c00480949cf8ba03e88cf55f292f64ea988b792f Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Fri, 6 Sep 2024 23:35:14 +0200 Subject: [PATCH 01/12] fix typo in upper mac prometheus metrics --- include/l2/upper_mac_metrics.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/l2/upper_mac_metrics.hpp b/include/l2/upper_mac_metrics.hpp index 4ef75c5..a47d929 100644 --- a/include/l2/upper_mac_metrics.hpp +++ b/include/l2/upper_mac_metrics.hpp @@ -214,7 +214,7 @@ class UpperMacMetrics { } break; case MacPacketType::kMacFragmentUplink: - c_plane_signalling_packet_metrics_.increment("MacResource"); + c_plane_signalling_packet_metrics_.increment("MacFragmentUplink"); break; case MacPacketType::kMacEndUplink: c_plane_signalling_packet_metrics_.increment("MacEndUplink"); From 0fa12ce31fdf229c9aac35a833163dee6beda158 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sat, 7 Sep 2024 00:36:15 +0200 Subject: [PATCH 02/12] handle null pdu for uplink correctly --- include/l2/upper_mac_packet.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/l2/upper_mac_packet.hpp b/include/l2/upper_mac_packet.hpp index d8fb7f3..08e3ffc 100644 --- a/include/l2/upper_mac_packet.hpp +++ b/include/l2/upper_mac_packet.hpp @@ -446,7 +446,9 @@ struct UpperMacCPlaneSignallingPacket { /// check if this packet is a null pdu [[nodiscard]] auto is_null_pdu() const -> bool { - return type_ == MacPacketType::kMacResource && address_ == Address{}; + return (type_ == MacPacketType::kMacResource && address_ == Address{}) || + (type_ == MacPacketType::kMacAccess && !tm_sdu_.has_value()) || + (type_ == MacPacketType::kMacData && !tm_sdu_.has_value()); }; /// check if this packet is part of a downlink fragment From e96018565b7b8c7b422a167b2069332fa602d8b6 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sat, 7 Sep 2024 01:26:54 +0200 Subject: [PATCH 03/12] add missing breaks in switch case for upper mac packet count metrics --- include/l2/upper_mac_metrics.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/l2/upper_mac_metrics.hpp b/include/l2/upper_mac_metrics.hpp index a47d929..a3e8658 100644 --- a/include/l2/upper_mac_metrics.hpp +++ b/include/l2/upper_mac_metrics.hpp @@ -218,8 +218,10 @@ class UpperMacMetrics { break; case MacPacketType::kMacEndUplink: c_plane_signalling_packet_metrics_.increment("MacEndUplink"); + break; case MacPacketType::kMacUBlck: c_plane_signalling_packet_metrics_.increment("MacUBlck"); + break; case MacPacketType::kMacUSignal: throw std::runtime_error("C-Plane signalling may not be of type MacUSignal"); } From 6e93e4dba314da1c5d60564df2d4058e870fc071 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sat, 7 Sep 2024 01:54:33 +0200 Subject: [PATCH 04/12] handle address of null pdu in the uplink --- include/l2/upper_mac_packet_builder.hpp | 34 ++++++++++++++++++++----- src/l2/upper_mac.cpp | 3 +++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/include/l2/upper_mac_packet_builder.hpp b/include/l2/upper_mac_packet_builder.hpp index e33604f..3b4bcf8 100644 --- a/include/l2/upper_mac_packet_builder.hpp +++ b/include/l2/upper_mac_packet_builder.hpp @@ -53,6 +53,28 @@ struct UpperMacPackets { } } + /// Distribute the information of the uplink c-plane signalling null pdu to all other c-plane signalling packets. + /// This operation will associate uplink packets with no address (MacFragmentUplink and MacEndUplink) with the + /// address of the uplink null pdu. + auto apply_uplink_null_pdu_information() -> void { + std::optional null_pdu; + + for (auto const& packet : c_plane_signalling_packets_) { + if (packet.is_null_pdu()) { + null_pdu = packet; + } + } + + if (null_pdu) { + for (auto& packet : c_plane_signalling_packets_) { + if ((packet.type_ == MacPacketType::kMacFragmentUplink) || + (packet.type_ == MacPacketType::kMacEndUplink)) { + packet.address_ = null_pdu->address_; + } + } + } + } + /// Check if the packet contains data that is of importance for C-Plane or U-Plane /// \return true if the UpperMacPackets contain user or control plane data (either signalling or traffic) [[nodiscard]] auto has_user_or_control_plane_data() const -> bool { @@ -108,22 +130,22 @@ class UpperMacPacketBuilder { /// \param channel the logical channel on which the packets are sent /// \param data the BitVector which holds the packets /// \return the parsed c-plane signalling packets - [[nodiscard]] static auto parse_c_plane_signalling(BurstType burst_type, LogicalChannel channel, BitVector&& data) - -> std::vector; + [[nodiscard]] static auto parse_c_plane_signalling(BurstType burst_type, LogicalChannel channel, + BitVector&& data) -> std::vector; /// Parse the user plane signalling packet contained in a BitVector /// \param channel the logical channel on which the packet is sent /// \param data the BitVector which holds the packet /// \return the parsed u-plane signalling packet - [[nodiscard]] static auto parse_u_plane_signalling(LogicalChannel channel, BitVector&& data) - -> UpperMacUPlaneSignallingPacket; + [[nodiscard]] static auto parse_u_plane_signalling(LogicalChannel channel, + BitVector&& data) -> UpperMacUPlaneSignallingPacket; /// Parse the user plane traffic packet contained in a BitVector /// \param channel the logical channel on which the packet is sent /// \param data the BitVector which holds the packet /// \return the parsed u-plane traffic packet - [[nodiscard]] static auto parse_u_plane_traffic(LogicalChannel channel, BitVector&& data) - -> UpperMacUPlaneTrafficPacket; + [[nodiscard]] static auto parse_u_plane_traffic(LogicalChannel channel, + BitVector&& data) -> UpperMacUPlaneTrafficPacket; public: UpperMacPacketBuilder() = default; diff --git a/src/l2/upper_mac.cpp b/src/l2/upper_mac.cpp index 0c590cf..06c4d25 100644 --- a/src/l2/upper_mac.cpp +++ b/src/l2/upper_mac.cpp @@ -90,6 +90,9 @@ auto UpperMac::process(const Slots& slots) -> void { } } + /// This step takes care of adding the correct adresses for some uplink packets. + packets.apply_uplink_null_pdu_information(); + try { processPackets(std::move(packets)); } catch (std::runtime_error& e) { From 446027fb1e96bb589d4b4bb48e85c5aaaa91834f Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sat, 7 Sep 2024 11:52:37 +0200 Subject: [PATCH 05/12] fix is_uplink_burst. implement continous fragmentation rebuilding for the uplink. --- include/l2/upper_mac.hpp | 8 +- include/l2/upper_mac_fragments.hpp | 150 ++++++++++++++++++++++++++--- include/l2/upper_mac_packet.hpp | 3 +- include/utils/address.hpp | 7 ++ src/l2/upper_mac.cpp | 35 ++++--- 5 files changed, 176 insertions(+), 27 deletions(-) diff --git a/include/l2/upper_mac.hpp b/include/l2/upper_mac.hpp index a5b5064..eb57851 100644 --- a/include/l2/upper_mac.hpp +++ b/include/l2/upper_mac.hpp @@ -66,12 +66,14 @@ class UpperMac { std::unique_ptr metrics_; /// The prometheus metrics for the fragmentation - std::shared_ptr fragmentation_metrics_continous_; - std::shared_ptr fragmentation_metrics_stealing_channel_; + std::shared_ptr fragmentation_metrics_downlink_continous_; + std::shared_ptr fragmentation_metrics_uplink_continous_; + std::shared_ptr fragmentation_metrics_downlink_stealing_channel_; LogicalLinkControlParser logical_link_control_; - std::unique_ptr fragmentation_; + std::unique_ptr downlink_fragmentation_; + std::unique_ptr uplink_fragmentation_; /// The worker thread std::thread worker_thread_; diff --git a/include/l2/upper_mac_fragments.hpp b/include/l2/upper_mac_fragments.hpp index 6691fb4..00c4226 100644 --- a/include/l2/upper_mac_fragments.hpp +++ b/include/l2/upper_mac_fragments.hpp @@ -10,6 +10,7 @@ #include "l2/upper_mac_packet.hpp" #include "prometheus.h" +#include "utils/address.hpp" #include #include #include @@ -49,10 +50,8 @@ class UpperMacFragmentsPrometheusCounters { auto increment_fragment_count() -> void { fragment_count_total_.Increment(); } }; -/// Class that provides the fragment reconstruction for uplink and downlink packets. -/// TODO: Uplink fragmentation may include reserved slots and is therefore harder to reconstruct. This is not handled -/// with this class. -class UpperMacFragmentation { +/// Class that provides the fragment reconstruction for downlink packets. +class UpperMacDownlinkFragmentation { private: /// Holds the internal state of the fragment rebuilder enum class State { @@ -76,8 +75,8 @@ class UpperMacFragmentation { /// \param new_state the new state into which the state machine would be transfered with this fragment /// \param fragment the control plane signalling packet that is fragmented /// \return an optional reconstructed control plane signalling packet when reconstuction was successful - auto change_state(State new_state, const UpperMacCPlaneSignallingPacket& fragment) - -> std::optional { + auto change_state(State new_state, + const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { const auto& valid_state_changes = allowed_state_changes_[state_]; // increment the total fragment counters @@ -125,12 +124,12 @@ class UpperMacFragmentation { }; public: - UpperMacFragmentation() = delete; + UpperMacDownlinkFragmentation() = delete; /// Constructor for the fragmentations. Optionally specify if an arbitraty numner of continuation fragments are /// allowed - explicit UpperMacFragmentation(const std::shared_ptr& metrics, - bool continuation_fragments_allowed = true) + explicit UpperMacDownlinkFragmentation(const std::shared_ptr& metrics, + bool continuation_fragments_allowed = true) : state_(State::kStart) , metrics_(metrics) { if (continuation_fragments_allowed) { @@ -153,8 +152,8 @@ class UpperMacFragmentation { /// Push a fragment for reconstruction. /// \param fragment the control plane signalling packet that is fragmented /// \return an optional reconstructed control plane signalling packet when reconstuction was successful - auto push_fragment(const UpperMacCPlaneSignallingPacket& fragment) - -> std::optional { + auto + push_fragment(const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { switch (fragment.type_) { case MacPacketType::kMacResource: assert(fragment.fragmentation_); @@ -167,6 +166,133 @@ class UpperMacFragmentation { throw std::runtime_error("No fragmentation in MacDBlck"); case MacPacketType::kMacBroadcast: throw std::runtime_error("No fragmentation in MacBroadcast"); + case MacPacketType::kMacAccess: + throw std::runtime_error("MacAccess is not handled by UpperMacDownlinkFragmentation"); + case MacPacketType::kMacData: + throw std::runtime_error("MacData is not handled by UpperMacDownlinkFragmentation"); + case MacPacketType::kMacFragmentUplink: + throw std::runtime_error("MacFragmentUplink is not handled by UpperMacDownlinkFragmentation"); + case MacPacketType::kMacEndHu: + throw std::runtime_error("MacEndHu is not handled by UpperMacDownlinkFragmentation"); + case MacPacketType::kMacEndUplink: + throw std::runtime_error("MacEndUplink is not handled by UpperMacDownlinkFragmentation"); + case MacPacketType::kMacUBlck: + throw std::runtime_error("No fragmentation in MacUBlck"); + case MacPacketType::kMacUSignal: + throw std::runtime_error("No fragmentation in MacUSignal"); + } + }; +}; + +/// Class that provides the fragment reconstruction for uplink packets. +/// Uplink fragmentation may include reserved slots and is therefore harder to reconstruct. This is not handled +/// with this class. +class UpperMacUplinkFragmentation { + private: + /// Holds the internal state of the fragment rebuilder + enum class State { + kStart, + kStartFragmentReceived, + kContinuationFragmentReceived, + kEndFragmentReceived, + }; + /// The vector that holds the accumulated fragments for each mobile station by its address + std::map> fragments_per_address_; + /// Are continuation allowed in the state machine? + std::map> allowed_state_changes_; + /// The current state of the fragment reassembler for each mobile station by its address + std::map state_per_address_; + + /// the metrics for the fragmentation + std::shared_ptr metrics_; + + /// Try the state transtition with a fragment. Increment the error metrics if there is an invalid state transition + /// attempted + /// \param new_state the new state into which the state machine would be transfered with this fragment + /// \param fragment the control plane signalling packet that is fragmented + /// \return an optional reconstructed control plane signalling packet when reconstuction was successful + auto change_state(State new_state, + const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { + const auto& address = fragment.address_; + auto& state = state_per_address_[address]; + auto& fragments = fragments_per_address_[address]; + + const auto& valid_state_changes = allowed_state_changes_[state]; + + // increment the total fragment counters + if (metrics_) { + metrics_->increment_fragment_count(); + } + + if (valid_state_changes.count(new_state)) { + // valid state change. perform and add fragment + fragments.emplace_back(fragment); + state = new_state; + } else { + // increment the invalid state metrics + if (metrics_) { + metrics_->increment_fragment_reconstruction_error(); + } + + // always save the start segment + if (new_state == State::kStartFragmentReceived) { + fragments = {fragment}; + state = State::kStartFragmentReceived; + } else { + fragments.clear(); + state = State::kStart; + } + } + + // if we are in the end state reassmeble the packet. + if (state == State::kEndFragmentReceived) { + std::optional packet; + for (const auto& fragment : fragments) { + if (packet) { + packet->tm_sdu_->append(*fragment.tm_sdu_); + } else { + packet = fragment; + } + } + fragments.clear(); + state = State::kStart; + + return packet; + } + + return std::nullopt; + }; + + public: + UpperMacUplinkFragmentation() = delete; + + /// Constructor for the fragmentations. Optionally specify if an arbitraty numner of continuation fragments are + /// allowed + explicit UpperMacUplinkFragmentation(const std::shared_ptr& metrics) + : metrics_(metrics) { + allowed_state_changes_ = { + {State::kStart, {State::kStartFragmentReceived}}, + {State::kStartFragmentReceived, {State::kContinuationFragmentReceived, State::kEndFragmentReceived}}, + {State::kContinuationFragmentReceived, {State::kContinuationFragmentReceived, State::kEndFragmentReceived}}, + {State::kEndFragmentReceived, {State::kStart}}}; + }; + + /// Push a fragment for reconstruction. + /// \param fragment the control plane signalling packet that is fragmented + /// \return an optional reconstructed control plane signalling packet when reconstuction was successful + auto + push_fragment(const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { + switch (fragment.type_) { + case MacPacketType::kMacResource: + throw std::runtime_error("MacResource is not handled by UpperMacUplinkFragmentation"); + case MacPacketType::kMacFragmentDownlink: + throw std::runtime_error("MacFragmentDownlink is not handled by UpperMacUplinkFragmentation"); + case MacPacketType::kMacEndDownlink: + throw std::runtime_error("MacEndDownlink is not handled by UpperMacUplinkFragmentation"); + case MacPacketType::kMacDBlck: + throw std::runtime_error("No fragmentation in MacDBlck"); + case MacPacketType::kMacBroadcast: + throw std::runtime_error("No fragmentation in MacBroadcast"); case MacPacketType::kMacAccess: case MacPacketType::kMacData: assert(fragment.fragmentation_); @@ -174,6 +300,8 @@ class UpperMacFragmentation { case MacPacketType::kMacFragmentUplink: return change_state(State::kContinuationFragmentReceived, fragment); case MacPacketType::kMacEndHu: + throw std::runtime_error("MacEndHu is in a reserverd subslot and not handled since there is no " + "integration between the uplink and downlink processing"); case MacPacketType::kMacEndUplink: return change_state(State::kEndFragmentReceived, fragment); case MacPacketType::kMacUBlck: diff --git a/include/l2/upper_mac_packet.hpp b/include/l2/upper_mac_packet.hpp index 08e3ffc..e52d736 100644 --- a/include/l2/upper_mac_packet.hpp +++ b/include/l2/upper_mac_packet.hpp @@ -462,7 +462,8 @@ struct UpperMacCPlaneSignallingPacket { [[nodiscard]] auto is_uplink_fragment() const -> bool { return (type_ == MacPacketType::kMacData && fragmentation_) || (type_ == MacPacketType::kMacData && fragmentation_on_stealling_channel_) || - (type_ == MacPacketType::kMacFragmentUplink) || (type_ == MacPacketType::kMacEndUplink); + (type_ == MacPacketType::kMacFragmentUplink) || (type_ == MacPacketType::kMacEndUplink) || + (type_ == MacPacketType::kMacEndHu); }; /// check if this packet is sent on downlink diff --git a/include/utils/address.hpp b/include/utils/address.hpp index 7677696..af69962 100644 --- a/include/utils/address.hpp +++ b/include/utils/address.hpp @@ -85,6 +85,13 @@ class Address { } } + // Overload this operator for usage of the Address as a map key + auto operator<(const Address& other) const -> bool { + return std::tie(country_code_, network_code_, sna_, ssi_, event_label_, ussi_, smi_, usage_marker_) < + std::tie(other.country_code_, other.network_code_, other.sna_, other.ssi_, other.event_label_, + other.ussi_, other.smi_, other.usage_marker_); + } + friend auto operator<<(std::ostream& stream, const Address& address_type) -> std::ostream&; NLOHMANN_DEFINE_TYPE_INTRUSIVE(Address, country_code_, network_code_, sna_, ssi_, event_label_, ussi_, smi_, diff --git a/src/l2/upper_mac.cpp b/src/l2/upper_mac.cpp index 06c4d25..1ecfbe4 100644 --- a/src/l2/upper_mac.cpp +++ b/src/l2/upper_mac.cpp @@ -28,12 +28,17 @@ UpperMac::UpperMac(const std::shared_ptr(prometheus_exporter); - fragmentation_metrics_continous_ = - std::make_shared(prometheus_exporter, "Continous"); - fragmentation_metrics_stealing_channel_ = - std::make_shared(prometheus_exporter, "Stealing Channel"); + fragmentation_metrics_downlink_continous_ = + std::make_shared(prometheus_exporter, "Continous Downlink"); + fragmentation_metrics_uplink_continous_ = + std::make_shared(prometheus_exporter, "Continous Uplink"); + fragmentation_metrics_downlink_stealing_channel_ = + std::make_shared(prometheus_exporter, "Stealing Channel Downlink"); } - fragmentation_ = std::make_unique(fragmentation_metrics_continous_); + downlink_fragmentation_ = + std::make_unique(fragmentation_metrics_downlink_continous_); + uplink_fragmentation_ = std::make_unique(fragmentation_metrics_uplink_continous_); + worker_thread_ = std::thread(&UpperMac::worker, this); #if defined(__linux__) @@ -110,9 +115,10 @@ auto UpperMac::process(const Slots& slots) -> void { auto UpperMac::processPackets(UpperMacPackets&& packets) -> void { // the fragmentation reconstructor for over two stealing channel in the same burst - auto& fragmentation = *fragmentation_; + auto& downlink_fragmentation = *downlink_fragmentation_; auto stealling_channel_fragmentation = - UpperMacFragmentation(fragmentation_metrics_stealing_channel_, /*continuation_fragments_allowed=*/false); + UpperMacDownlinkFragmentation(fragmentation_metrics_downlink_stealing_channel_, + /*continuation_fragments_allowed=*/false); std::vector c_plane_packets; @@ -122,13 +128,18 @@ auto UpperMac::processPackets(UpperMacPackets&& packets) -> void { metrics_->increment_c_plane_packet_counters(packet); } - if (packet.is_downlink_fragment() || packet.is_uplink_fragment()) { + if (packet.is_downlink_fragment()) { /// populate the fragmenter for stealing channel if (packet.fragmentation_on_stealling_channel_) { - fragmentation = stealling_channel_fragmentation; + downlink_fragmentation = stealling_channel_fragmentation; } - auto reconstructed_fragment = fragmentation.push_fragment(packet); + auto reconstructed_fragment = downlink_fragmentation.push_fragment(packet); + if (reconstructed_fragment) { + c_plane_packets.emplace_back(std::move(*reconstructed_fragment)); + } + } else if (packet.is_uplink_fragment()) { + auto reconstructed_fragment = uplink_fragmentation_->push_fragment(packet); if (reconstructed_fragment) { c_plane_packets.emplace_back(std::move(*reconstructed_fragment)); } @@ -138,8 +149,8 @@ auto UpperMac::processPackets(UpperMacPackets&& packets) -> void { } /// increment the reconstruction error counter if we could not complete the fragmentation over stealing channel - if (!stealling_channel_fragmentation.is_in_start_state() && fragmentation_metrics_stealing_channel_) { - fragmentation_metrics_stealing_channel_->increment_fragment_reconstruction_error(); + if (!stealling_channel_fragmentation.is_in_start_state() && fragmentation_metrics_downlink_stealing_channel_) { + fragmentation_metrics_downlink_stealing_channel_->increment_fragment_reconstruction_error(); } /// increment the packet counter From 568416bd3d1735ccb676b09674593c88b2d3edb0 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sat, 7 Sep 2024 12:07:22 +0200 Subject: [PATCH 06/12] add debug print for UpperMacUplinkFragmentation state change --- include/l2/upper_mac_fragments.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/l2/upper_mac_fragments.hpp b/include/l2/upper_mac_fragments.hpp index 00c4226..b9c4a5b 100644 --- a/include/l2/upper_mac_fragments.hpp +++ b/include/l2/upper_mac_fragments.hpp @@ -213,6 +213,7 @@ class UpperMacUplinkFragmentation { /// \return an optional reconstructed control plane signalling packet when reconstuction was successful auto change_state(State new_state, const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { + std::cout << fragment << std::endl; const auto& address = fragment.address_; auto& state = state_per_address_[address]; auto& fragments = fragments_per_address_[address]; From a79cb8fc1a47670b318d761bd0d124bb8f3c4e1b Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sat, 7 Sep 2024 12:12:49 +0200 Subject: [PATCH 07/12] add mac access fragments to is_uplink_fragment code --- include/l2/upper_mac_packet.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/l2/upper_mac_packet.hpp b/include/l2/upper_mac_packet.hpp index e52d736..0057e29 100644 --- a/include/l2/upper_mac_packet.hpp +++ b/include/l2/upper_mac_packet.hpp @@ -460,7 +460,9 @@ struct UpperMacCPlaneSignallingPacket { /// check if this packet is part of a uplink fragment [[nodiscard]] auto is_uplink_fragment() const -> bool { - return (type_ == MacPacketType::kMacData && fragmentation_) || + return (type_ == MacPacketType::kMacAccess && fragmentation_) || + (type_ == MacPacketType::kMacAccess && fragmentation_on_stealling_channel_) || + (type_ == MacPacketType::kMacData && fragmentation_) || (type_ == MacPacketType::kMacData && fragmentation_on_stealling_channel_) || (type_ == MacPacketType::kMacFragmentUplink) || (type_ == MacPacketType::kMacEndUplink) || (type_ == MacPacketType::kMacEndHu); From 424625e30cdc3cfc1692562c42d018ce82f1204b Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sat, 7 Sep 2024 12:23:12 +0200 Subject: [PATCH 08/12] Revert "add debug print for UpperMacUplinkFragmentation state change" This reverts commit 568416bd3d1735ccb676b09674593c88b2d3edb0. --- include/l2/upper_mac_fragments.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/l2/upper_mac_fragments.hpp b/include/l2/upper_mac_fragments.hpp index b9c4a5b..00c4226 100644 --- a/include/l2/upper_mac_fragments.hpp +++ b/include/l2/upper_mac_fragments.hpp @@ -213,7 +213,6 @@ class UpperMacUplinkFragmentation { /// \return an optional reconstructed control plane signalling packet when reconstuction was successful auto change_state(State new_state, const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { - std::cout << fragment << std::endl; const auto& address = fragment.address_; auto& state = state_per_address_[address]; auto& fragments = fragments_per_address_[address]; From 6a72cead1fc96946492d1893145822914f0fe315 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Tue, 10 Sep 2024 13:06:32 +0200 Subject: [PATCH 09/12] clang-format --- src/l2/upper_mac_packet_builder.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/l2/upper_mac_packet_builder.cpp b/src/l2/upper_mac_packet_builder.cpp index 58aba0d..923b1a1 100644 --- a/src/l2/upper_mac_packet_builder.cpp +++ b/src/l2/upper_mac_packet_builder.cpp @@ -107,8 +107,8 @@ auto UpperMacPacketBuilder::parse_broadcast(LogicalChannel channel, BitVector&& } auto UpperMacPacketBuilder::extract_tm_sdu(BitVector& data, std::size_t preprocessing_bit_count, - unsigned _BitInt(1) fill_bit_indication, std::optional length) - -> BitVector { + unsigned _BitInt(1) fill_bit_indication, + std::optional length) -> BitVector { // 1. calculate the header size of the MAC. this step must be performed before removing fill bits, as this would // change the number of bits in the BitVector const auto mac_header_length = preprocessing_bit_count - data.bits_left(); @@ -527,8 +527,8 @@ auto UpperMacPacketBuilder::parse_c_plane_signalling(const BurstType burst_type, return packets; } -auto UpperMacPacketBuilder::parse_u_plane_signalling(const LogicalChannel channel, BitVector&& data) - -> UpperMacUPlaneSignallingPacket { +auto UpperMacPacketBuilder::parse_u_plane_signalling(const LogicalChannel channel, + BitVector&& data) -> UpperMacUPlaneSignallingPacket { // the only valid packet here is MAC-U-SIGNAL auto pdu_type = data.take<2>(); @@ -542,7 +542,7 @@ auto UpperMacPacketBuilder::parse_u_plane_signalling(const LogicalChannel channe .logical_channel_ = channel, .type_ = MacPacketType::kMacUSignal, .tm_sdu_ = std::move(data)}; } -auto UpperMacPacketBuilder::parse_u_plane_traffic(const LogicalChannel channel, BitVector&& data) - -> UpperMacUPlaneTrafficPacket { +auto UpperMacPacketBuilder::parse_u_plane_traffic(const LogicalChannel channel, + BitVector&& data) -> UpperMacUPlaneTrafficPacket { return UpperMacUPlaneTrafficPacket{.logical_channel_ = channel, .data_ = std::move(data)}; } \ No newline at end of file From 5a56403fd13c9370e51bf78e36c053fd1f2ac778 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Tue, 10 Sep 2024 13:18:56 +0200 Subject: [PATCH 10/12] clang-format --- include/l2/upper_mac_fragments.hpp | 16 ++++++++-------- include/l2/upper_mac_packet_builder.hpp | 12 ++++++------ src/l2/upper_mac_packet_builder.cpp | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/l2/upper_mac_fragments.hpp b/include/l2/upper_mac_fragments.hpp index 00c4226..9f623c5 100644 --- a/include/l2/upper_mac_fragments.hpp +++ b/include/l2/upper_mac_fragments.hpp @@ -75,8 +75,8 @@ class UpperMacDownlinkFragmentation { /// \param new_state the new state into which the state machine would be transfered with this fragment /// \param fragment the control plane signalling packet that is fragmented /// \return an optional reconstructed control plane signalling packet when reconstuction was successful - auto change_state(State new_state, - const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { + auto change_state(State new_state, const UpperMacCPlaneSignallingPacket& fragment) + -> std::optional { const auto& valid_state_changes = allowed_state_changes_[state_]; // increment the total fragment counters @@ -152,8 +152,8 @@ class UpperMacDownlinkFragmentation { /// Push a fragment for reconstruction. /// \param fragment the control plane signalling packet that is fragmented /// \return an optional reconstructed control plane signalling packet when reconstuction was successful - auto - push_fragment(const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { + auto push_fragment(const UpperMacCPlaneSignallingPacket& fragment) + -> std::optional { switch (fragment.type_) { case MacPacketType::kMacResource: assert(fragment.fragmentation_); @@ -211,8 +211,8 @@ class UpperMacUplinkFragmentation { /// \param new_state the new state into which the state machine would be transfered with this fragment /// \param fragment the control plane signalling packet that is fragmented /// \return an optional reconstructed control plane signalling packet when reconstuction was successful - auto change_state(State new_state, - const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { + auto change_state(State new_state, const UpperMacCPlaneSignallingPacket& fragment) + -> std::optional { const auto& address = fragment.address_; auto& state = state_per_address_[address]; auto& fragments = fragments_per_address_[address]; @@ -280,8 +280,8 @@ class UpperMacUplinkFragmentation { /// Push a fragment for reconstruction. /// \param fragment the control plane signalling packet that is fragmented /// \return an optional reconstructed control plane signalling packet when reconstuction was successful - auto - push_fragment(const UpperMacCPlaneSignallingPacket& fragment) -> std::optional { + auto push_fragment(const UpperMacCPlaneSignallingPacket& fragment) + -> std::optional { switch (fragment.type_) { case MacPacketType::kMacResource: throw std::runtime_error("MacResource is not handled by UpperMacUplinkFragmentation"); diff --git a/include/l2/upper_mac_packet_builder.hpp b/include/l2/upper_mac_packet_builder.hpp index 3b4bcf8..b4de413 100644 --- a/include/l2/upper_mac_packet_builder.hpp +++ b/include/l2/upper_mac_packet_builder.hpp @@ -130,22 +130,22 @@ class UpperMacPacketBuilder { /// \param channel the logical channel on which the packets are sent /// \param data the BitVector which holds the packets /// \return the parsed c-plane signalling packets - [[nodiscard]] static auto parse_c_plane_signalling(BurstType burst_type, LogicalChannel channel, - BitVector&& data) -> std::vector; + [[nodiscard]] static auto parse_c_plane_signalling(BurstType burst_type, LogicalChannel channel, BitVector&& data) + -> std::vector; /// Parse the user plane signalling packet contained in a BitVector /// \param channel the logical channel on which the packet is sent /// \param data the BitVector which holds the packet /// \return the parsed u-plane signalling packet - [[nodiscard]] static auto parse_u_plane_signalling(LogicalChannel channel, - BitVector&& data) -> UpperMacUPlaneSignallingPacket; + [[nodiscard]] static auto parse_u_plane_signalling(LogicalChannel channel, BitVector&& data) + -> UpperMacUPlaneSignallingPacket; /// Parse the user plane traffic packet contained in a BitVector /// \param channel the logical channel on which the packet is sent /// \param data the BitVector which holds the packet /// \return the parsed u-plane traffic packet - [[nodiscard]] static auto parse_u_plane_traffic(LogicalChannel channel, - BitVector&& data) -> UpperMacUPlaneTrafficPacket; + [[nodiscard]] static auto parse_u_plane_traffic(LogicalChannel channel, BitVector&& data) + -> UpperMacUPlaneTrafficPacket; public: UpperMacPacketBuilder() = default; diff --git a/src/l2/upper_mac_packet_builder.cpp b/src/l2/upper_mac_packet_builder.cpp index 923b1a1..58aba0d 100644 --- a/src/l2/upper_mac_packet_builder.cpp +++ b/src/l2/upper_mac_packet_builder.cpp @@ -107,8 +107,8 @@ auto UpperMacPacketBuilder::parse_broadcast(LogicalChannel channel, BitVector&& } auto UpperMacPacketBuilder::extract_tm_sdu(BitVector& data, std::size_t preprocessing_bit_count, - unsigned _BitInt(1) fill_bit_indication, - std::optional length) -> BitVector { + unsigned _BitInt(1) fill_bit_indication, std::optional length) + -> BitVector { // 1. calculate the header size of the MAC. this step must be performed before removing fill bits, as this would // change the number of bits in the BitVector const auto mac_header_length = preprocessing_bit_count - data.bits_left(); @@ -527,8 +527,8 @@ auto UpperMacPacketBuilder::parse_c_plane_signalling(const BurstType burst_type, return packets; } -auto UpperMacPacketBuilder::parse_u_plane_signalling(const LogicalChannel channel, - BitVector&& data) -> UpperMacUPlaneSignallingPacket { +auto UpperMacPacketBuilder::parse_u_plane_signalling(const LogicalChannel channel, BitVector&& data) + -> UpperMacUPlaneSignallingPacket { // the only valid packet here is MAC-U-SIGNAL auto pdu_type = data.take<2>(); @@ -542,7 +542,7 @@ auto UpperMacPacketBuilder::parse_u_plane_signalling(const LogicalChannel channe .logical_channel_ = channel, .type_ = MacPacketType::kMacUSignal, .tm_sdu_ = std::move(data)}; } -auto UpperMacPacketBuilder::parse_u_plane_traffic(const LogicalChannel channel, - BitVector&& data) -> UpperMacUPlaneTrafficPacket { +auto UpperMacPacketBuilder::parse_u_plane_traffic(const LogicalChannel channel, BitVector&& data) + -> UpperMacUPlaneTrafficPacket { return UpperMacUPlaneTrafficPacket{.logical_channel_ = channel, .data_ = std::move(data)}; } \ No newline at end of file From 2543aa906cf2111ae080442325026fdfc7f482e0 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Tue, 10 Sep 2024 14:30:33 +0200 Subject: [PATCH 11/12] add metrics for uplink macaccess fragments --- include/l2/upper_mac_metrics.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/l2/upper_mac_metrics.hpp b/include/l2/upper_mac_metrics.hpp index a3e8658..659bdad 100644 --- a/include/l2/upper_mac_metrics.hpp +++ b/include/l2/upper_mac_metrics.hpp @@ -201,7 +201,11 @@ class UpperMacMetrics { case MacPacketType::kMacBroadcast: throw std::runtime_error("C-Plane signalling may not be of type MacBroadcast"); case MacPacketType::kMacAccess: - c_plane_signalling_packet_metrics_.increment("MacAccess"); + if (packet.is_uplink_fragment()) { + c_plane_signalling_packet_metrics_.increment("MacAccess fragments"); + } else { + c_plane_signalling_packet_metrics_.increment("MacAccess"); + } break; case MacPacketType::kMacEndHu: c_plane_signalling_packet_metrics_.increment("MacEndHu"); From dfc60d114e85f64985044556ff67c98820d1f173 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Tue, 10 Sep 2024 14:37:14 +0200 Subject: [PATCH 12/12] add metrics for null pdus --- include/l2/upper_mac_metrics.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/l2/upper_mac_metrics.hpp b/include/l2/upper_mac_metrics.hpp index 659bdad..6490e73 100644 --- a/include/l2/upper_mac_metrics.hpp +++ b/include/l2/upper_mac_metrics.hpp @@ -186,6 +186,8 @@ class UpperMacMetrics { case MacPacketType::kMacResource: if (packet.is_downlink_fragment()) { c_plane_signalling_packet_metrics_.increment("MacResource fragments"); + } else if (packet.is_null_pdu()) { + c_plane_signalling_packet_metrics_.increment("MacResource null pdu"); } else { c_plane_signalling_packet_metrics_.increment("MacResource"); } @@ -203,6 +205,8 @@ class UpperMacMetrics { case MacPacketType::kMacAccess: if (packet.is_uplink_fragment()) { c_plane_signalling_packet_metrics_.increment("MacAccess fragments"); + } else if (packet.is_null_pdu()) { + c_plane_signalling_packet_metrics_.increment("MacAccess null pdu"); } else { c_plane_signalling_packet_metrics_.increment("MacAccess"); } @@ -213,6 +217,8 @@ class UpperMacMetrics { case MacPacketType::kMacData: if (packet.is_uplink_fragment()) { c_plane_signalling_packet_metrics_.increment("MacData fragments"); + } else if (packet.is_null_pdu()) { + c_plane_signalling_packet_metrics_.increment("MacData null pdu"); } else { c_plane_signalling_packet_metrics_.increment("MacData"); }