This documentation is not the
Latest Release
.
A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
30
// This is an example TestCase.
31
class
LrWpanPlmeAndPdInterfaceTestCase
:
public
TestCase
32
{
33
public
:
34
LrWpanPlmeAndPdInterfaceTestCase
();
35
virtual
~
LrWpanPlmeAndPdInterfaceTestCase
();
36
37
private
:
38
virtual
void
DoRun (
void
);
39
void
ReceivePdDataInndication (uint32_t psduLength,
Ptr<Packet>
p, uint8_t lqi);
40
};
41
42
LrWpanPlmeAndPdInterfaceTestCase::LrWpanPlmeAndPdInterfaceTestCase
()
43
:
TestCase
(
"Test the PLME and PD SAP per IEEE 802.15.4"
)
44
{
45
}
46
47
LrWpanPlmeAndPdInterfaceTestCase::~LrWpanPlmeAndPdInterfaceTestCase
()
48
{
49
}
50
51
void
52
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataInndication
(uint32_t psduLength,
53
Ptr<Packet>
p,
54
uint8_t lqi)
55
{
56
NS_LOG_UNCOND
(
"At: "
<<
Simulator::Now
()
57
<<
" Received frame size: "
<< psduLength <<
" LQI: "
<<
58
lqi);
59
}
60
61
void
62
LrWpanPlmeAndPdInterfaceTestCase::DoRun
(
void
)
63
{
64
LogComponentEnableAll
(
LOG_PREFIX_FUNC
);
65
LogComponentEnable
(
"LrWpanPhy"
,
LOG_LEVEL_ALL
);
66
67
Ptr<LrWpanPhy>
sender = CreateObject<LrWpanPhy> ();
68
Ptr<LrWpanPhy>
receiver = CreateObject<LrWpanPhy> ();
69
70
Ptr<SingleModelSpectrumChannel>
channel
= CreateObject<SingleModelSpectrumChannel> ();
71
sender->
SetChannel
(channel);
72
receiver->SetChannel (channel);
73
74
receiver->SetPdDataIndicationCallback (
MakeCallback
(
75
&
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataInndication
,
76
this
));
77
78
uint32_t n = 10;
79
Ptr<Packet>
p = Create<Packet> (n);
80
sender->
PdDataRequest
(p->
GetSize
(), p);
81
82
Simulator::Destroy ();
83
}
84
85
// ==============================================================================
86
class
LrWpanPlmeAndPdInterfaceTestSuite
:
public
TestSuite
87
{
88
public
:
89
LrWpanPlmeAndPdInterfaceTestSuite
();
90
};
91
92
LrWpanPlmeAndPdInterfaceTestSuite::LrWpanPlmeAndPdInterfaceTestSuite
()
93
:
TestSuite
(
"lr-wpan-plme-pd-sap"
, UNIT)
94
{
95
AddTestCase
(
new
LrWpanPlmeAndPdInterfaceTestCase
, TestCase::QUICK);
96
}
97
98
// Do not forget to allocate an instance of this TestSuite
99
static
LrWpanPlmeAndPdInterfaceTestSuite
lrWpanPlmeAndPdInterfaceTestSuite
;
third.channel
tuple channel
Definition:
third.py:85
ns3::Ptr< Packet >
LrWpanPlmeAndPdInterfaceTestCase::ReceivePdDataInndication
void ReceivePdDataInndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
Definition:
lr-wpan-pd-plme-sap-test.cc:52
ns3::TestSuite
A suite of tests to run.
Definition:
test.h:1333
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:786
ns3::TestCase
encapsulates test code
Definition:
test.h:1147
LrWpanPlmeAndPdInterfaceTestCase
Definition:
lr-wpan-pd-plme-sap-test.cc:31
ns3::LrWpanPhy::SetChannel
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
Definition:
lr-wpan-phy.cc:233
ns3::LogComponentEnable
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition:
log.cc:351
ns3::TestCase::AddTestCase
void AddTestCase(TestCase *testCase, enum TestDuration duration)
Add an individual child TestCase to this test suite.
Definition:
test.cc:297
LrWpanPlmeAndPdInterfaceTestCase::LrWpanPlmeAndPdInterfaceTestCase
LrWpanPlmeAndPdInterfaceTestCase()
Definition:
lr-wpan-pd-plme-sap-test.cc:42
lrWpanPlmeAndPdInterfaceTestSuite
static LrWpanPlmeAndPdInterfaceTestSuite lrWpanPlmeAndPdInterfaceTestSuite
Definition:
lr-wpan-pd-plme-sap-test.cc:99
ns3::MakeCallback
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition:
callback.h:1480
ns3::LogComponentEnableAll
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
Definition:
log.cc:375
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
LrWpanPlmeAndPdInterfaceTestCase::DoRun
virtual void DoRun(void)
Implementation to actually run this TestCase.
Definition:
lr-wpan-pd-plme-sap-test.cc:62
ns3::LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition:
log.h:114
NS_LOG_UNCOND
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
Definition:
log-macros-enabled.h:238
LrWpanPlmeAndPdInterfaceTestSuite::LrWpanPlmeAndPdInterfaceTestSuite
LrWpanPlmeAndPdInterfaceTestSuite()
Definition:
lr-wpan-pd-plme-sap-test.cc:92
ns3::LrWpanPhy::PdDataRequest
void PdDataRequest(const uint32_t psduLength, Ptr< Packet > p)
IEEE 802.15.4-2006 section 6.2.1.1 PD-DATA.request Request to transfer MPDU from MAC (transmitting) ...
Definition:
lr-wpan-phy.cc:523
ns3::LOG_LEVEL_ALL
Print everything.
Definition:
log.h:112
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition:
simulator.cc:330
LrWpanPlmeAndPdInterfaceTestCase::~LrWpanPlmeAndPdInterfaceTestCase
virtual ~LrWpanPlmeAndPdInterfaceTestCase()
Definition:
lr-wpan-pd-plme-sap-test.cc:47
LrWpanPlmeAndPdInterfaceTestSuite
Definition:
lr-wpan-pd-plme-sap-test.cc:86
src
lr-wpan
test
lr-wpan-pd-plme-sap-test.cc
Generated on Wed Nov 11 2015 20:00:36 for ns-3 by
1.8.9.1