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
28using namespace ns3;
29
37{
38public:
41
42private:
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
63void
66 uint8_t lqi)
67{
68 NS_LOG_UNCOND ("At: " << Simulator::Now ()
69 << " Received frame size: " << psduLength << " LQI: " <<
70 lqi);
71}
72
73void
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{
105public:
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
LrWpan PLME and PD Interfaces Test.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void ReceivePdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
Receives a PdData indication.
LrWpan PLME and PD Interfaces TestSuite.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:856
encapsulates test code
Definition: test.h:994
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Definition: test.cc:299
A suite of tests to run.
Definition: test.h:1188
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
static LrWpanPlmeAndPdInterfaceTestSuite g_lrWpanPlmeAndPdInterfaceTestSuite
Static variable for test initialization.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
@ LOG_LEVEL_ALL
Print everything.
Definition: log.h:116
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
Definition: log.h:118
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Definition: log.cc:361
void LogComponentEnableAll(enum LogLevel level)
Enable the logging output for all registered log components.
Definition: log.cc:385
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
channel
Definition: third.py:92