run check-style.py on src/spectrum

This commit is contained in:
Nicola Baldo
2011-05-07 22:05:29 +02:00
parent d2165cf81a
commit 041b7f3341
33 changed files with 283 additions and 296 deletions

View File

@@ -3,7 +3,7 @@
* Copyright (c) 2010 CTTC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
@@ -52,7 +52,7 @@ static bool g_verbose = false;
void
PhyTxStartTrace (std::string context, Ptr<const Packet> p)
{
{
if (g_verbose)
{
std::cout << context << " PHY TX START p: " << p << std::endl;
@@ -62,7 +62,7 @@ PhyTxStartTrace (std::string context, Ptr<const Packet> p)
void
PhyTxEndTrace (std::string context, Ptr<const Packet> p)
{
{
if (g_verbose)
{
std::cout << context << " PHY TX END p: " << p << std::endl;
@@ -74,7 +74,7 @@ PhyRxStartTrace (std::string context, Ptr<const Packet> p)
{
if (g_verbose)
{
std::cout << context << " PHY RX START p:" << p << std::endl;
std::cout << context << " PHY RX START p:" << p << std::endl;
}
}
@@ -83,7 +83,7 @@ PhyRxEndOkTrace (std::string context, Ptr<const Packet> p)
{
if (g_verbose)
{
std::cout << context << " PHY RX END OK p:" << p << std::endl;
std::cout << context << " PHY RX END OK p:" << p << std::endl;
}
}
@@ -92,7 +92,7 @@ PhyRxEndErrorTrace (std::string context, Ptr<const Packet> p)
{
if (g_verbose)
{
std::cout << context << " PHY RX END ERROR p:" << p << std::endl;
std::cout << context << " PHY RX END ERROR p:" << p << std::endl;
}
}
@@ -108,7 +108,7 @@ ReceivePacket (Ptr<Socket> socket)
}
if (g_verbose)
{
std::cout << "SOCKET received " << bytes << " bytes" <<std::endl;
std::cout << "SOCKET received " << bytes << " bytes" << std::endl;
}
}
@@ -127,12 +127,12 @@ int main (int argc, char** argv)
CommandLine cmd;
cmd.AddValue ("verbose", "Print trace information if true", g_verbose);
cmd.Parse (argc, argv);
NodeContainer ofdmNodes;
NodeContainer waveformGeneratorNodes;
NodeContainer spectrumAnalyzerNodes;
NodeContainer allNodes;
ofdmNodes.Create (2);
waveformGeneratorNodes.Create (1);
spectrumAnalyzerNodes.Create (1);
@@ -151,7 +151,7 @@ int main (int argc, char** argv)
mobility.Install (allNodes);
SpectrumChannelHelper channelHelper = SpectrumChannelHelper::Default ();
channelHelper.SetChannel ("ns3::MultiModelSpectrumChannel");
Ptr<SpectrumChannel> channel = channelHelper.Create ();
@@ -165,18 +165,18 @@ int main (int argc, char** argv)
double txPower = 0.1; // Watts
uint32_t channelNumber = 2;
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, channelNumber);
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, channelNumber);
// for the noise, we use the Power Spectral Density of thermal noise
// at room temperature. The value of the PSD will be constant over the band of interest.
// at room temperature. The value of the PSD will be constant over the band of interest.
const double k = 1.381e-23; //Boltzmann's constant
const double T = 290; // temperature in Kelvin
double noisePsdValue = k*T; // watts per hertz
Ptr<SpectrumValue> noisePsd = sf.CreateConstant (noisePsdValue);
double noisePsdValue = k * T; // watts per hertz
Ptr<SpectrumValue> noisePsd = sf.CreateConstant (noisePsdValue);
AdhocAlohaNoackIdealPhyHelper adhocAlohaOfdmHelper;
adhocAlohaOfdmHelper.SetChannel(channel);
adhocAlohaOfdmHelper.SetChannel (channel);
adhocAlohaOfdmHelper.SetTxPowerSpectralDensity (txPsd);
adhocAlohaOfdmHelper.SetNoisePowerSpectralDensity (noisePsd);
adhocAlohaOfdmHelper.SetPhyAttribute ("Rate", DataRateValue (DataRate ("1Mbps")));
@@ -186,7 +186,7 @@ int main (int argc, char** argv)
packetSocket.Install (ofdmNodes);
PacketSocketAddress socket;
socket.SetSingleDevice(ofdmDevices.Get (0)->GetIfIndex ());
socket.SetSingleDevice (ofdmDevices.Get (0)->GetIfIndex ());
socket.SetPhysicalAddress (ofdmDevices.Get (1)->GetAddress ());
socket.SetProtocol (1);
@@ -199,13 +199,13 @@ int main (int argc, char** argv)
ApplicationContainer apps = onoff.Install (ofdmNodes.Get (0));
apps.Start (Seconds (0.0));
apps.Stop (Seconds (2));
Ptr<Socket> recvSink = SetupPacketReceive (ofdmNodes.Get (1));
/////////////////////////////////
// Configure waveform generator
/////////////////////////////////
@@ -214,29 +214,29 @@ int main (int argc, char** argv)
NS_LOG_INFO ("mwoPsd : " << *mwoPsd);
WaveformGeneratorHelper waveformGeneratorHelper;
waveformGeneratorHelper.SetChannel(channel);
waveformGeneratorHelper.SetChannel (channel);
waveformGeneratorHelper.SetTxPowerSpectralDensity (mwoPsd);
waveformGeneratorHelper.SetPhyAttribute ("Period", TimeValue(Seconds(1.0/60))); // corresponds to 60 Hz
waveformGeneratorHelper.SetPhyAttribute ("DutyCycle", DoubleValue(0.5));
waveformGeneratorHelper.SetPhyAttribute ("Period", TimeValue (Seconds (1.0 / 60))); // corresponds to 60 Hz
waveformGeneratorHelper.SetPhyAttribute ("DutyCycle", DoubleValue (0.5));
NetDeviceContainer waveformGeneratorDevices = waveformGeneratorHelper.Install (waveformGeneratorNodes);
Simulator::Schedule(Seconds(0.1), &WaveformGenerator::Start,
waveformGeneratorDevices.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());
Simulator::Schedule (Seconds (0.1), &WaveformGenerator::Start,
waveformGeneratorDevices.Get (0)->GetObject<NonCommunicatingNetDevice> ()->GetPhy ()->GetObject<WaveformGenerator> ());
/////////////////////////////////
// Configure spectrum analyzer
/////////////////////////////////
SpectrumAnalyzerHelper spectrumAnalyzerHelper;
spectrumAnalyzerHelper.SetChannel(channel);
spectrumAnalyzerHelper.SetChannel (channel);
spectrumAnalyzerHelper.SetRxSpectrumModel (SpectrumModelIsm2400MhzRes1Mhz);
spectrumAnalyzerHelper.SetPhyAttribute ("Resolution", TimeValue(MilliSeconds (2)));
spectrumAnalyzerHelper.SetPhyAttribute ("Resolution", TimeValue (MilliSeconds (2)));
spectrumAnalyzerHelper.SetPhyAttribute ("NoisePowerSpectralDensity", DoubleValue (1e-15)); // -120 dBm/Hz
spectrumAnalyzerHelper.EnableAsciiAll ("spectrum-analyzer-output");
spectrumAnalyzerHelper.EnableAsciiAll ("spectrum-analyzer-output");
NetDeviceContainer spectrumAnalyzerDevices = spectrumAnalyzerHelper.Install (spectrumAnalyzerNodes);
@@ -249,15 +249,15 @@ int main (int argc, char** argv)
Config::Connect ("/NodeList/*/DeviceList/*/Phy/RxStart", MakeCallback (&PhyRxStartTrace));
Config::Connect ("/NodeList/*/DeviceList/*/Phy/RxEndOk", MakeCallback (&PhyRxEndOkTrace));
Config::Connect ("/NodeList/*/DeviceList/*/Phy/RxEndError", MakeCallback (&PhyRxEndErrorTrace));
Simulator::Stop (Seconds (0.3));
Simulator::Run ();
Simulator::Stop (Seconds (0.3));
Simulator::Destroy ();
Simulator::Run ();
Simulator::Destroy ();
}

View File

@@ -3,7 +3,7 @@
* Copyright (c) 2010 CTTC
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
@@ -47,7 +47,7 @@ static bool g_verbose = false;
void
PhyTxStartTrace (std::string context, Ptr<const Packet> p)
{
{
if (g_verbose)
{
std::cout << context << " PHY TX START p: " << p << std::endl;
@@ -57,7 +57,7 @@ PhyTxStartTrace (std::string context, Ptr<const Packet> p)
void
PhyTxEndTrace (std::string context, Ptr<const Packet> p)
{
{
if (g_verbose)
{
std::cout << context << " PHY TX END p: " << p << std::endl;
@@ -69,7 +69,7 @@ PhyRxStartTrace (std::string context, Ptr<const Packet> p)
{
if (g_verbose)
{
std::cout << context << " PHY RX START p:" << p << std::endl;
std::cout << context << " PHY RX START p:" << p << std::endl;
}
}
@@ -78,7 +78,7 @@ PhyRxEndOkTrace (std::string context, Ptr<const Packet> p)
{
if (g_verbose)
{
std::cout << context << " PHY RX END OK p:" << p << std::endl;
std::cout << context << " PHY RX END OK p:" << p << std::endl;
}
}
@@ -87,7 +87,7 @@ PhyRxEndErrorTrace (std::string context, Ptr<const Packet> p)
{
if (g_verbose)
{
std::cout << context << " PHY RX END ERROR p:" << p << std::endl;
std::cout << context << " PHY RX END ERROR p:" << p << std::endl;
}
}
@@ -103,7 +103,7 @@ ReceivePacket (Ptr<Socket> socket)
}
if (g_verbose)
{
std::cout << "SOCKET received " << bytes << " bytes" <<std::endl;
std::cout << "SOCKET received " << bytes << " bytes" << std::endl;
}
}
@@ -122,7 +122,7 @@ int main (int argc, char** argv)
CommandLine cmd;
cmd.AddValue ("verbose", "Print trace information if true", g_verbose);
cmd.Parse (argc, argv);
NodeContainer c;
c.Create (2);
@@ -134,8 +134,8 @@ int main (int argc, char** argv)
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (c);
SpectrumChannelHelper channelHelper = SpectrumChannelHelper::Default ();
Ptr<SpectrumChannel> channel = channelHelper.Create ();
@@ -143,17 +143,17 @@ int main (int argc, char** argv)
double txPower = 0.1; // Watts
uint32_t channelNumber = 1;
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, channelNumber);
Ptr<SpectrumValue> txPsd = sf.CreateTxPowerSpectralDensity (txPower, channelNumber);
// for the noise, we use the Power Spectral Density of thermal noise
// at room temperature. The value of the PSD will be constant over the band of interest.
// at room temperature. The value of the PSD will be constant over the band of interest.
const double k = 1.381e-23; //Boltzmann's constant
const double T = 290; // temperature in Kelvin
double noisePsdValue = k*T; // watts per hertz
Ptr<SpectrumValue> noisePsd = sf.CreateConstant (noisePsdValue);
double noisePsdValue = k * T; // watts per hertz
Ptr<SpectrumValue> noisePsd = sf.CreateConstant (noisePsdValue);
AdhocAlohaNoackIdealPhyHelper deviceHelper;
deviceHelper.SetChannel(channel);
deviceHelper.SetChannel (channel);
deviceHelper.SetTxPowerSpectralDensity (txPsd);
deviceHelper.SetNoisePowerSpectralDensity (noisePsd);
deviceHelper.SetPhyAttribute ("Rate", DataRateValue (DataRate ("1Mbps")));
@@ -163,7 +163,7 @@ int main (int argc, char** argv)
packetSocket.Install (c);
PacketSocketAddress socket;
socket.SetSingleDevice(devices.Get (0)->GetIfIndex ());
socket.SetSingleDevice (devices.Get (0)->GetIfIndex ());
socket.SetPhysicalAddress (devices.Get (1)->GetAddress ());
socket.SetProtocol (1);
@@ -176,7 +176,7 @@ int main (int argc, char** argv)
ApplicationContainer apps = onoff.Install (c.Get (0));
apps.Start (Seconds (0.1));
apps.Stop (Seconds (0.104));
Ptr<Socket> recvSink = SetupPacketReceive (c.Get (1));
Simulator::Stop (Seconds (10.0));

View File

@@ -39,8 +39,8 @@ NS_LOG_COMPONENT_DEFINE ("SpectrumAnalyzerHelper");
namespace ns3 {
static void
WriteAveragePowerSpectralDensityReport (Ptr<OutputStreamWrapper> streamWrapper,
static void
WriteAveragePowerSpectralDensityReport (Ptr<OutputStreamWrapper> streamWrapper,
Ptr<const SpectrumValue> avgPowerSpectralDensity)
{
NS_LOG_FUNCTION (streamWrapper << avgPowerSpectralDensity);
@@ -62,7 +62,7 @@ WriteAveragePowerSpectralDensityReport (Ptr<OutputStreamWrapper> streamWrapper,
*ostream << std::endl;
}
}
SpectrumAnalyzerHelper::SpectrumAnalyzerHelper ()
@@ -108,7 +108,7 @@ SpectrumAnalyzerHelper::SetDeviceAttribute (std::string name, const AttributeVal
m_device.Set (name, v);
}
void
SpectrumAnalyzerHelper::SetRxSpectrumModel (Ptr<SpectrumModel> m)
{
@@ -121,7 +121,7 @@ SpectrumAnalyzerHelper::EnableAsciiAll (std::string prefix)
{
NS_LOG_FUNCTION (this);
m_prefix = prefix;
}
}
@@ -135,7 +135,7 @@ SpectrumAnalyzerHelper::Install (NodeContainer c) const
Ptr<Node> node = *i;
Ptr<NonCommunicatingNetDevice> dev = m_device.Create ()->GetObject<NonCommunicatingNetDevice> ();
Ptr<SpectrumAnalyzer> phy = m_phy.Create ()->GetObject<SpectrumAnalyzer> ();
NS_ASSERT (phy);
@@ -158,7 +158,7 @@ SpectrumAnalyzerHelper::Install (NodeContainer c) const
uint32_t devId = node->AddDevice (dev);
devices.Add (dev);
if (! m_prefix.empty ())
if (!m_prefix.empty ())
{
NS_LOG_LOGIC ("creating new output stream and binding it to the callback");
AsciiTraceHelper asciiTraceHelper;
@@ -170,7 +170,7 @@ SpectrumAnalyzerHelper::Install (NodeContainer c) const
// the following is inspired from YansWifiPhyHelper::EnableAsciiInternal
std::ostringstream oss;
oss.str ("");
oss.str ("");
oss << "/NodeList/" << node->GetId () << "/DeviceList/" << devId << "/$ns3::NonCommunicatingNetDevice/Phy/AveragePowerSpectralDensityReport";
Config::ConnectWithoutContext (oss.str (), MakeBoundCallback (&WriteAveragePowerSpectralDensityReport, stream));

View File

@@ -91,7 +91,7 @@ WaveformGeneratorHelper::Install (NodeContainer c) const
Ptr<Node> node = *i;
Ptr<NonCommunicatingNetDevice> dev = m_device.Create ()->GetObject<NonCommunicatingNetDevice> ();
Ptr<WaveformGenerator> phy = m_phy.Create ()->GetObject<WaveformGenerator> ();
NS_ASSERT (phy);

View File

@@ -106,7 +106,7 @@ AlohaNoackNetDevice::AlohaNoackNetDevice ()
{
NS_LOG_FUNCTION (this);
}
AlohaNoackNetDevice::~AlohaNoackNetDevice ()
{
NS_LOG_FUNCTION (this);

View File

@@ -57,7 +57,8 @@ class Queue;
class AlohaNoackNetDevice : public NetDevice
{
public:
enum State {
enum State
{
IDLE, TX, RX
};

View File

@@ -71,7 +71,7 @@ HalfDuplexIdealPhy::DoDispose ()
std::ostream& operator<< (std::ostream& os, HalfDuplexIdealPhy::State s)
{
switch (s)
switch (s)
{
case HalfDuplexIdealPhy::IDLE:
os << "IDLE";
@@ -165,7 +165,7 @@ HalfDuplexIdealPhy::SetChannel (Ptr<SpectrumChannel> c)
m_channel = c;
}
Ptr<const SpectrumModel>
Ptr<const SpectrumModel>
HalfDuplexIdealPhy::GetRxSpectrumModel () const
{
if (m_txPsd)
@@ -249,7 +249,7 @@ HalfDuplexIdealPhy::SetGenericPhyRxEndOkCallback (GenericPhyRxEndOkCallback c)
m_phyMacRxEndOkCallback = c;
}
void
void
HalfDuplexIdealPhy::ChangeState (State newState)
{
NS_LOG_LOGIC (this << " state: " << m_state << " -> " << newState);
@@ -268,7 +268,7 @@ HalfDuplexIdealPhy::StartTx (Ptr<Packet> p)
{
case RX:
AbortRx ();
// fall through
// fall through
case IDLE:
{
@@ -278,7 +278,7 @@ HalfDuplexIdealPhy::StartTx (Ptr<Packet> p)
Ptr<PacketBurst> pb = Create<PacketBurst> ();
pb->AddPacket (p);
m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), Seconds (txTimeSeconds), GetObject<SpectrumPhy> ());
Simulator::Schedule(Seconds (txTimeSeconds), &HalfDuplexIdealPhy::EndTx, this);
Simulator::Schedule (Seconds (txTimeSeconds), &HalfDuplexIdealPhy::EndTx, this);
}
break;
@@ -341,7 +341,7 @@ HalfDuplexIdealPhy::StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPs
case IDLE:
// preamble detection and synchronization is supposed to be always successful.
NS_LOG_LOGIC (this << " receiving " << pb->GetNPackets () << " packet(s)" );
NS_LOG_LOGIC (this << " receiving " << pb->GetNPackets () << " packet(s)" );
NS_ASSERT (pb->GetNPackets () == 1); // this PHY only supports a single packet per waveform
Ptr<Packet> p = pb->GetPackets ().front ();
m_phyRxStartTrace (p);
@@ -365,7 +365,7 @@ HalfDuplexIdealPhy::StartRx (Ptr<PacketBurst> pb, Ptr <const SpectrumValue> rxPs
}
}
NS_LOG_LOGIC (this << "state: " << m_state);
}

View File

@@ -83,7 +83,8 @@ public:
* PHY states
*
*/
enum State {
enum State
{
IDLE, TX, RX
};
@@ -97,7 +98,7 @@ public:
Ptr<Object> GetDevice ();
Ptr<const SpectrumModel> GetRxSpectrumModel () const;
void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
/**
@@ -183,9 +184,8 @@ public:
private:
virtual void DoDispose (void);
void ChangeState (State newState);
void EndTx ();
void AbortRx ();

View File

@@ -25,7 +25,7 @@ NS_LOG_COMPONENT_DEFINE ("MicrowaveOvenSpectrumValue");
namespace ns3 {
Ptr<SpectrumModel> g_MicrowaveOvenSpectrumModel5Mhz;
Ptr<SpectrumModel> g_MicrowaveOvenSpectrumModel6Mhz;
@@ -35,9 +35,9 @@ class MicrowaveOvenSpectrumModel5MhzInitializer
public:
MicrowaveOvenSpectrumModel5MhzInitializer ()
{
NS_LOG_FUNCTION(this);
NS_LOG_FUNCTION (this);
Bands bands;
for (double fl = 2400e6; fl < 2499e6; fl += 5e6)
for (double fl = 2400e6; fl < 2499e6; fl += 5e6)
{
BandInfo bi;
bi.fl = fl;
@@ -45,8 +45,8 @@ public:
bi.fh = fl + 10e6;
bands.push_back (bi);
}
NS_LOG_LOGIC("bands.size () :" << bands.size ());
g_MicrowaveOvenSpectrumModel5Mhz = Create<SpectrumModel> (bands);
NS_LOG_LOGIC ("bands.size () :" << bands.size ());
g_MicrowaveOvenSpectrumModel5Mhz = Create<SpectrumModel> (bands);
}
} g_MicrowaveOvenSpectrumModel5MhzInitializerInstance;
@@ -57,7 +57,7 @@ class MicrowaveOvenSpectrumModel6MhzInitializer
public:
MicrowaveOvenSpectrumModel6MhzInitializer ()
{
NS_LOG_FUNCTION(this);
NS_LOG_FUNCTION (this);
Bands bands;
for (double fl = 2360e6; fl < 2479e6; fl += 6e6)
{
@@ -67,7 +67,7 @@ public:
bi.fh = fl + 12e6;
bands.push_back (bi);
}
NS_LOG_LOGIC("bands.size () :" << bands.size ());
NS_LOG_LOGIC ("bands.size () :" << bands.size ());
g_MicrowaveOvenSpectrumModel6Mhz = Create<SpectrumModel> (bands);
}
} g_MicrowaveOvenSpectrumModel6MhzInitializerInstance;
@@ -76,13 +76,13 @@ public:
Ptr<SpectrumValue>
Ptr<SpectrumValue>
MicrowaveOvenSpectrumValueHelper::CreatePowerSpectralDensityMwo1 ()
{
{
Ptr<SpectrumValue> psd = Create <SpectrumValue> (g_MicrowaveOvenSpectrumModel6Mhz);
// values from this paper:
// Tanim M. Taher, Matthew J. Misurac, Joseph L. LoCicero, and Donald R. Ucci,
// Tanim M. Taher, Matthew J. Misurac, Joseph L. LoCicero, and Donald R. Ucci,
// "MICROWAVE OVEN SIGNAL MODELING", in Proc. of IEEE WCNC, 2008,
// see Figure 3, "Experimental PSD of MWO #1"
// the figure has a resolution of 12 MHz per division; we use a
@@ -112,18 +112,18 @@ MicrowaveOvenSpectrumValueHelper::CreatePowerSpectralDensityMwo1 ()
(*psd)[19] = -67.5;
// convert to W/Hz
(*psd) = Pow(10.0, ((*psd) - 30)/10.0);
(*psd) = Pow (10.0, ((*psd) - 30) / 10.0);
return psd;
}
Ptr<SpectrumValue>
Ptr<SpectrumValue>
MicrowaveOvenSpectrumValueHelper::CreatePowerSpectralDensityMwo2 ()
{
{
// values from this paper:
// Tanim M. Taher, Matthew J. Misurac, Joseph L. LoCicero, and Donald R. Ucci,
// Tanim M. Taher, Matthew J. Misurac, Joseph L. LoCicero, and Donald R. Ucci,
// "MICROWAVE OVEN SIGNAL MODELING", in Proc. of IEEE WCNC, 2008,
// see Figure 9, "Experimental PSD of actual MWO #2"
// the figure has a resolution of 10 MHz per division; we use a
@@ -133,14 +133,14 @@ MicrowaveOvenSpectrumValueHelper::CreatePowerSpectralDensityMwo2 ()
Ptr<SpectrumValue> psd = Create <SpectrumValue> (g_MicrowaveOvenSpectrumModel5Mhz);
(*psd)[0] = -68;
(*psd)[1] = -68;
(*psd)[0] = -68;
(*psd)[1] = -68;
(*psd)[2] = -68;
(*psd)[3] = -68;
(*psd)[4] = -65;
(*psd)[4] = -65;
(*psd)[5] = -62;
(*psd)[6] = -56;
(*psd)[7] = -55;
(*psd)[6] = -56;
(*psd)[7] = -55;
(*psd)[8] = -47;
(*psd)[9] = -40;
(*psd)[10] = -37;
@@ -155,7 +155,7 @@ MicrowaveOvenSpectrumValueHelper::CreatePowerSpectralDensityMwo2 ()
(*psd)[19] = -68;
// convert to W/Hz
(*psd) = Pow(10.0, ((*psd) - 30)/10.0);
(*psd) = Pow (10.0, ((*psd) - 30) / 10.0);
return psd;
}

View File

@@ -28,30 +28,29 @@ namespace ns3 {
/**
/**
* This class provides methods for the creation of SpectrumValue
* instances that mimic the Power Spectral Density of commercial
* microwave ovens based on the measurements reported in the following paper:
* Tanim M. Taher, Matthew J. Misurac, Joseph L. LoCicero, and Donald R. Ucci,
* Tanim M. Taher, Matthew J. Misurac, Joseph L. LoCicero, and Donald R. Ucci,
* "MICROWAVE OVEN SIGNAL MODELING", in Proc. of IEEE WCNC, 2008
*
*/
class MicrowaveOvenSpectrumValueHelper
class MicrowaveOvenSpectrumValueHelper
{
public:
/**
*
/**
*
* @return the Power Spectral Density of Micro Wave Oven #1 in the
* cited paper
*/
static Ptr<SpectrumValue> CreatePowerSpectralDensityMwo1 ();
/**
*
/**
*
* @return the Power Spectral Density of Micro Wave Oven #2 in the
* cited paper
*/
*/
static Ptr<SpectrumValue> CreatePowerSpectralDensityMwo2 ();
};
@@ -59,7 +58,7 @@ public:
} //namespace ns3

View File

@@ -112,7 +112,7 @@ MultiModelSpectrumChannel::AddRx (Ptr<SpectrumPhy> phy)
NS_ASSERT_MSG ((0 != rxSpectrumModel), "phy->GetRxSpectrumModel () returned 0. Please check that the RxSpectrumModel is already set for the phy before calling MultiModelSpectrumChannel::AddRx (phy)");
SpectrumModelUid_t rxSpectrumModelUid = rxSpectrumModel->GetUid ();
std::vector<Ptr<SpectrumPhy> >::const_iterator it;
// make sure this phy had not been already added
@@ -121,18 +121,18 @@ MultiModelSpectrumChannel::AddRx (Ptr<SpectrumPhy> phy)
NS_ASSERT (*it != phy);
}
m_phyVector.push_back (phy);
RxSpectrumModelInfoMap_t::iterator rxInfoIterator = m_rxSpectrumModelInfoMap.find (rxSpectrumModelUid);
if (rxInfoIterator == m_rxSpectrumModelInfoMap.end ())
{
// spectrum model unknown, add it to the list of RxSpectrumModels
std::pair<RxSpectrumModelInfoMap_t::iterator, bool> ret;
ret = m_rxSpectrumModelInfoMap.insert (std::make_pair (rxSpectrumModelUid, RxSpectrumModelInfo (rxSpectrumModel)));
ret = m_rxSpectrumModelInfoMap.insert (std::make_pair (rxSpectrumModelUid, RxSpectrumModelInfo (rxSpectrumModel)));
NS_ASSERT (ret.second);
// also add the phy to the newly created list of SpectrumPhy for this RxSpectrumModel
ret.first->second.m_rxPhyList.push_back (phy);
// and create the necessary converters for all the TX spectrum models that we know of
for (TxSpectrumModelInfoMap_t::iterator txInfoIterator = m_txSpectrumModelInfoMap.begin ();
txInfoIterator != m_txSpectrumModelInfoMap.end ();
@@ -142,7 +142,7 @@ MultiModelSpectrumChannel::AddRx (Ptr<SpectrumPhy> phy)
NS_LOG_LOGIC ("Creating converters between SpectrumModelUids " << txSpectrumModel->GetUid () << " and " << rxSpectrumModelUid );
SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
NS_ASSERT (ret2.second);
}
}
@@ -151,7 +151,7 @@ MultiModelSpectrumChannel::AddRx (Ptr<SpectrumPhy> phy)
// spectrum model is already known, just add the device to the corresponding list
rxInfoIterator->second.m_rxPhyList.push_back (phy);
}
}
@@ -161,16 +161,16 @@ MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel (Ptr<const Spectr
NS_LOG_FUNCTION (this << txSpectrumModel);
SpectrumModelUid_t txSpectrumModelUid = txSpectrumModel->GetUid ();
TxSpectrumModelInfoMap_t::iterator txInfoIterator = m_txSpectrumModelInfoMap.find (txSpectrumModelUid);
if (txInfoIterator == m_txSpectrumModelInfoMap.end ())
{
{
// first time we see this TX SpectrumModel
// we add it to the list
std::pair<TxSpectrumModelInfoMap_t::iterator, bool> ret;
ret = m_txSpectrumModelInfoMap.insert (std::make_pair (txSpectrumModelUid, TxSpectrumModelInfo (txSpectrumModel)));
NS_ASSERT (ret.second);
NS_ASSERT (ret.second);
txInfoIterator = ret.first;
// and we create the converters for all the RX SpectrumModels that we know of
for (RxSpectrumModelInfoMap_t::const_iterator rxInfoIterator = m_rxSpectrumModelInfoMap.begin ();
rxInfoIterator != m_rxSpectrumModelInfoMap.end ();
@@ -185,14 +185,14 @@ MultiModelSpectrumChannel::FindAndEventuallyAddTxSpectrumModel (Ptr<const Spectr
SpectrumConverter converter (txSpectrumModel, rxSpectrumModel);
std::pair<SpectrumConverterMap_t::iterator, bool> ret2;
ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
ret2 = txInfoIterator->second.m_spectrumConverterMap.insert (std::make_pair (rxSpectrumModelUid, converter));
NS_ASSERT (ret2.second);
}
}
}
}
else
{
NS_LOG_LOGIC ("SpectrumModelUid " << txSpectrumModelUid << " already present");
NS_LOG_LOGIC ("SpectrumModelUid " << txSpectrumModelUid << " already present");
}
return txInfoIterator;
}
@@ -205,7 +205,7 @@ MultiModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> orig
NS_ASSERT (txPhy);
NS_ASSERT (originalTxPowerSpectrum);
Ptr<MobilityModel> txMobility = txPhy->GetMobility ()->GetObject<MobilityModel> ();
SpectrumModelUid_t txSpectrumModelUid = originalTxPowerSpectrum->GetSpectrumModelUid ();
@@ -246,7 +246,7 @@ MultiModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> 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)
{
Ptr <SpectrumValue> rxPowerSpectrum;
@@ -296,7 +296,7 @@ MultiModelSpectrumChannel::StartTx (Ptr<PacketBurst> p, Ptr <SpectrumValue> orig
Simulator::Schedule (delay, &MultiModelSpectrumChannel::StartRx, this,
pktBurstCopy, rxPowerSpectrum, st, duration, *rxPhyIterator);
}
}
}
++rxPhyIterator;
}

View File

@@ -40,7 +40,7 @@ class TxSpectrumModelInfo
{
public:
TxSpectrumModelInfo (Ptr<const SpectrumModel> txSpectrumModel);
Ptr<const SpectrumModel> m_txSpectrumModel;
SpectrumConverterMap_t m_spectrumConverterMap;
};
@@ -52,9 +52,9 @@ class RxSpectrumModelInfo
{
public:
RxSpectrumModelInfo (Ptr<const SpectrumModel> rxSpectrumModel);
Ptr<const SpectrumModel> m_rxSpectrumModel;
std::list<Ptr<SpectrumPhy> > m_rxPhyList;
std::list<Ptr<SpectrumPhy> > m_rxPhyList;
};
typedef std::map<SpectrumModelUid_t, RxSpectrumModelInfo> RxSpectrumModelInfoMap_t;
@@ -97,25 +97,23 @@ protected:
private:
/**
/**
* this method checks if m_rxSpectrumModelInfoMap contains an entry
* for the given TX SpectrumModel. If such entry exists, it returns
* an interator pointing to it. If not, it creates a new entry in
* m_txSpectrumMpodelInfoMap, and returns an iterator to it.
*
*
* @param txSpectrumModel the TX SpectrumModel being considered
*
*
* @return an iterator pointing to the corresponding entry in m_txSpectrumModelInfoMap
*/
TxSpectrumModelInfoMap_t::const_iterator FindAndEventuallyAddTxSpectrumModel (Ptr<const SpectrumModel> txSpectrumModel);
/**
/**
* make sure that there are SpectrumConverters from any
* SpectrumPhy being used for TX to the given SpectrumModel being used for RX
*
*
* @param rxPhy the RXing SpectrumPhy
* @param rxSpectrumModel the SpectrumModel used for RX by rxPhy
*/
@@ -153,8 +151,8 @@ private:
/**
* data structure holding, for each TX SpectrumModel, all the
* converters to any RX SpectrumModel, and all the corresponding
* SpectrumPhy instances.
*
* SpectrumPhy instances.
*
*/
TxSpectrumModelInfoMap_t m_txSpectrumModelInfoMap;
@@ -162,10 +160,10 @@ private:
/**
* data structure holding, for each RX spectrum model, all the
* corresponding SpectrumPhy instances.
*
*
*/
RxSpectrumModelInfoMap_t m_rxSpectrumModelInfoMap;
/**
* this is only used to provide a straighforward implementation of
* GetNDevices() and GetDevice()

View File

@@ -43,7 +43,7 @@ NonCommunicatingNetDevice::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::NonCommunicatingNetDevice")
.SetParent<NetDevice> ()
.AddConstructor<NonCommunicatingNetDevice> ()
.AddConstructor<NonCommunicatingNetDevice> ()
.AddAttribute ("Phy", "The PHY layer attached to this device.",
PointerValue (),
MakePointerAccessor (&NonCommunicatingNetDevice::GetPhy,

View File

@@ -52,7 +52,6 @@ class Queue;
class NonCommunicatingNetDevice : public NetDevice
{
public:
static TypeId GetTypeId (void);
NonCommunicatingNetDevice ();
@@ -120,7 +119,6 @@ public:
private:
virtual void DoDispose (void);
Ptr<Node> m_node;

View File

@@ -204,10 +204,10 @@ SingleModelSpectrumChannel::SetPropagationDelayModel (Ptr<PropagationDelayModel>
}
Ptr<SpectrumPropagationLossModel>
Ptr<SpectrumPropagationLossModel>
SingleModelSpectrumChannel::GetSpectrumPropagationLossModel (void)
{
NS_LOG_FUNCTION (this);
NS_LOG_FUNCTION (this);
return m_PropagationLoss;
}

View File

@@ -48,10 +48,10 @@ public:
virtual void AddSpectrumPropagationLossModel (Ptr<SpectrumPropagationLossModel> loss);
virtual void SetPropagationDelayModel (Ptr<PropagationDelayModel> delay);
virtual void AddRx (Ptr<SpectrumPhy> phy);
virtual void StartTx (Ptr<PacketBurst> p,
Ptr <SpectrumValue> txPsd,
SpectrumType st,
Time duration,
virtual void StartTx (Ptr<PacketBurst> p,
Ptr <SpectrumValue> txPsd,
SpectrumType st,
Time duration,
Ptr<SpectrumPhy> sender);
@@ -65,7 +65,6 @@ public:
virtual Ptr<SpectrumPropagationLossModel> GetSpectrumPropagationLossModel (void);
private:
virtual void DoDispose ();
/**

View File

@@ -36,7 +36,7 @@ SpectrumAnalyzer::SpectrumAnalyzer ()
m_netDevice (0),
m_channel (0),
m_spectrumModel (0),
m_sumPowerSpectralDensity (0),
m_sumPowerSpectralDensity (0),
m_resolution (MilliSeconds (50)),
m_active (false)
{
@@ -77,7 +77,7 @@ SpectrumAnalyzer::GetTypeId (void)
MakeTimeChecker ())
.AddAttribute ("NoisePowerSpectralDensity",
"the power spectral density of the measuring instrument noise, in Watt/Hz. Mostly useful to make spectrograms look more similar to those obtained by real devices. Defaults to the value for thermal noise at 300K.",
DoubleValue (1.38e-23*300),
DoubleValue (1.38e-23 * 300),
MakeDoubleAccessor (&SpectrumAnalyzer::m_noisePowerSpectralDensity),
MakeDoubleChecker<double> ())
.AddTraceSource ("AveragePowerSpectralDensityReport",
@@ -103,7 +103,7 @@ SpectrumAnalyzer::GetMobility ()
}
Ptr<const SpectrumModel>
Ptr<const SpectrumModel>
SpectrumAnalyzer::GetRxSpectrumModel () const
{
return m_spectrumModel;
@@ -136,9 +136,9 @@ SpectrumAnalyzer::SetChannel (Ptr<SpectrumChannel> c)
void
SpectrumAnalyzer::StartRx (Ptr<PacketBurst> pb,
Ptr <const SpectrumValue> rxPowerSpectralDensity,
SpectrumType st,
SpectrumAnalyzer::StartRx (Ptr<PacketBurst> pb,
Ptr <const SpectrumValue> rxPowerSpectralDensity,
SpectrumType st,
Time duration)
{
NS_LOG_FUNCTION ( this << st << duration << *rxPowerSpectralDensity);
@@ -157,7 +157,7 @@ SpectrumAnalyzer::AddSignal (Ptr<const SpectrumValue> psd)
void
SpectrumAnalyzer::SubtractSignal (Ptr<const SpectrumValue> psd)
{
{
NS_LOG_FUNCTION (this << *psd);
UpdateEnergyReceivedSoFar ();
(*m_sumPowerSpectralDensity) -= (*psd);
@@ -185,7 +185,7 @@ SpectrumAnalyzer::GenerateReport ()
UpdateEnergyReceivedSoFar ();
Ptr<SpectrumValue> avgPowerSpectralDensity = Create<SpectrumValue> (m_sumPowerSpectralDensity->GetSpectrumModel ());
(*avgPowerSpectralDensity) = (*m_energySpectralDensity) / m_resolution.GetSeconds ();
(*avgPowerSpectralDensity) = (*m_energySpectralDensity) / m_resolution.GetSeconds ();
(*avgPowerSpectralDensity) += m_noisePowerSpectralDensity;
(*m_energySpectralDensity) = 0;

View File

@@ -62,11 +62,11 @@ public:
/**
* Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals
*
* @param m
* @param m
*/
void SetRxSpectrumModel (Ptr<SpectrumModel> m);
/**
* Start the spectrum analyzer
*
@@ -81,16 +81,13 @@ public:
protected:
void DoDispose ();
private:
private:
Ptr<Object> m_mobility;
Ptr<Object> m_netDevice;
Ptr<SpectrumChannel> m_channel;
virtual void GenerateReport ();
void AddSignal (Ptr<const SpectrumValue> psd);

View File

@@ -43,7 +43,6 @@ class PropagationDelayModel;
class SpectrumChannel : public Channel
{
public:
virtual ~SpectrumChannel ();
static TypeId GetTypeId (void);
@@ -85,13 +84,13 @@ public:
* SpectrumChannel instance, so that the SpectrumPhy can receive
* packets sent on that channel. Note that a SpectrumPhy that only
* transmits (without receiveing ever) does not need to be added to
* the channel.
* the channel.
*
* This method is to be implemented by all classes inheriting from
* SpectrumChannel.
* SpectrumChannel.
*
* @param phy the SpectrumPhy instance to be added to the channel as
* a receiver.
* a receiver.
*/
virtual void AddRx (Ptr<SpectrumPhy> phy) = 0;

View File

@@ -51,7 +51,7 @@ public:
SpectrumConverter (Ptr<const SpectrumModel> fromSpectrumModel, Ptr<const SpectrumModel> toSpectrumModel);
SpectrumConverter ();
/**

View File

@@ -53,13 +53,13 @@ SpectrumInterference::DoDispose ()
m_rxSignal = 0;
m_allSignals = 0;
m_noise = 0;
m_errorModel = 0;
m_errorModel = 0;
Object::DoDispose ();
}
void
SpectrumInterference::StartRx (Ptr<const Packet> p, Ptr<const SpectrumValue> rxPsd)
{
{
NS_LOG_FUNCTION (this << p << *rxPsd);
m_rxSignal = rxPsd;
m_lastChangeTime = Now ();
@@ -89,7 +89,7 @@ SpectrumInterference::AddSignal (Ptr<const SpectrumValue> spd, const Time durati
void
SpectrumInterference::DoAddSignal (Ptr<const SpectrumValue> spd)
{
{
NS_LOG_FUNCTION (this << *spd);
ConditionallyEvaluateChunk ();
(*m_allSignals) += (*spd);
@@ -98,7 +98,7 @@ SpectrumInterference::DoAddSignal (Ptr<const SpectrumValue> spd)
void
SpectrumInterference::DoSubtractSignal (Ptr<const SpectrumValue> spd)
{
{
NS_LOG_FUNCTION (this << *spd);
ConditionallyEvaluateChunk ();
(*m_allSignals) -= (*spd);

View File

@@ -97,7 +97,6 @@ public:
protected:
void DoDispose ();
private:

View File

@@ -33,16 +33,16 @@ namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (SpectrumPhy);
TypeId
TypeId
SpectrumPhy::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::SpectrumPhy")
.SetParent<Object> ()
;
;
return tid;
}
SpectrumPhy::~SpectrumPhy ()
{
NS_LOG_FUNCTION (this);

View File

@@ -43,11 +43,9 @@ class SpectrumPhy : public Object
{
public:
virtual ~SpectrumPhy ();
static TypeId GetTypeId (void);
static TypeId GetTypeId (void);
/**
* set the associated NetDevice instance
@@ -85,8 +83,8 @@ public:
*/
virtual void SetChannel (Ptr<SpectrumChannel> c) = 0;
/**
*
/**
*
* @return returns the SpectrumModel that this SpectrumPhy expects to be used
* for all SpectrumValues that are passed to StartRx. If 0 is
* returned, it means that any model will be accepted.
@@ -103,7 +101,7 @@ public:
* @param duration the duration of the incoming waveform
*/
virtual void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration) = 0;
};
@@ -115,7 +113,7 @@ public:
} // namespace ns3
} // namespace ns3

View File

@@ -75,7 +75,7 @@ public:
protected:
virtual void DoDispose ();
private:
/**

View File

@@ -32,7 +32,7 @@ namespace ns3 {
SpectrumValue::SpectrumValue ()
{
{
}
SpectrumValue::SpectrumValue (Ptr<const SpectrumModel> sof)

View File

@@ -76,7 +76,7 @@ public:
SpectrumValue ();
/**
* Access value at given frequency index

View File

@@ -83,7 +83,7 @@ WaveformGenerator::GetTypeId (void)
.AddTraceSource ("TxEnd",
"Trace fired when a previosuly started transmission is finished",
MakeTraceSourceAccessor (&WaveformGenerator::m_phyTxEndTrace))
;
;
return tid;
}
@@ -103,7 +103,7 @@ WaveformGenerator::GetMobility ()
}
Ptr<const SpectrumModel>
Ptr<const SpectrumModel>
WaveformGenerator::GetRxSpectrumModel () const
{
// this device is not interested in RX
@@ -190,11 +190,11 @@ WaveformGenerator::GenerateWaveform ()
Ptr<PacketBurst> pb = Create<PacketBurst> ();
Time duration = Time (m_period * m_dutyCycle);
NS_LOG_LOGIC ("generating waveform : " << *m_txPowerSpectralDensity);
m_phyTxStartTrace (0);
m_channel->StartTx (pb, m_txPowerSpectralDensity, GetSpectrumType (), duration, GetObject<SpectrumPhy> ());
if (m_active)
{
NS_LOG_LOGIC ("scheduling next waveform");
@@ -220,7 +220,7 @@ WaveformGenerator::Start ()
void
WaveformGenerator::Stop ()
{
NS_LOG_FUNCTION (this);
NS_LOG_FUNCTION (this);
m_active = false;
}

View File

@@ -59,7 +59,7 @@ public:
Ptr<Object> GetMobility ();
Ptr<Object> GetDevice ();
Ptr<const SpectrumModel> GetRxSpectrumModel () const;
void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
void StartRx (Ptr<PacketBurst> p, Ptr <const SpectrumValue> rxPsd, SpectrumType st, Time duration);
/**
@@ -88,21 +88,21 @@ public:
void SetPeriod (Time period);
/**
*
/**
*
* @return the value of the period according to which the WaveformGenerator switches
* on and off
*/
Time GetPeriod () const;
/**
*
/**
*
* @param value the value of the duty cycle
*/
void SetDutyCycle (double value);
/**
/**
*
* @return the value of the duty cycle
*/
@@ -125,7 +125,6 @@ public:
private:
virtual void DoDispose (void);
Ptr<Object> m_mobility;

View File

@@ -23,7 +23,7 @@
namespace ns3 {
Ptr<SpectrumModel> g_WifiSpectrumModel5Mhz;
WifiSpectrumValueHelper::~WifiSpectrumValueHelper ()
@@ -40,12 +40,12 @@ public:
WifiSpectrumModel5MhzInitializer ()
{
Bands bands;
for (int i = -4; i < 13+7; i++)
for (int i = -4; i < 13 + 7; i++)
{
BandInfo bi;
bi.fl = 2407.0e6 + i * 5.0e6;
bi.fh = 2407.0e6 + (i+1) * 5.0e6;
bi.fc = (bi.fl + bi.fh)/2;
bi.fh = 2407.0e6 + (i + 1) * 5.0e6;
bi.fc = (bi.fl + bi.fh) / 2;
bands.push_back (bi);
}
g_WifiSpectrumModel5Mhz = Create<SpectrumModel> (bands);
@@ -54,18 +54,18 @@ public:
Ptr<SpectrumValue>
Ptr<SpectrumValue>
WifiSpectrumValue5MhzFactory::CreateConstant (double v)
{
{
Ptr<SpectrumValue> c = Create <SpectrumValue> (g_WifiSpectrumModel5Mhz);
(*c) = v;
return c;
}
Ptr<SpectrumValue>
Ptr<SpectrumValue>
WifiSpectrumValue5MhzFactory::CreateTxPowerSpectralDensity (double txPower, uint32_t channel)
{
{
Ptr<SpectrumValue> txPsd = Create <SpectrumValue> (g_WifiSpectrumModel5Mhz);
// since the spectrum model has a resolution of 5 MHz, we model
@@ -75,10 +75,10 @@ WifiSpectrumValue5MhzFactory::CreateTxPowerSpectralDensity (double txPower, uint
// calculated considering the transmit spectrum mask, see IEEE
// Std. 802.11-2007, Annex I
double txPowerDensity = txPower / 20e6;
double txPowerDensity = txPower / 20e6;
NS_ASSERT(channel >= 1);
NS_ASSERT(channel <= 13);
NS_ASSERT (channel >= 1);
NS_ASSERT (channel <= 13);
(*txPsd)[channel - 1] = txPowerDensity * 1e-4; // -40dB
(*txPsd)[channel] = txPowerDensity * 1e-4; // -40dB
@@ -97,13 +97,13 @@ WifiSpectrumValue5MhzFactory::CreateTxPowerSpectralDensity (double txPower, uint
}
Ptr<SpectrumValue>
Ptr<SpectrumValue>
WifiSpectrumValue5MhzFactory::CreateRfFilter (uint32_t channel)
{
{
Ptr<SpectrumValue> rf = Create <SpectrumValue> (g_WifiSpectrumModel5Mhz);
NS_ASSERT(channel >= 1);
NS_ASSERT(channel <= 13);
NS_ASSERT (channel >= 1);
NS_ASSERT (channel <= 13);
(*rf)[channel - 1] = 1;
(*rf)[channel ] = 1;

View File

@@ -28,18 +28,18 @@ namespace ns3 {
/**
/**
* this abstract class defines the interface for interacting with all WifiSpectrumValue implementations.
*
*/
class WifiSpectrumValueHelper
class WifiSpectrumValueHelper
{
public:
virtual ~WifiSpectrumValueHelper ();
/*
*
* @param value the constant value
*
*
* @return a Ptr to a newly created SpectrumValue instance which
* has a constant value for all frequencies
*/
@@ -48,8 +48,8 @@ public:
/*
*
* @param txPower the total TX power in W
* @param channel the number of the channel
*
* @param channel the number of the channel
*
* @return a Ptr to a newly created SpectrumValue instance which
* represents the TX Power Spectral Density of a wifi device
* corresponding to the provided parameters
@@ -58,19 +58,19 @@ public:
/*
*
* @param channel the number of the channel
*
* @param channel the number of the channel
*
* @return a Ptr to a newly created SpectrumValue instance which
* represents the frequency response of the RF filter which is used
* by a wifi device to receive signals when tuned to a particular channel
*/
virtual Ptr<SpectrumValue> CreateRfFilter (uint32_t channel) = 0;
};
/**
/**
* Implements WifiSpectrumValue for the 2.4 GHz ISM band only, with a
* 5 MHz spectrum resolution.
*
@@ -87,7 +87,7 @@ public:
};
} //namespace ns3

View File

@@ -175,7 +175,7 @@ SpectrumInterferenceTestSuite::SpectrumInterferenceTestSuite ()
AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast<uint32_t> (b * 0.5 + 0.5), true, "sdBm = [-46 -48] tx bytes: b*0.5"));
AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast<uint32_t> (b * (1 - e) + 0.5), true, "sdBm = [-46 -48] tx bytes: b*(1-e)"));
AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast<uint32_t> (b * (1 + e) + 0.5), false, "sdBm = [-46 -48] tx bytes: b*(1+e)"));
AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast<uint32_t>(b * 1.5 + 0.5), false, "sdBm = [-46 -48] tx bytes: b*1.5"));
AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast<uint32_t> (b * 1.5 + 0.5), false, "sdBm = [-46 -48] tx bytes: b*1.5"));
AddTestCase (new SpectrumInterferenceTestCase (s1, 0xffffffff, false, "sdBm = [-46 -48] tx bytes: 2^32-1"));
// Power Spectral Density of the signal of interest = [-63 -61] dBm;

View File

@@ -17,99 +17,99 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Nicola Baldo <nbaldo@cttc.es>
* part of the code copied from test.h
* part of the code copied from test.h
*/
#include <ns3/test.h>
#include <ns3/spectrum-value.h>
/**
/**
* \brief Test if two SpectrumModel instances are equal within a given tolerance.
*
* This test compares component-by-component the two SpectrumModel
* instances; if any pair of components differs by more than the given
* tolerance, the test fails.
*
* tolerance, the test fails.
*
* \param actual the actual value obtained by the simulator
* \param expected the expected value obtained by off-line calculations
* \param tol the tolerance
* \param msg the message to print if the test fails
*
*
*/
#define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL(actual, expected, tol, msg) \
NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL(actual, expected, tol, msg, __FILE__, __LINE__)
NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL (actual, expected, tol, msg, __FILE__, __LINE__)
/**
* \internal
*/
#define NS_TEST_ASSERT_MSG_SPECTRUM_MODEL_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
do \
{ \
Bands::const_iterator i = (actual).Begin (); \
Bands::const_iterator j = (expected).Begin (); \
do \
{ \
Bands::const_iterator i = (actual).Begin (); \
Bands::const_iterator j = (expected).Begin (); \
uint32_t k = 0; \
while (i != (actual).End () && j != (expected).End ()) \
while (i != (actual).End () && j != (expected).End ()) \
{ \
if ((i->fl > j->fl + (tol)) || (i->fl < j->fl - (tol)) || \
(i->fc > j->fc + (tol)) || (i->fc < j->fc - (tol)) || \
(i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol))) \
if ((i->fl > j->fl + (tol)) || (i->fl < j->fl - (tol)) \
|| (i->fc > j->fc + (tol)) || (i->fc < j->fc - (tol)) \
|| (i->fh > j->fh + (tol)) || (i->fh < j->fh - (tol))) \
{ \
if (gBreakOnFailure) {*(int *)0 = 0;} \
std::ostringstream indexStream; \
indexStream << "[" << k << "]"; \
std::ostringstream msgStream; \
msgStream << (msg); \
std::ostringstream actualStream; \
if (gBreakOnFailure) { *(int *)0 = 0;} \
std::ostringstream indexStream; \
indexStream << "[" << k << "]"; \
std::ostringstream msgStream; \
msgStream << (msg); \
std::ostringstream actualStream; \
actualStream << i->fl << " <-- " << i->fc << " --> " << i->fh; \
std::ostringstream expectedStream; \
expectedStream << j->fl << " <-- " << j->fc << " --> " << j->fh; \
ReportTestFailure (std::string (#actual) + indexStream.str () + " == " + std::string (#expected) + indexStream.str (), \
std::ostringstream expectedStream; \
expectedStream << j->fl << " <-- " << j->fc << " --> " << j->fh; \
ReportTestFailure (std::string (# actual) + indexStream.str () + " == " + std::string (# expected) + indexStream.str (), \
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
} \
++i; \
++j; \
++k; \
} \
} \
++i; \
++j; \
++k; \
} \
if (i != (actual).End () || j != (expected).End ()) \
{ \
std::ostringstream msgStream; \
msgStream << (msg); \
std::ostringstream actualStream; \
actualStream << (i != (actual).End ()); \
std::ostringstream expectedStream; \
expectedStream << (j != (expected).End ()); \
ReportTestFailure ("Bands::iterator == End ()" , \
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
} \
} \
{ \
std::ostringstream msgStream; \
msgStream << (msg); \
std::ostringstream actualStream; \
actualStream << (i != (actual).End ()); \
std::ostringstream expectedStream; \
expectedStream << (j != (expected).End ()); \
ReportTestFailure ("Bands::iterator == End ()", \
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
} \
} \
while (false); \
/**
/**
* \brief Test if two SpectrumValue instances are equal within a given tolerance.
*
* This test compares component-by-component the two SpectrumValue
* instances; if any pair of components differs by more than the given
* tolerance, the test fails.
*
* tolerance, the test fails.
*
* \param actual the actual value obtained by the simulator
* \param expected the expected value obtained by off-line calculations
* \param tol the tolerance
* \param msg the message to print if the test fails
*
*
*/
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(actual, expected, tol, msg) \
NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL(actual, expected, tol, msg, __FILE__, __LINE__)
NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL (actual, expected, tol, msg, __FILE__, __LINE__)
/**
* \internal
*/
#define NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL_INTERNAL(actual, expected, tol, msg, file, line) \
do \
{ \
do \
{ \
Values::const_iterator i = (actual).ConstValuesBegin (); \
Values::const_iterator j = (expected).ConstValuesBegin (); \
uint32_t k = 0; \
@@ -117,36 +117,36 @@
{ \
if ((*i) > (*j) + (tol) || (*i) < (*j) - (tol)) \
{ \
if (gBreakOnFailure) {*(int *)0 = 0;} \
std::ostringstream indexStream; \
indexStream << "[" << k << "]"; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream expectedStream; \
expectedStream << expected; \
ReportTestFailure (std::string (#actual) + indexStream.str () + " == " + std::string (#expected) + indexStream.str (), \
actualStream.str (), expectedStream.str (), msgStream.str (), file, line); \
} \
++i; \
++j; \
++k; \
} \
if (gBreakOnFailure) { *(int *)0 = 0;} \
std::ostringstream indexStream; \
indexStream << "[" << k << "]"; \
std::ostringstream msgStream; \
msgStream << msg; \
std::ostringstream actualStream; \
actualStream << actual; \
std::ostringstream expectedStream; \
expectedStream << expected; \
ReportTestFailure (std::string (# actual) + indexStream.str () + " == " + std::string (# expected) + indexStream.str (), \
actualStream.str (), expectedStream.str (), msgStream.str (), file, line); \
} \
++i; \
++j; \
++k; \
} \
if (i != (actual).ConstValuesEnd () || j != (expected).ConstValuesEnd ()) \
{ \
std::ostringstream msgStream; \
msgStream << (msg); \
std::ostringstream actualStream; \
actualStream << (i != (actual).ConstValuesEnd ()); \
std::ostringstream expectedStream; \
expectedStream << (j != (expected).ConstValuesEnd ()); \
ReportTestFailure ("Values::const_iterator == ConstValuesEnd ()" , \
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
} \
} \
{ \
std::ostringstream msgStream; \
msgStream << (msg); \
std::ostringstream actualStream; \
actualStream << (i != (actual).ConstValuesEnd ()); \
std::ostringstream expectedStream; \
expectedStream << (j != (expected).ConstValuesEnd ()); \
ReportTestFailure ("Values::const_iterator == ConstValuesEnd ()", \
actualStream.str (), expectedStream.str (), msgStream.str (), (file), (line)); \
} \
} \
while (false); \