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