27#include <ns3/constant-position-mobility-model.h>
28#include <ns3/core-module.h>
30#include <ns3/lr-wpan-module.h>
31#include <ns3/packet.h>
32#include <ns3/propagation-delay-model.h>
33#include <ns3/propagation-loss-model.h>
34#include <ns3/simulator.h>
35#include <ns3/single-model-spectrum-channel.h>
75 NS_LOG_UNCOND(context <<
" state change at " << now.
As(Time::S) <<
" from "
76 << LrWpanHelper::LrWpanPhyEnumerationPrinter(oldState) <<
" to "
77 << LrWpanHelper::LrWpanPhyEnumerationPrinter(newState));
81main(
int argc,
char* argv[])
88 cmd.AddValue(
"verbose",
"turn on all log components",
verbose);
89 cmd.AddValue(
"extended",
"use extended addressing",
extended);
91 cmd.Parse(argc, argv);
118 mac0->SetExtendedAddress(
Mac64Address(
"00:00:00:00:00:00:00:01"));
119 mac1->SetExtendedAddress(
Mac64Address(
"00:00:00:00:00:00:00:02"));
125 CreateObject<LogDistancePropagationLossModel>();
127 CreateObject<ConstantSpeedPropagationDelayModel>();
128 channel->AddPropagationLossModel(propModel);
129 channel->SetPropagationDelayModel(delayModel);
139 dev0->
GetPhy()->TraceConnect(
"TrxState",
142 dev1->
GetPhy()->TraceConnect(
"TrxState",
147 CreateObject<ConstantPositionMobilityModel>();
148 sender0Mobility->SetPosition(
Vector(0, 0, 0));
149 dev0->
GetPhy()->SetMobility(sender0Mobility);
151 CreateObject<ConstantPositionMobilityModel>();
153 sender1Mobility->SetPosition(
Vector(0, 10, 0));
154 dev1->
GetPhy()->SetMobility(sender1Mobility);
158 dev0->
GetMac()->SetMcpsDataConfirmCallback(cb0);
162 dev0->
GetMac()->SetMcpsDataIndicationCallback(cb1);
166 dev1->
GetMac()->SetMcpsDataConfirmCallback(cb2);
170 dev1->
GetMac()->SetMcpsDataIndicationCallback(cb3);
173 lrWpanHelper.
EnablePcapAll(std::string(
"lr-wpan-data"),
true);
199 Simulator::ScheduleWithContext(1,
201 &LrWpanMac::McpsDataRequest,
216 Simulator::ScheduleWithContext(2,
218 &LrWpanMac::McpsDataRequest,
225 Simulator::Destroy();
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
Manage ASCII trace files for device models.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
Parse command-line arguments.
helps to manage and create IEEE 802.15.4 NetDevice objects
void EnableLogComponents()
Helper to enable all LrWpan log components with one statement.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
Ptr< LrWpanMac > GetMac() const
Get the MAC used by this NetDevice.
Ptr< LrWpanPhy > GetPhy() const
Get the PHY used by this NetDevice.
void SetAddress(Address address) override
This method indirects to LrWpanMac::SetShortAddress ()
This class can contain 16 bit addresses.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
@ TX_OPTION_ACK
TX_OPTION_ACK.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void DataConfirm(McpsDataConfirmParams params)
Function called when a Data confirm is invoked.
static void DataIndication(McpsDataIndicationParams params, Ptr< Packet > p)
Function called when a Data indication is invoked.
static void StateChangeNotification(std::string context, Time now, LrWpanPhyEnumeration oldState, LrWpanPhyEnumeration newState)
Function called when a the PHY state changes.
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...
MCPS-DATA.confirm params.
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
MCPS-DATA.indication params.
MCPS-DATA.request params.
LrWpanAddressMode m_srcAddrMode
Source address mode.
Mac64Address m_dstExtAddr
Destination extended address.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
uint16_t m_dstPanId
Destination PAN identifier.
Mac16Address m_dstAddr
Destination address.
uint8_t m_msduHandle
MSDU handle.
uint8_t m_txOptions
Tx Options (bitfield)