|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
28 #include <ns3/callback.h>
29 #include <ns3/packet.h>
30 #include <ns3/simulator.h>
31 #include <ns3/lr-wpan-error-model.h>
32 #include <ns3/propagation-loss-model.h>
33 #include <ns3/lr-wpan-net-device.h>
34 #include <ns3/spectrum-value.h>
35 #include <ns3/lr-wpan-spectrum-value-helper.h>
36 #include <ns3/lr-wpan-mac.h>
38 #include <ns3/net-device.h>
39 #include <ns3/single-model-spectrum-channel.h>
40 #include <ns3/multi-model-spectrum-channel.h>
41 #include <ns3/mac16-address.h>
42 #include <ns3/constant-position-mobility-model.h>
43 #include <ns3/uinteger.h>
44 #include <ns3/nstime.h>
45 #include <ns3/abort.h>
46 #include <ns3/command-line.h>
47 #include <ns3/gnuplot.h>
72 int main (
int argc,
char *argv[])
74 std::ostringstream os;
75 std::ofstream berfile (
"802.15.4-psr-distance.plt");
78 int maxDistance = 200;
80 int maxPackets = 1000;
83 uint32_t channelNumber = 11;
87 cmd.AddValue (
"txPower",
"transmit power (dBm)", txPower);
88 cmd.AddValue (
"packetSize",
"packet (MSDU) size (bytes)",
packetSize);
89 cmd.AddValue (
"channelNumber",
"channel number", channelNumber);
91 cmd.Parse (argc, argv);
93 os <<
"Packet (MSDU) size = " <<
packetSize <<
" bytes; tx power = " << txPower <<
" dBm; channel = " << channelNumber;
106 channel->AddPropagationLossModel (model);
112 dev0->
GetPhy ()->SetMobility (mob0);
114 dev1->
GetPhy ()->SetMobility (mob1);
118 dev0->
GetPhy ()->SetTxPowerSpectralDensity (psd);
122 dev1->
GetMac ()->SetMcpsDataIndicationCallback (cb0);
135 for (
int j = minDistance; j < maxDistance; )
137 for (
int i = 0; i < maxPackets; i++)
142 dev0->
GetMac (), params, p);
155 psrplot.
SetTerminal (
"postscript eps color enh \"Times-BoldItalic\"");
156 psrplot.
SetLegend (
"distance (m)",
"Packet Success Rate (PSR)");
157 psrplot.
SetExtra (
"set xrange [0:200]\n\
160 set style line 1 linewidth 5\n\
161 set style increment user");
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< SpectrumValue > CreateTxPowerSpectralDensity(double txPower, uint32_t channel)
create spectrum value
Parse command-line arguments.
void SetLegend(const std::string &xLegend, const std::string &yLegend)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
This class can contain 16 bit addresses.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
uint16_t m_dstPanId
Destination PAN identifier.
This class defines all functions to create spectrum model for LrWpan.
void SetPosition(const Vector &position)
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
void SetTerminal(const std::string &terminal)
static uint32_t g_received
number of packets received
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void SetExtra(const std::string &extra)
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
uint8_t m_txOptions
Tx Options (bitfield)
Class to represent a 2D points plot.
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void AddDataset(const GnuplotDataset &dataset)
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
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...
static void Run(void)
Run the simulation.
static void LrWpanErrorDistanceCallback(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when a Data indication is invoked.
static const uint32_t packetSize
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
MCPS-DATA.indication params.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
void SetTitle(const std::string &title)
LrWpanAddressMode m_srcAddrMode
Source address mode.
Mac16Address m_dstAddr
Destination address.
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
void McpsDataRequest(McpsDataRequestParams params, Ptr< Packet > p)
IEEE 802.15.4-2006, section 7.1.1.1 MCPS-DATA.request Request to transfer a MSDU.
MCPS-DATA.request params.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
uint8_t m_msduHandle
MSDU handle.