From 0164d8d3d456277bba697603ca5f5e7be98fa1ee Mon Sep 17 00:00:00 2001 From: Biljana Bojovic Date: Tue, 21 Feb 2023 15:35:07 +0100 Subject: [PATCH] lte: Add PDCP-RLC discard timer --- src/lte/model/lte-enb-rrc.cc | 1 + src/lte/model/lte-rlc-um.cc | 39 +++++++++++++++++++++++++++++++++++- src/lte/model/lte-rlc-um.h | 9 ++++++--- src/lte/model/lte-rlc.cc | 7 +++++++ src/lte/model/lte-rlc.h | 7 +++++++ 5 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/lte/model/lte-enb-rrc.cc b/src/lte/model/lte-enb-rrc.cc index f06e5c009..2dbdd4b0b 100644 --- a/src/lte/model/lte-enb-rrc.cc +++ b/src/lte/model/lte-enb-rrc.cc @@ -436,6 +436,7 @@ UeManager::SetupDataRadioBearer(EpsBearer bearer, Ptr rlc = rlcObjectFactory.Create()->GetObject(); rlc->SetLteMacSapProvider(m_rrc->m_macSapProvider); rlc->SetRnti(m_rnti); + rlc->SetPacketDelayBudgetMs(bearer.GetPacketDelayBudgetMs()); drbInfo->m_rlc = rlc; diff --git a/src/lte/model/lte-rlc-um.cc b/src/lte/model/lte-rlc-um.cc index 79eb09878..4eff9a750 100644 --- a/src/lte/model/lte-rlc-um.cc +++ b/src/lte/model/lte-rlc-um.cc @@ -68,7 +68,21 @@ LteRlcUm::GetTypeId() "Value of the t-Reordering timer (See section 7.3 of 3GPP TS 36.322)", TimeValue(MilliSeconds(100)), MakeTimeAccessor(&LteRlcUm::m_reorderingTimerValue), - MakeTimeChecker()); + MakeTimeChecker()) + .AddAttribute( + "EnablePdcpDiscarding", + "Whether to use the PDCP discarding, i.e., perform discarding at the moment " + "of passing the PDCP SDU to RLC)", + BooleanValue(true), + MakeBooleanAccessor(&LteRlcUm::m_enablePdcpDiscarding), + MakeBooleanChecker()) + .AddAttribute("DiscardTimerMs", + "Discard timer in milliseconds to be used to discard packets. " + "If set to 0 then packet delay budget will be used as the discard " + "timer value, otherwise it will be used this value.", + UintegerValue(0), + MakeUintegerAccessor(&LteRlcUm::m_discardTimerMs), + MakeUintegerChecker()); return tid; } @@ -93,6 +107,29 @@ LteRlcUm::DoTransmitPdcpPdu(Ptr p) if (m_txBufferSize + p->GetSize() <= m_maxTxBufferSize) { + if (m_enablePdcpDiscarding) + { + // discart the packet + uint32_t headOfLineDelayInMs = 0; + uint32_t discardTimerMs = + (m_discardTimerMs > 0) ? m_discardTimerMs : m_packetDelayBudgetMs; + + if (!m_txBuffer.empty()) + { + headOfLineDelayInMs = + (Simulator::Now() - m_txBuffer.begin()->m_waitingSince).GetMilliSeconds(); + } + NS_LOG_DEBUG("head of line delay in MS:" << headOfLineDelayInMs); + if (headOfLineDelayInMs > discardTimerMs) + { + NS_LOG_DEBUG("Tx HOL is higher than this packet can allow. RLC SDU discarded"); + NS_LOG_DEBUG("headOfLineDelayInMs = " << headOfLineDelayInMs); + NS_LOG_DEBUG("m_packetDelayBudgetMs = " << m_packetDelayBudgetMs); + NS_LOG_DEBUG("packet size = " << p->GetSize()); + m_txDropTrace(p); + } + } + /** Store PDCP PDU */ LteRlcSduStatusTag tag; tag.SetStatus(LteRlcSduStatusTag::FULL_SDU); diff --git a/src/lte/model/lte-rlc-um.h b/src/lte/model/lte-rlc-um.h index cd3566f0e..632199fb1 100644 --- a/src/lte/model/lte-rlc-um.h +++ b/src/lte/model/lte-rlc-um.h @@ -143,9 +143,12 @@ class LteRlcUm : public LteRlc /** * Timers. See section 7.3 in TS 36.322 */ - Time m_reorderingTimerValue; ///< reordering timer value - EventId m_reorderingTimer; ///< reordering timer - EventId m_rbsTimer; ///< RBS timer + Time m_reorderingTimerValue; ///< reordering timer value + EventId m_reorderingTimer; ///< reordering timer + EventId m_rbsTimer; ///< RBS timer + bool m_enablePdcpDiscarding{false}; //!< whether to use the PDCP discarding (perform discarding + //!< at the moment of passing the PDCP SDU to RLC) + uint32_t m_discardTimerMs{0}; //!< the discard timer value in milliseconds /** * Reassembling state diff --git a/src/lte/model/lte-rlc.cc b/src/lte/model/lte-rlc.cc index b5e9cf5b5..c43551fd4 100644 --- a/src/lte/model/lte-rlc.cc +++ b/src/lte/model/lte-rlc.cc @@ -144,6 +144,13 @@ LteRlc::SetLcId(uint8_t lcId) m_lcid = lcId; } +void +LteRlc::SetPacketDelayBudgetMs(uint16_t packetDelayBudget) +{ + NS_LOG_FUNCTION(this << +packetDelayBudget); + m_packetDelayBudgetMs = packetDelayBudget; +} + void LteRlc::SetLteRlcSapUser(LteRlcSapUser* s) { diff --git a/src/lte/model/lte-rlc.h b/src/lte/model/lte-rlc.h index ee45fee8a..2247dbe95 100644 --- a/src/lte/model/lte-rlc.h +++ b/src/lte/model/lte-rlc.h @@ -75,6 +75,11 @@ class LteRlc : public Object // SimpleRefCount */ void SetLcId(uint8_t lcId); + /** + * \param packetDelayBudget + */ + void SetPacketDelayBudgetMs(uint16_t packetDelayBudget); + /** * * @@ -165,6 +170,8 @@ class LteRlc : public Object // SimpleRefCount uint16_t m_rnti; ///< RNTI uint8_t m_lcid; ///< LCID + uint16_t m_packetDelayBudgetMs{ + UINT16_MAX}; //!< the packet delay budget in ms of the corresponding logical channel /** * Used to inform of a PDU delivery to the MAC SAP provider