25 #include <ns3/core-module.h> 26 #include <ns3/lr-wpan-module.h> 27 #include <ns3/propagation-loss-model.h> 28 #include <ns3/propagation-delay-model.h> 29 #include <ns3/simulator.h> 30 #include <ns3/single-model-spectrum-channel.h> 31 #include <ns3/constant-position-mobility-model.h> 32 #include <ns3/packet.h> 33 #include "ns3/rng-seed-manager.h" 102 virtual void DoRun (
void);
116 :
TestCase (
"Test the 802.15.4 ACK handling")
139 replyParams.m_msduHandle = 0;
144 replyParams.m_srcAddrMode =
EXT_ADDR;
145 replyParams.m_dstAddrMode =
EXT_ADDR;
146 replyParams.m_dstExtAddr =
Mac64Address (
"00:00:00:00:00:00:00:01");
186 RngSeedManager::SetSeed (1);
187 RngSeedManager::SetRun (6);
189 Packet::EnablePrinting ();
193 std::string asciiPrefix;
199 m_dev0 = CreateObject<LrWpanNetDevice> ();
200 m_dev1 = CreateObject<LrWpanNetDevice> ();
217 channel->AddPropagationLossModel (propModel);
218 channel->SetPropagationDelayModel (delayModel);
253 uint8_t expectedAckCount = 0;
260 expectedAckCount = 1;
265 params.m_dstAddr = Mac16Address::GetMulticast (Ipv6Address::GetAllNodesMulticast ());
266 expectedAckCount = 0;
271 params.m_dstAddr = Mac16Address::GetBroadcast ();
272 expectedAckCount = 0;
277 params.m_dstExtAddr =
Mac64Address (
"00:00:00:00:00:00:00:02");
278 expectedAckCount = 1;
281 params.m_dstPanId = 0;
282 params.m_msduHandle = 0;
285 Simulator::ScheduleNow (&LrWpanMac::McpsDataRequest,
m_dev0->
GetMac (), params, p0);
291 uint8_t ackCounter = 0;
292 std::string sub (
"Frame Type = 2");
293 for( std::string line; getline ( traceFile, line ); )
295 if (line.find(sub, 0) != std::string::npos)
307 NS_TEST_EXPECT_MSG_EQ (ackCounter, expectedAckCount,
"The right amount of ACKs have been seen on the channel (as expected)");
312 Simulator::Destroy ();
Time m_replySentTime
Reply successfully sent time.
static LrWpanAckTestSuite g_lrWpanAckTestSuite
Static variable for test initialization.
Ptr< LrWpanNetDevice > m_dev0
1st LrWpanNetDevice.
uint16_t m_dstPanId
Destination PAN identifier.
Simulation virtual time values and global simulation resolution.
short addresses, multicast
Time m_replyArrivalTime
Reply arrival time.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
short addresses, broadcast
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Time m_requestSentTime
Request successfully sent time.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to...
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
MCPS-DATA.confirm params.
Ptr< LrWpanNetDevice > m_dev1
2nd LrWpanNetDevice.
TestMode_e m_mode
Test mode.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LrWpanAckTestCase(const char *const prefix, TestMode_e mode)
Create test case.
virtual void DoRun(void)
Implementation to actually run this TestCase.
This class can contain 16 bit addresses.
#define NS_TEST_EXPECT_MSG_GT(actual, limit, msg)
Test that an actual value is greater than a limit and report if not.
void SetPosition(const Vector &position)
void DataIndicationDev0(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when DataIndication is hit on dev0.
void EnableAscii(std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
Enable ascii trace output on the indicated net device.
void DataConfirmDev1(McpsDataConfirmParams params)
Function called when DataConfirm is hit on dev1.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
std::string CreateTempDirFilename(std::string filename)
Construct the full path to a file in a temporary directory.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time m_replyTime
Reply time.
void DataConfirmDev0(McpsDataConfirmParams params)
Function called when DataConfirm is hit on dev0.
#define NS_TEST_EXPECT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report if not.
std::string m_prefix
Filename prefix.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
MCPS-DATA.request params.
helps to manage and create IEEE 802.15.4 NetDevice objects
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
Time m_requestTime
Request time.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void DataIndicationDev1(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when DataIndication is hit on dev1.
MCPS-DATA.indication params.