From 6e93e4dba314da1c5d60564df2d4058e870fc071 Mon Sep 17 00:00:00 2001 From: Markus Schmidl Date: Sat, 7 Sep 2024 01:54:33 +0200 Subject: [PATCH] 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) {