21 #include "ns3/uan-net-device.h"
22 #include "ns3/uan-channel.h"
23 #include "ns3/uan-mac-aloha.h"
24 #include "ns3/uan-phy-gen.h"
25 #include "ns3/uan-transducer-hd.h"
26 #include "ns3/uan-prop-model-ideal.h"
27 #include "ns3/constant-position-mobility-model.h"
28 #include "ns3/simulator.h"
31 #include "ns3/object-factory.h"
32 #include "ns3/pointer.h"
33 #include "ns3/callback.h"
42 virtual void DoRun (
void);
46 uint32_t DoOnePhyTest (
Time t1,
Time t2, uint32_t r1, uint32_t r2,
Ptr<UanPropModel> prop, uint32_t mode1 = 0, uint32_t mode2 = 0);
55 UanTest::UanTest () :
TestCase (
"UAN")
86 mobility->SetPosition (pos);
87 node->AggregateObject (mobility);
88 mac->SetAddress (UanAddress::Allocate ());
92 dev->SetChannel (chan);
93 dev->SetTransducer (trans);
94 node->AddDevice (dev);
101 UanTest::DoOnePhyTest (
Time txTime1,
119 Simulator::Schedule (txTime1, &UanTest::SendOnePacket,
this, dev1, mode1);
120 Simulator::Schedule (txTime2, &UanTest::SendOnePacket,
this, dev2, mode2);
123 Simulator::Stop (Seconds (20.0));
125 Simulator::Destroy ();
132 UanTest::DoPhyTests ()
136 UanTxMode mode = UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 10000, 4000, 2,
"TestMode");
143 m_phyFac.
Set (
"SupportedModes", UanModesListValue (mList));
148 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (3.001), 50, 50, prop),
149 34,
"Should have received 34 bytes from 2 disjoint packets");
152 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (2.99), 50, 50, prop),
153 0,
"Expected collision resulting in loss of both packets");
161 m_phyFac.
Set (
"SupportedModes", UanModesListValue (mList));
163 #ifdef UAN_PROP_BH_INSTALLED
165 #endif // UAN_PROP_BH_INSTALLED
168 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (3.001), 50, 50, prop),
169 34,
"Should have received 34 bytes from 2 disjoint packets");
172 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (1.0126), 50, 50, prop),
173 17,
"Should have recieved 17 bytes from first arriving packet");
176 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (1.0 + 7.01 * (13.0 / 80.0)), 50, 50, prop),
177 0,
"Packets should collide, but received data");
180 UanTxMode mode00 = UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 10000, 4000, 2,
"TestMode00");
181 UanTxMode mode10 = UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 11000, 4000, 2,
"TestMode10");
182 UanTxMode mode20 = UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 15000, 4000, 2,
"TestMode20");
183 UanTxMode mode01 = UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 10000, 4000, 2,
"TestMode01");
184 UanTxMode mode11 = UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 11000, 4000, 2,
"TestMode11");
185 UanTxMode mode21 = UanTxModeFactory::CreateMode (UanTxMode::FSK, 80, 80, 15000, 4000, 2,
"TestMode21");
198 m_phyFac.
Set (
"SupportedModesPhy1", UanModesListValue (m0));
199 m_phyFac.
Set (
"SupportedModesPhy2", UanModesListValue (m1));
202 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (3.01), 50, 50, prop),
203 34,
"Expected no collision");
205 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (2.99), 50, 50, prop, 0, 0),
206 0,
"Expected collision with both packets lost");
208 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (2.99), 50, 50, prop, 0, 2),
209 17,
"Expected collision with only one packets lost");
211 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (2.99), 50, 50, prop, 0, 5),
212 34,
"Expected no collision");
214 NS_TEST_ASSERT_MSG_EQ_RETURNS_BOOL (DoOnePhyTest (Seconds (1.0), Seconds (2.99), 50, 50, prop, 2, 3),
215 34,
"Expected no collision");
226 double error = per->
CalcPer (pkt, 9, UanPhyGen::GetDefaultModes ()[0]);
227 NS_TEST_ASSERT_MSG_EQ_TOL (error, 0.539, 0.001,
"Got PER outside of tolerance");
229 #ifdef UAN_PROP_BH_INSTALLED
232 BellhopResp resp = propBh->GetResp (10000, 50, 50, 1000);
234 NS_TEST_ASSERT_MSG_EQ_TOL (resp.GetPathLossDb (), -44.1753, 0.001,
"Got BH Pathloss outside of tolerance");
236 NS_TEST_ASSERT_MSG_EQ_TOL (resp.GetPdp ().GetTap (4).GetAmp (), 0.14159, 0.001,
"Got BH arrival outside of tolerance");
238 #endif // UAN_PROP_BH_INSTALLED
250 UanTestSuite::UanTestSuite ()
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
smart pointer class similar to boost::intrusive_ptr
void SetTypeId(TypeId tid)
uint32_t GetSize(void) const
Container for UanTxModes.
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual void DoRun(void)
Implementation to actually run this test case.
virtual Address GetBroadcast(void) const
a polymophic address class
Ptr< Object > Create(void) const
Abstraction of packet modulation information.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
hold objects of type Ptr<T>
virtual double CalcPer(Ptr< Packet > pkt, double sinrDb, UanTxMode mode)
void Set(std::string name, const AttributeValue &value)
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Base class for UAN Phy models.
instantiate subclasses of ns3::Object.
void AppendMode(UanTxMode mode)
void SetAttribute(std::string name, const AttributeValue &value)