From c309dd62fe09d9475e5456e4fbb0a6f598e01d16 Mon Sep 17 00:00:00 2001 From: iamine Date: Sun, 4 Jul 2010 15:52:12 +0200 Subject: [PATCH] Fix Bug 905 - WimaxNetDevice loses packet uid, tags, and memory optimization --- src/devices/wimax/simple-ofdm-send-param.cc | 22 +++ src/devices/wimax/simple-ofdm-send-param.h | 9 ++ .../wimax/simple-ofdm-wimax-channel.cc | 32 ++--- src/devices/wimax/simple-ofdm-wimax-channel.h | 12 +- src/devices/wimax/simple-ofdm-wimax-phy.cc | 126 +++++++++--------- src/devices/wimax/simple-ofdm-wimax-phy.h | 48 ++++--- src/devices/wimax/ss-net-device.cc | 6 +- 7 files changed, 150 insertions(+), 105 deletions(-) diff --git a/src/devices/wimax/simple-ofdm-send-param.cc b/src/devices/wimax/simple-ofdm-send-param.cc index 7029aea8e..f8f85a34f 100644 --- a/src/devices/wimax/simple-ofdm-send-param.cc +++ b/src/devices/wimax/simple-ofdm-send-param.cc @@ -53,6 +53,23 @@ simpleOfdmSendParam::simpleOfdmSendParam (const bvec &fecBlock, m_rxPowerDbm = rxPowerDbm; } +simpleOfdmSendParam::simpleOfdmSendParam (uint32_t burstSize, + bool isFirstBlock, + uint64_t Frequency, + WimaxPhy::ModulationType modulationType, + uint8_t direction, + double rxPowerDbm, + Ptr burst) +{ + m_burstSize = burstSize; + m_isFirstBlock = isFirstBlock; + m_frequency = Frequency; + m_modulationType = modulationType; + m_direction = direction; + m_rxPowerDbm = rxPowerDbm; + m_burst = burst; +} + simpleOfdmSendParam::~simpleOfdmSendParam (void) { @@ -130,5 +147,10 @@ simpleOfdmSendParam::GetRxPowerDbm (void) { return m_rxPowerDbm; } +Ptr +simpleOfdmSendParam::GetBurst (void) +{ + return m_burst; +} } diff --git a/src/devices/wimax/simple-ofdm-send-param.h b/src/devices/wimax/simple-ofdm-send-param.h index e8551f9fc..942234b77 100644 --- a/src/devices/wimax/simple-ofdm-send-param.h +++ b/src/devices/wimax/simple-ofdm-send-param.h @@ -37,6 +37,10 @@ public: bool isFirstBlock, uint64_t Frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, double rxPowerDbm); + simpleOfdmSendParam (uint32_t burstSize, + bool isFirstBlock, uint64_t Frequency, + WimaxPhy::ModulationType modulationType, uint8_t direction, + double rxPowerDbm, Ptr burst); ~simpleOfdmSendParam (void); /** * \brief sent the fec block to send @@ -96,6 +100,10 @@ public: * \return the Received power */ double GetRxPowerDbm (void); + /** + * \return the received burst + */ + Ptr GetBurst(void); private: bvec m_fecBlock; @@ -105,6 +113,7 @@ private: WimaxPhy::ModulationType m_modulationType; uint8_t m_direction; double m_rxPowerDbm; + Ptr m_burst; }; } // namespace ns3 diff --git a/src/devices/wimax/simple-ofdm-wimax-channel.cc b/src/devices/wimax/simple-ofdm-wimax-channel.cc index bdde8b8c7..76a40d413 100644 --- a/src/devices/wimax/simple-ofdm-wimax-channel.cc +++ b/src/devices/wimax/simple-ofdm-wimax-channel.cc @@ -133,20 +133,21 @@ SimpleOfdmWimaxChannel::DoGetDevice (uint32_t index) const void SimpleOfdmWimaxChannel::Send (Time BlockTime, - const bvec &fecBlock, uint32_t burstSize, Ptr phy, bool isFirstBlock, + bool isLastBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, - double txPowerDbm) + double txPowerDbm, + Ptr burst) { double rxPowerDbm = 0; Ptr senderMobility = 0; Ptr receiverMobility = 0; senderMobility = phy->GetDevice ()->GetNode ()->GetObject (); - + simpleOfdmSendParam * param; for (std::list >::iterator iter = m_phyList.begin (); iter != m_phyList.end (); ++iter) { Time delay = Seconds(0); @@ -160,14 +161,14 @@ SimpleOfdmWimaxChannel::Send (Time BlockTime, delay = Seconds(distance/300000000.0); rxPowerDbm = m_loss->CalcRxPower (txPowerDbm, senderMobility, receiverMobility); } - simpleOfdmSendParam * param = new simpleOfdmSendParam (fecBlock, - burstSize, - isFirstBlock, - frequency, - modulationType, - direction, - rxPowerDbm); + param = new simpleOfdmSendParam (burstSize, + isFirstBlock, + frequency, + modulationType, + direction, + rxPowerDbm, + burst); Ptr dstNetDevice = (*iter)->GetDevice (); uint32_t dstNode; if (dstNetDevice == 0) @@ -180,7 +181,7 @@ SimpleOfdmWimaxChannel::Send (Time BlockTime, } Simulator::ScheduleWithContext (dstNode, delay, - &SimpleOfdmWimaxChannel::EndSend, + &SimpleOfdmWimaxChannel::EndSendDummyBlock, this, *iter, param); @@ -190,17 +191,16 @@ SimpleOfdmWimaxChannel::Send (Time BlockTime, } void -SimpleOfdmWimaxChannel::EndSend (Ptr rxphy, simpleOfdmSendParam * param) +SimpleOfdmWimaxChannel::EndSendDummyBlock (Ptr rxphy, simpleOfdmSendParam * param) { - rxphy->StartReceive (param->GetFecBlock (), - param->GetBurstSize (), + rxphy->StartReceive (param->GetBurstSize (), param->GetIsFirstBlock (), param->GetFrequency (), param->GetModulationType (), param->GetDirection (), - param->GetRxPowerDbm ()); + param->GetRxPowerDbm (), + param->GetBurst()); delete param; } - } // namespace ns3 diff --git a/src/devices/wimax/simple-ofdm-wimax-channel.h b/src/devices/wimax/simple-ofdm-wimax-channel.h index 6ef292a61..1230e0909 100644 --- a/src/devices/wimax/simple-ofdm-wimax-channel.h +++ b/src/devices/wimax/simple-ofdm-wimax-channel.h @@ -53,22 +53,26 @@ public: * \param propModel the propagation model to use */ SimpleOfdmWimaxChannel (PropModel propModel); + /** - * \brief Sends a fec block to all connected physical devices + * \brief Sends a dummy fec block to all connected physical devices * \param BlockTime the time needed to send the block * \param fecBlock the fec block being sent * \param burstSize the size of the burst * \param phy the sender device * \param isFirstBlock true if this block is the first one, false otherwise + * \param isLastBlock true if this block is the last one, false otherwise * \param frequency the frequency on which the block is sent * \param modulationType the modulation used to send the fec block * \param direction uplink or downlink * \param txPowerDbm the transmission power + * \param burst the packet burst to send */ - void Send (Time BlockTime, const bvec &fecBlock, + void Send (Time BlockTime, uint32_t burstSize, Ptr phy, bool isFirstBlock, + bool isLastBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, - uint8_t direction, double txPowerDbm); + uint8_t direction, double txPowerDbm, Ptr burts); /** * \brief sets the propagation model * \param propModel the propagation model to used @@ -79,7 +83,7 @@ private: void DoAttach (Ptr phy); std::list > m_phyList; uint32_t DoGetNDevices (void) const; - void EndSend (Ptr rxphy, simpleOfdmSendParam * param); + void EndSendDummyBlock (Ptr rxphy, simpleOfdmSendParam * param); Ptr DoGetDevice (uint32_t i) const; Ptr m_loss; }; diff --git a/src/devices/wimax/simple-ofdm-wimax-phy.cc b/src/devices/wimax/simple-ofdm-wimax-phy.cc index c66e87da0..3d8c8af6a 100644 --- a/src/devices/wimax/simple-ofdm-wimax-phy.cc +++ b/src/devices/wimax/simple-ofdm-wimax-phy.cc @@ -148,6 +148,7 @@ SimpleOfdmWimaxPhy::InitSimpleOfdmWimaxPhy (void) m_txPower = 30; // dBm SetBandwidth (10000000); // 10Mhz m_nbErroneousBlock = 0; + m_nrRecivedFecBlocks = 0; m_snrToBlockErrorRateManager = new SNRToBlockErrorRateManager (); } @@ -260,58 +261,68 @@ SimpleOfdmWimaxPhy::Send (Ptr burst, { m_currentBurstSize = burst->GetSize (); m_nrFecBlocksSent = 0; - bvec buffer = ConvertBurstToBits (burst); + m_currentBurst = burst; SetBlockParameters (burst->GetSize (), modulationType); - CreateFecBlocks (buffer, modulationType); - StartSendFecBlock (true, modulationType, direction); + NotifyTxBegin(m_currentBurst); + StartSendDummyFecBlock (true, modulationType, direction); m_traceTx (burst); } } void -SimpleOfdmWimaxPhy::StartSendFecBlock (bool isFirstBlock, - WimaxPhy::ModulationType modulationType, - uint8_t direction) +SimpleOfdmWimaxPhy::StartSendDummyFecBlock (bool isFirstBlock, + WimaxPhy::ModulationType modulationType, + uint8_t direction) { SetState (PHY_STATE_TX); - bvec fecBlock = m_fecBlocks->front (); - - m_fecBlocks->pop_front (); + bool isLastFecBlock = 0; if (isFirstBlock) { m_blockTime = GetBlockTransmissionTime (modulationType); } - Simulator::Schedule (m_blockTime, &SimpleOfdmWimaxPhy::EndSendFecBlock, this, modulationType, direction); - SimpleOfdmWimaxChannel *channel = dynamic_cast (PeekPointer (GetChannel ())); - NotifyTxBegin (fecBlock); - channel->Send (m_blockTime, - fecBlock, - m_currentBurstSize, - this, - isFirstBlock, - GetTxFrequency (), - modulationType, - direction, - m_txPower); + if (m_nrRemainingBlocksToSend==1) + { + isLastFecBlock = true; + } + else + { + isLastFecBlock = false; + } + channel->Send (m_blockTime, + m_currentBurstSize, + this, + isFirstBlock, + isLastFecBlock, + GetTxFrequency (), + modulationType, + direction, + m_txPower, + m_currentBurst); + + m_nrRemainingBlocksToSend --; + Simulator::Schedule (m_blockTime, &SimpleOfdmWimaxPhy::EndSendFecBlock, this, modulationType, direction); } + void SimpleOfdmWimaxPhy::EndSendFecBlock (WimaxPhy::ModulationType modulationType, uint8_t direction) { m_nrFecBlocksSent++; SetState (PHY_STATE_IDLE); - // this is the last FEC block of the burst + if (m_nrFecBlocksSent * m_blockSize == m_currentBurstSize * 8 + m_paddingBits) { - NS_ASSERT_MSG (m_fecBlocks->size () == 0, "Error while sending a fec block: size of the fec bloc !=0"); + // this is the last FEC block of the burst + NS_ASSERT_MSG (m_nrRemainingBlocksToSend == 0, "Error while sending a burst"); + NotifyTxEnd(m_currentBurst); } else { - StartSendFecBlock(false,modulationType,direction); + StartSendDummyFecBlock(false,modulationType,direction); } } @@ -322,13 +333,13 @@ SimpleOfdmWimaxPhy::EndSend (void) } void -SimpleOfdmWimaxPhy::StartReceive (const bvec &fecBlock, - uint32_t burstSize, +SimpleOfdmWimaxPhy::StartReceive (uint32_t burstSize, bool isFirstBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, - double rxPower) + double rxPower, + Ptr burst) { UniformVariable URNG; @@ -380,21 +391,23 @@ SimpleOfdmWimaxPhy::StartReceive (const bvec &fecBlock, case PHY_STATE_IDLE: if (frequency == GetRxFrequency ()) { - NotifyRxBegin (fecBlock); if (isFirstBlock) { + NotifyRxBegin(burst); m_receivedFecBlocks->clear (); + m_nrRecivedFecBlocks=0; SetBlockParameters (burstSize, modulationType); m_blockTime = GetBlockTransmissionTime (modulationType); } + Simulator::Schedule (m_blockTime, &SimpleOfdmWimaxPhy::EndReceiveFecBlock, this, - fecBlock, burstSize, modulationType, direction, - drop); + drop, + burst); SetState (PHY_STATE_RX); } @@ -412,44 +425,37 @@ SimpleOfdmWimaxPhy::StartReceive (const bvec &fecBlock, } void -SimpleOfdmWimaxPhy::EndReceiveFecBlock (bvec fecBlock, - uint32_t burstSize, +SimpleOfdmWimaxPhy::EndReceiveFecBlock (uint32_t burstSize, WimaxPhy::ModulationType modulationType, uint8_t direction, - uint8_t drop) + uint8_t drop, + Ptr burst) { - NS_ASSERT_MSG ((uint32_t) fecBlock.size () == GetFecBlockSize (modulationType), - "Error while receiving FEC block: The FEC bloc size is not correctly received: " << fecBlock.size () - << "Should be:" - << GetFecBlockSize (modulationType)); - SetState (PHY_STATE_IDLE); - m_receivedFecBlocks->push_back (fecBlock); + m_nrRecivedFecBlocks++; + if (drop == true) { m_nbErroneousBlock++; } - uint16_t recblocks = m_receivedFecBlocks->size (); - - // all blocks received, concatenate them to re-create the burst - if ((uint32_t) recblocks * m_blockSize == burstSize * 8 + m_paddingBits) + if ((uint32_t) m_nrRecivedFecBlocks * m_blockSize == burstSize * 8 + m_paddingBits) { + NotifyRxEnd (burst); if (m_nbErroneousBlock == 0) { Simulator::Schedule (Seconds (0), &SimpleOfdmWimaxPhy::EndReceive, this, - ConvertBitsToBurst (RecreateBuffer ())); + burst); } else { - NotifyRxDrop (fecBlock); + NotifyRxDrop (burst); } m_nbErroneousBlock = 0; - m_receivedFecBlocks->clear (); + m_nrRecivedFecBlocks = 0; } - NotifyRxEnd (fecBlock); } void @@ -790,7 +796,7 @@ SimpleOfdmWimaxPhy::SetBlockParameters (uint32_t burstSize, WimaxPhy::Modulation m_blockSize = GetFecBlockSize (modulationType); m_nrBlocks = GetNrBlocks (burstSize, modulationType); m_paddingBits = (m_nrBlocks * m_blockSize) - (burstSize * 8); - + m_nrRemainingBlocksToSend = m_nrBlocks; NS_ASSERT_MSG (m_paddingBits >= 0, "Size of padding bytes < 0"); } @@ -1050,39 +1056,39 @@ SimpleOfdmWimaxPhy::SetTraceFilePath (std::string path) } void -SimpleOfdmWimaxPhy::NotifyTxBegin (bvec packet) +SimpleOfdmWimaxPhy::NotifyTxBegin (Ptr burst) { - m_phyTxBeginTrace (packet); + m_phyTxBeginTrace (burst); } void -SimpleOfdmWimaxPhy::NotifyTxEnd (bvec packet) +SimpleOfdmWimaxPhy::NotifyTxEnd (Ptr burst) { - m_phyTxEndTrace (packet); + m_phyTxEndTrace (burst); } void -SimpleOfdmWimaxPhy::NotifyTxDrop (bvec packet) +SimpleOfdmWimaxPhy::NotifyTxDrop (Ptr burst) { - m_phyTxDropTrace (packet); + m_phyTxDropTrace (burst); } void -SimpleOfdmWimaxPhy::NotifyRxBegin (bvec packet) +SimpleOfdmWimaxPhy::NotifyRxBegin (Ptr burst) { - m_phyRxBeginTrace (packet); + m_phyRxBeginTrace (burst); } void -SimpleOfdmWimaxPhy::NotifyRxEnd (bvec packet) +SimpleOfdmWimaxPhy::NotifyRxEnd (Ptr burst) { - m_phyRxEndTrace (packet); + m_phyRxEndTrace (burst); } void -SimpleOfdmWimaxPhy::NotifyRxDrop (bvec packet) +SimpleOfdmWimaxPhy::NotifyRxDrop (Ptr burst) { - m_phyRxDropTrace (packet); + m_phyRxDropTrace (burst); } } // namespace ns3 diff --git a/src/devices/wimax/simple-ofdm-wimax-phy.h b/src/devices/wimax/simple-ofdm-wimax-phy.h index 6787aec95..d0dfe18a3 100644 --- a/src/devices/wimax/simple-ofdm-wimax-phy.h +++ b/src/devices/wimax/simple-ofdm-wimax-phy.h @@ -98,15 +98,16 @@ public: * \param modulationType the modulation used to transmit this fec Block * \param direction set to uplink and downlink * \param rxPower the received power. + * \param burst the burst to be sent */ - void StartReceive (const bvec &fecBlock, - uint32_t burstSize, + void StartReceive (uint32_t burstSize, bool isFirstBlock, uint64_t frequency, WimaxPhy::ModulationType modulationType, uint8_t direction, - double rxPower); + double rxPower, + Ptr burst); /** * \return the bandwidth @@ -140,37 +141,37 @@ public: * Public method used to fire a PhyTxBegin trace. Implemented for encapsulation * purposes. */ - void NotifyTxBegin (bvec packet); + void NotifyTxBegin (Ptr burst); /** * Public method used to fire a PhyTxEnd trace. Implemented for encapsulation * purposes. */ - void NotifyTxEnd (bvec packet); + void NotifyTxEnd (Ptr burst); /** * Public method used to fire a PhyTxDrop trace. Implemented for encapsulation * purposes. */ - void NotifyTxDrop (bvec packet); + void NotifyTxDrop (Ptr burst); /** * Public method used to fire a PhyRxBegin trace. Implemented for encapsulation * purposes. */ - void NotifyRxBegin (bvec packet); + void NotifyRxBegin (Ptr burst); /** * Public method used to fire a PhyRxEnd trace. Implemented for encapsulation * purposes. */ - void NotifyRxEnd (bvec packet); + void NotifyRxEnd (Ptr burst); /** * Public method used to fire a PhyRxDrop trace. Implemented for encapsulation * purposes. */ - void NotifyRxDrop (bvec packet); + void NotifyRxDrop (Ptr burst); private: Time DoGetTransmissionTime (uint32_t size, WimaxPhy::ModulationType modulationType) const; uint64_t DoGetNrSymbols (uint32_t size, WimaxPhy::ModulationType modulationType) const; @@ -187,14 +188,14 @@ private: void EndSend (void); void EndSendFecBlock (WimaxPhy::ModulationType modulationType, uint8_t direction); void EndReceive (Ptr burst); - void EndReceiveFecBlock (bvec fecBlock, - uint32_t burstSize, + void EndReceiveFecBlock (uint32_t burstSize, WimaxPhy::ModulationType modulationType, uint8_t direction, - uint8_t drop); - void StartSendFecBlock (bool isFirstBlock, - WimaxPhy::ModulationType modulationType, - uint8_t direction); + uint8_t drop, + Ptr burst); + void StartSendDummyFecBlock (bool isFirstBlock, + WimaxPhy::ModulationType modulationType, + uint8_t direction); Time GetBlockTransmissionTime (WimaxPhy::ModulationType modulationType) const; void DoSetDataRates (void); void InitSimpleOfdmWimaxPhy (void); @@ -240,9 +241,12 @@ private: // parameters to store for a per burst life-time uint16_t m_nrBlocks; + uint16_t m_nrRemainingBlocksToSend; + Ptr m_currentBurst; uint16_t m_blockSize; uint32_t m_paddingBits; - uint8_t m_nbErroneousBlock; + uint16_t m_nbErroneousBlock; + uint16_t m_nrRecivedFecBlocks; uint16_t m_nfft; double m_g; double m_bandWidth; @@ -256,7 +260,7 @@ private: * * \see class CallBackTraceSource */ - TracedCallback m_phyTxBeginTrace; + TracedCallback > m_phyTxBeginTrace; /** * The trace source fired when a packet ends the transmission process on @@ -264,7 +268,7 @@ private: * * \see class CallBackTraceSource */ - TracedCallback m_phyTxEndTrace; + TracedCallback > m_phyTxEndTrace; /** * The trace source fired when the phy layer drops a packet as it tries @@ -272,7 +276,7 @@ private: * * \see class CallBackTraceSource */ - TracedCallback m_phyTxDropTrace; + TracedCallback > m_phyTxDropTrace; /** * The trace source fired when a packet begins the reception process from @@ -280,7 +284,7 @@ private: * * \see class CallBackTraceSource */ - TracedCallback m_phyRxBeginTrace; + TracedCallback > m_phyRxBeginTrace; /** * The trace source fired when a packet ends the reception process from @@ -288,14 +292,14 @@ private: * * \see class CallBackTraceSource */ - TracedCallback m_phyRxEndTrace; + TracedCallback > m_phyRxEndTrace; /** * The trace source fired when the phy layer drops a packet it has received. * * \see class CallBackTraceSource */ - TracedCallback m_phyRxDropTrace; + TracedCallback > m_phyRxDropTrace; SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager; diff --git a/src/devices/wimax/ss-net-device.cc b/src/devices/wimax/ss-net-device.cc index 526643c9a..cf6571cc2 100644 --- a/src/devices/wimax/ss-net-device.cc +++ b/src/devices/wimax/ss-net-device.cc @@ -923,7 +923,7 @@ SubscriberStationNetDevice::DoReceive (Ptr packet) m_linkManager->PerformRanging (cid, rngrsp); break; default: - NS_FATAL_ERROR ("Invalid management message type"); + NS_LOG_ERROR ("Invalid management message type"); } } else if (m_basicConnection != 0 && cid == m_basicConnection->GetCid () && !fragmentation) @@ -942,7 +942,7 @@ SubscriberStationNetDevice::DoReceive (Ptr packet) m_linkManager->PerformRanging (cid, rngrsp); break; default: - NS_FATAL_ERROR ("Invalid management message type"); + NS_LOG_ERROR ("Invalid management message type"); } } else if (m_primaryConnection != 0 && cid == m_primaryConnection->GetCid () && !fragmentation) @@ -974,7 +974,7 @@ SubscriberStationNetDevice::DoReceive (Ptr packet) by BS is not supported, ignore*/ break; default: - NS_FATAL_ERROR ("Invalid management message type"); + NS_LOG_ERROR ("Invalid management message type"); } } else if (GetConnectionManager ()->GetConnection (cid)) // transport connection