diff -r f41fab27cd75 src/applications/model/udp-client.cc --- a/src/applications/model/udp-client.cc Tue Jun 14 21:15:52 2016 +0200 +++ b/src/applications/model/udp-client.cc Wed Jun 15 22:09:50 2016 +0200 @@ -69,6 +69,9 @@ UintegerValue (1024), MakeUintegerAccessor (&UdpClient::m_size), MakeUintegerChecker (12,1500)) + .AddTraceSource ("Tx", "A new packet is created and is sent", + MakeTraceSourceAccessor (&UdpClient::m_txTrace), + "ns3::Packet::TracedCallback") ; return tid; } @@ -170,6 +173,7 @@ peerAddressStringStream << Ipv6Address::ConvertFrom (m_peerAddress); } + m_txTrace (p); if ((m_socket->Send (p)) >= 0) { ++m_sent; diff -r f41fab27cd75 src/applications/model/udp-client.h --- a/src/applications/model/udp-client.h Tue Jun 14 21:15:52 2016 +0200 +++ b/src/applications/model/udp-client.h Wed Jun 15 22:09:50 2016 +0200 @@ -27,6 +27,7 @@ #include "ns3/event-id.h" #include "ns3/ptr.h" #include "ns3/ipv4-address.h" +#include "ns3/traced-callback.h" namespace ns3 { @@ -95,6 +96,9 @@ uint16_t m_peerPort; //!< Remote peer port EventId m_sendEvent; //!< Event to send the next packet + /// Callbacks for tracing the packet Tx events + TracedCallback > m_txTrace; + }; } // namespace ns3 diff -r f41fab27cd75 src/wifi/test/wifi-test.cc --- a/src/wifi/test/wifi-test.cc Tue Jun 14 21:15:52 2016 +0200 +++ b/src/wifi/test/wifi-test.cc Wed Jun 15 22:09:50 2016 +0200 @@ -17,8 +17,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Authors: Mathieu Lacage - * Quincy Tse (Case for Bug 991) - * Sébastien Deronne (Case for bug 730) + * Quincy Tse + * Sébastien Deronne */ #include "ns3/yans-wifi-helper.h" @@ -39,6 +39,16 @@ #include "ns3/packet-socket-server.h" #include "ns3/packet-socket-client.h" #include "ns3/packet-socket-helper.h" +#include "ns3/udp-client-server-helper.h" +#include "ns3/qos-tag.h" +#include "ns3/internet-stack-helper.h" +#include "ns3/ipv4-address-helper.h" +#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/ipv4-interface.h" +#include "ns3/ipv4-l3-protocol.h" +#include "ns3/arp-cache.h" +#include "ns3/node-list.h" +#include "ns3/object-vector.h" using namespace ns3; @@ -74,6 +84,14 @@ } } +void +TagMarker(uint8_t tid, Ptr packet) +{ + QosTag qosTag; + qosTag.SetTid(tid); + packet->AddPacketTag(qosTag); +} + class WifiTest : public TestCase { @@ -619,6 +637,162 @@ } //----------------------------------------------------------------------------- +/** + * Make sure that when virtual collision occurs the wifi remote station manager + * is triggered and the retry counter is increased. + * + * See \bugid{2222} + */ + +class Bug2222TestCase : public TestCase +{ +public: + Bug2222TestCase (); + virtual ~Bug2222TestCase (); + + virtual void DoRun (void); + + +private: + uint32_t m_countInternalCollisions; + + void PopulateArpCache (); + void TxDataFailedTrace (std::string context, Mac48Address adr); +}; + +Bug2222TestCase::Bug2222TestCase () + : TestCase ("Test case for Bug 2222"), + m_countInternalCollisions (0) +{ +} + +Bug2222TestCase::~Bug2222TestCase () +{ +} + +void Bug2222TestCase::PopulateArpCache() +{ + Ptr arp = CreateObject (); + arp->SetAliveTimeout (Seconds (3600 * 24 * 365)); + for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) + { + Ptr ip = (*i)->GetObject (); + ObjectVectorValue interfaces; + ip->GetAttribute ("InterfaceList", interfaces); + for (ObjectVectorValue::Iterator j = interfaces.Begin (); j != interfaces.End (); j++) + { + Ptr ipIface = StaticCast ((*j).second); + Ptr device = ipIface->GetDevice (); + Mac48Address addr = Mac48Address::ConvertFrom(device->GetAddress ()); + for (uint32_t k = 0; k < ipIface->GetNAddresses (); k++) + { + Ipv4Address ipAddr = ipIface->GetAddress (k).GetLocal (); + if (ipAddr == Ipv4Address::GetLoopback ()) + continue; + ArpCache::Entry * entry = arp->Add (ipAddr); + entry->SetMacAddresss (addr); + entry->MarkPermanent (); + } + } + } + for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) + { + Ptr ip = (*i)->GetObject (); + ObjectVectorValue interfaces; + ip->GetAttribute("InterfaceList", interfaces); + for (ObjectVectorValue::Iterator j = interfaces.Begin (); j != interfaces.End (); j++) + { + Ptr ipIface = StaticCast ((*j).second); + ipIface->SetAttribute ("ArpCache", PointerValue (arp)); + } + } +} + +void +Bug2222TestCase::TxDataFailedTrace (std::string context, Mac48Address adr) +{ + //Indicate the long retry counter has been increased in the wifi remote station manager + m_countInternalCollisions++; +} + +void +Bug2222TestCase::DoRun (void) +{ + m_countInternalCollisions = 0; + + //Generate same backoff for AC_VI and AC_VO + RngSeedManager::SetSeed (1); + RngSeedManager::SetRun (9); + + NodeContainer wifiApNode; + NodeContainer wifiStaNode; + wifiApNode.Create (1); + wifiStaNode.Create (1); + + YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); + YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); + phy.SetChannel (channel.Create ()); + phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); + + WifiHelper wifi; + WifiMacHelper mac; + Ssid ssid = Ssid ("ns3-80211a"); + mac.SetType ("ns3::AdhocWifiMac", + "Ssid", SsidValue(ssid), + "QosSupported", BooleanValue (true)); + NetDeviceContainer apDevice = wifi.Install (phy, mac, wifiApNode); + NetDeviceContainer staDevice = wifi.Install (phy, mac, wifiStaNode); + + Ptr positionAllocator = CreateObject(); + positionAllocator->Add (Vector (0.0, 0.0, 0.0)); + positionAllocator->Add (Vector (1.0, 0.0, 0.0)); + MobilityHelper mobility; + mobility.SetPositionAllocator (positionAllocator); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (wifiApNode); + mobility.Install (wifiStaNode); + + InternetStackHelper stack; + stack.Install (wifiApNode); + stack.Install (wifiStaNode); + + Ipv4AddressHelper address; + address.SetBase ("192.168.1.0", "255.255.255.0"); + Ipv4InterfaceContainer apNodeInterface = address.Assign (apDevice); + address.Assign (staDevice); + + UdpClientHelper clientHelperVideo (apNodeInterface.GetAddress (0), 4000); + clientHelperVideo.SetAttribute ("MaxPackets", UintegerValue (1u)); + clientHelperVideo.SetAttribute ("PacketSize", UintegerValue (1500)); + ApplicationContainer clientAppVideo = clientHelperVideo.Install (wifiStaNode); + clientAppVideo.Start (Seconds (0.0)); + Ptr udpClientVideo; + udpClientVideo = DynamicCast (clientAppVideo.Get (0)); + udpClientVideo->TraceConnectWithoutContext ("Tx", MakeBoundCallback(&TagMarker, UP_VI)); + + UdpClientHelper clientHelperVoice (apNodeInterface.GetAddress (0), 5000); + clientHelperVoice.SetAttribute ("MaxPackets", UintegerValue (1u)); + clientHelperVoice.SetAttribute ("PacketSize", UintegerValue (1000)); + ApplicationContainer clientAppVoice = clientHelperVoice.Install(wifiStaNode); + clientAppVoice.Start (Seconds (0.0)); + Ptr udpClientVoice; + udpClientVoice = DynamicCast (clientAppVoice.Get (0)); + udpClientVoice->TraceConnectWithoutContext ("Tx", MakeBoundCallback(&TagMarker, UP_VO)); + + Bug2222TestCase::PopulateArpCache (); + Ipv4GlobalRoutingHelper::PopulateRoutingTables (); + + Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this)); + + Simulator::Stop (Seconds (1.0)); + Simulator::Run (); + Simulator::Destroy (); + + NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!"); +} + +//----------------------------------------------------------------------------- + class WifiTestSuite : public TestSuite { public: @@ -633,6 +807,7 @@ AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 AddTestCase (new Bug555TestCase, TestCase::QUICK); //Bug 555 AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 + AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222 } static WifiTestSuite g_wifiTestSuite; diff -r f41fab27cd75 src/wifi/wscript --- a/src/wifi/wscript Tue Jun 14 21:15:52 2016 +0200 +++ b/src/wifi/wscript Wed Jun 15 22:09:50 2016 +0200 @@ -1,7 +1,7 @@ ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- def build(bld): - obj = bld.create_ns3_module('wifi', ['network', 'propagation', 'energy']) + obj = bld.create_ns3_module('wifi', ['applications', 'network', 'internet', 'propagation', 'energy']) obj.source = [ 'model/wifi-information-element.cc', 'model/wifi-information-element-vector.cc',