A Discrete-Event Network Simulator
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 
37 {
38 public:
41 
42 private:
43  virtual void DoRun (void);
44 
51  void ReceivePdDataIndication (uint32_t psduLength, Ptr<Packet> p, uint8_t lqi);
52 };
53 
55  : TestCase ("Test the PLME and PD SAP per IEEE 802.15.4")
56 {
57 }
58 
60 {
61 }
62 
63 void
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
75 {
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 (
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 
104 {
105 public:
107 };
108 
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
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
A suite of tests to run.
Definition: test.h:1342
encapsulates test code
Definition: test.h:1155
LrWpan PLME and PD Interfaces Test.
channel
Definition: third.py:85
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
Definition: lr-wpan-phy.cc:233
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:369
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
Definition: log.cc:393
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual void DoRun(void)
Implementation to actually run this TestCase.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Prefix all trace prints with function.
Definition: log.h:117
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
Print everything.
Definition: log.h:115
static LrWpanPlmeAndPdInterfaceTestSuite g_lrWpanPlmeAndPdInterfaceTestSuite
Static variable for test initialization.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:309
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
Receives a PdData indication.
LrWpan PLME and PD Interfaces TestSuite.