|
|
| 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> (Case for Bug 991) |
20 |
* Quincy Tse <quincy.tse@nicta.com.au> |
| 21 |
* Sébastien Deronne <sebastien.deronne@gmail.com> (Case for bug 730) |
21 |
* Sébastien Deronne <sebastien.deronne@gmail.com> |
| 22 |
*/ |
22 |
*/ |
| 23 |
|
23 |
|
| 24 |
#include "ns3/yans-wifi-helper.h" |
24 |
#include "ns3/yans-wifi-helper.h" |
|
|
| 950 |
} |
950 |
} |
| 951 |
|
951 |
|
| 952 |
//----------------------------------------------------------------------------- |
952 |
//----------------------------------------------------------------------------- |
|
|
953 |
/** |
| 954 |
* Make sure that when virtual collision occurs the wifi remote station manager |
| 955 |
* is triggered and the retry counter is increased. |
| 956 |
* |
| 957 |
* See \bugid{2222} |
| 958 |
*/ |
| 959 |
|
| 960 |
class Bug2222TestCase : public TestCase |
| 961 |
{ |
| 962 |
public: |
| 963 |
Bug2222TestCase (); |
| 964 |
virtual ~Bug2222TestCase (); |
| 965 |
|
| 966 |
virtual void DoRun (void); |
| 967 |
|
| 968 |
|
| 969 |
private: |
| 970 |
uint32_t m_countInternalCollisions; |
| 971 |
|
| 972 |
void PopulateArpCache (); |
| 973 |
void TxDataFailedTrace (std::string context, Mac48Address adr); |
| 974 |
}; |
| 975 |
|
| 976 |
Bug2222TestCase::Bug2222TestCase () |
| 977 |
: TestCase ("Test case for Bug 2222"), |
| 978 |
m_countInternalCollisions (0) |
| 979 |
{ |
| 980 |
} |
| 981 |
|
| 982 |
Bug2222TestCase::~Bug2222TestCase () |
| 983 |
{ |
| 984 |
} |
| 985 |
|
| 986 |
void |
| 987 |
Bug2222TestCase::TxDataFailedTrace (std::string context, Mac48Address adr) |
| 988 |
{ |
| 989 |
//Indicate the long retry counter has been increased in the wifi remote station manager |
| 990 |
m_countInternalCollisions++; |
| 991 |
} |
| 992 |
|
| 993 |
void |
| 994 |
Bug2222TestCase::DoRun (void) |
| 995 |
{ |
| 996 |
m_countInternalCollisions = 0; |
| 997 |
|
| 998 |
//Generate same backoff for AC_VI and AC_VO |
| 999 |
RngSeedManager::SetSeed (1); |
| 1000 |
RngSeedManager::SetRun (31); |
| 1001 |
|
| 1002 |
NodeContainer wifiNodes; |
| 1003 |
wifiNodes.Create (2); |
| 1004 |
|
| 1005 |
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
| 1006 |
YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
| 1007 |
phy.SetChannel (channel.Create ()); |
| 1008 |
|
| 1009 |
WifiHelper wifi; |
| 1010 |
WifiMacHelper mac; |
| 1011 |
Ssid ssid = Ssid ("ns-3-ssid"); |
| 1012 |
mac.SetType ("ns3::AdhocWifiMac", |
| 1013 |
"QosSupported", BooleanValue (true)); |
| 1014 |
|
| 1015 |
NetDeviceContainer wifiDevices; |
| 1016 |
wifiDevices = wifi.Install (phy, mac, wifiNodes); |
| 1017 |
|
| 1018 |
MobilityHelper mobility; |
| 1019 |
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> (); |
| 1020 |
|
| 1021 |
positionAlloc->Add (Vector (0.0, 0.0, 0.0)); |
| 1022 |
positionAlloc->Add (Vector (1.0, 0.0, 0.0)); |
| 1023 |
mobility.SetPositionAllocator (positionAlloc); |
| 1024 |
|
| 1025 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
| 1026 |
mobility.Install (wifiNodes); |
| 1027 |
|
| 1028 |
Ptr<WifiNetDevice> device1 = DynamicCast<WifiNetDevice> (wifiDevices.Get (0)); |
| 1029 |
Ptr<WifiNetDevice> device2 = DynamicCast<WifiNetDevice> (wifiDevices.Get (1)); |
| 1030 |
|
| 1031 |
PacketSocketAddress socket; |
| 1032 |
socket.SetSingleDevice (device1->GetIfIndex ()); |
| 1033 |
socket.SetPhysicalAddress (device2->GetAddress ()); |
| 1034 |
socket.SetProtocol (1); |
| 1035 |
|
| 1036 |
PacketSocketHelper packetSocket; |
| 1037 |
packetSocket.Install (wifiNodes); |
| 1038 |
|
| 1039 |
Ptr<PacketSocketClient> clientLowPriority = CreateObject<PacketSocketClient> (); |
| 1040 |
clientLowPriority->SetAttribute ("PacketSize", UintegerValue (1460)); |
| 1041 |
clientLowPriority->SetAttribute ("MaxPackets", UintegerValue (1)); |
| 1042 |
clientLowPriority->SetAttribute ("Priority", UintegerValue (4)); //AC_VI |
| 1043 |
clientLowPriority->SetRemote (socket); |
| 1044 |
wifiNodes.Get(0)->AddApplication (clientLowPriority); |
| 1045 |
clientLowPriority->SetStartTime (Seconds (0.0)); |
| 1046 |
clientLowPriority->SetStopTime (Seconds (1.0)); |
| 1047 |
|
| 1048 |
Ptr<PacketSocketClient> clientHighPriority = CreateObject<PacketSocketClient> (); |
| 1049 |
clientHighPriority->SetAttribute ("PacketSize", UintegerValue (1460)); |
| 1050 |
clientHighPriority->SetAttribute ("MaxPackets", UintegerValue (1)); |
| 1051 |
clientHighPriority->SetAttribute ("Priority", UintegerValue (6)); //AC_VO |
| 1052 |
clientHighPriority->SetRemote (socket); |
| 1053 |
wifiNodes.Get(0)->AddApplication (clientHighPriority); |
| 1054 |
clientHighPriority->SetStartTime (Seconds (0.0)); |
| 1055 |
clientHighPriority->SetStopTime (Seconds (1.0)); |
| 1056 |
|
| 1057 |
Ptr<PacketSocketServer> server = CreateObject<PacketSocketServer> (); |
| 1058 |
server->SetLocal (socket); |
| 1059 |
wifiNodes.Get(1)->AddApplication (server); |
| 1060 |
server->SetStartTime (Seconds (0.0)); |
| 1061 |
server->SetStopTime (Seconds (1.0)); |
| 1062 |
|
| 1063 |
Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this)); |
| 1064 |
|
| 1065 |
Simulator::Stop (Seconds (1.0)); |
| 1066 |
Simulator::Run (); |
| 1067 |
Simulator::Destroy (); |
| 1068 |
|
| 1069 |
NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!"); |
| 1070 |
} |
| 1071 |
|
| 1072 |
//----------------------------------------------------------------------------- |
| 1073 |
|
| 953 |
class WifiTestSuite : public TestSuite |
1074 |
class WifiTestSuite : public TestSuite |
| 954 |
{ |
1075 |
{ |
| 955 |
public: |
1076 |
public: |
|
|
| 965 |
AddTestCase (new Bug555TestCase, TestCase::QUICK); //Bug 555 |
1086 |
AddTestCase (new Bug555TestCase, TestCase::QUICK); //Bug 555 |
| 966 |
AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 |
1087 |
AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 |
| 967 |
AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK); |
1088 |
AddTestCase (new SetChannelFrequencyTest, TestCase::QUICK); |
|
|
1089 |
AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222 |
| 968 |
} |
1090 |
} |
| 969 |
|
1091 |
|
| 970 |
static WifiTestSuite g_wifiTestSuite; |
1092 |
static WifiTestSuite g_wifiTestSuite; |