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