From 881590b6d788ea61df2e55aa2bbd2a119ea1e13d Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Wed, 19 Mar 2008 15:30:41 -0700 Subject: [PATCH] A bunch of wifi smoke tests. --- src/devices/wifi/wifi-test.cc | 129 ++++++++++++++++++++++++++++++++++ src/devices/wifi/wscript | 1 + 2 files changed, 130 insertions(+) create mode 100644 src/devices/wifi/wifi-test.cc diff --git a/src/devices/wifi/wifi-test.cc b/src/devices/wifi/wifi-test.cc new file mode 100644 index 000000000..28e219d4f --- /dev/null +++ b/src/devices/wifi/wifi-test.cc @@ -0,0 +1,129 @@ +#ifdef RUN_SELF_TESTS + +#include "wifi-net-device.h" +#include "wifi-channel.h" +#include "adhoc-wifi-mac.h" +#include "wifi-phy.h" +#include "arf-wifi-manager.h" +#include "propagation-delay-model.h" +#include "propagation-loss-model.h" +#include "ns3/static-mobility-model.h" +#include "ns3/node.h" +#include "ns3/simulator.h" +#include "ns3/test.h" +#include "ns3/object-factory.h" + +namespace ns3 { + +class WifiTest : public Test +{ +public: + WifiTest (); + + virtual bool RunTests (void); +private: + void RunOne (void); + void CreateOne (Vector pos, Ptr channel); + void SendOnePacket (Ptr dev); + + ObjectFactory m_manager; + ObjectFactory m_mac; + ObjectFactory m_propDelay; +}; + +WifiTest::WifiTest () + : Test ("Wifi") +{} + +void +WifiTest::SendOnePacket (Ptr dev) +{ + Ptr p = Create (); + dev->Send (p, dev->GetBroadcast (), 1); +} + +void +WifiTest::CreateOne (Vector pos, Ptr channel) +{ + Ptr node = CreateObject (); + Ptr dev = CreateObject (); + + Ptr mac = m_mac.Create (); + Ptr mobility = CreateObject (); + Ptr phy = CreateObject (); + Ptr manager = m_manager.Create (); + + mobility->SetPosition (pos); + node->AggregateObject (mobility); + mac->SetAddress (Mac48Address::Allocate ()); + dev->SetMac (mac); + dev->SetPhy (phy); + dev->SetRemoteStationManager (manager); + dev->SetChannel (channel); + node->AddDevice (dev); + + Simulator::Schedule (Seconds (1.0), &WifiTest::SendOnePacket, this, dev); +} + +void +WifiTest::RunOne (void) +{ + Ptr channel = CreateObject (); + Ptr propDelay = m_propDelay.Create (); + Ptr propLoss = CreateObject (); + channel->SetPropagationDelayModel (propDelay); + channel->SetPropagationLossModel (propLoss); + + CreateOne (Vector (0.0, 0.0, 0.0), channel); + CreateOne (Vector (5.0, 0.0, 0.0), channel); + CreateOne (Vector (5.0, 0.0, 0.0), channel); + + Simulator::Run (); + Simulator::Destroy (); + + Simulator::StopAt (Seconds (10.0)); +} + +bool +WifiTest::RunTests (void) +{ + bool result = true; + + m_mac.SetTypeId ("ns3::AdhocWifiMac"); + m_propDelay.SetTypeId ("ns3::ConstantSpeedPropagationDelayModel"); + + + m_manager.SetTypeId ("ns3::ArfWifiManager"); + RunOne (); + m_manager.SetTypeId ("ns3::AarfWifiManager"); + RunOne (); + m_manager.SetTypeId ("ns3::ConstantRateWifiManager"); + RunOne (); + m_manager.SetTypeId ("ns3::OnoeWifiManager"); + RunOne (); + m_manager.SetTypeId ("ns3::AmrrWifiManager"); + RunOne (); + m_manager.SetTypeId ("ns3::IdealWifiManager"); + RunOne (); + + m_mac.SetTypeId ("ns3::AdhocWifiMac"); + RunOne (); + m_mac.SetTypeId ("ns3::NqapWifiMac"); + RunOne (); + m_mac.SetTypeId ("ns3::NqstaWifiMac"); + RunOne (); + + + m_propDelay.SetTypeId ("ns3::RandomPropagationDelayModel"); + m_mac.SetTypeId ("ns3::AdhocWifiMac"); + RunOne (); + + return result; +} + +WifiTest g_wifiTest; + + +} // namespace ns3 + +#endif /* RUN_SELF_TESTS */ diff --git a/src/devices/wifi/wscript b/src/devices/wifi/wscript index b9a715fff..41a9e4862 100644 --- a/src/devices/wifi/wscript +++ b/src/devices/wifi/wscript @@ -36,6 +36,7 @@ def build(bld): 'onoe-wifi-manager.cc', 'rraa-wifi-manager.cc', 'constant-rate-wifi-manager.cc', + 'wifi-test.cc', ] headers = bld.create_obj('ns3header') headers.module = 'wifi'