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