|
|
| 34 |
#include "ns3/pointer.h" |
34 |
#include "ns3/pointer.h" |
| 35 |
#include "ns3/rng-seed-manager.h" |
35 |
#include "ns3/rng-seed-manager.h" |
| 36 |
#include "ns3/config.h" |
36 |
#include "ns3/config.h" |
|
|
37 |
#include "ns3/error-model.h" |
| 37 |
#include "ns3/packet-socket-server.h" |
38 |
#include "ns3/packet-socket-server.h" |
| 38 |
#include "ns3/packet-socket-client.h" |
39 |
#include "ns3/packet-socket-client.h" |
| 39 |
#include "ns3/packet-socket-helper.h" |
40 |
#include "ns3/packet-socket-helper.h" |
|
Lines 605-612
Bug730TestCase::DoRun (void)
|
Link Here
|
|---|
|
| 605 |
{ |
606 |
{ |
| 606 |
m_received = 0; |
607 |
m_received = 0; |
| 607 |
|
608 |
|
| 608 |
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2304")); |
|
|
| 609 |
|
| 610 |
NodeContainer wifiStaNode; |
609 |
NodeContainer wifiStaNode; |
| 611 |
wifiStaNode.Create (1); |
610 |
wifiStaNode.Create (1); |
| 612 |
|
611 |
|
|
Lines 899-905
SetChannelFrequencyTest::DoRun ()
|
Link Here
|
|---|
|
| 899 |
NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration"); |
898 |
NS_TEST_ASSERT_MSG_EQ (phySta->GetChannelWidth (), 40, "802.11 5GHz configuration"); |
| 900 |
NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration"); |
899 |
NS_TEST_ASSERT_MSG_EQ (phySta->GetFrequency (), 5220, "802.11 5GHz configuration"); |
| 901 |
} |
900 |
} |
| 902 |
// modify cases 13 and 14 to avoid Config::SetDefault () |
|
|
| 903 |
{ |
901 |
{ |
| 904 |
// case 13 |
902 |
// case 13 |
| 905 |
WifiHelper wifi; |
903 |
WifiHelper wifi; |
|
Lines 1268-1276
Bug2483TestCase::SendPacketBurst (uint8_t numPackets, Ptr<NetDevice> sourceDevic
|
Link Here
|
|---|
|
| 1268 |
void |
1266 |
void |
| 1269 |
Bug2483TestCase::DoRun (void) |
1267 |
Bug2483TestCase::DoRun (void) |
| 1270 |
{ |
1268 |
{ |
| 1271 |
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames |
|
|
| 1272 |
Config::SetDefault ("ns3::WifiPhy::CcaMode1Threshold", DoubleValue (-62.0)); |
| 1273 |
|
| 1274 |
uint16_t channelWidth = 40; // at least 40 MHz expected here |
1269 |
uint16_t channelWidth = 40; // at least 40 MHz expected here |
| 1275 |
|
1270 |
|
| 1276 |
NodeContainer wifiStaNode; |
1271 |
NodeContainer wifiStaNode; |
|
Lines 1295-1306
Bug2483TestCase::DoRun (void)
|
Link Here
|
|---|
|
| 1295 |
spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth)); |
1290 |
spectrumPhy.Set ("ChannelWidth", UintegerValue (channelWidth)); |
| 1296 |
spectrumPhy.Set ("TxPowerStart", DoubleValue (10)); |
1291 |
spectrumPhy.Set ("TxPowerStart", DoubleValue (10)); |
| 1297 |
spectrumPhy.Set ("TxPowerEnd", DoubleValue (10)); |
1292 |
spectrumPhy.Set ("TxPowerEnd", DoubleValue (10)); |
|
|
1293 |
spectrumPhy.Set ("CcaMode1Threshold", DoubleValue (-62.0)); |
| 1298 |
|
1294 |
|
| 1299 |
WifiHelper wifi; |
1295 |
WifiHelper wifi; |
| 1300 |
wifi.SetStandard (WIFI_PHY_STANDARD_80211ac); |
1296 |
wifi.SetStandard (WIFI_PHY_STANDARD_80211ac); |
| 1301 |
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", |
1297 |
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", |
| 1302 |
"DataMode", StringValue ("VhtMcs8"), |
1298 |
"DataMode", StringValue ("VhtMcs8"), |
| 1303 |
"ControlMode", StringValue ("VhtMcs8")); |
1299 |
"ControlMode", StringValue ("VhtMcs8"), |
|
|
1300 |
"RtsCtsThreshold", StringValue ("500")); // so as to force RTS/CTS for data frames |
| 1304 |
|
1301 |
|
| 1305 |
WifiMacHelper mac; |
1302 |
WifiMacHelper mac; |
| 1306 |
mac.SetType ("ns3::StaWifiMac"); |
1303 |
mac.SetType ("ns3::StaWifiMac"); |
|
Lines 1700-1705
StaWifiMacScanningTestCase::DoRun (void)
|
Link Here
|
|---|
|
| 1700 |
} |
1697 |
} |
| 1701 |
} |
1698 |
} |
| 1702 |
|
1699 |
|
|
|
1700 |
//----------------------------------------------------------------------------- |
| 1701 |
/** |
| 1702 |
* Make sure that the ADDBA handshake process is protected. |
| 1703 |
* |
| 1704 |
* The scenario considers an access point and a station. It utilizes |
| 1705 |
* ReceiveListErrorModel to drop by force ADDBA request on STA or ADDBA |
| 1706 |
* response on AP. The AP sends 5 packets of each 1000 bytes (thus generating |
| 1707 |
* BA agreement), 2 times during the test at 0.5s and 0.8s. We only drop the |
| 1708 |
* first ADDBA request/response of the first BA negotiation. Therefore, we |
| 1709 |
* expect that the packets still in queue after the failed BA agreement will be |
| 1710 |
* sent with normal MPDU, and packets queued after that should be sent with |
| 1711 |
* A-MPDU. |
| 1712 |
* |
| 1713 |
* This test consider 2 cases: |
| 1714 |
* |
| 1715 |
* 1. ADDBA request packets are blocked on receive at STA, triggering |
| 1716 |
* transmission failure at AP |
| 1717 |
* 2. ADDBA response packets are blocked on receive at AP, STA stops |
| 1718 |
* retransmission of ADDBA response |
| 1719 |
* |
| 1720 |
* See \bugid{2470} |
| 1721 |
*/ |
| 1722 |
|
| 1723 |
class Bug2470TestCase : public TestCase |
| 1724 |
{ |
| 1725 |
public: |
| 1726 |
Bug2470TestCase (); |
| 1727 |
virtual ~Bug2470TestCase (); |
| 1728 |
virtual void DoRun (void); |
| 1729 |
|
| 1730 |
private: |
| 1731 |
/** |
| 1732 |
* Callback when packet is received |
| 1733 |
* \param context node context |
| 1734 |
* \param p the received packet |
| 1735 |
* \param channelFreqMhz the channel frequency in MHz |
| 1736 |
* \param txVector the TX vector |
| 1737 |
* \param aMpdu the A-MPDU info |
| 1738 |
* \param signalNoise the signal noise in dBm |
| 1739 |
*/ |
| 1740 |
void RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise); |
| 1741 |
/** |
| 1742 |
* Callback when packet is dropped |
| 1743 |
* \param context node context |
| 1744 |
* \param p the received packet |
| 1745 |
*/ |
| 1746 |
void RxDropCallback (std::string context, Ptr<const Packet> p); |
| 1747 |
/** |
| 1748 |
* Triggers the arrival of a burst of 1000 Byte-long packets in the source device |
| 1749 |
* \param numPackets number of packets in burst |
| 1750 |
* \param sourceDevice pointer to the source NetDevice |
| 1751 |
* \param destination address of the destination device |
| 1752 |
*/ |
| 1753 |
void SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, Address& destination) const; |
| 1754 |
/** |
| 1755 |
* Run subtest for this test suite |
| 1756 |
* \param apErrorModel ErrorModel used for AP |
| 1757 |
* \param staErrorModel ErrorModel used for STA |
| 1758 |
*/ |
| 1759 |
void RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel); |
| 1760 |
|
| 1761 |
uint8_t m_receivedNormalMpduCount; ///< Count received normal MPDU packets on STA |
| 1762 |
uint8_t m_receivedAmpduCount; ///< Count received A-MPDU packets on STA |
| 1763 |
uint8_t m_droppedActionCount; ///< Count dropped ADDBA request/response |
| 1764 |
}; |
| 1765 |
|
| 1766 |
Bug2470TestCase::Bug2470TestCase () |
| 1767 |
: TestCase ("Test case for Bug 2470"), |
| 1768 |
m_receivedNormalMpduCount (0), |
| 1769 |
m_receivedAmpduCount (0), |
| 1770 |
m_droppedActionCount (0) |
| 1771 |
{ |
| 1772 |
} |
| 1773 |
|
| 1774 |
Bug2470TestCase::~Bug2470TestCase () |
| 1775 |
{ |
| 1776 |
} |
| 1777 |
|
| 1778 |
void |
| 1779 |
Bug2470TestCase::RxCallback (std::string context, Ptr<const Packet> p, uint16_t channelFreqMhz, WifiTxVector txVector, MpduInfo aMpdu, SignalNoiseDbm signalNoise) |
| 1780 |
{ |
| 1781 |
Ptr<Packet> packet = p->Copy (); |
| 1782 |
if (aMpdu.type != MpduType::NORMAL_MPDU) |
| 1783 |
{ |
| 1784 |
m_receivedAmpduCount++; |
| 1785 |
} |
| 1786 |
else |
| 1787 |
{ |
| 1788 |
WifiMacHeader hdr; |
| 1789 |
packet->RemoveHeader (hdr); |
| 1790 |
if (hdr.IsData ()) |
| 1791 |
{ |
| 1792 |
m_receivedNormalMpduCount++; |
| 1793 |
} |
| 1794 |
} |
| 1795 |
} |
| 1796 |
|
| 1797 |
void |
| 1798 |
Bug2470TestCase::RxDropCallback (std::string context, Ptr<const Packet> p) |
| 1799 |
{ |
| 1800 |
Ptr<Packet> packet = p->Copy (); |
| 1801 |
WifiMacHeader hdr; |
| 1802 |
packet->RemoveHeader (hdr); |
| 1803 |
if (hdr.IsAction ()) |
| 1804 |
{ |
| 1805 |
m_droppedActionCount++; |
| 1806 |
} |
| 1807 |
} |
| 1808 |
|
| 1809 |
void |
| 1810 |
Bug2470TestCase::SendPacketBurst (uint32_t numPackets, Ptr<NetDevice> sourceDevice, |
| 1811 |
Address& destination) const |
| 1812 |
{ |
| 1813 |
for (uint32_t i = 0; i < numPackets; i++) |
| 1814 |
{ |
| 1815 |
Ptr<Packet> pkt = Create<Packet> (1000); // 1000 dummy bytes of data |
| 1816 |
sourceDevice->Send (pkt, destination, 0); |
| 1817 |
} |
| 1818 |
} |
| 1819 |
|
| 1820 |
void |
| 1821 |
Bug2470TestCase::RunSubtest (PointerValue apErrorModel, PointerValue staErrorModel) |
| 1822 |
{ |
| 1823 |
RngSeedManager::SetSeed (1); |
| 1824 |
RngSeedManager::SetRun (1); |
| 1825 |
|
| 1826 |
NodeContainer wifiApNode, wifiStaNode; |
| 1827 |
wifiApNode.Create (1); |
| 1828 |
wifiStaNode.Create (1); |
| 1829 |
|
| 1830 |
YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
| 1831 |
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
| 1832 |
phy.SetChannel (channel.Create ()); |
| 1833 |
|
| 1834 |
WifiHelper wifi; |
| 1835 |
wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ); |
| 1836 |
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", |
| 1837 |
"DataMode", StringValue ("HtMcs7"), |
| 1838 |
"ControlMode", StringValue ("HtMcs7")); |
| 1839 |
|
| 1840 |
WifiMacHelper mac; |
| 1841 |
NetDeviceContainer apDevice; |
| 1842 |
phy.Set ("PostReceptionErrorModel", apErrorModel); |
| 1843 |
mac.SetType ("ns3::ApWifiMac", "EnableBeaconJitter", BooleanValue (false)); |
| 1844 |
apDevice = wifi.Install (phy, mac, wifiApNode); |
| 1845 |
|
| 1846 |
NetDeviceContainer staDevice; |
| 1847 |
phy.Set ("PostReceptionErrorModel", staErrorModel); |
| 1848 |
mac.SetType ("ns3::StaWifiMac"); |
| 1849 |
staDevice = wifi.Install (phy, mac, wifiStaNode); |
| 1850 |
|
| 1851 |
MobilityHelper mobility; |
| 1852 |
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> (); |
| 1853 |
positionAlloc->Add (Vector (0.0, 0.0, 0.0)); |
| 1854 |
positionAlloc->Add (Vector (1.0, 0.0, 0.0)); |
| 1855 |
mobility.SetPositionAllocator (positionAlloc); |
| 1856 |
|
| 1857 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
| 1858 |
mobility.Install (wifiApNode); |
| 1859 |
mobility.Install (wifiStaNode); |
| 1860 |
|
| 1861 |
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/MonitorSnifferRx", MakeCallback (&Bug2470TestCase::RxCallback, this)); |
| 1862 |
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/$ns3::WifiPhy/PhyRxDrop", MakeCallback (&Bug2470TestCase::RxDropCallback, this)); |
| 1863 |
|
| 1864 |
Simulator::Schedule (Seconds (0.5), &Bug2470TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ()); |
| 1865 |
Simulator::Schedule (Seconds (0.8), &Bug2470TestCase::SendPacketBurst, this, 5, apDevice.Get (0), staDevice.Get (0)->GetAddress ()); |
| 1866 |
|
| 1867 |
Simulator::Stop (Seconds (1.0)); |
| 1868 |
Simulator::Run (); |
| 1869 |
Simulator::Destroy (); |
| 1870 |
} |
| 1871 |
|
| 1872 |
void |
| 1873 |
Bug2470TestCase::DoRun (void) |
| 1874 |
{ |
| 1875 |
// Create ReceiveListErrorModel to corrupt ADDBA req packet. We use ReceiveListErrorModel |
| 1876 |
// instead of ListErrorModel since packet UID is incremented between simulations. But |
| 1877 |
// problem may occur because of random stream, therefore we suppress usage of RNG as |
| 1878 |
// much as possible (i.e., removing beacon jitter). |
| 1879 |
Ptr<ReceiveListErrorModel> staPem = CreateObject<ReceiveListErrorModel> (); |
| 1880 |
std::list<uint32_t> blackList; |
| 1881 |
// Block ADDBA request 6 times (== maximum number of MAC frame transmissions in the addba response timeout interval) |
| 1882 |
blackList.push_back (8); |
| 1883 |
blackList.push_back (9); |
| 1884 |
blackList.push_back (10); |
| 1885 |
blackList.push_back (11); |
| 1886 |
blackList.push_back (12); |
| 1887 |
blackList.push_back (13); |
| 1888 |
staPem->SetList (blackList); |
| 1889 |
|
| 1890 |
{ |
| 1891 |
RunSubtest (PointerValue (), PointerValue (staPem)); |
| 1892 |
NS_TEST_ASSERT_MSG_EQ (m_droppedActionCount, 6, "ADDBA request packet is not dropped correctly"); |
| 1893 |
// There are two sets of 5 packets to be transmitted. The first 5 packets should be sent by normal |
| 1894 |
// MPDU because of failed ADDBA handshake. For the second set, the first packet should be sent by |
| 1895 |
// normal MPDU, and the rest with A-MPDU. In total we expect to receive 2 normal MPDU packets and |
| 1896 |
// 8 A-MPDU packets. |
| 1897 |
NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 2, "Receiving incorrect number of normal MPDU packet on subtest 1"); |
| 1898 |
NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 8, "Receiving incorrect number of A-MPDU packet on subtest 1"); |
| 1899 |
} |
| 1900 |
|
| 1901 |
m_receivedNormalMpduCount = 0; |
| 1902 |
m_receivedAmpduCount = 0; |
| 1903 |
m_droppedActionCount = 0; |
| 1904 |
Ptr<ReceiveListErrorModel> apPem = CreateObject<ReceiveListErrorModel> (); |
| 1905 |
blackList.clear (); |
| 1906 |
// Block ADDBA request 3 times (== maximum number of MAC frame transmissions in the addba response timeout interval) |
| 1907 |
blackList.push_back (4); |
| 1908 |
blackList.push_back (5); |
| 1909 |
blackList.push_back (6); |
| 1910 |
apPem->SetList (blackList); |
| 1911 |
|
| 1912 |
{ |
| 1913 |
RunSubtest (PointerValue (apPem), PointerValue ()); |
| 1914 |
NS_TEST_ASSERT_MSG_EQ (m_droppedActionCount, 3, "ADDBA response packet is not dropped correctly"); |
| 1915 |
// Similar to subtest 1, we also expect to receive 6 normal MPDU packets and 4 A-MPDU packets. |
| 1916 |
NS_TEST_ASSERT_MSG_EQ (m_receivedNormalMpduCount, 6, "Receiving incorrect number of normal MPDU packet on subtest 2"); |
| 1917 |
NS_TEST_ASSERT_MSG_EQ (m_receivedAmpduCount, 4, "Receiving incorrect number of A-MPDU packet on subtest 2"); |
| 1918 |
} |
| 1919 |
} |
| 1920 |
|
| 1703 |
/** |
1921 |
/** |
| 1704 |
* \ingroup wifi-test |
1922 |
* \ingroup wifi-test |
| 1705 |
* \ingroup tests |
1923 |
* \ingroup tests |
|
Lines 1725-1730
WifiTestSuite::WifiTestSuite ()
|
Link Here
|
|---|
|
| 1725 |
AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483 |
1943 |
AddTestCase (new Bug2483TestCase, TestCase::QUICK); //Bug 2483 |
| 1726 |
AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831 |
1944 |
AddTestCase (new Bug2831TestCase, TestCase::QUICK); //Bug 2831 |
| 1727 |
AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399 |
1945 |
AddTestCase (new StaWifiMacScanningTestCase, TestCase::QUICK); //Bug 2399 |
|
|
1946 |
AddTestCase (new Bug2470TestCase, TestCase::QUICK); //Bug 2470 |
| 1728 |
} |
1947 |
} |
| 1729 |
|
1948 |
|
| 1730 |
static WifiTestSuite g_wifiTestSuite; ///< the test suite |
1949 |
static WifiTestSuite g_wifiTestSuite; ///< the test suite |