A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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.
32 {
33 public:
36 
37 private:
38  virtual void DoRun (void);
39  void ReceivePdDataInndication (uint32_t psduLength, Ptr<Packet> p, uint8_t lqi);
40 };
41 
43  : TestCase ("Test the PLME and PD SAP per IEEE 802.15.4")
44 {
45 }
46 
48 {
49 }
50 
51 void
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
63 {
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 (
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 // ==============================================================================
87 {
88 public:
90 };
91 
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
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
Definition: log.cc:342
void ReceivePdDataInndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
A suite of tests to run.
Definition: test.h:1105
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:744
encapsulates test code
Definition: test.h:929
void SetChannel(Ptr< SpectrumChannel > c)
Set the channel attached to this device.
Definition: lr-wpan-phy.cc:214
static LrWpanPlmeAndPdInterfaceTestSuite lrWpanPlmeAndPdInterfaceTestSuite
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1242
virtual void DoRun(void)
Implementation to actually run this TestCase.
prefix all trace prints with function
Definition: log.h:95
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionaly.
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
Definition: test.cc:184
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
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:475
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:318