40#include <ns3/callback.h>
41#include <ns3/command-line.h>
42#include <ns3/constant-position-mobility-model.h>
43#include <ns3/gnuplot.h>
45#include <ns3/lr-wpan-error-model.h>
46#include <ns3/lr-wpan-mac.h>
47#include <ns3/lr-wpan-net-device.h>
48#include <ns3/lr-wpan-spectrum-value-helper.h>
49#include <ns3/mac16-address.h>
50#include <ns3/multi-model-spectrum-channel.h>
51#include <ns3/net-device.h>
53#include <ns3/nstime.h>
54#include <ns3/packet.h>
55#include <ns3/propagation-loss-model.h>
56#include <ns3/simulator.h>
57#include <ns3/single-model-spectrum-channel.h>
58#include <ns3/spectrum-value.h>
60#include <ns3/uinteger.h>
86main(
int argc,
char* argv[])
88 std::ostringstream os;
89 std::ofstream berfile(
"802.15.4-psr-distance.plt");
92 int maxDistance = 200;
94 int maxPackets = 1000;
98 double rxSensitivity = -106.58;
102 cmd.AddValue(
"txPower",
"transmit power (dBm)", txPower);
103 cmd.AddValue(
"packetSize",
"packet (MSDU) size (bytes)",
packetSize);
104 cmd.AddValue(
"channelNumber",
"channel number", channelNumber);
105 cmd.AddValue(
"rxSensitivity",
"the rx sensitivity (dBm)", rxSensitivity);
107 cmd.Parse(argc, argv);
109 os <<
"Packet (MSDU) size = " <<
packetSize <<
" bytes; tx power = " << txPower
110 <<
" dBm; channel = " << channelNumber <<
"; Rx sensitivity = " << rxSensitivity <<
" dBm";
123 channel->AddPropagationLossModel(model);
124 dev0->SetChannel(channel);
125 dev1->SetChannel(channel);
129 dev0->GetPhy()->SetMobility(mob0);
131 dev1->GetPhy()->SetMobility(mob1);
135 dev0->GetPhy()->SetTxPowerSpectralDensity(psd);
138 dev1->GetPhy()->SetRxSensitivity(rxSensitivity);
142 dev1->GetMac()->SetMcpsDataIndicationCallback(cb0);
153 mob0->SetPosition(Vector(0, 0, 0));
154 mob1->SetPosition(Vector(minDistance, 0, 0));
155 for (
int j = minDistance; j < maxDistance; j += increment)
157 for (
int i = 0; i < maxPackets; i++)
167 mob1->SetPosition(Vector(j, 0, 0));
173 psrplot.
SetTerminal(
"postscript eps color enh \"Times-BoldItalic\"");
174 psrplot.
SetLegend(
"distance (m)",
"Packet Success Rate (PSR)");
175 psrplot.
SetExtra(
"set xrange [0:200]\n\
178 set style line 1 linewidth 5\n\
179 set style increment user");
Parse command-line arguments.
Class to represent a 2D points plot.
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void AddDataset(const GnuplotDataset &dataset)
void SetLegend(const std::string &xLegend, const std::string &yLegend)
void SetTerminal(const std::string &terminal)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void SetExtra(const std::string &extra)
void SetTitle(const std::string &title)
This class can contain 16 bit addresses.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
void McpsDataRequest(McpsDataRequestParams params, Ptr< Packet > p) override
IEEE 802.15.4-2006, section 7.1.1.1 MCPS-DATA.request Request to transfer a MSDU.
This class defines all functions to create spectrum model for LrWpan.
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint32_t channel)
create spectrum value
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
void LrWpanErrorDistanceCallback(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when a Data indication is invoked.
uint32_t g_packetsReceived
number of packets received
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
FtrParams params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
MCPS-DATA.indication params.
MCPS-DATA.request params.
static const uint32_t packetSize
Packet size generated at the AP.