|
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> (Case for Bug 991) |
|
|
21 |
* Sébastien Deronne <sebastien.deronne@gmail.com> (Case for bug 730) |
21 |
*/ |
22 |
*/ |
22 |
|
23 |
|
|
|
24 |
#include "ns3/nqos-wifi-mac-helper.h" |
25 |
#include "ns3/yans-wifi-helper.h" |
26 |
#include "ns3/internet-stack-helper.h" |
27 |
#include "ns3/ipv4-address-helper.h" |
28 |
#include "ns3/packet-sink-helper.h" |
29 |
#include "ns3/on-off-helper.h" |
30 |
#include "ns3/mobility-helper.h" |
23 |
#include "ns3/wifi-net-device.h" |
31 |
#include "ns3/wifi-net-device.h" |
24 |
#include "ns3/yans-wifi-channel.h" |
|
|
25 |
#include "ns3/adhoc-wifi-mac.h" |
32 |
#include "ns3/adhoc-wifi-mac.h" |
26 |
#include "ns3/yans-wifi-phy.h" |
|
|
27 |
#include "ns3/arf-wifi-manager.h" |
28 |
#include "ns3/propagation-delay-model.h" |
33 |
#include "ns3/propagation-delay-model.h" |
29 |
#include "ns3/propagation-loss-model.h" |
34 |
#include "ns3/propagation-loss-model.h" |
30 |
#include "ns3/error-rate-model.h" |
|
|
31 |
#include "ns3/yans-error-rate-model.h" |
35 |
#include "ns3/yans-error-rate-model.h" |
32 |
#include "ns3/constant-position-mobility-model.h" |
36 |
#include "ns3/constant-position-mobility-model.h" |
33 |
#include "ns3/node.h" |
|
|
34 |
#include "ns3/simulator.h" |
35 |
#include "ns3/test.h" |
37 |
#include "ns3/test.h" |
36 |
#include "ns3/object-factory.h" |
|
|
37 |
#include "ns3/dca-txop.h" |
38 |
#include "ns3/mac-rx-middle.h" |
39 |
#include "ns3/pointer.h" |
38 |
#include "ns3/pointer.h" |
40 |
#include "ns3/rng-seed-manager.h" |
39 |
#include "ns3/rng-seed-manager.h" |
41 |
#include "ns3/edca-txop-n.h" |
|
|
42 |
#include "ns3/config.h" |
40 |
#include "ns3/config.h" |
43 |
#include "ns3/boolean.h" |
41 |
#include "ns3/boolean.h" |
|
|
42 |
#include "ns3/string.h" |
44 |
|
43 |
|
45 |
using namespace ns3; |
44 |
using namespace ns3; |
46 |
|
45 |
|
|
483 |
|
482 |
|
484 |
|
483 |
|
485 |
//----------------------------------------------------------------------------- |
484 |
//----------------------------------------------------------------------------- |
|
|
485 |
/** |
486 |
* TODO description |
487 |
* |
488 |
* See \bugid{730} |
489 |
*/ |
490 |
|
491 |
class Bug730TestCase : public TestCase |
492 |
{ |
493 |
public: |
494 |
Bug730TestCase (); |
495 |
virtual ~Bug730TestCase (); |
496 |
|
497 |
virtual void DoRun (void); |
498 |
|
499 |
|
500 |
private: |
501 |
void Receive (std::string context, Ptr<const Packet> p, const Address &adr); |
502 |
|
503 |
uint32_t m_received; |
504 |
}; |
505 |
|
506 |
Bug730TestCase::Bug730TestCase () |
507 |
: TestCase ("Test case for Bug 730"), |
508 |
m_received (0) |
509 |
{ |
510 |
} |
511 |
|
512 |
Bug730TestCase::~Bug730TestCase () |
513 |
{ |
514 |
} |
515 |
|
516 |
void |
517 |
Bug730TestCase::Receive (std::string context, Ptr<const Packet> p, const Address &adr) |
518 |
{ |
519 |
std::cout << Simulator::Now ().GetSeconds () << ": " << context << " size=" << p->GetSize() << std::endl; |
520 |
if ((p->GetSize()==1460) && (Simulator::Now () > Seconds (20))) |
521 |
{ |
522 |
m_received++; |
523 |
} |
524 |
} |
525 |
|
526 |
void |
527 |
Bug730TestCase::DoRun (void) |
528 |
{ |
529 |
m_received = 0; |
530 |
|
531 |
Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue ("2304")); |
532 |
Config::SetDefault ("ns3::TcpSocket::DelAckCount", UintegerValue (2)); |
533 |
Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (1460)); |
534 |
|
535 |
NodeContainer wifiStaNode; |
536 |
wifiStaNode.Create (1); |
537 |
|
538 |
NodeContainer wifiApNode; |
539 |
wifiApNode.Create(1); |
540 |
|
541 |
YansWifiChannelHelper channel = YansWifiChannelHelper::Default (); |
542 |
YansWifiPhyHelper phy = YansWifiPhyHelper::Default (); |
543 |
phy.SetChannel (channel.Create()); |
544 |
|
545 |
WifiHelper wifi = WifiHelper::Default (); |
546 |
wifi.SetStandard (WIFI_PHY_STANDARD_80211b); |
547 |
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", |
548 |
"DataMode", StringValue ("DsssRate1Mbps")); |
549 |
|
550 |
NqosWifiMacHelper mac = NqosWifiMacHelper::Default (); |
551 |
Ssid ssid = Ssid ("ns-3-ssid"); |
552 |
mac.SetType ("ns3::StaWifiMac", |
553 |
"Ssid", SsidValue (ssid), |
554 |
"ActiveProbing", BooleanValue (false)); |
555 |
|
556 |
NetDeviceContainer staDevices; |
557 |
staDevices = wifi.Install (phy, mac, wifiStaNode); |
558 |
|
559 |
mac.SetType ("ns3::ApWifiMac", |
560 |
"Ssid", SsidValue (ssid), |
561 |
"BeaconGeneration", BooleanValue (true)); |
562 |
|
563 |
NetDeviceContainer apDevices; |
564 |
apDevices = wifi.Install (phy, mac, wifiApNode); |
565 |
|
566 |
MobilityHelper mobility; |
567 |
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> (); |
568 |
|
569 |
positionAlloc->Add (Vector (0.0, 0.0, 0.0)); |
570 |
positionAlloc->Add (Vector (1.0, 0.0, 0.0)); |
571 |
mobility.SetPositionAllocator (positionAlloc); |
572 |
|
573 |
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); |
574 |
mobility.Install (wifiApNode); |
575 |
mobility.Install (wifiStaNode); |
576 |
|
577 |
InternetStackHelper stack; |
578 |
stack.Install (wifiApNode); |
579 |
stack.Install (wifiStaNode); |
580 |
|
581 |
Ipv4AddressHelper address; |
582 |
address.SetBase ("10.1.1.0", "255.255.255.0"); |
583 |
Ipv4InterfaceContainer StaInterface; |
584 |
StaInterface = address.Assign (staDevices); |
585 |
Ipv4InterfaceContainer ApInterface; |
586 |
ApInterface = address.Assign (apDevices); |
587 |
|
588 |
Address sinkLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), 21)); |
589 |
PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory", sinkLocalAddress); |
590 |
ApplicationContainer sinkApp = sinkHelper.Install (wifiApNode.Get (0)); |
591 |
sinkApp.Start (Seconds (1.0)); |
592 |
sinkApp.Stop (Seconds (51.0)); |
593 |
|
594 |
OnOffHelper sourceHelper ("ns3::TcpSocketFactory", Address ()); |
595 |
sourceHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Constant=1]")); |
596 |
sourceHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]")); |
597 |
AddressValue remoteAddress (InetSocketAddress (ApInterface.GetAddress (0), 21)); |
598 |
sourceHelper.SetAttribute ("Remote", remoteAddress); |
599 |
sourceHelper.SetAttribute ("PacketSize", UintegerValue (1460)); |
600 |
sourceHelper.SetAttribute ("DataRate", StringValue ("10Mb/s")); |
601 |
ApplicationContainer sourceApp; |
602 |
sourceApp.Add (sourceHelper.Install (wifiStaNode.Get(0))); |
603 |
sourceApp.Start (Seconds (1.0)); |
604 |
sourceApp.Stop (Seconds (51.0)); |
605 |
|
606 |
Config::Connect ("/NodeList/*/ApplicationList/0/$ns3::PacketSink/Rx", MakeCallback (&Bug730TestCase::Receive, this)); |
607 |
|
608 |
Simulator::Schedule (Seconds (10.0), Config::Set, "/NodeList/0/DeviceList/0/RemoteStationManager/FragmentationThreshold", StringValue ("800")); |
609 |
|
610 |
Simulator::Stop (Seconds(55)); |
611 |
Simulator::Run (); |
612 |
Simulator::Destroy (); |
613 |
|
614 |
bool result = (m_received > 0); |
615 |
NS_TEST_ASSERT_MSG_EQ (result, true, ""); |
616 |
} |
617 |
|
618 |
|
619 |
//----------------------------------------------------------------------------- |
486 |
class WifiTestSuite : public TestSuite |
620 |
class WifiTestSuite : public TestSuite |
487 |
{ |
621 |
{ |
488 |
public: |
622 |
public: |
|
496 |
AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK); |
630 |
AddTestCase (new QosUtilsIsOldPacketTest, TestCase::QUICK); |
497 |
AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 |
631 |
AddTestCase (new InterferenceHelperSequenceTest, TestCase::QUICK); //Bug 991 |
498 |
AddTestCase (new Bug555TestCase, TestCase::QUICK); //Bug 555 |
632 |
AddTestCase (new Bug555TestCase, TestCase::QUICK); //Bug 555 |
|
|
633 |
AddTestCase (new Bug730TestCase, TestCase::QUICK); //Bug 730 |
499 |
} |
634 |
} |
500 |
|
635 |
|
501 |
static WifiTestSuite g_wifiTestSuite; |
636 |
static WifiTestSuite g_wifiTestSuite; |