A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lr-wpan-pd-plme-sap-test.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011 The Boeing Company
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Gary Pei <guangyu.pei@boeing.com>
7 */
8#include <ns3/log.h>
9#include <ns3/lr-wpan-mac.h>
10#include <ns3/lr-wpan-phy.h>
11#include <ns3/packet.h>
12#include <ns3/simulator.h>
13#include <ns3/single-model-spectrum-channel.h>
14#include <ns3/test.h>
15
16using namespace ns3;
17using namespace ns3::lrwpan;
18
19/**
20 * \ingroup lr-wpan-test
21 * \ingroup tests
22 *
23 * \brief LrWpan PLME and PD Interfaces Test
24 */
26{
27 public:
30
31 private:
32 void DoRun() override;
33
34 /**
35 * \brief Receives a PdData indication
36 * \param psduLength The PSDU length.
37 * \param p The packet.
38 * \param lqi The LQI.
39 */
40 void ReceivePdDataIndication(uint32_t psduLength, Ptr<Packet> p, uint8_t lqi);
41};
42
44 : TestCase("Test the PLME and PD SAP per IEEE 802.15.4")
45{
46}
47
51
52void
55 uint8_t lqi)
56{
57 NS_LOG_UNCOND("At: " << Simulator::Now() << " Received frame size: " << psduLength
58 << " LQI: " << lqi);
59}
60
61void
63{
66
69
71 sender->SetChannel(channel);
72 receiver->SetChannel(channel);
73
74 receiver->SetPdDataIndicationCallback(
76
77 uint32_t n = 10;
79 sender->PdDataRequest(p->GetSize(), p);
80
82}
83
84/**
85 * \ingroup lr-wpan-test
86 * \ingroup tests
87 *
88 * \brief LrWpan PLME and PD Interfaces TestSuite
89 */
95
97 : TestSuite("lr-wpan-plme-pd-sap", Type::UNIT)
98{
99 AddTestCase(new LrWpanPlmeAndPdInterfaceTestCase, TestCase::Duration::QUICK);
100}
101
102// Do not forget to allocate an instance of this TestSuite
104 g_lrWpanPlmeAndPdInterfaceTestSuite; //!< Static variable for test initialization
LrWpan PLME and PD Interfaces Test.
void DoRun() override
Implementation to actually run this TestCase.
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
Receives a PdData indication.
LrWpan PLME and PD Interfaces TestSuite.
Smart pointer class similar to boost::intrusive_ptr.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition simulator.cc:131
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
encapsulates test code
Definition test.h:1050
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
Definition test.cc:292
A suite of tests to run.
Definition test.h:1267
Type
Type of test.
Definition test.h:1274
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
static LrWpanPlmeAndPdInterfaceTestSuite g_lrWpanPlmeAndPdInterfaceTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition log.cc:291
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition callback.h:684
@ LOG_LEVEL_ALL
Print everything.
Definition log.h:105
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition log.h:107
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
Definition log.cc:309