author | Tom Henderson <tomh@tomh.org> |
Mon, 28 Sep 2015 20:27:25 -0700 | |
changeset 11676 | 05ea1489e509 |
parent 10720 | 4e4a0de88982 |
permissions | -rw-r--r-- |
10711 | 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> |
|
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10712
diff
changeset
|
22 |
#include <ns3/packet.h> |
10711 | 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 |
#include <ns3/constant-position-mobility-model.h> |
|
28 |
||
29 |
using namespace ns3; |
|
30 |
||
31 |
void GetSetTRXStateConfirm (LrWpanPhyEnumeration status) |
|
32 |
{ |
|
33 |
NS_LOG_UNCOND ("At: " << Simulator::Now () |
|
34 |
<< " Received Set TRX Confirm: " << status); |
|
35 |
} |
|
36 |
||
37 |
void |
|
38 |
ReceivePdDataIndication (uint32_t psduLength, |
|
10712
b953606d11fa
roll-up of many updates to models, tests, examples
Tom Henderson <tomh@tomh.org>
parents:
10711
diff
changeset
|
39 |
Ptr<Packet> p, |
10720
4e4a0de88982
ACK (Sascha Jopen), NetDevice (Tommaso Pecorella and Margherita Filippetti), FCS changes (Erwan Livolant), and clang compliance
Tommaso Pecorella <tommaso.pecorella@unifi.it>
parents:
10712
diff
changeset
|
40 |
uint8_t lqi) |
10711 | 41 |
{ |
42 |
NS_LOG_UNCOND ("At: " << Simulator::Now () |
|
43 |
<< " Received frame size: " << psduLength << " LQI: " << |
|
44 |
lqi); |
|
45 |
} |
|
46 |
||
47 |
void SendOnePacket (Ptr<LrWpanPhy> sender, Ptr<LrWpanPhy> receiver) |
|
48 |
{ |
|
49 |
uint32_t n = 10; |
|
50 |
Ptr<Packet> p = Create<Packet> (n); |
|
51 |
sender->PdDataRequest (p->GetSize (), p); |
|
52 |
} |
|
53 |
||
54 |
||
55 |
int main (int argc, char *argv[]) |
|
56 |
{ |
|
57 |
LogComponentEnableAll (LOG_PREFIX_FUNC); |
|
58 |
LogComponentEnable ("LrWpanPhy", LOG_LEVEL_ALL); |
|
59 |
LogComponentEnable ("SingleModelSpectrumChannel", LOG_LEVEL_ALL); |
|
60 |
||
61 |
Ptr<LrWpanPhy> sender = CreateObject<LrWpanPhy> (); |
|
62 |
Ptr<LrWpanPhy> receiver = CreateObject<LrWpanPhy> (); |
|
63 |
||
64 |
Ptr<SingleModelSpectrumChannel> channel = CreateObject<SingleModelSpectrumChannel> (); |
|
65 |
sender->SetChannel (channel); |
|
66 |
receiver->SetChannel (channel); |
|
67 |
channel->AddRx (sender); |
|
68 |
channel->AddRx (receiver); |
|
69 |
||
70 |
// CONFIGURE MOBILITY |
|
71 |
Ptr<ConstantPositionMobilityModel> senderMobility = CreateObject<ConstantPositionMobilityModel> (); |
|
72 |
sender->SetMobility (senderMobility); |
|
73 |
Ptr<ConstantPositionMobilityModel> receiverMobility = CreateObject<ConstantPositionMobilityModel> (); |
|
74 |
receiver->SetMobility (senderMobility); |
|
75 |
||
76 |
||
77 |
sender->SetPlmeSetTRXStateConfirmCallback (MakeCallback (&GetSetTRXStateConfirm)); |
|
78 |
receiver->SetPlmeSetTRXStateConfirmCallback (MakeCallback (&GetSetTRXStateConfirm)); |
|
79 |
||
80 |
sender->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_TX_ON); |
|
81 |
receiver->PlmeSetTRXStateRequest (IEEE_802_15_4_PHY_RX_ON); |
|
82 |
||
83 |
receiver->SetPdDataIndicationCallback (MakeCallback (&ReceivePdDataIndication)); |
|
84 |
||
85 |
Simulator::Schedule (Seconds (1.0), &SendOnePacket, sender, receiver); |
|
86 |
||
87 |
Simulator::Stop (Seconds (10.0)); |
|
88 |
||
89 |
Simulator::Run (); |
|
90 |
||
91 |
Simulator::Destroy (); |
|
92 |
||
93 |
return 0; |
|
94 |
} |