A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
lr-wpan-pd-plme-sap-test.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 The Boeing Company
3
*
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 2 as
6
* published by the Free Software Foundation;
7
*
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
12
*
13
* You should have received a copy of the GNU General Public License
14
* along with this program; if not, write to the Free Software
15
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
*
17
* Author: Gary Pei <guangyu.pei@boeing.com>
18
*/
19
#include <ns3/log.h>
20
#include <ns3/lr-wpan-mac.h>
21
#include <ns3/lr-wpan-phy.h>
22
#include <ns3/packet.h>
23
#include <ns3/simulator.h>
24
#include <ns3/single-model-spectrum-channel.h>
25
#include <ns3/test.h>
26
27
using namespace
ns3
;
28
35
class
LrWpanPlmeAndPdInterfaceTestCase
:
public
TestCase
36
{
37
public
:
38
LrWpanPlmeAndPdInterfaceTestCase
();
39
~
LrWpanPlmeAndPdInterfaceTestCase
()
override
;
40
41
private
:
42
void
DoRun()
override
;
43
50
void
ReceivePdDataIndication
(uint32_t psduLength,
Ptr<Packet>
p, uint8_t lqi);
51
};
52
53
LrWpanPlmeAndPdInterfaceTestCase::LrWpanPlmeAndPdInterfaceTestCase
()
54
:
TestCase
(
"Test the PLME and PD SAP per IEEE 802.15.4"
)
55
{
56
}
57
58
LrWpanPlmeAndPdInterfaceTestCase::~LrWpanPlmeAndPdInterfaceTestCase
()
59
{
60
}
61
62
void
63
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataIndication
(uint32_t psduLength,
64
Ptr<Packet>
p,
65
uint8_t lqi)
66
{
67
NS_LOG_UNCOND
(
"At: "
<<
Simulator::Now
() <<
" Received frame size: "
<< psduLength
68
<<
" LQI: "
<< lqi);
69
}
70
71
void
72
LrWpanPlmeAndPdInterfaceTestCase::DoRun
()
73
{
74
LogComponentEnableAll
(
LOG_PREFIX_FUNC
);
75
LogComponentEnable
(
"LrWpanPhy"
,
LOG_LEVEL_ALL
);
76
77
Ptr<LrWpanPhy>
sender = CreateObject<LrWpanPhy>();
78
Ptr<LrWpanPhy>
receiver = CreateObject<LrWpanPhy>();
79
80
Ptr<SingleModelSpectrumChannel>
channel
= CreateObject<SingleModelSpectrumChannel>();
81
sender->SetChannel(
channel
);
82
receiver->SetChannel(
channel
);
83
84
receiver->SetPdDataIndicationCallback(
85
MakeCallback
(&
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataIndication
,
this
));
86
87
uint32_t n = 10;
88
Ptr<Packet>
p = Create<Packet>(n);
89
sender->PdDataRequest(p->
GetSize
(), p);
90
91
Simulator::Destroy();
92
}
93
100
class
LrWpanPlmeAndPdInterfaceTestSuite
:
public
TestSuite
101
{
102
public
:
103
LrWpanPlmeAndPdInterfaceTestSuite
();
104
};
105
106
LrWpanPlmeAndPdInterfaceTestSuite::LrWpanPlmeAndPdInterfaceTestSuite
()
107
:
TestSuite
(
"lr-wpan-plme-pd-sap"
, UNIT)
108
{
109
AddTestCase
(
new
LrWpanPlmeAndPdInterfaceTestCase
, TestCase::QUICK);
110
}
111
112
// Do not forget to allocate an instance of this TestSuite
113
static
LrWpanPlmeAndPdInterfaceTestSuite
114
g_lrWpanPlmeAndPdInterfaceTestSuite
;
LrWpanPlmeAndPdInterfaceTestCase
LrWpan PLME and PD Interfaces Test.
Definition:
lr-wpan-pd-plme-sap-test.cc:36
LrWpanPlmeAndPdInterfaceTestCase::LrWpanPlmeAndPdInterfaceTestCase
LrWpanPlmeAndPdInterfaceTestCase()
Definition:
lr-wpan-pd-plme-sap-test.cc:53
LrWpanPlmeAndPdInterfaceTestCase::~LrWpanPlmeAndPdInterfaceTestCase
~LrWpanPlmeAndPdInterfaceTestCase() override
Definition:
lr-wpan-pd-plme-sap-test.cc:58
LrWpanPlmeAndPdInterfaceTestCase::DoRun
void DoRun() override
Implementation to actually run this TestCase.
Definition:
lr-wpan-pd-plme-sap-test.cc:72
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataIndication
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
Receives a PdData indication.
Definition:
lr-wpan-pd-plme-sap-test.cc:63
LrWpanPlmeAndPdInterfaceTestSuite
LrWpan PLME and PD Interfaces TestSuite.
Definition:
lr-wpan-pd-plme-sap-test.cc:101
LrWpanPlmeAndPdInterfaceTestSuite::LrWpanPlmeAndPdInterfaceTestSuite
LrWpanPlmeAndPdInterfaceTestSuite()
Definition:
lr-wpan-pd-plme-sap-test.cc:106
ns3::Packet::GetSize
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition:
packet.h:861
ns3::Ptr< Packet >
ns3::TestCase
encapsulates test code
Definition:
test.h:1060
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition:
test.cc:301
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1256
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Definition:
log-macros-enabled.h:264
ns3::Now
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:305
g_lrWpanPlmeAndPdInterfaceTestSuite
static LrWpanPlmeAndPdInterfaceTestSuite g_lrWpanPlmeAndPdInterfaceTestSuite
Static variable for test initialization.
Definition:
lr-wpan-pd-plme-sap-test.cc:114
ReceivePdDataIndication
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
Function called when a the PHY receives a packet.
Definition:
lr-wpan-phy-test.cc:48
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::LogComponentEnable
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Definition:
log.cc:302
ns3::MakeCallback
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:704
ns3::LOG_LEVEL_ALL
@ LOG_LEVEL_ALL
Print everything.
Definition:
log.h:116
ns3::LOG_PREFIX_FUNC
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition:
log.h:118
ns3::LogComponentEnableAll
void LogComponentEnableAll(LogLevel level)
Enable the logging output for all registered log components.
Definition:
log.cc:320
third.channel
channel
Definition:
third.py:88
src
lr-wpan
test
lr-wpan-pd-plme-sap-test.cc
Generated on Sun Mar 3 2024 17:11:01 for ns-3 by
1.9.1