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, |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 * GNU General Public License for more details. | 13 * GNU General Public License for more details. |
14 * | 14 * |
15 * You should have received a copy of the GNU General Public License | 15 * You should have received a copy of the GNU General Public License |
16 * along with this program; if not, write to the Free Software | 16 * along with this program; if not, write to the Free Software |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 * | 18 * |
19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> | 19 * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
20 * Quincy Tse <quincy.tse@nicta.com.au> | 20 * Quincy Tse <quincy.tse@nicta.com.au> |
21 * Sébastien Deronne <sebastien.deronne@gmail.com> | 21 * Sébastien Deronne <sebastien.deronne@gmail.com> |
22 */ | 22 */ |
23 | 23 |
| 24 #include "ns3/string.h" |
24 #include "ns3/yans-wifi-helper.h" | 25 #include "ns3/yans-wifi-helper.h" |
25 #include "ns3/mobility-helper.h" | 26 #include "ns3/mobility-helper.h" |
26 #include "ns3/wifi-net-device.h" | 27 #include "ns3/wifi-net-device.h" |
27 #include "ns3/adhoc-wifi-mac.h" | 28 #include "ns3/adhoc-wifi-mac.h" |
28 #include "ns3/propagation-delay-model.h" | |
29 #include "ns3/propagation-loss-model.h" | 29 #include "ns3/propagation-loss-model.h" |
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" | |
37 #include "ns3/packet-socket-server.h" | 36 #include "ns3/packet-socket-server.h" |
38 #include "ns3/packet-socket-client.h" | 37 #include "ns3/packet-socket-client.h" |
39 #include "ns3/packet-socket-helper.h" | 38 #include "ns3/packet-socket-helper.h" |
40 #include "ns3/spectrum-wifi-helper.h" | 39 #include "ns3/spectrum-wifi-helper.h" |
41 #include "ns3/spectrum-value.h" | |
42 #include "ns3/multi-model-spectrum-channel.h" | 40 #include "ns3/multi-model-spectrum-channel.h" |
43 #include "ns3/wifi-spectrum-signal-parameters.h" | 41 #include "ns3/wifi-spectrum-signal-parameters.h" |
44 #include "ns3/wifi-phy-tag.h" | 42 #include "ns3/wifi-phy-tag.h" |
45 #include <tuple> | 43 #include "ns3/yans-wifi-phy.h" |
46 #include <vector> | 44 #include "ns3/mgt-headers.h" |
47 | 45 |
48 using namespace ns3; | 46 using namespace ns3; |
49 | 47 |
50 //Helper function to assign streams to random variables, to control | 48 //Helper function to assign streams to random variables, to control |
51 //randomness in the tests | 49 //randomness in the tests |
52 static void | 50 static void |
53 AssignWifiRandomStreams (Ptr<WifiMac> mac, int64_t stream) | 51 AssignWifiRandomStreams (Ptr<WifiMac> mac, int64_t stream) |
54 { | 52 { |
55 int64_t currentStream = stream; | 53 int64_t currentStream = stream; |
56 Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac); | 54 Ptr<RegularWifiMac> rmac = DynamicCast<RegularWifiMac> (mac); |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 { | 581 { |
584 } | 582 } |
585 | 583 |
586 Bug730TestCase::~Bug730TestCase () | 584 Bug730TestCase::~Bug730TestCase () |
587 { | 585 { |
588 } | 586 } |
589 | 587 |
590 void | 588 void |
591 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address
&adr) | 589 Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address
&adr) |
592 { | 590 { |
593 NS_UNUSED(adr); | |
594 if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20))) | 591 if ((p->GetSize () == 1460) && (Simulator::Now () > Seconds (20))) |
595 { | 592 { |
596 m_received++; | 593 m_received++; |
597 } | 594 } |
598 } | 595 } |
599 | 596 |
600 | 597 |
601 void | 598 void |
602 Bug730TestCase::DoRun (void) | 599 Bug730TestCase::DoRun (void) |
603 { | 600 { |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 { | 1061 { |
1065 } | 1062 } |
1066 | 1063 |
1067 Bug2222TestCase::~Bug2222TestCase () | 1064 Bug2222TestCase::~Bug2222TestCase () |
1068 { | 1065 { |
1069 } | 1066 } |
1070 | 1067 |
1071 void | 1068 void |
1072 Bug2222TestCase::TxDataFailedTrace (std::string context, Mac48Address adr) | 1069 Bug2222TestCase::TxDataFailedTrace (std::string context, Mac48Address adr) |
1073 { | 1070 { |
1074 NS_UNUSED(adr); | |
1075 //Indicate the long retry counter has been increased in the wifi remote statio
n manager | 1071 //Indicate the long retry counter has been increased in the wifi remote statio
n manager |
1076 m_countInternalCollisions++; | 1072 m_countInternalCollisions++; |
1077 } | 1073 } |
1078 | 1074 |
1079 void | 1075 void |
1080 Bug2222TestCase::DoRun (void) | 1076 Bug2222TestCase::DoRun (void) |
1081 { | 1077 { |
1082 m_countInternalCollisions = 0; | 1078 m_countInternalCollisions = 0; |
1083 | 1079 |
1084 //Generate same backoff for AC_VI and AC_VO | 1080 //Generate same backoff for AC_VI and AC_VO |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 { | 1176 { |
1181 public: | 1177 public: |
1182 Bug2483TestCase (); | 1178 Bug2483TestCase (); |
1183 virtual ~Bug2483TestCase (); | 1179 virtual ~Bug2483TestCase (); |
1184 virtual void DoRun (void); | 1180 virtual void DoRun (void); |
1185 | 1181 |
1186 private: | 1182 private: |
1187 /** | 1183 /** |
1188 * A tuple of {starting frequency, channelWidth, Number of subbands in Spectru
mModel, modulation type} | 1184 * A tuple of {starting frequency, channelWidth, Number of subbands in Spectru
mModel, modulation type} |
1189 */ | 1185 */ |
1190 typedef std::tuple<double, uint8_t, size_t, WifiModulationClass> FreqWidthSubb
andModulationTuple; | 1186 typedef std::tuple<double, uint16_t, size_t, WifiModulationClass> FreqWidthSub
bandModulationTuple; |
1191 std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples; ///< vector of
distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,
modulation type} tuples | 1187 std::vector<FreqWidthSubbandModulationTuple> m_distinctTuples; ///< vector of
distinct {starting frequency, channelWidth, Number of subbands in SpectrumModel,
modulation type} tuples |
1192 | 1188 |
1193 /** | 1189 /** |
1194 * Stores the distinct {starting frequency, channelWidth, Number of subbands i
n SpectrumModel, modulation type} tuples | 1190 * Stores the distinct {starting frequency, channelWidth, Number of subbands i
n SpectrumModel, modulation type} tuples |
1195 * that have been used during the testcase run. | 1191 * that have been used during the testcase run. |
1196 * \param context the context | 1192 * \param context the context |
1197 * \param txParams spectrum signal parameters set by transmitter | 1193 * \param txParams spectrum signal parameters set by transmitter |
1198 */ | 1194 */ |
1199 void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> tx
Params); | 1195 void StoreDistinctTuple (std::string context, Ptr<SpectrumSignalParameters> tx
Params); |
1200 /** | 1196 /** |
(...skipping 25 matching lines...) Expand all Loading... |
1226 // Get channel bandwidth and modulation class | 1222 // Get channel bandwidth and modulation class |
1227 Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectru
mSignalParameters> (txParams); | 1223 Ptr<const WifiSpectrumSignalParameters> wifiTxParams = DynamicCast<WifiSpectru
mSignalParameters> (txParams); |
1228 Ptr<Packet> packet = wifiTxParams->packet->Copy (); | 1224 Ptr<Packet> packet = wifiTxParams->packet->Copy (); |
1229 WifiPhyTag tag; | 1225 WifiPhyTag tag; |
1230 if (!packet->RemovePacketTag (tag)) | 1226 if (!packet->RemovePacketTag (tag)) |
1231 { | 1227 { |
1232 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); | 1228 NS_FATAL_ERROR ("Received Wi-Fi Signal with no WifiPhyTag"); |
1233 return; | 1229 return; |
1234 } | 1230 } |
1235 WifiTxVector txVector = tag.GetWifiTxVector (); | 1231 WifiTxVector txVector = tag.GetWifiTxVector (); |
1236 uint8_t channelWidth = txVector.GetChannelWidth (); | 1232 uint16_t channelWidth = txVector.GetChannelWidth (); |
1237 WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass (
); | 1233 WifiModulationClass modulationClass = txVector.GetMode ().GetModulationClass (
); |
1238 | 1234 |
1239 // Build a tuple and check if seen before (if so store it) | 1235 // Build a tuple and check if seen before (if so store it) |
1240 FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingF
req, channelWidth, | 1236 FreqWidthSubbandModulationTuple tupleForCurrentTx = std::make_tuple (startingF
req, channelWidth, |
1241 numBands,
modulationClass); | 1237 numBands,
modulationClass); |
1242 bool found = false; | 1238 bool found = false; |
1243 for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_disti
nctTuples.begin (); it != m_distinctTuples.end (); it++) | 1239 for (std::vector<FreqWidthSubbandModulationTuple>::const_iterator it = m_disti
nctTuples.begin (); it != m_distinctTuples.end (); it++) |
1244 { | 1240 { |
1245 if (*it == tupleForCurrentTx) | 1241 if (*it == tupleForCurrentTx) |
1246 { | 1242 { |
1247 found = true; | 1243 found = true; |
1248 } | 1244 } |
1249 } | 1245 } |
1250 if (!found) | 1246 if (!found) |
1251 { | 1247 { |
1252 m_distinctTuples.push_back (tupleForCurrentTx); | 1248 m_distinctTuples.push_back (tupleForCurrentTx); |
1253 } | 1249 } |
1254 } | 1250 } |
1255 | 1251 |
1256 void | 1252 void |
1257 Bug2483TestCase::SendPacketBurst (unsigned int numPackets, Ptr<NetDevice> source
Device, | 1253 Bug2483TestCase::SendPacketBurst (unsigned int numPackets, Ptr<NetDevice> source
Device, |
1258 Address& destination) const | 1254 Address& destination) const |
1259 { | 1255 { |
1260 for (uint16_t i = 0; i < numPackets; i++) | 1256 for (unsigned int i = 0; i < numPackets; i++) |
1261 { | 1257 { |
1262 Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data | 1258 Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data |
1263 sourceDevice->Send (pkt, destination, 0); | 1259 sourceDevice->Send (pkt, destination, 0); |
1264 } | 1260 } |
1265 } | 1261 } |
1266 | 1262 |
1267 void | 1263 void |
1268 Bug2483TestCase::DoRun (void) | 1264 Bug2483TestCase::DoRun (void) |
1269 { | 1265 { |
1270 Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringVa
lue ("500")); // so as to force RTS/CTS for data frames | 1266 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)); | 1267 Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0)); |
1272 | 1268 |
1273 uint8_t channelWidth = 40; // at least 40 MHz expected here | 1269 uint16_t channelWidth = 40; // at least 40 MHz expected here |
1274 | 1270 |
1275 NodeContainer wifiStaNode; | 1271 NodeContainer wifiStaNode; |
1276 wifiStaNode.Create (1); | 1272 wifiStaNode.Create (1); |
1277 | 1273 |
1278 NodeContainer wifiApNode; | 1274 NodeContainer wifiApNode; |
1279 wifiApNode.Create (1); | 1275 wifiApNode.Create (1); |
1280 | 1276 |
1281 SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default (); | 1277 SpectrumWifiPhyHelper spectrumPhy = SpectrumWifiPhyHelper::Default (); |
1282 Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectr
umChannel> (); | 1278 Ptr<MultiModelSpectrumChannel> spectrumChannel = CreateObject<MultiModelSpectr
umChannel> (); |
1283 Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossMo
del> (); | 1279 Ptr<FriisPropagationLossModel> lossModel = CreateObject<FriisPropagationLossMo
del> (); |
1284 lossModel->SetFrequency (5.180e9); | 1280 lossModel->SetFrequency (5.180e9); |
1285 spectrumChannel->AddPropagationLossModel (lossModel); | 1281 spectrumChannel->AddPropagationLossModel (lossModel); |
1286 | 1282 |
1287 Ptr<ConstantSpeedPropagationDelayModel> delayModel | 1283 Ptr<ConstantSpeedPropagationDelayModel> delayModel |
1288 = CreateObject<ConstantSpeedPropagationDelayModel> (); | 1284 = CreateObject<ConstantSpeedPropagationDelayModel> (); |
1289 spectrumChannel->SetPropagationDelayModel (delayModel); | 1285 spectrumChannel->SetPropagationDelayModel (delayModel); |
1290 | 1286 |
1291 spectrumPhy.SetChannel (spectrumChannel); | 1287 spectrumPhy.SetChannel (spectrumChannel); |
1292 spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel"); | 1288 spectrumPhy.SetErrorRateModel ("ns3::NistErrorRateModel"); |
1293 spectrumPhy.Set ("Frequency", UintegerValue (5180)); | 1289 spectrumPhy.Set ("Frequency", UintegerValue (5180)); |
1294 spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth)); | 1290 spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth)); |
1295 spectrumPhy.Set ("TxPowerStart", DoubleValue (10)); | 1291 spectrumPhy.Set ("TxPowerStart", DoubleValue (10)); |
1296 spectrumPhy.Set ("TxPowerEnd", DoubleValue (10)); | 1292 spectrumPhy.Set ("TxPowerEnd", DoubleValue (10)); |
1297 | 1293 |
1298 WifiHelper wifi; | 1294 WifiHelper wifi; |
(...skipping 15 matching lines...) Expand all Loading... |
1314 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>
(); | 1310 Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>
(); |
1315 positionAlloc->Add (Vector (0.0, 0.0, 0.0)); | 1311 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 | 1312 positionAlloc->Add (Vector (1.0, 0.0, 0.0)); // put close enough in order to u
se MCS |
1317 mobility.SetPositionAllocator (positionAlloc); | 1313 mobility.SetPositionAllocator (positionAlloc); |
1318 | 1314 |
1319 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); | 1315 mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
1320 mobility.Install (wifiApNode); | 1316 mobility.Install (wifiApNode); |
1321 mobility.Install (wifiStaNode); | 1317 mobility.Install (wifiStaNode); |
1322 | 1318 |
1323 // Send two 5 packet-bursts | 1319 // Send two 5 packet-bursts |
1324 Simulator::Schedule (Seconds (0.5), &Bug2483TestCase::SendPacketBurst, this, 5
U, apDevice.Get (0), staDevice.Get (0)->GetAddress ()); | 1320 Simulator::Schedule (Seconds (0.5), &Bug2483TestCase::SendPacketBurst, this, 5
, 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 ()); | 1321 Simulator::Schedule (Seconds (0.6), &Bug2483TestCase::SendPacketBurst, this, 5
, apDevice.Get (0), staDevice.Get (0)->GetAddress ()); |
1326 | 1322 |
1327 Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams",
MakeCallback (&Bug2483TestCase::StoreDistinctTuple, this)); | 1323 Config::Connect ("/ChannelList/*/$ns3::MultiModelSpectrumChannel/TxSigParams",
MakeCallback (&Bug2483TestCase::StoreDistinctTuple, this)); |
1328 | 1324 |
1329 Simulator::Stop (Seconds (0.8)); | 1325 Simulator::Stop (Seconds (0.8)); |
1330 Simulator::Run (); | 1326 Simulator::Run (); |
1331 | 1327 |
1332 Simulator::Destroy (); | 1328 Simulator::Destroy (); |
1333 | 1329 |
1334 // {starting frequency, channelWidth, Number of subbands in SpectrumModel, mod
ulation type} tuples | 1330 // {starting frequency, channelWidth, Number of subbands in SpectrumModel, mod
ulation type} tuples |
1335 std::size_t numberTuples = m_distinctTuples.size (); | 1331 std::size_t numberTuples = m_distinctTuples.size (); |
1336 NS_TEST_ASSERT_MSG_EQ (numberTuples, 2, "Only two distinct tuples expected"); | 1332 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"); | 1333 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"); |
1338 // Note that the first tuple should the one initiated by the beacon, i.e. lega
cy OFDM (20 MHz) | 1334 // 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"); | 1335 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)"); | 1336 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)"); |
1341 NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass:
:WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM"); | 1337 NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[0]), WifiModulationClass:
:WIFI_MOD_CLASS_OFDM, "First tuple should be OFDM"); |
1342 // Second tuple | 1338 // 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"); | 1339 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)"); | 1340 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)"); |
1345 NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass:
:WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM"); | 1341 NS_TEST_ASSERT_MSG_EQ (std::get<3> (m_distinctTuples[1]), WifiModulationClass:
:WIFI_MOD_CLASS_VHT, "Second tuple should be VHT_OFDM"); |
| 1342 } |
| 1343 |
| 1344 //----------------------------------------------------------------------------- |
| 1345 /** |
| 1346 * Make sure that the channel width and the channel number can be changed at run
time. |
| 1347 * |
| 1348 * The scenario considers an access point and a station using a 20 MHz channel w
idth. |
| 1349 * After 1s, we change the channel width and the channel number to use a 40 MHz
channel. |
| 1350 * The tests checks the operational channel width sent in Beacon frames |
| 1351 * and verify that a reassociation procedure is executed. |
| 1352 * |
| 1353 * See \bugid{2831} |
| 1354 */ |
| 1355 |
| 1356 class Bug2831TestCase : public TestCase |
| 1357 { |
| 1358 public: |
| 1359 Bug2831TestCase (); |
| 1360 virtual ~Bug2831TestCase (); |
| 1361 virtual void DoRun (void); |
| 1362 |
| 1363 private: |
| 1364 /** |
| 1365 * Function called to change the supported channel width at runtime |
| 1366 */ |
| 1367 void ChangeSupportedChannelWidth (void); |
| 1368 /** |
| 1369 * Callback triggered when a packet is received by the PHYs |
| 1370 * \param context the context |
| 1371 * \param p the received packet |
| 1372 */ |
| 1373 void RxCallback (std::string context, Ptr<const Packet> p); |
| 1374 |
| 1375 Ptr<YansWifiPhy> m_apPhy; ///< AP PHY |
| 1376 Ptr<YansWifiPhy> m_staPhy; ///< STA PHY |
| 1377 |
| 1378 uint8_t m_reassocReqCount; ///< count number of reassociation requests |
| 1379 uint8_t m_reassocRespCount; ///< count number of reassociation responses |
| 1380 uint8_t m_countOperationalChannelWidth20; ///< count number of beacon frames a
nnouncing a 20 MHz operating channel width |
| 1381 uint8_t m_countOperationalChannelWidth40; ///< count number of beacon frames a
nnouncing a 40 MHz operating channel width |
| 1382 }; |
| 1383 |
| 1384 Bug2831TestCase::Bug2831TestCase () |
| 1385 : TestCase ("Test case for Bug 2831"), |
| 1386 m_reassocReqCount (0), |
| 1387 m_reassocRespCount (0), |
| 1388 m_countOperationalChannelWidth20 (0), |
| 1389 m_countOperationalChannelWidth40 (0) |
| 1390 { |
| 1391 } |
| 1392 |
| 1393 Bug2831TestCase::~Bug2831TestCase () |
| 1394 { |
| 1395 } |
| 1396 |
| 1397 void |
| 1398 Bug2831TestCase::ChangeSupportedChannelWidth () |
| 1399 { |
| 1400 m_apPhy->SetChannelNumber (38); |
| 1401 m_apPhy->SetChannelWidth (40); |
| 1402 m_staPhy->SetChannelNumber (38); |
| 1403 m_staPhy->SetChannelWidth (40); |
| 1404 } |
| 1405 |
| 1406 void |
| 1407 Bug2831TestCase::RxCallback (std::string context, Ptr<const Packet> p) |
| 1408 { |
| 1409 Ptr<Packet> packet = p->Copy (); |
| 1410 WifiMacHeader hdr; |
| 1411 packet->RemoveHeader (hdr); |
| 1412 if (hdr.IsReassocReq ()) |
| 1413 { |
| 1414 m_reassocReqCount++; |
| 1415 } |
| 1416 else if (hdr.IsReassocResp ()) |
| 1417 { |
| 1418 m_reassocRespCount++; |
| 1419 } |
| 1420 else if (hdr.IsBeacon ()) |
| 1421 { |
| 1422 MgtBeaconHeader beacon; |
| 1423 packet->RemoveHeader (beacon); |
| 1424 HtOperation htOperation = beacon.GetHtOperation (); |
| 1425 if (htOperation.GetStaChannelWidth () > 0) |
| 1426 { |
| 1427 m_countOperationalChannelWidth40++; |
| 1428 } |
| 1429 else |
| 1430 { |
| 1431 m_countOperationalChannelWidth20++; |
| 1432 } |
| 1433 } |
| 1434 } |
| 1435 |
| 1436 void |
| 1437 Bug2831TestCase::DoRun (void) |
| 1438 { |
| 1439 Ptr<YansWifiChannel> channel = CreateObject<YansWifiChannel> (); |
| 1440 ObjectFactory propDelay; |
| 1441 propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel"); |
| 1442 Ptr<PropagationDelayModel> propagationDelay = propDelay.Create<PropagationDela
yModel> (); |
| 1443 Ptr<PropagationLossModel> propagationLoss = CreateObject<RandomPropagationLoss
Model> (); |
| 1444 channel->SetPropagationDelayModel (propagationDelay); |
| 1445 channel->SetPropagationLossModel (propagationLoss); |
| 1446 |
| 1447 Ptr<Node> apNode = CreateObject<Node> (); |
| 1448 Ptr<WifiNetDevice> apDev = CreateObject<WifiNetDevice> (); |
| 1449 ObjectFactory mac; |
| 1450 mac.SetTypeId ("ns3::ApWifiMac"); |
| 1451 Ptr<WifiMac> apMac = mac.Create<WifiMac> (); |
| 1452 apMac->ConfigureStandard (WIFI_PHY_STANDARD_80211ax_5GHZ); |
| 1453 |
| 1454 Ptr<Node> staNode = CreateObject<Node> (); |
| 1455 Ptr<WifiNetDevice> staDev = CreateObject<WifiNetDevice> (); |
| 1456 mac.SetTypeId ("ns3::StaWifiMac"); |
| 1457 Ptr<WifiMac> staMac = mac.Create<WifiMac> (); |
| 1458 staMac->ConfigureStandard (WIFI_PHY_STANDARD_80211ax_5GHZ); |
| 1459 |
| 1460 Ptr<ConstantPositionMobilityModel> apMobility = CreateObject<ConstantPositionM
obilityModel> (); |
| 1461 apMobility->SetPosition (Vector (0.0, 0.0, 0.0)); |
| 1462 apNode->AggregateObject (apMobility); |
| 1463 |
| 1464 Ptr<ErrorRateModel> error = CreateObject<YansErrorRateModel> (); |
| 1465 m_apPhy = CreateObject<YansWifiPhy> (); |
| 1466 m_apPhy->SetErrorRateModel (error); |
| 1467 m_apPhy->SetChannel (channel); |
| 1468 m_apPhy->SetMobility (apMobility); |
| 1469 m_apPhy->SetDevice (apDev); |
| 1470 m_apPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211ax_5GHZ); |
| 1471 m_apPhy->SetChannelNumber (36); |
| 1472 m_apPhy->SetChannelWidth (20); |
| 1473 |
| 1474 Ptr<ConstantPositionMobilityModel> staMobility = CreateObject<ConstantPosition
MobilityModel> (); |
| 1475 staMobility->SetPosition (Vector (1.0, 0.0, 0.0)); |
| 1476 staNode->AggregateObject (staMobility); |
| 1477 |
| 1478 m_staPhy = CreateObject<YansWifiPhy> (); |
| 1479 m_staPhy->SetErrorRateModel (error); |
| 1480 m_staPhy->SetChannel (channel); |
| 1481 m_staPhy->SetMobility (staMobility); |
| 1482 m_staPhy->SetDevice (apDev); |
| 1483 m_staPhy->ConfigureStandard (WIFI_PHY_STANDARD_80211ax_5GHZ); |
| 1484 m_staPhy->SetChannelNumber (36); |
| 1485 m_staPhy->SetChannelWidth (20); |
| 1486 |
| 1487 apMac->SetAddress (Mac48Address::Allocate ()); |
| 1488 apDev->SetMac (apMac); |
| 1489 apDev->SetPhy (m_apPhy); |
| 1490 ObjectFactory manager; |
| 1491 manager.SetTypeId ("ns3::ConstantRateWifiManager"); |
| 1492 apDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ()); |
| 1493 apNode->AddDevice (apDev); |
| 1494 |
| 1495 staMac->SetAddress (Mac48Address::Allocate ()); |
| 1496 staDev->SetMac (staMac); |
| 1497 staDev->SetPhy (m_staPhy); |
| 1498 staDev->SetRemoteStationManager (manager.Create<WifiRemoteStationManager> ()); |
| 1499 staNode->AddDevice (staDev); |
| 1500 |
| 1501 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiP
hy/PhyRxBegin", MakeCallback (&Bug2831TestCase::RxCallback, this)); |
| 1502 |
| 1503 Simulator::Schedule (Seconds (1.0), &Bug2831TestCase::ChangeSupportedChannelWi
dth, this); |
| 1504 |
| 1505 Simulator::Stop (Seconds (3.0)); |
| 1506 Simulator::Run (); |
| 1507 Simulator::Destroy (); |
| 1508 |
| 1509 NS_TEST_ASSERT_MSG_EQ (m_reassocReqCount, 1, "Reassociation request not receiv
ed"); |
| 1510 NS_TEST_ASSERT_MSG_EQ (m_reassocRespCount, 1, "Reassociation response not rece
ived"); |
| 1511 NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth20, 10, "Incorrect operat
ional channel width before channel change"); |
| 1512 NS_TEST_ASSERT_MSG_EQ (m_countOperationalChannelWidth40, 20, "Incorrect operat
ional channel width after channel change"); |
1346 } | 1513 } |
1347 | 1514 |
1348 /** | 1515 /** |
1349 * \ingroup wifi-test | 1516 * \ingroup wifi-test |
1350 * \ingroup tests | 1517 * \ingroup tests |
1351 * | 1518 * |
1352 * \brief Wifi Test Suite | 1519 * \brief Wifi Test Suite |
1353 */ | 1520 */ |
1354 class WifiTestSuite : public TestSuite | 1521 class WifiTestSuite : public TestSuite |
1355 { | 1522 { |
1356 public: | 1523 public: |
1357 WifiTestSuite (); | 1524 WifiTestSuite (); |
1358 }; | 1525 }; |
1359 | 1526 |
1360 WifiTestSuite::WifiTestSuite () | 1527 WifiTestSuite::WifiTestSuite () |
1361 : TestSuite ("devices-wifi", UNIT) | 1528 : TestSuite ("devices-wifi", UNIT) |
1362 { | 1529 { |
1363 AddTestCase (new WifiTest, TestCase::QUICK); | 1530 AddTestCase (new WifiTest, TestCase::QUICK); |
1364 AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK); | 1531 AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK); |
1365 AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 | 1532 AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 |
1366 AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK); | 1533 AddTestCase (new DcfImmediateAccessBroadcastTestCase, TestCase::QUICK); |
1367 AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 | 1534 AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 |
1368 AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK); | 1535 AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK); |
1369 AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222 | 1536 AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222 |
1370 AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483 | 1537 AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483 |
| 1538 AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831 |
1371 } | 1539 } |
1372 | 1540 |
1373 static WifiTestSuite g_wifiTestSuite; ///< the test suite | 1541 static WifiTestSuite g_wifiTestSuite; ///< the test suite |
LEFT | RIGHT |