LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2005,2006 INRIA | 3 * Copyright (c) 2005,2006 INRIA |
4 * 2010 NICTA | 4 * 2010 NICTA |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "ns3/yans-error-rate-model.h" | 30 #include "ns3/yans-error-rate-model.h" |
31 #include "ns3/constant-position-mobility-model.h" | 31 #include "ns3/constant-position-mobility-model.h" |
32 #include "ns3/test.h" | 32 #include "ns3/test.h" |
33 #include "ns3/pointer.h" | 33 #include "ns3/pointer.h" |
34 #include "ns3/rng-seed-manager.h" | 34 #include "ns3/rng-seed-manager.h" |
35 #include "ns3/config.h" | 35 #include "ns3/config.h" |
36 #include "ns3/string.h" | 36 #include "ns3/string.h" |
37 #include "ns3/packet-socket-server.h" | 37 #include "ns3/packet-socket-server.h" |
38 #include "ns3/packet-socket-client.h" | 38 #include "ns3/packet-socket-client.h" |
39 #include "ns3/packet-socket-helper.h" | 39 #include "ns3/packet-socket-helper.h" |
| 40 #include "ns3/spectrum-wifi-helper.h" |
| 41 #include "ns3/spectrum-value.h" |
| 42 #include "ns3/multi-model-spectrum-channel.h" |
| 43 #include "ns3/wifi-spectrum-signal-parameters.h" |
| 44 #include "ns3/wifi-phy-tag.h" |
| 45 #include <tuple> |
| 46 #include <vector> |
40 | 47 |
41 using namespace ns3; | 48 using namespace ns3; |
42 | 49 |
43 //Helper function to assign streams to random variables, to control | 50 //Helper function to assign streams to random variables, to control |
44 //randomness in the tests | 51 //randomness in the tests |
45 static void | 52 static void |
46 AssignWifiRandomStreams (Ptr<WifiMac> mac, int64_t stream) | 53 AssignWifiRandomStreams (Ptr<WifiMac> mac, int64_t stream) |
47 { | 54 { |
48 int64_t currentStream = stream; | 55 int64_t currentStream = stream; |
49 Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac); | 56 Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac); |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 | 1156 |
1150 Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFaile
d", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this)); | 1157 Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFaile
d", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this)); |
1151 | 1158 |
1152 Simulator::Stop (Seconds (2.0)); | 1159 Simulator::Stop (Seconds (2.0)); |
1153 Simulator::Run (); | 1160 Simulator::Run (); |
1154 Simulator::Destroy (); | 1161 Simulator::Destroy (); |
1155 | 1162 |
1156 NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of int
ernal collisions!"); | 1163 NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of int
ernal collisions!"); |
1157 } | 1164 } |
1158 | 1165 |
| 1166 //----------------------------------------------------------------------------- |
| 1167 /** |
| 1168 * Make sure that the correct channel width and center frequency have been set |
| 1169 * for OFDM basic rate transmissions and BSS channel widths larger than 20 MHz. |
| 1170 * |
| 1171 * The scenario considers a UDP transmission between a 40 MHz 802.11ac station a
nd a |
| 1172 * 40 MHz 802.11ac access point. All transmission parameters are checked so as |
| 1173 * to ensure that only 2 {starting frequency, channelWidth, Number of subbands |
| 1174 * in SpectrumModel, modulation type} tuples are used. |
| 1175 * |
| 1176 * See \bugid{2483} |
| 1177 */ |
| 1178 |
| 1179 class Bug2483TestCase : public TestCase |
| 1180 { |
| 1181 public: |
| 1182 Bug2483TestCase (); |
| 1183 virtual ~Bug2483TestCase (); |
| 1184 virtual void DoRun (void); |
| 1185 |
| 1186 private: |
| 1187 /** |
| 1188 * A tuple of {starting frequency, channelWidth, Number of subbands in Spectru
mModel, modulation type} |
| 1189 */ |
| 1190 typedef std::tuple<double, uint8_t, size_t, WifiModulationClass> FreqWidthSubb
andModulationTuple; |
| 1191 std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples; ///< vector of
distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,
modulation type} tuples |
| 1192 |
| 1193 /** |
| 1194 * Stores the distinct {starting frequency, channelWidth, Number of subbands i
n SpectrumModel, modulation type} tuples |
| 1195 * that have been used during the testcase run. |
| 1196 * \param context the context |
| 1197 * \param txParams spectrum signal parameters set by transmitter |
| 1198 */ |
| 1199 void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> tx
Params); |
| 1200 /** |
| 1201 * Triggers the arrival of a burst of 1000 Byte-long packets in the source dev
ice |
| 1202 * \param numPackets number of packets in burst (maximum: 255) |
| 1203 * \param sourceDevice pointer to the source NetDevice |
| 1204 * \param destination address of the destination device |
| 1205 */ |
| 1206 void SendPacketBurst (unsigned int numPackets, Ptr<NetDevice> sourceDevice, Ad
dress& destination) const; |
| 1207 }; |
| 1208 |
| 1209 Bug2483TestCase::Bug2483TestCase () |
| 1210 : TestCase ("Test case for Bug 2483") |
| 1211 { |
| 1212 } |
| 1213 |
| 1214 Bug2483TestCase::~Bug2483TestCase () |
| 1215 { |
| 1216 } |
| 1217 |
| 1218 void |
| 1219 Bug2483TestCase::StoreDistinctTuple (std::string context, Ptr<SpectrumSignalPar
ameters> txParams) |
| 1220 { |
| 1221 // Extract starting frequency and number of subbands |
| 1222 Ptr<const SpectrumModel> c = txParams->psd->GetSpectrumModel (); |
| 1223 std::size_t numBands = c->GetNumBands (); |
| 1224 double startingFreq = c->Begin ()->fl; |
| 1225 |
| 1226 // Get channel bandwidth and modulation class |
| 1227 Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectru
mSignalParameters> (txParams); |
| 1228 Ptr<Packet> packet = wifiTxParams->packet->Copy (); |
| 1229 WifiPhyTag tag; |
| 1230 if (!packet->RemovePacketTag (tag)) |
| 1231 { |
| 1232 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); |
| 1233 return; |
| 1234 } |
| 1235 WifiTxVector txVector = tag.GetWifiTxVector (); |
| 1236 uint8_t channelWidth = txVector.GetChannelWidth (); |
| 1237 WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass (
); |
| 1238 |
| 1239 // Build a tuple and check if seen before (if so store it) |
| 1240 FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingF
req, channelWidth, |
| 1241 numBands,
modulationClass); |
| 1242 bool found = false; |
| 1243 for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_disti
nctTuples.begin (); it != m_distinctTuples.end (); it++) |
| 1244 { |
| 1245 if (*it == tupleForCurrentTx) |
| 1246 { |
| 1247 found = true; |
| 1248 } |
| 1249 } |
| 1250 if (!found) |
| 1251 { |
| 1252 m_distinctTuples.push_back (tupleForCurrentTx); |
| 1253 } |
| 1254 } |
| 1255 |
| 1256 void |
| 1257 Bug2483TestCase::SendPacketBurst (unsigned int numPackets, Ptr<NetDevice> source
Device, |
| 1258 Address& destination) const |
| 1259 { |
| 1260 for (uint16_t i = 0; i < numPackets; i++) |
| 1261 { |
| 1262 Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data |
| 1263 sourceDevice->Send (pkt, destination, 0); |
| 1264 } |
| 1265 } |
| 1266 |
| 1267 void |
| 1268 Bug2483TestCase::DoRun (void) |
| 1269 { |
| 1270 Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringVa
lue ("500")); // so as to force RTS/CTS for data frames |
| 1271 Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0)); |
| 1272 |
| 1273 uint8_t channelWidth = 40; // at least 40 MHz expected here |
| 1274 |
| 1275 NodeContainer wifiStaNode; |
| 1276 wifiStaNode.Create (1); |
| 1277 |
| 1278 NodeContainer wifiApNode; |
| 1279 wifiApNode.Create (1); |
| 1280 |
| 1281 SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default (); |
| 1282 Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectr
umChannel> (); |
| 1283 Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossMo
del> (); |
| 1284 lossModel->SetFrequency (5.180e9); |
| 1285 spectrumChannel->AddPropagationLossModel (lossModel); |
| 1286 |
| 1287 Ptr<ConstantSpeedPropagationDelayModel> delayModel |
| 1288 = CreateObject<ConstantSpeedPropagationDelayModel> (); |
| 1289 spectrumChannel->SetPropagationDelayModel (delayModel); |
| 1290 |
| 1291 spectrumPhy.SetChannel (spectrumChannel); |
| 1292 spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel"); |
| 1293 spectrumPhy.Set ("Frequency", UintegerValue (5180)); |
| 1294 spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth)); |
| 1295 spectrumPhy.Set ("TxPowerStart", DoubleValue (10)); |
| 1296 spectrumPhy.Set ("TxPowerEnd", DoubleValue (10)); |
| 1297 |
| 1298 WifiHelper wifi; |
| 1299 wifi.SetStandard (WIFI_PHY_STANDARD_80211ac); |
| 1300 wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", |
| 1301 "DataMode", StringValue ("VhtMcs8"), |
| 1302 "ControlMode", StringValue ("VhtMcs8")); |
| 1303 |
| 1304 WifiMacHelper mac; |
| 1305 mac.SetType ("ns3::StaWifiMac"); |
| 1306 NetDeviceContainer staDevice; |
| 1307 staDevice = wifi.Install (spectrumPhy, mac, wifiStaNode); |
| 1308 |
| 1309 mac.SetType ("ns3::ApWifiMac"); |
| 1310 NetDeviceContainer apDevice; |
| 1311 apDevice = wifi.Install (spectrumPhy, mac, wifiApNode); |
| 1312 |
| 1313 MobilityHelper mobility; |
| 1314 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>
(); |
| 1315 positionAlloc->Add (Vector (0.0, 0.0, 0.0)); |
| 1316 positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to u
se MCS |
| 1317 mobility.SetPositionAllocator (positionAlloc); |
| 1318 |
| 1319 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
| 1320 mobility.Install (wifiApNode); |
| 1321 mobility.Install (wifiStaNode); |
| 1322 |
| 1323 // Send two 5 packet-bursts |
| 1324 Simulator::Schedule (Seconds (0.5), &Bug2483TestCase::SendPacketBurst, this, 5
U, apDevice.Get (0), staDevice.Get (0)->GetAddress ()); |
| 1325 Simulator::Schedule (Seconds (0.6), &Bug2483TestCase::SendPacketBurst, this, 5
U, apDevice.Get (0), staDevice.Get (0)->GetAddress ()); |
| 1326 |
| 1327 Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams",
MakeCallback (&Bug2483TestCase::StoreDistinctTuple, this)); |
| 1328 |
| 1329 Simulator::Stop (Seconds (0.8)); |
| 1330 Simulator::Run (); |
| 1331 |
| 1332 Simulator::Destroy (); |
| 1333 |
| 1334 // {starting frequency, channelWidth, Number of subbands in SpectrumModel, mod
ulation type} tuples |
| 1335 std::size_t numberTuples = m_distinctTuples.size (); |
| 1336 NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected"); |
| 1337 NS_TEST_ASSERT_MSG_EQ (std::get<0> (m_distinctTuples[0]), std::get<0> (m_disti
nctTuples[1]), "Both tuples should have same starting frequency"); |
| 1338 // Note that the first tuple should the one initiated by the beacon, i.e. lega
cy OFDM (20 MHz) |
| 1339 NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[0]), 20, "First tuple's c
hannel width should be 20 MHz"); |
| 1340 NS_TEST_ASSERT_MSG_EQ (std::get<2> (m_distinctTuples[0]), 129, "First tuple sh
ould have 129 subbands (64+DC, 20MHz+DC, inband and 32*2 out-of-band, 10MHz on e
ach side)"); |
| 1341 NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass:
:WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM"); |
| 1342 // Second tuple |
| 1343 NS_TEST_ASSERT_MSG_EQ (std::get<1> (m_distinctTuples[1]), channelWidth, "Secon
d tuple's channel width should be 40 MHz"); |
| 1344 NS_TEST_ASSERT_MSG_EQ (std::get<2> (m_distinctTuples[1]), 193, "Second tuple s
hould have 193 subbands (128+DC, 40MHz+DC, inband and 32*2 out-of-band, 10MHz on
each side)"); |
| 1345 NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass:
:WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM"); |
| 1346 } |
| 1347 |
1159 /** | 1348 /** |
1160 * \ingroup wifi-test | 1349 * \ingroup wifi-test |
1161 * \ingroup tests | 1350 * \ingroup tests |
1162 * | 1351 * |
1163 * \brief Wifi Test Suite | 1352 * \brief Wifi Test Suite |
1164 */ | 1353 */ |
1165 class WifiTestSuite : public TestSuite | 1354 class WifiTestSuite : public TestSuite |
1166 { | 1355 { |
1167 public: | 1356 public: |
1168 WifiTestSuite (); | 1357 WifiTestSuite (); |
1169 }; | 1358 }; |
1170 | 1359 |
1171 WifiTestSuite::WifiTestSuite () | 1360 WifiTestSuite::WifiTestSuite () |
1172 : TestSuite ("devices-wifi", UNIT) | 1361 : TestSuite ("devices-wifi", UNIT) |
1173 { | 1362 { |
1174 AddTestCase (new WifiTest, TestCase::QUICK); | 1363 AddTestCase (new WifiTest, TestCase::QUICK); |
1175 AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK); | 1364 AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK); |
1176 AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 | 1365 AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 |
1177 AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK); | 1366 AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK); |
1178 AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 | 1367 AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 |
1179 AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK); | 1368 AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK); |
1180 AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222 | 1369 AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222 |
| 1370 AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483 |
1181 } | 1371 } |
1182 | 1372 |
1183 static WifiTestSuite g_wifiTestSuite; ///< the test suite | 1373 static WifiTestSuite g_wifiTestSuite; ///< the test suite |
LEFT | RIGHT |