wifi: Check style of previous commit

This commit is contained in:
Sébastien Deronne
2018-03-04 11:15:47 +01:00
parent a7eb13a278
commit 2bbbf098f6
4 changed files with 62 additions and 63 deletions

View File

@@ -42,7 +42,7 @@ struct WifiSpectrumModelId
* \param w the channel width (in MHz)
* \param b the width of each band (in Hz)
* \param g the guard band width (in MHz)
*/
*/
WifiSpectrumModelId (uint32_t f, uint8_t w, double b, uint8_t g);
uint32_t m_centerFrequency; ///< center frequency (in MHz)
uint8_t m_channelWidth; ///< channel width (in MHz)
@@ -64,20 +64,20 @@ WifiSpectrumModelId::WifiSpectrumModelId (uint32_t f, uint8_t w, double b, uint8
* \param a the first wifi spectrum to compare
* \param b the second wifi spectrum to compare
* \returns true if the first spectrum is less than the second spectrum
*/
*/
bool
operator < (const WifiSpectrumModelId& a, const WifiSpectrumModelId& b)
{
return ( (a.m_centerFrequency < b.m_centerFrequency)
|| ((a.m_centerFrequency == b.m_centerFrequency) &&
(a.m_channelWidth < b.m_channelWidth))
|| ((a.m_centerFrequency == b.m_centerFrequency) &&
(a.m_channelWidth == b.m_channelWidth) &&
(a.m_bandBandwidth < b.m_bandBandwidth)) // to cover coexistence of 11ax with legacy case
|| ((a.m_centerFrequency == b.m_centerFrequency) &&
(a.m_channelWidth == b.m_channelWidth) &&
(a.m_bandBandwidth == b.m_bandBandwidth) &&
(a.m_guardBandwidth < b.m_guardBandwidth))); // to cover 2.4 GHz case, where DSSS coexists with OFDM
|| ((a.m_centerFrequency == b.m_centerFrequency)
&& (a.m_channelWidth < b.m_channelWidth))
|| ((a.m_centerFrequency == b.m_centerFrequency)
&& (a.m_channelWidth == b.m_channelWidth)
&& (a.m_bandBandwidth < b.m_bandBandwidth)) // to cover coexistence of 11ax with legacy case
|| ((a.m_centerFrequency == b.m_centerFrequency)
&& (a.m_channelWidth == b.m_channelWidth)
&& (a.m_bandBandwidth == b.m_bandBandwidth)
&& (a.m_guardBandwidth < b.m_guardBandwidth))); // to cover 2.4 GHz case, where DSSS coexists with OFDM
}
static std::map<WifiSpectrumModelId, Ptr<SpectrumModel> > g_wifiSpectrumModelMap; ///< static initializer for the class
@@ -105,21 +105,21 @@ WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint8_t cha
{
// round up to the nearest odd number of subbands so that bands
// are symmetric around center frequency
numBands += 1;
numBands += 1;
}
NS_ASSERT_MSG (numBands % 2 == 1, "Number of bands should be odd");
NS_LOG_DEBUG ("Num bands " << numBands << " band bandwidth " << bandBandwidth);
// lay down numBands/2 bands symmetrically around center frequency
// and place an additional band at center frequency
double startingFrequencyHz = centerFrequencyHz - (numBands/2 * bandBandwidth) - bandBandwidth/2;
for (size_t i = 0; i < numBands; i++)
double startingFrequencyHz = centerFrequencyHz - (numBands / 2 * bandBandwidth) - bandBandwidth / 2;
for (size_t i = 0; i < numBands; i++)
{
BandInfo info;
double f = startingFrequencyHz + (i * bandBandwidth);
info.fl = f;
f += bandBandwidth/2;
f += bandBandwidth / 2;
info.fc = f;
f += bandBandwidth/2;
f += bandBandwidth / 2;
info.fh = f;
NS_LOG_DEBUG ("creating band " << i << " (" << info.fl << ":" << info.fc << ":" << info.fh << ")");
bands.push_back (info);
@@ -131,7 +131,7 @@ WifiSpectrumValueHelper::GetSpectrumModel (uint32_t centerFrequency, uint8_t cha
return ret;
}
// Power allocated to 71 center subbands out of 135 total subbands in the band
// Power allocated to 71 center subbands out of 135 total subbands in the band
Ptr<SpectrumValue>
WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW, uint8_t guardBandwidth)
{
@@ -141,8 +141,8 @@ WifiSpectrumValueHelper::CreateDsssTxPowerSpectralDensity (uint32_t centerFreque
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
Values::iterator vit = c->ValuesBegin ();
Bands::const_iterator bit = c->ConstBandsBegin ();
uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nGuardBands = static_cast<uint32_t> (((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t> (((channelWidth * 1e6) / bandBandwidth) + 0.5);
NS_ASSERT (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1));
// Evenly spread power across 22 MHz
double txPowerPerBand = txPowerW / nAllocatedBands;
@@ -166,15 +166,15 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque
{
case 20:
bandBandwidth = 312500;
innerSlopeWidth = static_cast<uint32_t>((2e6 / bandBandwidth) + 0.5); // [-11;-9] & [9;11]
innerSlopeWidth = static_cast<uint32_t> ((2e6 / bandBandwidth) + 0.5); // [-11;-9] & [9;11]
break;
case 10:
bandBandwidth = 156250;
innerSlopeWidth = static_cast<uint32_t>((1e6 / bandBandwidth) + 0.5); // [-5.5;-4.5] & [4.5;5.5]
innerSlopeWidth = static_cast<uint32_t> ((1e6 / bandBandwidth) + 0.5); // [-5.5;-4.5] & [4.5;5.5]
break;
case 5:
bandBandwidth = 78125;
innerSlopeWidth = static_cast<uint32_t>((5e5 / bandBandwidth) + 0.5); // [-2.75;-2.5] & [2.5;2.75]
innerSlopeWidth = static_cast<uint32_t> ((5e5 / bandBandwidth) + 0.5); // [-2.75;-2.5] & [2.5;2.75]
break;
default:
NS_FATAL_ERROR ("Channel width " << +channelWidth << " should be correctly set.");
@@ -182,8 +182,8 @@ WifiSpectrumValueHelper::CreateOfdmTxPowerSpectralDensity (uint32_t centerFreque
}
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nGuardBands = static_cast<uint32_t> (((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t> (((channelWidth * 1e6) / bandBandwidth) + 0.5);
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ());
// 52 subcarriers (48 data + 4 pilot)
// skip guard band and 6 subbands, then place power in 26 subbands, then
@@ -215,8 +215,8 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq
NS_LOG_FUNCTION (centerFrequency << +channelWidth << txPowerW << +guardBandwidth);
double bandBandwidth = 312500;
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nGuardBands = static_cast<uint32_t> (((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t> (((channelWidth * 1e6) / bandBandwidth) + 0.5);
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ());
double txPowerPerBandW = 0.0;
// skip the guard band and 4 subbands, then place power in 28 subbands, then
@@ -256,10 +256,10 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq
uint32_t start16 = stop15 + 2;
uint32_t stop16 = start16 + 28 - 1;
//Prepare spectrum mask specific variables
uint32_t innerSlopeWidth = static_cast<uint32_t>((2e6 / bandBandwidth) + 0.5); //size in number of subcarriers of the 0dBr<->20dBr slope (2MHz for HT/VHT)
uint32_t innerSlopeWidth = static_cast<uint32_t> ((2e6 / bandBandwidth) + 0.5); //size in number of subcarriers of the 0dBr<->20dBr slope (2MHz for HT/VHT)
double lowestPointDbr = (centerFrequency >= 5000) ?
-40.0 : //if 5 GHz band
-45.0; //if 2.4 GHz band
-40.0 : //if 5 GHz band
-45.0; //if 2.4 GHz band
std::vector <StartStop> subBands; //list of data/pilot-containing subBands (sent at 0dBr)
StartStop maskBand (0, nAllocatedBands + nGuardBands);
switch (channelWidth)
@@ -271,7 +271,7 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq
subBands.push_back (std::make_pair (start2, stop2));
break;
case 40:
// 112 subcarriers (104 data + 8 pilot)
// 112 subcarriers (104 data + 8 pilot)
// possible alternative: 114 subcarriers (108 data + 6 pilot)
txPowerPerBandW = txPowerW / 112;
subBands.push_back (std::make_pair (start1, stop1));
@@ -280,7 +280,7 @@ WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFreq
subBands.push_back (std::make_pair (start4, stop4));
break;
case 80:
// 224 subcarriers (208 data + 16 pilot)
// 224 subcarriers (208 data + 16 pilot)
// possible alternative: 242 subcarriers (234 data + 8 pilot)
txPowerPerBandW = txPowerW / 224;
NS_ASSERT (lowestPointDbr == -40.0);
@@ -332,8 +332,8 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq
NS_LOG_FUNCTION (centerFrequency << +channelWidth << txPowerW << +guardBandwidth);
double bandBandwidth = 78125;
Ptr<SpectrumValue> c = Create<SpectrumValue> (GetSpectrumModel (centerFrequency, channelWidth, bandBandwidth, guardBandwidth));
uint32_t nGuardBands = static_cast<uint32_t>(((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t>(((channelWidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nGuardBands = static_cast<uint32_t> (((2 * guardBandwidth * 1e6) / bandBandwidth) + 0.5);
uint32_t nAllocatedBands = static_cast<uint32_t> (((channelWidth * 1e6) / bandBandwidth) + 0.5);
NS_ASSERT_MSG (c->GetSpectrumModel ()->GetNumBands () == (nAllocatedBands + nGuardBands + 1), "Unexpected number of bands " << c->GetSpectrumModel ()->GetNumBands ());
double txPowerPerBandW = 0.0;
uint32_t start1;
@@ -345,10 +345,10 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq
uint32_t start4;
uint32_t stop4;
//Prepare spectrum mask specific variables
uint32_t innerSlopeWidth = static_cast<uint32_t>((1e6 / bandBandwidth) + 0.5); //size in number of subcarriers of the 0dBr<->20dBr slope
uint32_t innerSlopeWidth = static_cast<uint32_t> ((1e6 / bandBandwidth) + 0.5); //size in number of subcarriers of the 0dBr<->20dBr slope
double lowestPointDbr = (centerFrequency >= 5000) ?
-40.0 : //if 5 GHz band
-45.0; //if 2.4 GHz band
-40.0 : //if 5 GHz band
-45.0; //if 2.4 GHz band
std::vector <StartStop> subBands; //list of data/pilot-containing subBands (sent at 0dBr)
StartStop maskBand (0, nAllocatedBands + nGuardBands);
switch (channelWidth)
@@ -356,7 +356,7 @@ WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (uint32_t centerFreq
case 20:
// 242 subcarriers (234 data + 8 pilot)
txPowerPerBandW = txPowerW / 242;
innerSlopeWidth = static_cast<uint32_t>((5e5 / bandBandwidth) + 0.5); // [-10.25;-9.75] & [9.75;10.25]
innerSlopeWidth = static_cast<uint32_t> ((5e5 / bandBandwidth) + 0.5); // [-10.25;-9.75] & [9.75;10.25]
// skip the guard band and 6 subbands, then place power in 121 subbands, then
// skip 3 DC, then place power in 121 subbands, then skip
// the final 6 subbands and the guard band.
@@ -457,7 +457,7 @@ WifiSpectrumValueHelper::CreateRfFilter (uint32_t centerFrequency, uint8_t chann
Bands::const_iterator bit = c->ConstBandsBegin ();
Values::iterator vit = c->ValuesBegin ();
uint32_t bandBandwidth = static_cast<uint32_t> (bandGranularity);
size_t numBandsInFilter = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth);
size_t numBandsInFilter = static_cast<size_t> (channelWidth * 1e6 / bandBandwidth);
if (channelWidth % bandBandwidth != 0)
{
numBandsInFilter += 1;
@@ -523,9 +523,9 @@ WifiSpectrumValueHelper::CreateSpectrumMaskForOfdm (Ptr<SpectrumValue> c, std::v
"middleBandRight=[" << middleBandRight.first << ";" << middleBandRight.second << "] " <<
"outerBandRight=[" << outerBandRight.first << ";" << outerBandRight.second << "] ");
NS_ASSERT (numMaskBands == ((allocatedSubBands.back ().second - allocatedSubBands.front ().first + 1) //equivalent to allocatedBand (includes notches and DC)
+ 2 * (innerSlopeWidth + middleSlopeWidth + outerSlopeWidth)
+ (flatJunctionLeft.second - flatJunctionLeft.first + 1) //flat junctions
+ (flatJunctionRight.second - flatJunctionRight.first + 1)));
+ 2 * (innerSlopeWidth + middleSlopeWidth + outerSlopeWidth)
+ (flatJunctionLeft.second - flatJunctionLeft.first + 1) //flat junctions
+ (flatJunctionRight.second - flatJunctionRight.first + 1)));
//Different slopes
double innerSlope = 20.0 / innerSlopeWidth; //0 to 20dBr
@@ -595,7 +595,7 @@ WifiSpectrumValueHelper::CreateSpectrumMaskForOfdm (Ptr<SpectrumValue> c, std::v
NS_FATAL_ERROR ("Should have handled all cases");
}
double txPowerDbr = 10 * std::log10 (txPowerW / txPowerPerBandW);
NS_LOG_LOGIC (uint32_t(i) << " -> " << txPowerDbr);
NS_LOG_LOGIC (uint32_t (i) << " -> " << txPowerDbr);
*vit = txPowerW / (bit->fh - bit->fl);
}
NS_LOG_INFO ("Added signal power to subbands " << allocatedSubBands.front ().first << "-" << allocatedSubBands.back ().second);

View File

@@ -31,7 +31,7 @@ namespace ns3 {
/**
* \ingroup spectrum
*
* This class defines all functions to create a spectrum model for
* This class defines all functions to create a spectrum model for
* Wi-Fi based on a a spectral model aligned with an OFDM subcarrier
* spacing of 312.5 KHz (model also reused for DSSS modulations)
*/
@@ -42,11 +42,11 @@ public:
* Destructor
*/
virtual ~WifiSpectrumValueHelper ();
/**
* Return a SpectrumModel instance corresponding to the center frequency
* and channel width. The spectrum model spans the channel width
* +/- the guard bands (i.e. the model will span (channelWidth +
* and channel width. The spectrum model spans the channel width
* +/- the guard bands (i.e. the model will span (channelWidth +
* 2 * guardBandwidth) MHz of bandwidth).
*
* \param centerFrequency center frequency (MHz)
@@ -55,14 +55,14 @@ public:
* \param guardBandwidth width of the guard band (MHz)
*
* \return the static SpectrumModel instance corresponding to the
* given carrier frequency and channel width configuration.
* given carrier frequency and channel width configuration.
*/
static Ptr<SpectrumModel> GetSpectrumModel (uint32_t centerFrequency, uint8_t channelWidth, double bandBandwidth, uint8_t guardBandwidth);
/**
* Create a transmit power spectral density corresponding to DSSS
* Create a transmit power spectral density corresponding to DSSS
*
* The center frequency typically corresponds to 802.11b channel
* The center frequency typically corresponds to 802.11b channel
* center frequencies but is not restricted to those frequencies.
*
* \note There is no channel width parameter; this method assumes 22 MHz
@@ -75,7 +75,7 @@ public:
static Ptr<SpectrumValue> CreateDsssTxPowerSpectralDensity (uint32_t centerFrequency, double txPowerW, uint8_t guardBandwidth);
/**
* Create a transmit power spectral density corresponding to OFDM
* Create a transmit power spectral density corresponding to OFDM
* (802.11a/g). Channel width may vary between 20, 10, and 5 MHz.
* Guard bandwidth also typically varies with channel width.
*
@@ -88,8 +88,8 @@ public:
static Ptr<SpectrumValue> CreateOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth);
/**
* Create a transmit power spectral density corresponding to OFDM
* High Throughput (HT) (802.11n/ac). Channel width may vary between
* Create a transmit power spectral density corresponding to OFDM
* High Throughput (HT) (802.11n/ac). Channel width may vary between
* 20, 40, 80, and 160 MHz.
*
* \param centerFrequency center frequency (MHz)
@@ -101,8 +101,8 @@ public:
static Ptr<SpectrumValue> CreateHtOfdmTxPowerSpectralDensity (uint32_t centerFrequency, uint8_t channelWidth, double txPowerW, uint8_t guardBandwidth);
/**
* Create a transmit power spectral density corresponding to OFDM
* High Efficiency (HE) (802.11ax). Channel width may vary between
* Create a transmit power spectral density corresponding to OFDM
* High Efficiency (HE) (802.11ax). Channel width may vary between
* 20, 40, 80, and 160 MHz.
*
* \param centerFrequency center frequency (MHz)
@@ -235,7 +235,7 @@ public:
*/
virtual Ptr<SpectrumValue> CreateConstant (double psd);
/**
* Creates a SpectrumValue instance that represents the TX Power Spectral
* Creates a SpectrumValue instance that represents the TX Power Spectral
* Density of a wifi device corresponding to the provided parameters
*
* Since the spectrum model has a resolution of 5 MHz, we model

View File

@@ -55,7 +55,7 @@ int main (int argc, char** argv)
cmd.AddValue ("txPower", "Transmit power (dBm)", pow);
cmd.AddValue ("verbose", "Display log messages for WifiSpectrumValueHelper and SpectrumWifiPhy", verbose);
cmd.Parse (argc,argv);
WifiHelper wifi;
Ssid ssid;
std::string dataRate;
@@ -190,7 +190,7 @@ int main (int argc, char** argv)
// FriisSpectrumPropagationLossModel already added by default in SpectrumChannelHelper
channelHelper.AddSpectrumPropagationLoss ("ns3::ConstantSpectrumPropagationLossModel");
Ptr<SpectrumChannel> channel = channelHelper.Create ();
/* Wi-Fi transmitter setup */
SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default ();

View File

@@ -39,7 +39,6 @@ NS_LOG_COMPONENT_DEFINE ("WifiTransmitMaskTest");
class WifiOfdmMaskSlopesTestCase : public TestCase
{
public:
/**
* typedef for a pair of sub-band index and relative power value (dBr)
*/
@@ -115,7 +114,7 @@ WifiOfdmMaskSlopesTestCase::WifiOfdmMaskSlopesTestCase (const char* str, WifiPhy
// 11g and 11a
case WIFI_PHY_STANDARD_80211g:
freq = 2412;
// no break on purpose
// no break on purpose
case WIFI_PHY_STANDARD_80211a:
case WIFI_PHY_STANDARD_holland:
NS_ASSERT (bw == 20);
@@ -125,7 +124,7 @@ WifiOfdmMaskSlopesTestCase::WifiOfdmMaskSlopesTestCase (const char* str, WifiPhy
// 11n
case WIFI_PHY_STANDARD_80211n_2_4GHZ:
freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
// no break on purpose
// no break on purpose
case WIFI_PHY_STANDARD_80211n_5GHZ:
NS_ASSERT (bw == 20 || bw == 40);
m_actualSpectrum = WifiSpectrumValueHelper::CreateHtOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
@@ -141,7 +140,7 @@ WifiOfdmMaskSlopesTestCase::WifiOfdmMaskSlopesTestCase (const char* str, WifiPhy
case WIFI_PHY_STANDARD_80211ax_2_4GHZ:
NS_ASSERT (bw != 160); // not enough space in 2.4 GHz bands
freq = 2402 + (bw / 2); //so as to have 2412/2422 for 20/40
// no break on purpose
// no break on purpose
case WIFI_PHY_STANDARD_80211ax_5GHZ:
NS_ASSERT (bw == 20 || bw == 40 || bw == 80 || bw == 160);
m_actualSpectrum = WifiSpectrumValueHelper::CreateHeOfdmTxPowerSpectralDensity (freq, bw, refTxPowerW, bw);
@@ -196,10 +195,10 @@ WifiOfdmMaskSlopesTestCase::InterpolateAndAppendValues (IndexPowerVect &vect, In
NS_LOG_LOGIC ("Append (" << i << ", " << val << ")");
}
NS_ASSERT (vect.back ().first == stop.first
&& TestDoubleIsEqual(vect.back ().second, stop.second, tol));
&& TestDoubleIsEqual (vect.back ().second, stop.second, tol));
}
void
void
WifiOfdmMaskSlopesTestCase::DoRun (void)
{
NS_LOG_FUNCTION (this);