|
|
| 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" |
|
|
| 39 |
#include "ns3/packet-socket-server.h" |
39 |
#include "ns3/packet-socket-server.h" |
| 40 |
#include "ns3/packet-socket-client.h" |
40 |
#include "ns3/packet-socket-client.h" |
| 41 |
#include "ns3/packet-socket-helper.h" |
41 |
#include "ns3/packet-socket-helper.h" |
|
|
42 |
#include "ns3/udp-client-server-helper.h" |
| 43 |
#include "ns3/qos-tag.h" |
| 44 |
#include "ns3/internet-stack-helper.h" |
| 45 |
#include "ns3/ipv4-address-helper.h" |
| 46 |
#include "ns3/ipv4-global-routing-helper.h" |
| 47 |
#include "ns3/ipv4-interface.h" |
| 48 |
#include "ns3/ipv4-l3-protocol.h" |
| 49 |
#include "ns3/arp-cache.h" |
| 50 |
#include "ns3/node-list.h" |
| 51 |
#include "ns3/object-vector.h" |
| 42 |
|
52 |
|
| 43 |
using namespace ns3; |
53 |
using namespace ns3; |
| 44 |
|
54 |
|
|
|
| 74 |
} |
84 |
} |
| 75 |
} |
85 |
} |
| 76 |
|
86 |
|
|
|
87 |
void |
| 88 |
TagMarker(uint8_t tid, Ptr<const Packet> packet) |
| 89 |
{ |
| 90 |
QosTag qosTag; |
| 91 |
qosTag.SetTid(tid); |
| 92 |
packet->AddPacketTag(qosTag); |
| 93 |
} |
| 94 |
|
| 77 |
|
95 |
|
| 78 |
class WifiTest : public TestCase |
96 |
class WifiTest : public TestCase |
| 79 |
{ |
97 |
{ |
|
|
| 619 |
} |
637 |
} |
| 620 |
|
638 |
|
| 621 |
//----------------------------------------------------------------------------- |
639 |
//----------------------------------------------------------------------------- |
|
|
640 |
/** |
| 641 |
* Make sure that when virtual collision occurs the wifi remote station manager |
| 642 |
* is triggered and the retry counter is increased. |
| 643 |
* |
| 644 |
* See \bugid{2222} |
| 645 |
*/ |
| 646 |
|
| 647 |
class Bug2222TestCase : public TestCase |
| 648 |
{ |
| 649 |
public: |
| 650 |
Bug2222TestCase (); |
| 651 |
virtual ~Bug2222TestCase (); |
| 652 |
|
| 653 |
virtual void DoRun (void); |
| 654 |
|
| 655 |
|
| 656 |
private: |
| 657 |
uint32_t m_countInternalCollisions; |
| 658 |
|
| 659 |
void PopulateArpCache (); |
| 660 |
void TxDataFailedTrace (std::string context, Mac48Address adr); |
| 661 |
}; |
| 662 |
|
| 663 |
Bug2222TestCase::Bug2222TestCase () |
| 664 |
: TestCase ("Test case for Bug 2222"), |
| 665 |
m_countInternalCollisions (0) |
| 666 |
{ |
| 667 |
} |
| 668 |
|
| 669 |
Bug2222TestCase::~Bug2222TestCase () |
| 670 |
{ |
| 671 |
} |
| 672 |
|
| 673 |
void Bug2222TestCase::PopulateArpCache() |
| 674 |
{ |
| 675 |
Ptr<ArpCache> arp = CreateObject<ArpCache> (); |
| 676 |
arp->SetAliveTimeout (Seconds (3600 * 24 * 365)); |
| 677 |
for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) |
| 678 |
{ |
| 679 |
Ptr<Ipv4L3Protocol> ip = (*i)->GetObject<Ipv4L3Protocol> (); |
| 680 |
ObjectVectorValue interfaces; |
| 681 |
ip->GetAttribute ("InterfaceList", interfaces); |
| 682 |
for (ObjectVectorValue::Iterator j = interfaces.Begin (); j != interfaces.End (); j++) |
| 683 |
{ |
| 684 |
Ptr<Ipv4Interface> ipIface = StaticCast<Ipv4Interface, Object> ((*j).second); |
| 685 |
Ptr<NetDevice> device = ipIface->GetDevice (); |
| 686 |
Mac48Address addr = Mac48Address::ConvertFrom(device->GetAddress ()); |
| 687 |
for (uint32_t k = 0; k < ipIface->GetNAddresses (); k++) |
| 688 |
{ |
| 689 |
Ipv4Address ipAddr = ipIface->GetAddress (k).GetLocal (); |
| 690 |
if (ipAddr == Ipv4Address::GetLoopback ()) |
| 691 |
continue; |
| 692 |
ArpCache::Entry * entry = arp->Add (ipAddr); |
| 693 |
entry->SetMacAddresss (addr); |
| 694 |
entry->MarkPermanent (); |
| 695 |
} |
| 696 |
} |
| 697 |
} |
| 698 |
for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) |
| 699 |
{ |
| 700 |
Ptr<Ipv4L3Protocol> ip = (*i)->GetObject<Ipv4L3Protocol> (); |
| 701 |
ObjectVectorValue interfaces; |
| 702 |
ip->GetAttribute("InterfaceList", interfaces); |
| 703 |
for (ObjectVectorValue::Iterator j = interfaces.Begin (); j != interfaces.End (); j++) |
| 704 |
{ |
| 705 |
Ptr<Ipv4Interface> ipIface = StaticCast<Ipv4Interface, Object> ((*j).second); |
| 706 |
ipIface->SetAttribute ("ArpCache", PointerValue (arp)); |
| 707 |
} |
| 708 |
} |
| 709 |
} |
| 710 |
|
| 711 |
void |
| 712 |
Bug2222TestCase::TxDataFailedTrace (std::string context, Mac48Address adr) |
| 713 |
{ |
| 714 |
//Indicate the long retry counter has been increased in the wifi remote station manager |
| 715 |
m_countInternalCollisions++; |
| 716 |
} |
| 717 |
|
| 718 |
void |
| 719 |
Bug2222TestCase::DoRun (void) |
| 720 |
{ |
| 721 |
m_countInternalCollisions = 0; |
| 722 |
|
| 723 |
//Generate same backoff for AC_VI and AC_VO |
| 724 |
RngSeedManager::SetSeed (1); |
| 725 |
RngSeedManager::SetRun (9); |
| 726 |
|
| 727 |
NodeContainer wifiApNode; |
| 728 |
NodeContainer wifiStaNode; |
| 729 |
wifiApNode.Create (1); |
| 730 |
wifiStaNode.Create (1); |
| 731 |
|
| 732 |
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
| 733 |
YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
| 734 |
phy.SetChannel (channel.Create ()); |
| 735 |
phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO); |
| 736 |
|
| 737 |
WifiHelper wifi; |
| 738 |
WifiMacHelper mac; |
| 739 |
Ssid ssid = Ssid ("ns3-80211a"); |
| 740 |
mac.SetType ("ns3::AdhocWifiMac", |
| 741 |
"Ssid", SsidValue(ssid), |
| 742 |
"QosSupported", BooleanValue (true)); |
| 743 |
NetDeviceContainer apDevice = wifi.Install (phy, mac, wifiApNode); |
| 744 |
NetDeviceContainer staDevice = wifi.Install (phy, mac, wifiStaNode); |
| 745 |
|
| 746 |
Ptr<ListPositionAllocator> positionAllocator = CreateObject<ListPositionAllocator>(); |
| 747 |
positionAllocator->Add (Vector (0.0, 0.0, 0.0)); |
| 748 |
positionAllocator->Add (Vector (1.0, 0.0, 0.0)); |
| 749 |
MobilityHelper mobility; |
| 750 |
mobility.SetPositionAllocator (positionAllocator); |
| 751 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
| 752 |
mobility.Install (wifiApNode); |
| 753 |
mobility.Install (wifiStaNode); |
| 754 |
|
| 755 |
InternetStackHelper stack; |
| 756 |
stack.Install (wifiApNode); |
| 757 |
stack.Install (wifiStaNode); |
| 758 |
|
| 759 |
Ipv4AddressHelper address; |
| 760 |
address.SetBase ("192.168.1.0", "255.255.255.0"); |
| 761 |
Ipv4InterfaceContainer apNodeInterface = address.Assign (apDevice); |
| 762 |
address.Assign (staDevice); |
| 763 |
|
| 764 |
UdpClientHelper clientHelperVideo (apNodeInterface.GetAddress (0), 4000); |
| 765 |
clientHelperVideo.SetAttribute ("MaxPackets", UintegerValue (1u)); |
| 766 |
clientHelperVideo.SetAttribute ("PacketSize", UintegerValue (1500)); |
| 767 |
ApplicationContainer clientAppVideo = clientHelperVideo.Install (wifiStaNode); |
| 768 |
clientAppVideo.Start (Seconds (0.0)); |
| 769 |
Ptr<UdpClient> udpClientVideo; |
| 770 |
udpClientVideo = DynamicCast<UdpClient> (clientAppVideo.Get (0)); |
| 771 |
udpClientVideo->TraceConnectWithoutContext ("Tx", MakeBoundCallback(&TagMarker, UP_VI)); |
| 772 |
|
| 773 |
UdpClientHelper clientHelperVoice (apNodeInterface.GetAddress (0), 5000); |
| 774 |
clientHelperVoice.SetAttribute ("MaxPackets", UintegerValue (1u)); |
| 775 |
clientHelperVoice.SetAttribute ("PacketSize", UintegerValue (1000)); |
| 776 |
ApplicationContainer clientAppVoice = clientHelperVoice.Install(wifiStaNode); |
| 777 |
clientAppVoice.Start (Seconds (0.0)); |
| 778 |
Ptr<UdpClient> udpClientVoice; |
| 779 |
udpClientVoice = DynamicCast<UdpClient> (clientAppVoice.Get (0)); |
| 780 |
udpClientVoice->TraceConnectWithoutContext ("Tx", MakeBoundCallback(&TagMarker, UP_VO)); |
| 781 |
|
| 782 |
Bug2222TestCase::PopulateArpCache (); |
| 783 |
Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
| 784 |
|
| 785 |
Config::Connect ("/NodeList/*/DeviceList/*/RemoteStationManager/MacTxDataFailed", MakeCallback (&Bug2222TestCase::TxDataFailedTrace, this)); |
| 786 |
|
| 787 |
Simulator::Stop (Seconds (1.0)); |
| 788 |
Simulator::Run (); |
| 789 |
Simulator::Destroy (); |
| 790 |
|
| 791 |
NS_TEST_ASSERT_MSG_EQ (m_countInternalCollisions, 1, "unexpected number of internal collisions!"); |
| 792 |
} |
| 793 |
|
| 794 |
//----------------------------------------------------------------------------- |
| 795 |
|
| 622 |
class WifiTestSuite : public TestSuite |
796 |
class WifiTestSuite : public TestSuite |
| 623 |
{ |
797 |
{ |
| 624 |
public: |
798 |
public: |
|
|
| 633 |
AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 |
807 |
AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 |
| 634 |
AddTestCase (new Bug555TestCase, TestCase::QUICK); //Bug 555 |
808 |
AddTestCase (new Bug555TestCase, TestCase::QUICK); //Bug 555 |
| 635 |
AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 |
809 |
AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 |
|
|
810 |
AddTestCase (new Bug2222TestCase, TestCase::QUICK); //Bug 2222 |
| 636 |
} |
811 |
} |
| 637 |
|
812 |
|
| 638 |
static WifiTestSuite g_wifiTestSuite; |
813 |
static WifiTestSuite g_wifiTestSuite; |