Fix Bug 905 - WimaxNetDevice loses packet uid, tags, and memory optimization

This commit is contained in:
iamine
2010-07-04 15:52:12 +02:00
parent 34fcbcf287
commit c309dd62fe
7 changed files with 150 additions and 105 deletions

View File

@@ -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<PacketBurst> 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<PacketBurst>
simpleOfdmSendParam::GetBurst (void)
{
return m_burst;
}
}

View File

@@ -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<PacketBurst> 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<PacketBurst> GetBurst(void);
private:
bvec m_fecBlock;
@@ -105,6 +113,7 @@ private:
WimaxPhy::ModulationType m_modulationType;
uint8_t m_direction;
double m_rxPowerDbm;
Ptr<PacketBurst> m_burst;
};
} // namespace ns3

View File

@@ -133,20 +133,21 @@ SimpleOfdmWimaxChannel::DoGetDevice (uint32_t index) const
void
SimpleOfdmWimaxChannel::Send (Time BlockTime,
const bvec &fecBlock,
uint32_t burstSize,
Ptr<WimaxPhy> phy,
bool isFirstBlock,
bool isLastBlock,
uint64_t frequency,
WimaxPhy::ModulationType modulationType,
uint8_t direction,
double txPowerDbm)
double txPowerDbm,
Ptr<PacketBurst> burst)
{
double rxPowerDbm = 0;
Ptr<MobilityModel> senderMobility = 0;
Ptr<MobilityModel> receiverMobility = 0;
senderMobility = phy->GetDevice ()->GetNode ()->GetObject<MobilityModel> ();
simpleOfdmSendParam * param;
for (std::list<Ptr<SimpleOfdmWimaxPhy> >::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<Object> 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<SimpleOfdmWimaxPhy> rxphy, simpleOfdmSendParam * param)
SimpleOfdmWimaxChannel::EndSendDummyBlock (Ptr<SimpleOfdmWimaxPhy> 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

View File

@@ -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<WimaxPhy> phy, bool isFirstBlock,
bool isLastBlock,
uint64_t frequency, WimaxPhy::ModulationType modulationType,
uint8_t direction, double txPowerDbm);
uint8_t direction, double txPowerDbm, Ptr<PacketBurst> burts);
/**
* \brief sets the propagation model
* \param propModel the propagation model to used
@@ -79,7 +83,7 @@ private:
void DoAttach (Ptr<WimaxPhy> phy);
std::list<Ptr<SimpleOfdmWimaxPhy> > m_phyList;
uint32_t DoGetNDevices (void) const;
void EndSend (Ptr<SimpleOfdmWimaxPhy> rxphy, simpleOfdmSendParam * param);
void EndSendDummyBlock (Ptr<SimpleOfdmWimaxPhy> rxphy, simpleOfdmSendParam * param);
Ptr<NetDevice> DoGetDevice (uint32_t i) const;
Ptr<PropagationLossModel> m_loss;
};

View File

@@ -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<PacketBurst> 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<SimpleOfdmWimaxChannel*> (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<PacketBurst> 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<PacketBurst> 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<PacketBurst> burst)
{
m_phyTxBeginTrace (packet);
m_phyTxBeginTrace (burst);
}
void
SimpleOfdmWimaxPhy::NotifyTxEnd (bvec packet)
SimpleOfdmWimaxPhy::NotifyTxEnd (Ptr<PacketBurst> burst)
{
m_phyTxEndTrace (packet);
m_phyTxEndTrace (burst);
}
void
SimpleOfdmWimaxPhy::NotifyTxDrop (bvec packet)
SimpleOfdmWimaxPhy::NotifyTxDrop (Ptr<PacketBurst> burst)
{
m_phyTxDropTrace (packet);
m_phyTxDropTrace (burst);
}
void
SimpleOfdmWimaxPhy::NotifyRxBegin (bvec packet)
SimpleOfdmWimaxPhy::NotifyRxBegin (Ptr<PacketBurst> burst)
{
m_phyRxBeginTrace (packet);
m_phyRxBeginTrace (burst);
}
void
SimpleOfdmWimaxPhy::NotifyRxEnd (bvec packet)
SimpleOfdmWimaxPhy::NotifyRxEnd (Ptr<PacketBurst> burst)
{
m_phyRxEndTrace (packet);
m_phyRxEndTrace (burst);
}
void
SimpleOfdmWimaxPhy::NotifyRxDrop (bvec packet)
SimpleOfdmWimaxPhy::NotifyRxDrop (Ptr<PacketBurst> burst)
{
m_phyRxDropTrace (packet);
m_phyRxDropTrace (burst);
}
} // namespace ns3

View File

@@ -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<PacketBurst> 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<PacketBurst> burst);
/**
* Public method used to fire a PhyTxEnd trace. Implemented for encapsulation
* purposes.
*/
void NotifyTxEnd (bvec packet);
void NotifyTxEnd (Ptr<PacketBurst> burst);
/**
* Public method used to fire a PhyTxDrop trace. Implemented for encapsulation
* purposes.
*/
void NotifyTxDrop (bvec packet);
void NotifyTxDrop (Ptr<PacketBurst> burst);
/**
* Public method used to fire a PhyRxBegin trace. Implemented for encapsulation
* purposes.
*/
void NotifyRxBegin (bvec packet);
void NotifyRxBegin (Ptr<PacketBurst> burst);
/**
* Public method used to fire a PhyRxEnd trace. Implemented for encapsulation
* purposes.
*/
void NotifyRxEnd (bvec packet);
void NotifyRxEnd (Ptr<PacketBurst> burst);
/**
* Public method used to fire a PhyRxDrop trace. Implemented for encapsulation
* purposes.
*/
void NotifyRxDrop (bvec packet);
void NotifyRxDrop (Ptr<PacketBurst> 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<const PacketBurst> 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<PacketBurst> 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<PacketBurst> 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<bvec> m_phyTxBeginTrace;
TracedCallback <Ptr<PacketBurst > > m_phyTxBeginTrace;
/**
* The trace source fired when a packet ends the transmission process on
@@ -264,7 +268,7 @@ private:
*
* \see class CallBackTraceSource
*/
TracedCallback<bvec> m_phyTxEndTrace;
TracedCallback<Ptr<PacketBurst > > 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<bvec> m_phyTxDropTrace;
TracedCallback<Ptr<PacketBurst > > m_phyTxDropTrace;
/**
* The trace source fired when a packet begins the reception process from
@@ -280,7 +284,7 @@ private:
*
* \see class CallBackTraceSource
*/
TracedCallback<bvec> m_phyRxBeginTrace;
TracedCallback<Ptr<PacketBurst > > m_phyRxBeginTrace;
/**
* The trace source fired when a packet ends the reception process from
@@ -288,14 +292,14 @@ private:
*
* \see class CallBackTraceSource
*/
TracedCallback<bvec> m_phyRxEndTrace;
TracedCallback<Ptr<PacketBurst > > m_phyRxEndTrace;
/**
* The trace source fired when the phy layer drops a packet it has received.
*
* \see class CallBackTraceSource
*/
TracedCallback<bvec> m_phyRxDropTrace;
TracedCallback<Ptr<PacketBurst > > m_phyRxDropTrace;
SNRToBlockErrorRateManager * m_snrToBlockErrorRateManager;

View File

@@ -923,7 +923,7 @@ SubscriberStationNetDevice::DoReceive (Ptr<Packet> 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> 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> 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