diff --git a/CHANGES.html b/CHANGES.html
index 9ce02915b..2e6093b9b 100644
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -80,6 +80,9 @@ instead of CXXDEFINES
Changes to existing API:
+- In the spectrum module, the parameters to SpectrumChannel::StartTx () and SpectrumPhy::StartRx () methods are now passed using the new struct SpectrumSignalParameters. This new struct supports inheritance, hence it allows technology-specific PHY implementations to provide technology-specific parameters in SpectrumChannel::StartTx() and SpectrumPhy::StartRx(), while at the same time keeping a set of technology-independent parameters common across all spectrum-enabled PHY implementations (i.e., the duration and the power spectral density which are needed for interference calculation). Additionally, the SpectrumType class has been removed, since now the type of a spectrum signal can be inferred by doing a dynamic cast on SpectrumSignalParameters. See the Spectrum API change discussion on ns-developers for the motivation behind this API change.
+
+
- The WifiPhyStandard enumerators for specifying half- and quarter-channel
width standards has had a change in capitalization:
diff --git a/src/lte/model/lte-phy.h b/src/lte/model/lte-phy.h
index 36c23479a..8a592afcf 100644
--- a/src/lte/model/lte-phy.h
+++ b/src/lte/model/lte-phy.h
@@ -28,10 +28,10 @@
#include
#include
#include
-#include
+#include
#include
#include
-#include "lte-spectrum-phy.h"
+#include
namespace ns3 {
@@ -54,12 +54,12 @@ public:
static TypeId GetTypeId (void);
- /**
+ /**
* \brief Set the device where the phy layer is attached
* \param d the device
*/
void SetDevice (Ptr d);
- /**
+ /**
* \brief Get the device where the phy layer is attached
* \return the pointer to the device
*/
@@ -123,8 +123,8 @@ public:
/**
* \brief set a list of sub channel to use in the downlink.
* A sub channel is composed by a couple of resource bloks (180KHz x 1 ms)
- * \param mask a vector of intefer values. Each elements of this vector carries information about
- * the corresponding DL sub channel. If the i-th value of mask is equal to 1 (0) it means that the corresponding sub channel is used (not used) for the downlink.
+ * \param mask a vector of intefer values. Each elements of this vector carries information about
+ * the corresponding DL sub channel. If the i-th value of mask is equal to 1 (0) it means that the corresponding sub channel is used (not used) for the downlink.
*/
void SetDownlinkSubChannels (std::vector mask );
/**
@@ -135,8 +135,8 @@ public:
/**
* \brief set a list of sub channel to use in the uplink.
* A sub channel is composed by a couple of resource bloks (180KHz x 1 ms)
- * \param mask a vector of intefer values. Each elements of this vector carries information about
- * the corresponding UL sub channel. If the i-th value of mask is equal to 1 (0) it means that the corresponding sub channel is used (not used) for the uplink.
+ * \param mask a vector of intefer values. Each elements of this vector carries information about
+ * the corresponding UL sub channel. If the i-th value of mask is equal to 1 (0) it means that the corresponding sub channel is used (not used) for the uplink.
*/
void SetUplinkSubChannels (std::vector mask);
/**
@@ -157,7 +157,7 @@ public:
/**
- * \brief Compute the TX Power Spectral Density
+ * \brief Compute the TX Power Spectral Density
* \return a Ptr to a created SpectrumValue
*/
virtual Ptr CreateTxPowerSpectralDensity () = 0;
diff --git a/src/lte/model/lte-spectrum-phy.cc b/src/lte/model/lte-spectrum-phy.cc
index 41303e0f9..2e0aa083a 100644
--- a/src/lte/model/lte-spectrum-phy.cc
+++ b/src/lte/model/lte-spectrum-phy.cc
@@ -28,6 +28,7 @@
#include
#include "ns3/spectrum-error-model.h"
#include "lte-spectrum-phy.h"
+#include "lte-spectrum-signal-parameters.h"
#include "lte-net-device.h"
NS_LOG_COMPONENT_DEFINE ("LteSpectrumPhy");
@@ -165,15 +166,6 @@ LteSpectrumPhy::GetRxSpectrumModel () const
}
-SpectrumType
-LteSpectrumPhy::GetSpectrumType ()
-{
- NS_LOG_FUNCTION (this);
- static SpectrumType st = SpectrumTypeFactory::Create ("IdealOfdm");
- return st;
-}
-
-
void
LteSpectrumPhy::SetTxPowerSpectralDensity (Ptr txPsd)
{
@@ -193,9 +185,9 @@ LteSpectrumPhy::SetNoisePowerSpectralDensity (Ptr noisePsd)
m_noise = noisePsd;
}
-Ptr
+Ptr
LteSpectrumPhy::GetNoisePowerSpectralDensity (void)
-{
+{
NS_LOG_FUNCTION (this);
return m_noise;
}
@@ -286,7 +278,12 @@ LteSpectrumPhy::StartTx (Ptr pb)
ChangeState (TX);
NS_ASSERT (m_channel);
double tti = 0.001;
- m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), Seconds (tti), GetObject ());
+ Ptr txParams = Create ();
+ txParams->duration = Seconds (tti);
+ txParams->txPhy = GetObject ();
+ txParams->psd = m_txPsd;
+ txParams->packetBurst = pb;
+ m_channel->StartTx (txParams);
Simulator::Schedule (Seconds (tti), &LteSpectrumPhy::EndTx, this);
return false;
}
@@ -329,18 +326,19 @@ LteSpectrumPhy::EndTx ()
void
-LteSpectrumPhy::StartRx (Ptr pb, Ptr rxPsd, SpectrumType st, Time duration)
+LteSpectrumPhy::StartRx (Ptr spectrumRxParams)
{
- NS_LOG_FUNCTION (this << pb << rxPsd << st << duration);
+ NS_LOG_FUNCTION (this << spectrumRxParams);
NS_LOG_LOGIC (this << "state: " << m_state);
// interference will happen regardless of the state of the receiver
// m_interference->AddSignal (rxPsd, duration);
+ Ptr lteRxParams = DynamicCast (spectrumRxParams);
// the device might start RX only if the signal is of a type understood by this device
// this corresponds in real device to preamble detection
- if (st == GetSpectrumType ())
+ if (lteRxParams != 0)
{
switch (m_state)
{
@@ -360,16 +358,17 @@ LteSpectrumPhy::StartRx (Ptr pb, Ptr rxPsd, S
// preamble detection and synchronization is supposed to be always successful.
NS_LOG_LOGIC (this << " receiving new packet");
- for (std::list >::const_iterator iter = pb->Begin (); iter
- != pb->End (); ++iter)
+ for (std::list >::const_iterator iter = lteRxParams->packetBurst->Begin (); iter
+ != lteRxParams->packetBurst->End (); ++iter)
{
Ptr packet = (*iter)->Copy ();
m_phyRxStartTrace (packet);
}
- m_rxPacket = pb;
- m_rxPsd = rxPsd;
+ m_rxPacket = lteRxParams->packetBurst;
+ m_rxPsd = lteRxParams->psd;
+ Time duration = lteRxParams->duration;
ChangeState (RX);
@@ -385,7 +384,7 @@ LteSpectrumPhy::StartRx (Ptr pb, Ptr rxPsd, S
// XXX: modify SpectrumInterference in order to compute
// the correct/erroneus reception of PacketBurst!!!
- /*
+ /*
for (std::list >::const_iterator iter = pb->Begin (); iter
!= pb->End (); ++iter)
{
diff --git a/src/lte/model/lte-spectrum-phy.h b/src/lte/model/lte-spectrum-phy.h
index 468e5bc16..e02a00cf6 100644
--- a/src/lte/model/lte-spectrum-phy.h
+++ b/src/lte/model/lte-spectrum-phy.h
@@ -30,7 +30,6 @@
#include
#include
#include
-#include
#include
#include
#include
@@ -70,6 +69,7 @@ public:
Ptr GetMobility ();
Ptr GetDevice ();
Ptr GetRxSpectrumModel () const;
+ void StartRx (Ptr params);
/**
* \brief Get the channel where the physical layer is attached
@@ -77,15 +77,6 @@ public:
*/
Ptr GetChannel (void);
-
- /**
- * Get the SpectrumType used by this PHY
- *
- * @return
- */
- SpectrumType GetSpectrumType ();
-
-
/**
* set the Power Spectral Density of outgoing signals in W/Hz.
*
@@ -117,15 +108,6 @@ public:
*/
bool StartTx (Ptr pb);
- /**
- * \brief Notify the SpectrumPhy instance of an incoming waveform
- * \param pb the burst of packet associated with the incoming waveform
- * \param rxPsd the Power Spectral Density of the incoming waveform.
- * The units of the SPD are the same specified for SpectrumChannel::StartTx().
- * \param st the spectrum type
- * \param duration the duration of the incoming waveform
- */
- void StartRx (Ptr pb, Ptr rxPsd, SpectrumType st, Time duration);
/**
* set the callback for the end of a TX, as part of the
@@ -170,7 +152,7 @@ public:
/**
* \brief Set the state of the phy layer
- * \param newState the state
+ * \param newState the state
*/
void SetState (State newState);
diff --git a/src/lte/wscript b/src/lte/wscript
index 3608ff50b..19cb18e28 100644
--- a/src/lte/wscript
+++ b/src/lte/wscript
@@ -5,6 +5,7 @@ def build(bld):
module = bld.create_ns3_module('lte', ['internet', 'spectrum', 'wimax'])
module.source = [
'model/lte-spectrum-phy.cc',
+ 'model/lte-spectrum-signal-parameters.cc',
'model/enb-lte-spectrum-phy.cc',
'model/ue-lte-spectrum-phy.cc',
'model/lte-phy.cc',
@@ -51,6 +52,7 @@ def build(bld):
headers.module = 'lte'
headers.source = [
'model/lte-spectrum-phy.h',
+ 'model/lte-spectrum-signal-parameters.h',
'model/enb-lte-spectrum-phy.h',
'model/ue-lte-spectrum-phy.h',
'model/lte-phy.h',
diff --git a/src/spectrum/model/half-duplex-ideal-phy.cc b/src/spectrum/model/half-duplex-ideal-phy.cc
index 38b1aaaa8..dda656455 100644
--- a/src/spectrum/model/half-duplex-ideal-phy.cc
+++ b/src/spectrum/model/half-duplex-ideal-phy.cc
@@ -27,13 +27,14 @@
#include
#include
#include "half-duplex-ideal-phy.h"
+#include "half-duplex-ideal-phy-signal-parameters.h"
#include "spectrum-error-model.h"
+
NS_LOG_COMPONENT_DEFINE ("HalfDuplexIdealPhy");
namespace ns3 {
-
NS_OBJECT_ENSURE_REGISTERED (HalfDuplexIdealPhy);
HalfDuplexIdealPhy::HalfDuplexIdealPhy ()
@@ -178,15 +179,6 @@ HalfDuplexIdealPhy::GetRxSpectrumModel () const
}
}
-
-SpectrumType
-HalfDuplexIdealPhy::GetSpectrumType ()
-{
- NS_LOG_FUNCTION (this);
- static SpectrumType st = SpectrumTypeFactory::Create ("IdealOfdm");
- return st;
-}
-
void
HalfDuplexIdealPhy::SetTxPowerSpectralDensity (Ptr txPsd)
{
@@ -274,10 +266,15 @@ HalfDuplexIdealPhy::StartTx (Ptr p)
{
m_txPacket = p;
ChangeState (TX);
+ Ptr txParams = Create ();
double txTimeSeconds = m_rate.CalculateTxTime (p->GetSize ());
- Ptr pb = Create ();
- pb->AddPacket (p);
- m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), Seconds (txTimeSeconds), GetObject ());
+ txParams->duration = Seconds (txTimeSeconds);
+ txParams->txPhy = GetObject ();
+ txParams->psd = m_txPsd;
+ txParams->data = m_txPacket;
+
+ NS_LOG_LOGIC (this << " tx power: " << 10 * log10 (Integral (*(txParams->psd))) + 30 << " dBm");
+ m_channel->StartTx (txParams);
Simulator::Schedule (Seconds (txTimeSeconds), &HalfDuplexIdealPhy::EndTx, this);
}
break;
@@ -295,7 +292,7 @@ void
HalfDuplexIdealPhy::EndTx ()
{
NS_LOG_FUNCTION (this);
- NS_LOG_LOGIC (this << "state: " << m_state);
+ NS_LOG_LOGIC (this << " state: " << m_state);
NS_ASSERT (m_state == TX);
@@ -312,18 +309,21 @@ HalfDuplexIdealPhy::EndTx ()
void
-HalfDuplexIdealPhy::StartRx (Ptr pb, Ptr rxPsd, SpectrumType st, Time duration)
+HalfDuplexIdealPhy::StartRx (Ptr spectrumParams)
{
- NS_LOG_FUNCTION (this << pb << rxPsd << st << duration);
- NS_LOG_LOGIC (this << "state: " << m_state);
+ NS_LOG_FUNCTION (this << spectrumParams);
+ NS_LOG_LOGIC (this << " state: " << m_state);
+ NS_LOG_LOGIC (this << " rx power: " << 10 * log10 (Integral (*(spectrumParams->psd))) + 30 << " dBm");
// interference will happen regardless of the state of the receiver
- m_interference.AddSignal (rxPsd, duration);
+ m_interference.AddSignal (spectrumParams->psd, spectrumParams->duration);
// the device might start RX only if the signal is of a type understood by this device
- // this corresponds in real device to preamble detection
- if (st == GetSpectrumType ())
+ // this corresponds in real devices to preamble detection
+ Ptr rxParams = DynamicCast (spectrumParams);
+ if (rxParams != 0)
{
+ // signal is of known type
switch (m_state)
{
case TX:
@@ -341,12 +341,11 @@ HalfDuplexIdealPhy::StartRx (Ptr pb, Ptr rxPs
case IDLE:
// preamble detection and synchronization is supposed to be always successful.
- NS_LOG_LOGIC (this << " receiving " << pb->GetNPackets () << " packet(s)" );
- NS_ASSERT (pb->GetNPackets () == 1); // this PHY only supports a single packet per waveform
- Ptr p = pb->GetPackets ().front ();
+
+ Ptr p = rxParams->data;
m_phyRxStartTrace (p);
m_rxPacket = p;
- m_rxPsd = rxPsd;
+ m_rxPsd = rxParams->psd;
ChangeState (RX);
if (!m_phyMacRxStartCallback.IsNull ())
{
@@ -357,16 +356,20 @@ HalfDuplexIdealPhy::StartRx (Ptr pb, Ptr rxPs
{
NS_LOG_LOGIC (this << " m_phyMacRxStartCallback is NULL");
}
- m_interference.StartRx (p, rxPsd);
- NS_LOG_LOGIC (this << " scheduling EndRx with delay " << duration);
- m_endRxEventId = Simulator::Schedule (duration, &HalfDuplexIdealPhy::EndRx, this);
+ m_interference.StartRx (p, rxParams->psd);
+ NS_LOG_LOGIC (this << " scheduling EndRx with delay " << rxParams->duration);
+ m_endRxEventId = Simulator::Schedule (rxParams->duration, &HalfDuplexIdealPhy::EndRx, this);
break;
}
}
+ else // rxParams == 0
+ {
+ NS_LOG_LOGIC (this << " signal of unknown type");
+ }
- NS_LOG_LOGIC (this << "state: " << m_state);
+ NS_LOG_LOGIC (this << " state: " << m_state);
}
@@ -388,7 +391,7 @@ void
HalfDuplexIdealPhy::EndRx ()
{
NS_LOG_FUNCTION (this);
- NS_LOG_LOGIC (this << "state: " << m_state);
+ NS_LOG_LOGIC (this << " state: " << m_state);
NS_ASSERT (m_state == RX);
diff --git a/src/spectrum/model/half-duplex-ideal-phy.h b/src/spectrum/model/half-duplex-ideal-phy.h
index 3f54e9772..1427bbdeb 100644
--- a/src/spectrum/model/half-duplex-ideal-phy.h
+++ b/src/spectrum/model/half-duplex-ideal-phy.h
@@ -29,16 +29,14 @@
#include
#include
#include
-#include
#include
#include
#include
#include
+#include
namespace ns3 {
-
-
/**
* \ingroup spectrum
*
@@ -99,16 +97,7 @@ public:
Ptr GetMobility ();
Ptr GetDevice ();
Ptr GetRxSpectrumModel () const;
- void StartRx (Ptr p, Ptr rxPsd, SpectrumType st, Time duration);
-
-
-
- /**
- * Get the SpectrumType used by this PHY
- *
- * @return
- */
- SpectrumType GetSpectrumType ();
+ void StartRx (Ptr params);
/**
diff --git a/src/spectrum/model/multi-model-spectrum-channel.cc b/src/spectrum/model/multi-model-spectrum-channel.cc
index 73704da3e..2630dd4c3 100644
--- a/src/spectrum/model/multi-model-spectrum-channel.cc
+++ b/src/spectrum/model/multi-model-spectrum-channel.cc
@@ -99,7 +99,7 @@ MultiModelSpectrumChannel::GetTypeId (void)
static TypeId tid = TypeId ("ns3::MultiModelSpectrumChannel")
.SetParent ()
.AddConstructor ()
- .AddAttribute ("MaxLossDb",
+ .AddAttribute ("MaxLossDb",
"If a single-frequency PropagationLossModel is used, this value "
"represents the maximum loss in dB for which transmissions will be "
"passed to the receiving PHY. Signals for which the PropagationLossModel "
@@ -223,20 +223,20 @@ MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel (Ptr p, Ptr originalTxPowerSpectrum, SpectrumType st, Time duration, Ptr txPhy)
+MultiModelSpectrumChannel::StartTx (Ptr txParams)
{
- NS_LOG_FUNCTION (this << p << *originalTxPowerSpectrum << duration << txPhy);
+ NS_LOG_FUNCTION (this << txParams);
- NS_ASSERT (txPhy);
- NS_ASSERT (originalTxPowerSpectrum);
+ NS_ASSERT (txParams->txPhy);
+ NS_ASSERT (txParams->psd);
- Ptr txMobility = txPhy->GetMobility ();
- SpectrumModelUid_t txSpectrumModelUid = originalTxPowerSpectrum->GetSpectrumModelUid ();
+ Ptr txMobility = txParams->txPhy->GetMobility ();
+ SpectrumModelUid_t txSpectrumModelUid = txParams->psd->GetSpectrumModelUid ();
NS_LOG_LOGIC (" txSpectrumModelUid " << txSpectrumModelUid);
//
- TxSpectrumModelInfoMap_t::const_iterator txInfoIteratorerator = FindAndEventuallyAddTxSpectrumModel (originalTxPowerSpectrum->GetSpectrumModel ());
+ TxSpectrumModelInfoMap_t::const_iterator txInfoIteratorerator = FindAndEventuallyAddTxSpectrumModel (txParams->psd->GetSpectrumModel ());
NS_ASSERT (txInfoIteratorerator != m_txSpectrumModelInfoMap.end ());
NS_LOG_LOGIC ("converter map for TX SpectrumModel with Uid " << txInfoIteratorerator->first);
@@ -251,20 +251,20 @@ MultiModelSpectrumChannel::StartTx (Ptr p, Ptr orig
NS_LOG_LOGIC (" rxSpectrumModelUids " << rxSpectrumModelUid);
Ptr convertedTxPowerSpectrum;
-
if (txSpectrumModelUid == rxSpectrumModelUid)
{
- NS_LOG_LOGIC ("no conversion needed");
- convertedTxPowerSpectrum = originalTxPowerSpectrum;
+ NS_LOG_LOGIC ("no spectrum conversion needed");
+ convertedTxPowerSpectrum = txParams->psd;
}
else
{
NS_LOG_LOGIC (" converting txPowerSpectrum SpectrumModelUids" << txSpectrumModelUid << " --> " << rxSpectrumModelUid);
SpectrumConverterMap_t::const_iterator rxConverterIterator = txInfoIteratorerator->second.m_spectrumConverterMap.find (rxSpectrumModelUid);
NS_ASSERT (rxConverterIterator != txInfoIteratorerator->second.m_spectrumConverterMap.end ());
- convertedTxPowerSpectrum = rxConverterIterator->second.Convert (originalTxPowerSpectrum);
+ convertedTxPowerSpectrum = rxConverterIterator->second.Convert (txParams->psd);
}
+
for (std::list >::const_iterator rxPhyIterator = rxInfoIterator->second.m_rxPhyList.begin ();
rxPhyIterator != rxInfoIterator->second.m_rxPhyList.end ();
++rxPhyIterator)
@@ -272,10 +272,14 @@ MultiModelSpectrumChannel::StartTx (Ptr p, Ptr orig
NS_ASSERT_MSG ((*rxPhyIterator)->GetRxSpectrumModel ()->GetUid () == rxSpectrumModelUid,
"MultiModelSpectrumChannel only supports devices that use a single RxSpectrumModel that does not change for the whole simulation");
- if ((*rxPhyIterator) != txPhy)
+
+
+ if ((*rxPhyIterator) != txParams->txPhy)
{
- Ptr rxPowerSpectrum = convertedTxPowerSpectrum->Copy ();
- Time delay = MicroSeconds (0);
+ NS_LOG_LOGIC (" copying signal parameters " << txParams);
+ Ptr rxParams = txParams->Copy ();
+ rxParams->psd = Copy (convertedTxPowerSpectrum);
+ Time delay = MicroSeconds (0);
Ptr receiverMobility = (*rxPhyIterator)->GetMobility ();
@@ -284,19 +288,19 @@ MultiModelSpectrumChannel::StartTx (Ptr p, Ptr orig
if (m_propagationLoss)
{
double gainDb = m_propagationLoss->CalcRxPower (0, txMobility, receiverMobility);
- m_propagationLossTrace (txPhy, *rxPhyIterator, -gainDb);
+ m_propagationLossTrace (txParams->txPhy, *rxPhyIterator, -gainDb);
if ( (-gainDb) > m_maxLossDb)
{
// beyond range
continue;
}
- double gainLinear = pow (10.0, gainDb/10.0);
- *rxPowerSpectrum = (*rxPowerSpectrum) * gainLinear;
+ double gainLinear = pow (10.0, gainDb / 10.0);
+ *(rxParams->psd) *= gainLinear;
}
if (m_spectrumPropagationLoss)
{
- rxPowerSpectrum = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxPowerSpectrum, txMobility, receiverMobility);
+ rxParams->psd = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams->psd, txMobility, receiverMobility);
}
if (m_propagationDelay)
@@ -305,20 +309,19 @@ MultiModelSpectrumChannel::StartTx (Ptr p, Ptr orig
}
}
- Ptr pktBurstCopy = p->Copy ();
Ptr netDev = (*rxPhyIterator)->GetDevice ();
if (netDev)
{
// the receiver has a NetDevice, so we expect that it is attached to a Node
uint32_t dstNode = netDev->GetNode ()->GetId ();
Simulator::ScheduleWithContext (dstNode, delay, &MultiModelSpectrumChannel::StartRx, this,
- pktBurstCopy, rxPowerSpectrum, st, duration, *rxPhyIterator);
+ rxParams, *rxPhyIterator);
}
else
{
// the receiver is not attached to a NetDevice, so we cannot assume that it is attached to a node
Simulator::Schedule (delay, &MultiModelSpectrumChannel::StartRx, this,
- pktBurstCopy, rxPowerSpectrum, st, duration, *rxPhyIterator);
+ rxParams, *rxPhyIterator);
}
}
}
@@ -328,10 +331,10 @@ MultiModelSpectrumChannel::StartTx (Ptr p, Ptr orig
}
void
-MultiModelSpectrumChannel::StartRx (Ptr pb, Ptr rxPsd, SpectrumType st, Time duration, Ptr receiver)
+MultiModelSpectrumChannel::StartRx (Ptr params, Ptr receiver)
{
NS_LOG_FUNCTION (this);
- receiver->StartRx (pb, rxPsd, st, duration);
+ receiver->StartRx (params);
}
diff --git a/src/spectrum/model/multi-model-spectrum-channel.h b/src/spectrum/model/multi-model-spectrum-channel.h
index 5ab4479e3..a50f22dae 100644
--- a/src/spectrum/model/multi-model-spectrum-channel.h
+++ b/src/spectrum/model/multi-model-spectrum-channel.h
@@ -92,7 +92,7 @@ public:
virtual void AddSpectrumPropagationLossModel (Ptr loss);
virtual void SetPropagationDelayModel (Ptr delay);
virtual void AddRx (Ptr phy);
- virtual void StartTx (Ptr p, Ptr txPsd, SpectrumType st, Time duration, Ptr sender);
+ virtual void StartTx (Ptr params);
// inherited from Channel
@@ -135,12 +135,10 @@ private:
/**
* used internally to reschedule transmission after the propagation delay
*
- * @param p
- * @param rxPowerSpectrum
- * @param duration
+ * @param params
* @param receiver
*/
- virtual void StartRx (Ptr p, Ptr rxPowerSpectrum, SpectrumType st, Time duration, Ptr receiver);
+ virtual void StartRx (Ptr params, Ptr receiver);
diff --git a/src/spectrum/model/single-model-spectrum-channel.cc b/src/spectrum/model/single-model-spectrum-channel.cc
index ad8b2e857..d964f02ec 100644
--- a/src/spectrum/model/single-model-spectrum-channel.cc
+++ b/src/spectrum/model/single-model-spectrum-channel.cc
@@ -68,7 +68,7 @@ SingleModelSpectrumChannel::GetTypeId (void)
static TypeId tid = TypeId ("ns3::SingleModelSpectrumChannel")
.SetParent ()
.AddConstructor ()
- .AddAttribute ("MaxLossDb",
+ .AddAttribute ("MaxLossDb",
"If a single-frequency PropagationLossModel is used, this value "
"represents the maximum loss in dB for which transmissions will be "
"passed to the receiving PHY. Signals for which the PropagationLossModel "
@@ -103,59 +103,59 @@ SingleModelSpectrumChannel::AddRx (Ptr phy)
void
-SingleModelSpectrumChannel::StartTx (Ptr p, Ptr txPsd, SpectrumType st, Time duration, Ptr txPhy)
+SingleModelSpectrumChannel::StartTx (Ptr txParams)
{
- NS_LOG_FUNCTION (this << p << *txPsd << st << duration << txPhy);
- NS_ASSERT_MSG (p, "NULL PacketBurst");
- NS_ASSERT_MSG (txPsd, "NULL txPsd");
- NS_ASSERT_MSG (txPhy, "NULL txPhy");
+ NS_LOG_FUNCTION (this << txParams->psd << txParams->duration << txParams->txPhy);
+ NS_ASSERT_MSG (txParams->psd, "NULL txPsd");
+ NS_ASSERT_MSG (txParams->txPhy, "NULL txPhy");
// just a sanity check routine. We might want to remove it to save some computational load -- one "if" statement ;-)
if (m_spectrumModel == 0)
{
// first pak, record SpectrumModel
- m_spectrumModel = txPsd->GetSpectrumModel ();
+ m_spectrumModel = txParams->psd->GetSpectrumModel ();
}
else
{
// all attached SpectrumPhy instances must use the same SpectrumModel
- NS_ASSERT (*(txPsd->GetSpectrumModel ()) == *m_spectrumModel);
+ NS_ASSERT (*(txParams->psd->GetSpectrumModel ()) == *m_spectrumModel);
}
- Ptr senderMobility = txPhy->GetMobility ();
+ Ptr senderMobility = txParams->txPhy->GetMobility ();
for (PhyList::const_iterator rxPhyIterator = m_phyList.begin ();
rxPhyIterator != m_phyList.end ();
++rxPhyIterator)
{
- if ((*rxPhyIterator) != txPhy)
+ if ((*rxPhyIterator) != txParams->txPhy)
{
- Ptr rxPsd = Copy (txPsd);
Time delay = MicroSeconds (0);
Ptr receiverMobility = (*rxPhyIterator)->GetMobility ();
+ NS_LOG_LOGIC ("copying signal parameters " << txParams);
+ Ptr rxParams = txParams->Copy ();
if (senderMobility && receiverMobility)
{
if (m_propagationLoss)
{
double gainDb = m_propagationLoss->CalcRxPower (0, senderMobility, receiverMobility);
- m_propagationLossTrace (txPhy, *rxPhyIterator, -gainDb);
+ m_propagationLossTrace (txParams->txPhy, *rxPhyIterator, -gainDb);
if ( (-gainDb) > m_maxLossDb)
{
// beyond range
continue;
}
- double gainLinear = pow (10.0, gainDb/10.0);
- *rxPsd = (*rxPsd) * gainLinear;
+ double gainLinear = pow (10.0, gainDb / 10.0);
+ *(rxParams->psd) *= gainLinear;
}
if (m_spectrumPropagationLoss)
{
- rxPsd = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxPsd, senderMobility, receiverMobility);
+ rxParams->psd = m_spectrumPropagationLoss->CalcRxPowerSpectralDensity (rxParams->psd, senderMobility, receiverMobility);
}
if (m_propagationDelay)
@@ -164,20 +164,19 @@ SingleModelSpectrumChannel::StartTx (Ptr p, Ptr txP
}
}
- Ptr pktBurstCopy = p->Copy ();
+
Ptr netDev = (*rxPhyIterator)->GetDevice ();
if (netDev)
{
// the receiver has a NetDevice, so we expect that it is attached to a Node
uint32_t dstNode = netDev->GetNode ()->GetId ();
- Simulator::ScheduleWithContext (dstNode, delay, &SingleModelSpectrumChannel::StartRx, this,
- pktBurstCopy, rxPsd, st, duration, *rxPhyIterator);
+ Simulator::ScheduleWithContext (dstNode, delay, &SingleModelSpectrumChannel::StartRx, this, rxParams, *rxPhyIterator);
}
else
{
// the receiver is not attached to a NetDevice, so we cannot assume that it is attached to a node
Simulator::Schedule (delay, &SingleModelSpectrumChannel::StartRx, this,
- pktBurstCopy, rxPsd, st, duration, *rxPhyIterator);
+ rxParams, *rxPhyIterator);
}
}
}
@@ -185,10 +184,10 @@ SingleModelSpectrumChannel::StartTx (Ptr p, Ptr txP
}
void
-SingleModelSpectrumChannel::StartRx (Ptr p, Ptr rxPsd, SpectrumType st, Time duration, Ptr receiver)
+SingleModelSpectrumChannel::StartRx (Ptr params, Ptr receiver)
{
- NS_LOG_FUNCTION (this << p << *rxPsd << st << duration << receiver);
- receiver->StartRx (p, rxPsd, st, duration);
+ NS_LOG_FUNCTION (this << params);
+ receiver->StartRx (params);
}
diff --git a/src/spectrum/model/single-model-spectrum-channel.h b/src/spectrum/model/single-model-spectrum-channel.h
index 0ab48c335..1bf4345f8 100644
--- a/src/spectrum/model/single-model-spectrum-channel.h
+++ b/src/spectrum/model/single-model-spectrum-channel.h
@@ -51,11 +51,7 @@ public:
virtual void AddSpectrumPropagationLossModel (Ptr loss);
virtual void SetPropagationDelayModel (Ptr delay);
virtual void AddRx (Ptr phy);
- virtual void StartTx (Ptr p,
- Ptr txPsd,
- SpectrumType st,
- Time duration,
- Ptr sender);
+ virtual void StartTx (Ptr params);
// inherited from Channel
@@ -73,13 +69,10 @@ private:
/**
* used internally to reschedule transmission after the propagation delay
*
- * @param p
- * @param rxPowerSpectrum
- * @param st
- * @param duration
+ * @param params
* @param receiver
*/
- virtual void StartRx (Ptr p, Ptr rxPowerSpectrum, SpectrumType st, Time duration, Ptr receiver);
+ void StartRx (Ptr params, Ptr receiver);
/**
* list of SpectrumPhy instances attached to
diff --git a/src/spectrum/model/spectrum-analyzer.cc b/src/spectrum/model/spectrum-analyzer.cc
index 9962efc47..09e230e85 100644
--- a/src/spectrum/model/spectrum-analyzer.cc
+++ b/src/spectrum/model/spectrum-analyzer.cc
@@ -136,14 +136,11 @@ SpectrumAnalyzer::SetChannel (Ptr c)
void
-SpectrumAnalyzer::StartRx (Ptr pb,
- Ptr rxPowerSpectralDensity,
- SpectrumType st,
- Time duration)
+SpectrumAnalyzer::StartRx (Ptr params)
{
- NS_LOG_FUNCTION ( this << st << duration << *rxPowerSpectralDensity);
- AddSignal (rxPowerSpectralDensity);
- Simulator::Schedule (duration, &SpectrumAnalyzer::SubtractSignal, this, rxPowerSpectralDensity);
+ NS_LOG_FUNCTION ( this << params);
+ AddSignal (params->psd);
+ Simulator::Schedule (params->duration, &SpectrumAnalyzer::SubtractSignal, this, params->psd);
}
diff --git a/src/spectrum/model/spectrum-analyzer.h b/src/spectrum/model/spectrum-analyzer.h
index decfdfa99..69c9caab2 100644
--- a/src/spectrum/model/spectrum-analyzer.h
+++ b/src/spectrum/model/spectrum-analyzer.h
@@ -58,7 +58,7 @@ public:
Ptr GetMobility ();
Ptr GetDevice ();
Ptr GetRxSpectrumModel () const;
- void StartRx (Ptr pb, Ptr rxPowerSpectralDensity, SpectrumType st, Time duration);
+ void StartRx (Ptr params);
/**
diff --git a/src/spectrum/model/spectrum-channel.h b/src/spectrum/model/spectrum-channel.h
index 45f08d7c8..a45fc4a82 100644
--- a/src/spectrum/model/spectrum-channel.h
+++ b/src/spectrum/model/spectrum-channel.h
@@ -25,7 +25,7 @@
#include
#include
#include
-#include
+#include
namespace ns3 {
@@ -53,7 +53,7 @@ public:
/**
* set the single-frequency propagation loss model to be used
* \warning only models that do not depend on the TX power should be used.
- *
+ *
* \param loss a pointer to the propagation loss model to be used.
*/
virtual void AddPropagationLossModel (Ptr loss) = 0;
@@ -72,21 +72,11 @@ public:
/**
- * Used by attached PHY instances to transmit waveforms on the channel
+ * Used by attached PHY instances to transmit signals on the channel
*
- * @param p the PacketBurst associated with the waveform being transmitted
- * @param txPsd the Power Spectral Density of the
- * waveform, in linear units. The exact unit will depend on the
- * type of transmission medium involved: W for radio communications, Pa for
- * underwater acoustic communications. Other transmission media to be defined.
- * @param st spectrum type
- * @param duration duration of the packet transmission. It is
- * assumed that the Power Spectral Density remains constant for the
- * whole duration of the transmission. In other words, all waveform
- * have a rect shape with respect to time.
- * @param sender the SpectrumPhy instance making this function call
+ * @param params the parameters of the signals being transmitted
*/
- virtual void StartTx (Ptr p, Ptr txPsd, SpectrumType st, Time duration, Ptr sender) = 0;
+ virtual void StartTx (Ptr params) = 0;
/**
* @brief add a SpectrumPhy to a channel, so it can receive packets
diff --git a/src/spectrum/model/spectrum-interference.cc b/src/spectrum/model/spectrum-interference.cc
index 1eb67a896..2af5738f2 100644
--- a/src/spectrum/model/spectrum-interference.cc
+++ b/src/spectrum/model/spectrum-interference.cc
@@ -110,10 +110,15 @@ void
SpectrumInterference::ConditionallyEvaluateChunk ()
{
NS_LOG_FUNCTION (this);
- if (m_receiving && (Now () > m_lastChangeTime))
+ NS_LOG_LOGIC ("m_receiving: " << m_receiving );
+ NS_LOG_LOGIC ("m_lastChangeTime: " << m_lastChangeTime << " Now: " << Now ());
+ bool condition = m_receiving && (Now () > m_lastChangeTime);
+ NS_LOG_LOGIC ("if condition: " << condition);
+ if (condition)
{
SpectrumValue sinr = (*m_rxSignal) / ((*m_allSignals) - (*m_rxSignal) + (*m_noise));
Time duration = Now () - m_lastChangeTime;
+ NS_LOG_LOGIC ("calling m_errorModel->EvaluateChunk (sinr, duration)");
m_errorModel->EvaluateChunk (sinr, duration);
}
}
diff --git a/src/spectrum/model/spectrum-phy.h b/src/spectrum/model/spectrum-phy.h
index 99563432e..b466fd6de 100644
--- a/src/spectrum/model/spectrum-phy.h
+++ b/src/spectrum/model/spectrum-phy.h
@@ -24,7 +24,6 @@
#include
#include
-#include
namespace ns3 {
@@ -34,6 +33,7 @@ class MobilityModel;
class SpectrumValue;
class SpectrumModel;
class NetDevice;
+struct SpectrumSignalParameters;
/**
* \ingroup spectrum
@@ -94,15 +94,11 @@ public:
virtual Ptr GetRxSpectrumModel () const = 0;
/**
- * Notify the SpectrumPhy instance of an incoming waveform
+ * Notify the SpectrumPhy instance of an incoming signal
*
- * @param p the PacketBurst associated with the incoming waveform
- * @param rxPsd the Power Spectral Density of the incoming
- * waveform. The units of the PSD are the same specified for SpectrumChannel::StartTx().
- * @param st spectrum type
- * @param duration the duration of the incoming waveform
+ * @param params the parameters of the signals being received
*/
- virtual void StartRx (Ptr p, Ptr rxPsd, SpectrumType st, Time duration) = 0;
+ virtual void StartRx (Ptr params) = 0;
};
diff --git a/src/spectrum/model/spectrum-value.cc b/src/spectrum/model/spectrum-value.cc
index 88fc136b0..90a20f6ea 100644
--- a/src/spectrum/model/spectrum-value.cc
+++ b/src/spectrum/model/spectrum-value.cc
@@ -24,7 +24,7 @@
#include
#ifdef __FreeBSD__
-#define log2(x) (log(x)/M_LN2)
+#define log2(x) (log (x) / M_LN2)
#endif
@@ -387,6 +387,24 @@ Prod (const SpectrumValue& x)
return s;
}
+double
+Integral (const SpectrumValue& x)
+{
+ double i = 0;
+ Values::const_iterator vit = x.ConstValuesBegin ();
+ Bands::const_iterator bit = x.ConstBandsBegin ();
+ while (vit != x.ConstValuesEnd ())
+ {
+ NS_ASSERT (bit != x.ConstBandsEnd ());
+ i += (*vit) * (bit->fh - bit->fl);
+ ++vit;
+ ++bit;
+ }
+ NS_ASSERT (bit == x.ConstBandsEnd ());
+ return i;
+}
+
+
Ptr
SpectrumValue::Copy () const
diff --git a/src/spectrum/model/spectrum-value.h b/src/spectrum/model/spectrum-value.h
index cba4d0a17..a6fd3188a 100644
--- a/src/spectrum/model/spectrum-value.h
+++ b/src/spectrum/model/spectrum-value.h
@@ -480,6 +480,15 @@ public:
*/
friend SpectrumValue Log (const SpectrumValue& arg);
+ /**
+ *
+ *
+ * @param arg the argument
+ *
+ * @return the value of the integral \f$\int_F g(f) df \f$
+ */
+ friend double Integral (const SpectrumValue& arg);
+
/**
*
* @return a Ptr to a copy of this instance
diff --git a/src/spectrum/model/waveform-generator.cc b/src/spectrum/model/waveform-generator.cc
index fb4874d09..91d1161f5 100644
--- a/src/spectrum/model/waveform-generator.cc
+++ b/src/spectrum/model/waveform-generator.cc
@@ -134,17 +134,9 @@ WaveformGenerator::SetChannel (Ptr c)
void
-WaveformGenerator::StartRx (Ptr pb, Ptr rxPowerSpectrum, SpectrumType st, Time duration)
+WaveformGenerator::StartRx (Ptr params)
{
- NS_LOG_FUNCTION (pb << rxPowerSpectrum << duration);
-}
-
-
-SpectrumType
-WaveformGenerator::GetSpectrumType ()
-{
- static SpectrumType st = SpectrumTypeFactory::Create ("GenericWaveform");
- return st;
+ NS_LOG_FUNCTION (this << params);
}
void
@@ -188,12 +180,14 @@ WaveformGenerator::GenerateWaveform ()
{
NS_LOG_FUNCTION (this);
- Ptr pb = Create ();
- Time duration = Time (m_period * m_dutyCycle);
+ Ptr txParams = Create ();
+ txParams->duration = Time (m_period * m_dutyCycle);
+ txParams->psd = m_txPowerSpectralDensity;
+ txParams->txPhy = GetObject ();
NS_LOG_LOGIC ("generating waveform : " << *m_txPowerSpectralDensity);
m_phyTxStartTrace (0);
- m_channel->StartTx (pb, m_txPowerSpectralDensity, GetSpectrumType (), duration, GetObject ());
+ m_channel->StartTx (txParams);
if (m_active)
{
diff --git a/src/spectrum/model/waveform-generator.h b/src/spectrum/model/waveform-generator.h
index 52fd896a2..2c1efcdcd 100644
--- a/src/spectrum/model/waveform-generator.h
+++ b/src/spectrum/model/waveform-generator.h
@@ -29,7 +29,6 @@
#include
#include
#include
-#include
#include
namespace ns3 {
@@ -61,7 +60,7 @@ public:
Ptr GetMobility ();
Ptr GetDevice ();
Ptr GetRxSpectrumModel () const;
- void StartRx (Ptr p, Ptr rxPsd, SpectrumType st, Time duration);
+ void StartRx (Ptr params);
/**
@@ -71,16 +70,6 @@ public:
*/
void SetTxPowerSpectralDensity (Ptr txs);
-
- /**
- * Get the SpectrumType used by this PHY
- *
- * @return
- */
- SpectrumType GetSpectrumType ();
-
-
-
/**
* Set the period according to which the WaveformGenerator switches
* on and off
diff --git a/src/spectrum/wscript b/src/spectrum/wscript
index 0ba4d8f4d..08e06d9a6 100644
--- a/src/spectrum/wscript
+++ b/src/spectrum/wscript
@@ -7,7 +7,7 @@ def build(bld):
'model/spectrum-model.cc',
'model/spectrum-value.cc',
'model/spectrum-converter.cc',
- 'model/spectrum-type.cc',
+ 'model/spectrum-signal-parameters.cc',
'model/spectrum-propagation-loss-model.cc',
'model/friis-spectrum-propagation-loss.cc',
'model/spectrum-phy.cc',
@@ -24,6 +24,7 @@ def build(bld):
'model/aloha-noack-mac-header.cc',
'model/aloha-noack-net-device.cc',
'model/half-duplex-ideal-phy.cc',
+ 'model/half-duplex-ideal-phy-signal-parameters.cc',
'model/non-communicating-net-device.cc',
'model/microwave-oven-spectrum-value-helper.cc',
'helper/spectrum-helper.cc',
@@ -45,7 +46,7 @@ def build(bld):
'model/spectrum-model.h',
'model/spectrum-value.h',
'model/spectrum-converter.h',
- 'model/spectrum-type.h',
+ 'model/spectrum-signal-parameters.h',
'model/spectrum-propagation-loss-model.h',
'model/friis-spectrum-propagation-loss.h',
'model/spectrum-phy.h',
@@ -62,6 +63,7 @@ def build(bld):
'model/aloha-noack-mac-header.h',
'model/aloha-noack-net-device.h',
'model/half-duplex-ideal-phy.h',
+ 'model/half-duplex-ideal-phy-signal-parameters.h',
'model/non-communicating-net-device.h',
'model/microwave-oven-spectrum-value-helper.h',
'helper/spectrum-helper.h',