diff --git a/src/spectrum/examples/adhoc-aloha-ideal-phy-with-microwave-oven.cc b/src/spectrum/examples/adhoc-aloha-ideal-phy-with-microwave-oven.cc index 30a541fcf..0ab9755c9 100644 --- a/src/spectrum/examples/adhoc-aloha-ideal-phy-with-microwave-oven.cc +++ b/src/spectrum/examples/adhoc-aloha-ideal-phy-with-microwave-oven.cc @@ -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 p) -{ +{ if (g_verbose) { std::cout << context << " PHY TX START p: " << p << std::endl; @@ -62,7 +62,7 @@ PhyTxStartTrace (std::string context, Ptr p) void PhyTxEndTrace (std::string context, Ptr p) -{ +{ if (g_verbose) { std::cout << context << " PHY TX END p: " << p << std::endl; @@ -74,7 +74,7 @@ PhyRxStartTrace (std::string context, Ptr 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 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 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) } if (g_verbose) { - std::cout << "SOCKET received " << bytes << " bytes" < channel = channelHelper.Create (); @@ -165,18 +165,18 @@ int main (int argc, char** argv) double txPower = 0.1; // Watts uint32_t channelNumber = 2; - Ptr txPsd = sf.CreateTxPowerSpectralDensity (txPower, channelNumber); - + Ptr 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 noisePsd = sf.CreateConstant (noisePsdValue); - + double noisePsdValue = k * T; // watts per hertz + Ptr 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 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 ()->GetPhy ()->GetObject ()); + + Simulator::Schedule (Seconds (0.1), &WaveformGenerator::Start, + waveformGeneratorDevices.Get (0)->GetObject ()->GetPhy ()->GetObject ()); + - ///////////////////////////////// // 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 (); } diff --git a/src/spectrum/examples/adhoc-aloha-ideal-phy.cc b/src/spectrum/examples/adhoc-aloha-ideal-phy.cc index 5210b58af..98627f07f 100644 --- a/src/spectrum/examples/adhoc-aloha-ideal-phy.cc +++ b/src/spectrum/examples/adhoc-aloha-ideal-phy.cc @@ -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 p) -{ +{ if (g_verbose) { std::cout << context << " PHY TX START p: " << p << std::endl; @@ -57,7 +57,7 @@ PhyTxStartTrace (std::string context, Ptr p) void PhyTxEndTrace (std::string context, Ptr p) -{ +{ if (g_verbose) { std::cout << context << " PHY TX END p: " << p << std::endl; @@ -69,7 +69,7 @@ PhyRxStartTrace (std::string context, Ptr 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 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 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) } if (g_verbose) { - std::cout << "SOCKET received " << bytes << " bytes" < channel = channelHelper.Create (); @@ -143,17 +143,17 @@ int main (int argc, char** argv) double txPower = 0.1; // Watts uint32_t channelNumber = 1; - Ptr txPsd = sf.CreateTxPowerSpectralDensity (txPower, channelNumber); - + Ptr 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 noisePsd = sf.CreateConstant (noisePsdValue); + double noisePsdValue = k * T; // watts per hertz + Ptr 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 recvSink = SetupPacketReceive (c.Get (1)); Simulator::Stop (Seconds (10.0)); diff --git a/src/spectrum/helper/spectrum-analyzer-helper.cc b/src/spectrum/helper/spectrum-analyzer-helper.cc index 8b3371921..fc1f9db34 100644 --- a/src/spectrum/helper/spectrum-analyzer-helper.cc +++ b/src/spectrum/helper/spectrum-analyzer-helper.cc @@ -39,8 +39,8 @@ NS_LOG_COMPONENT_DEFINE ("SpectrumAnalyzerHelper"); namespace ns3 { -static void -WriteAveragePowerSpectralDensityReport (Ptr streamWrapper, +static void +WriteAveragePowerSpectralDensityReport (Ptr streamWrapper, Ptr avgPowerSpectralDensity) { NS_LOG_FUNCTION (streamWrapper << avgPowerSpectralDensity); @@ -62,7 +62,7 @@ WriteAveragePowerSpectralDensityReport (Ptr 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 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 = *i; Ptr dev = m_device.Create ()->GetObject (); - + Ptr phy = m_phy.Create ()->GetObject (); 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)); diff --git a/src/spectrum/helper/waveform-generator-helper.cc b/src/spectrum/helper/waveform-generator-helper.cc index 1b6b51b96..278e2fdfa 100644 --- a/src/spectrum/helper/waveform-generator-helper.cc +++ b/src/spectrum/helper/waveform-generator-helper.cc @@ -91,7 +91,7 @@ WaveformGeneratorHelper::Install (NodeContainer c) const Ptr node = *i; Ptr dev = m_device.Create ()->GetObject (); - + Ptr phy = m_phy.Create ()->GetObject (); NS_ASSERT (phy); diff --git a/src/spectrum/model/aloha-noack-net-device.cc b/src/spectrum/model/aloha-noack-net-device.cc index b8fdead63..0bc39b14f 100644 --- a/src/spectrum/model/aloha-noack-net-device.cc +++ b/src/spectrum/model/aloha-noack-net-device.cc @@ -106,7 +106,7 @@ AlohaNoackNetDevice::AlohaNoackNetDevice () { NS_LOG_FUNCTION (this); } - + AlohaNoackNetDevice::~AlohaNoackNetDevice () { NS_LOG_FUNCTION (this); diff --git a/src/spectrum/model/aloha-noack-net-device.h b/src/spectrum/model/aloha-noack-net-device.h index f91780015..f77e508d8 100644 --- a/src/spectrum/model/aloha-noack-net-device.h +++ b/src/spectrum/model/aloha-noack-net-device.h @@ -57,7 +57,8 @@ class Queue; class AlohaNoackNetDevice : public NetDevice { public: - enum State { + enum State + { IDLE, TX, RX }; diff --git a/src/spectrum/model/half-duplex-ideal-phy.cc b/src/spectrum/model/half-duplex-ideal-phy.cc index d0742e5f7..2ae2c427a 100644 --- a/src/spectrum/model/half-duplex-ideal-phy.cc +++ b/src/spectrum/model/half-duplex-ideal-phy.cc @@ -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 c) m_channel = c; } -Ptr +Ptr 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 p) { case RX: AbortRx (); - // fall through + // fall through case IDLE: { @@ -278,7 +278,7 @@ HalfDuplexIdealPhy::StartTx (Ptr p) Ptr pb = Create (); pb->AddPacket (p); m_channel->StartTx (pb, m_txPsd, GetSpectrumType (), Seconds (txTimeSeconds), GetObject ()); - Simulator::Schedule(Seconds (txTimeSeconds), &HalfDuplexIdealPhy::EndTx, this); + Simulator::Schedule (Seconds (txTimeSeconds), &HalfDuplexIdealPhy::EndTx, this); } break; @@ -341,7 +341,7 @@ 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_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 (); m_phyRxStartTrace (p); @@ -365,7 +365,7 @@ HalfDuplexIdealPhy::StartRx (Ptr pb, Ptr rxPs } } - + NS_LOG_LOGIC (this << "state: " << m_state); } diff --git a/src/spectrum/model/half-duplex-ideal-phy.h b/src/spectrum/model/half-duplex-ideal-phy.h index f6ce085de..231b06c2b 100644 --- a/src/spectrum/model/half-duplex-ideal-phy.h +++ b/src/spectrum/model/half-duplex-ideal-phy.h @@ -83,7 +83,8 @@ public: * PHY states * */ - enum State { + enum State + { IDLE, TX, RX }; @@ -97,7 +98,7 @@ public: Ptr GetDevice (); Ptr GetRxSpectrumModel () const; void StartRx (Ptr p, Ptr rxPsd, SpectrumType st, Time duration); - + /** @@ -183,9 +184,8 @@ public: private: - virtual void DoDispose (void); - + void ChangeState (State newState); void EndTx (); void AbortRx (); diff --git a/src/spectrum/model/microwave-oven-spectrum-value-helper.cc b/src/spectrum/model/microwave-oven-spectrum-value-helper.cc index db929ab81..8e3e00ab5 100644 --- a/src/spectrum/model/microwave-oven-spectrum-value-helper.cc +++ b/src/spectrum/model/microwave-oven-spectrum-value-helper.cc @@ -25,7 +25,7 @@ NS_LOG_COMPONENT_DEFINE ("MicrowaveOvenSpectrumValue"); namespace ns3 { - + Ptr g_MicrowaveOvenSpectrumModel5Mhz; Ptr 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 (bands); + NS_LOG_LOGIC ("bands.size () :" << bands.size ()); + g_MicrowaveOvenSpectrumModel5Mhz = Create (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 (bands); } } g_MicrowaveOvenSpectrumModel6MhzInitializerInstance; @@ -76,13 +76,13 @@ public: -Ptr +Ptr MicrowaveOvenSpectrumValueHelper::CreatePowerSpectralDensityMwo1 () -{ +{ Ptr psd = Create (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 +Ptr 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 psd = Create (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; } diff --git a/src/spectrum/model/microwave-oven-spectrum-value-helper.h b/src/spectrum/model/microwave-oven-spectrum-value-helper.h index 39bfa4614..b0fdf36f8 100644 --- a/src/spectrum/model/microwave-oven-spectrum-value-helper.h +++ b/src/spectrum/model/microwave-oven-spectrum-value-helper.h @@ -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 CreatePowerSpectralDensityMwo1 (); - /** - * + /** + * * @return the Power Spectral Density of Micro Wave Oven #2 in the * cited paper - */ + */ static Ptr CreatePowerSpectralDensityMwo2 (); }; @@ -59,7 +58,7 @@ public: - + } //namespace ns3 diff --git a/src/spectrum/model/multi-model-spectrum-channel.cc b/src/spectrum/model/multi-model-spectrum-channel.cc index 33729cf71..cd6a4cf49 100644 --- a/src/spectrum/model/multi-model-spectrum-channel.cc +++ b/src/spectrum/model/multi-model-spectrum-channel.cc @@ -112,7 +112,7 @@ MultiModelSpectrumChannel::AddRx (Ptr 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 >::const_iterator it; // make sure this phy had not been already added @@ -121,18 +121,18 @@ MultiModelSpectrumChannel::AddRx (Ptr 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 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 phy) NS_LOG_LOGIC ("Creating converters between SpectrumModelUids " << txSpectrumModel->GetUid () << " and " << rxSpectrumModelUid ); SpectrumConverter converter (txSpectrumModel, rxSpectrumModel); std::pair 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 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 (PtrGetUid (); 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 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 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 p, Ptr orig NS_ASSERT (txPhy); NS_ASSERT (originalTxPowerSpectrum); - + Ptr txMobility = txPhy->GetMobility ()->GetObject (); SpectrumModelUid_t txSpectrumModelUid = originalTxPowerSpectrum->GetSpectrumModelUid (); @@ -246,7 +246,7 @@ 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) { Ptr rxPowerSpectrum; @@ -296,7 +296,7 @@ MultiModelSpectrumChannel::StartTx (Ptr p, Ptr orig Simulator::Schedule (delay, &MultiModelSpectrumChannel::StartRx, this, pktBurstCopy, rxPowerSpectrum, st, duration, *rxPhyIterator); } - } + } ++rxPhyIterator; } diff --git a/src/spectrum/model/multi-model-spectrum-channel.h b/src/spectrum/model/multi-model-spectrum-channel.h index 10b2c2868..8b42a7147 100644 --- a/src/spectrum/model/multi-model-spectrum-channel.h +++ b/src/spectrum/model/multi-model-spectrum-channel.h @@ -40,7 +40,7 @@ class TxSpectrumModelInfo { public: TxSpectrumModelInfo (Ptr txSpectrumModel); - + Ptr m_txSpectrumModel; SpectrumConverterMap_t m_spectrumConverterMap; }; @@ -52,9 +52,9 @@ class RxSpectrumModelInfo { public: RxSpectrumModelInfo (Ptr rxSpectrumModel); - + Ptr m_rxSpectrumModel; - std::list > m_rxPhyList; + std::list > m_rxPhyList; }; typedef std::map 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 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() diff --git a/src/spectrum/model/non-communicating-net-device.cc b/src/spectrum/model/non-communicating-net-device.cc index f256f41c5..1ce3508a8 100644 --- a/src/spectrum/model/non-communicating-net-device.cc +++ b/src/spectrum/model/non-communicating-net-device.cc @@ -43,7 +43,7 @@ NonCommunicatingNetDevice::GetTypeId (void) { static TypeId tid = TypeId ("ns3::NonCommunicatingNetDevice") .SetParent () - .AddConstructor () + .AddConstructor () .AddAttribute ("Phy", "The PHY layer attached to this device.", PointerValue (), MakePointerAccessor (&NonCommunicatingNetDevice::GetPhy, diff --git a/src/spectrum/model/non-communicating-net-device.h b/src/spectrum/model/non-communicating-net-device.h index 83ec6f07a..564c81ee2 100644 --- a/src/spectrum/model/non-communicating-net-device.h +++ b/src/spectrum/model/non-communicating-net-device.h @@ -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 m_node; diff --git a/src/spectrum/model/single-model-spectrum-channel.cc b/src/spectrum/model/single-model-spectrum-channel.cc index 1daf52524..025dd8051 100644 --- a/src/spectrum/model/single-model-spectrum-channel.cc +++ b/src/spectrum/model/single-model-spectrum-channel.cc @@ -204,10 +204,10 @@ SingleModelSpectrumChannel::SetPropagationDelayModel (Ptr } -Ptr +Ptr SingleModelSpectrumChannel::GetSpectrumPropagationLossModel (void) { - NS_LOG_FUNCTION (this); + NS_LOG_FUNCTION (this); return m_PropagationLoss; } diff --git a/src/spectrum/model/single-model-spectrum-channel.h b/src/spectrum/model/single-model-spectrum-channel.h index c1e2000ae..e28b6aa8d 100644 --- a/src/spectrum/model/single-model-spectrum-channel.h +++ b/src/spectrum/model/single-model-spectrum-channel.h @@ -48,10 +48,10 @@ 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, + virtual void StartTx (Ptr p, + Ptr txPsd, + SpectrumType st, + Time duration, Ptr sender); @@ -65,7 +65,6 @@ public: virtual Ptr GetSpectrumPropagationLossModel (void); private: - virtual void DoDispose (); /** diff --git a/src/spectrum/model/spectrum-analyzer.cc b/src/spectrum/model/spectrum-analyzer.cc index 342e8b34e..e51cbe6b3 100644 --- a/src/spectrum/model/spectrum-analyzer.cc +++ b/src/spectrum/model/spectrum-analyzer.cc @@ -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 ()) .AddTraceSource ("AveragePowerSpectralDensityReport", @@ -103,7 +103,7 @@ SpectrumAnalyzer::GetMobility () } -Ptr +Ptr SpectrumAnalyzer::GetRxSpectrumModel () const { return m_spectrumModel; @@ -136,9 +136,9 @@ SpectrumAnalyzer::SetChannel (Ptr c) void -SpectrumAnalyzer::StartRx (Ptr pb, - Ptr rxPowerSpectralDensity, - SpectrumType st, +SpectrumAnalyzer::StartRx (Ptr pb, + Ptr rxPowerSpectralDensity, + SpectrumType st, Time duration) { NS_LOG_FUNCTION ( this << st << duration << *rxPowerSpectralDensity); @@ -157,7 +157,7 @@ SpectrumAnalyzer::AddSignal (Ptr psd) void SpectrumAnalyzer::SubtractSignal (Ptr psd) -{ +{ NS_LOG_FUNCTION (this << *psd); UpdateEnergyReceivedSoFar (); (*m_sumPowerSpectralDensity) -= (*psd); @@ -185,7 +185,7 @@ SpectrumAnalyzer::GenerateReport () UpdateEnergyReceivedSoFar (); Ptr avgPowerSpectralDensity = Create (m_sumPowerSpectralDensity->GetSpectrumModel ()); - (*avgPowerSpectralDensity) = (*m_energySpectralDensity) / m_resolution.GetSeconds (); + (*avgPowerSpectralDensity) = (*m_energySpectralDensity) / m_resolution.GetSeconds (); (*avgPowerSpectralDensity) += m_noisePowerSpectralDensity; (*m_energySpectralDensity) = 0; diff --git a/src/spectrum/model/spectrum-analyzer.h b/src/spectrum/model/spectrum-analyzer.h index 32b9892d9..a2c4dfd76 100644 --- a/src/spectrum/model/spectrum-analyzer.h +++ b/src/spectrum/model/spectrum-analyzer.h @@ -62,11 +62,11 @@ public: /** * Set the spectrum model used by the SpectrumAnalyzer to represent incoming signals * - * @param m + * @param m */ void SetRxSpectrumModel (Ptr m); - + /** * Start the spectrum analyzer * @@ -81,16 +81,13 @@ public: protected: - void DoDispose (); -private: - - +private: Ptr m_mobility; Ptr m_netDevice; Ptr m_channel; - + virtual void GenerateReport (); void AddSignal (Ptr psd); diff --git a/src/spectrum/model/spectrum-channel.h b/src/spectrum/model/spectrum-channel.h index 0f828ad49..0ae4c142d 100644 --- a/src/spectrum/model/spectrum-channel.h +++ b/src/spectrum/model/spectrum-channel.h @@ -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 phy) = 0; diff --git a/src/spectrum/model/spectrum-converter.h b/src/spectrum/model/spectrum-converter.h index 82da3fb93..b685ac534 100644 --- a/src/spectrum/model/spectrum-converter.h +++ b/src/spectrum/model/spectrum-converter.h @@ -51,7 +51,7 @@ public: SpectrumConverter (Ptr fromSpectrumModel, Ptr toSpectrumModel); SpectrumConverter (); - + /** diff --git a/src/spectrum/model/spectrum-interference.cc b/src/spectrum/model/spectrum-interference.cc index 72cc8439e..0f5216d07 100644 --- a/src/spectrum/model/spectrum-interference.cc +++ b/src/spectrum/model/spectrum-interference.cc @@ -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 p, Ptr rxPsd) -{ +{ NS_LOG_FUNCTION (this << p << *rxPsd); m_rxSignal = rxPsd; m_lastChangeTime = Now (); @@ -89,7 +89,7 @@ SpectrumInterference::AddSignal (Ptr spd, const Time durati void SpectrumInterference::DoAddSignal (Ptr spd) -{ +{ NS_LOG_FUNCTION (this << *spd); ConditionallyEvaluateChunk (); (*m_allSignals) += (*spd); @@ -98,7 +98,7 @@ SpectrumInterference::DoAddSignal (Ptr spd) void SpectrumInterference::DoSubtractSignal (Ptr spd) -{ +{ NS_LOG_FUNCTION (this << *spd); ConditionallyEvaluateChunk (); (*m_allSignals) -= (*spd); diff --git a/src/spectrum/model/spectrum-interference.h b/src/spectrum/model/spectrum-interference.h index 68593f3cd..638737f20 100644 --- a/src/spectrum/model/spectrum-interference.h +++ b/src/spectrum/model/spectrum-interference.h @@ -97,7 +97,6 @@ public: protected: - void DoDispose (); private: diff --git a/src/spectrum/model/spectrum-phy.cc b/src/spectrum/model/spectrum-phy.cc index b146e19ee..644e4b2f8 100644 --- a/src/spectrum/model/spectrum-phy.cc +++ b/src/spectrum/model/spectrum-phy.cc @@ -33,16 +33,16 @@ namespace ns3 { NS_OBJECT_ENSURE_REGISTERED (SpectrumPhy); -TypeId +TypeId SpectrumPhy::GetTypeId (void) { static TypeId tid = TypeId ("ns3::SpectrumPhy") .SetParent () - ; + ; return tid; } - + SpectrumPhy::~SpectrumPhy () { NS_LOG_FUNCTION (this); diff --git a/src/spectrum/model/spectrum-phy.h b/src/spectrum/model/spectrum-phy.h index 28f38f32e..c5b532fce 100644 --- a/src/spectrum/model/spectrum-phy.h +++ b/src/spectrum/model/spectrum-phy.h @@ -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 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 p, Ptr rxPsd, SpectrumType st, Time duration) = 0; - + }; @@ -115,7 +113,7 @@ public: -} // namespace ns3 +} // namespace ns3 diff --git a/src/spectrum/model/spectrum-propagation-loss-model.h b/src/spectrum/model/spectrum-propagation-loss-model.h index 4729a8d9b..4d35ae25c 100644 --- a/src/spectrum/model/spectrum-propagation-loss-model.h +++ b/src/spectrum/model/spectrum-propagation-loss-model.h @@ -75,7 +75,7 @@ public: protected: virtual void DoDispose (); - + private: /** diff --git a/src/spectrum/model/spectrum-value.cc b/src/spectrum/model/spectrum-value.cc index 8ba0dae69..724036b62 100644 --- a/src/spectrum/model/spectrum-value.cc +++ b/src/spectrum/model/spectrum-value.cc @@ -32,7 +32,7 @@ namespace ns3 { SpectrumValue::SpectrumValue () -{ +{ } SpectrumValue::SpectrumValue (Ptr sof) diff --git a/src/spectrum/model/spectrum-value.h b/src/spectrum/model/spectrum-value.h index 03aa12c7b..75dc36c0e 100644 --- a/src/spectrum/model/spectrum-value.h +++ b/src/spectrum/model/spectrum-value.h @@ -76,7 +76,7 @@ public: SpectrumValue (); - + /** * Access value at given frequency index diff --git a/src/spectrum/model/waveform-generator.cc b/src/spectrum/model/waveform-generator.cc index 90eaf16c8..dcc5443c1 100644 --- a/src/spectrum/model/waveform-generator.cc +++ b/src/spectrum/model/waveform-generator.cc @@ -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 +Ptr WaveformGenerator::GetRxSpectrumModel () const { // this device is not interested in RX @@ -190,11 +190,11 @@ WaveformGenerator::GenerateWaveform () Ptr pb = Create (); 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 ()); - + 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; } diff --git a/src/spectrum/model/waveform-generator.h b/src/spectrum/model/waveform-generator.h index b4fb8fc97..16c266528 100644 --- a/src/spectrum/model/waveform-generator.h +++ b/src/spectrum/model/waveform-generator.h @@ -59,7 +59,7 @@ public: Ptr GetMobility (); Ptr GetDevice (); Ptr GetRxSpectrumModel () const; - void StartRx (Ptr p, Ptr rxPsd, SpectrumType st, Time duration); + void StartRx (Ptr p, Ptr 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 m_mobility; diff --git a/src/spectrum/model/wifi-spectrum-value-helper.cc b/src/spectrum/model/wifi-spectrum-value-helper.cc index 1768b6185..a4e3267f4 100644 --- a/src/spectrum/model/wifi-spectrum-value-helper.cc +++ b/src/spectrum/model/wifi-spectrum-value-helper.cc @@ -23,7 +23,7 @@ namespace ns3 { - + Ptr 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 (bands); @@ -54,18 +54,18 @@ public: -Ptr +Ptr WifiSpectrumValue5MhzFactory::CreateConstant (double v) -{ +{ Ptr c = Create (g_WifiSpectrumModel5Mhz); (*c) = v; return c; } -Ptr +Ptr WifiSpectrumValue5MhzFactory::CreateTxPowerSpectralDensity (double txPower, uint32_t channel) -{ +{ Ptr txPsd = Create (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 +Ptr WifiSpectrumValue5MhzFactory::CreateRfFilter (uint32_t channel) -{ +{ Ptr rf = Create (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; diff --git a/src/spectrum/model/wifi-spectrum-value-helper.h b/src/spectrum/model/wifi-spectrum-value-helper.h index 51cd0e4dd..31f9d7b36 100644 --- a/src/spectrum/model/wifi-spectrum-value-helper.h +++ b/src/spectrum/model/wifi-spectrum-value-helper.h @@ -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 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 diff --git a/src/spectrum/test/spectrum-interference-test.cc b/src/spectrum/test/spectrum-interference-test.cc index b12c6d6ce..7d592c74f 100644 --- a/src/spectrum/test/spectrum-interference-test.cc +++ b/src/spectrum/test/spectrum-interference-test.cc @@ -175,7 +175,7 @@ SpectrumInterferenceTestSuite::SpectrumInterferenceTestSuite () AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast (b * 0.5 + 0.5), true, "sdBm = [-46 -48] tx bytes: b*0.5")); AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast (b * (1 - e) + 0.5), true, "sdBm = [-46 -48] tx bytes: b*(1-e)")); AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast (b * (1 + e) + 0.5), false, "sdBm = [-46 -48] tx bytes: b*(1+e)")); - AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast(b * 1.5 + 0.5), false, "sdBm = [-46 -48] tx bytes: b*1.5")); + AddTestCase (new SpectrumInterferenceTestCase (s1, static_cast (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; diff --git a/src/spectrum/test/spectrum-test.h b/src/spectrum/test/spectrum-test.h index aab736c0b..d2033b8da 100644 --- a/src/spectrum/test/spectrum-test.h +++ b/src/spectrum/test/spectrum-test.h @@ -17,99 +17,99 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Author: Nicola Baldo - * part of the code copied from test.h + * part of the code copied from test.h */ #include #include -/** +/** * \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); \ - +