|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
31 #include <ns3/simulator.h>
33 #include <ns3/uinteger.h>
35 #include <ns3/packet.h>
36 #include <ns3/random-variable-stream.h>
37 #include <ns3/double.h>
39 #undef NS_LOG_APPEND_CONTEXT
40 #define NS_LOG_APPEND_CONTEXT \
41 std::clog << "[address " << m_shortAddress << "] ";
62 .SetGroupName (
"LrWpan")
64 .AddAttribute (
"PanId",
"16-bit identifier of the associated PAN",
67 MakeUintegerChecker<uint16_t> ())
68 .AddTraceSource (
"MacTxEnqueue",
69 "Trace source indicating a packet has been "
70 "enqueued in the transaction queue",
72 "ns3::Packet::TracedCallback")
73 .AddTraceSource (
"MacTxDequeue",
74 "Trace source indicating a packet has was "
75 "dequeued from the transaction queue",
77 "ns3::Packet::TracedCallback")
78 .AddTraceSource (
"MacTx",
79 "Trace source indicating a packet has "
80 "arrived for transmission by this device",
82 "ns3::Packet::TracedCallback")
83 .AddTraceSource (
"MacTxOk",
84 "Trace source indicating a packet has been "
87 "ns3::Packet::TracedCallback")
88 .AddTraceSource (
"MacTxDrop",
89 "Trace source indicating a packet has been "
90 "dropped during transmission",
92 "ns3::Packet::TracedCallback")
93 .AddTraceSource (
"MacPromiscRx",
94 "A packet has been received by this device, "
95 "has been passed up from the physical layer "
96 "and is being forwarded up the local protocol stack. "
97 "This is a promiscuous trace,",
99 "ns3::Packet::TracedCallback")
100 .AddTraceSource (
"MacRx",
101 "A packet has been received by this device, "
102 "has been passed up from the physical layer "
103 "and is being forwarded up the local protocol stack. "
104 "This is a non-promiscuous trace,",
106 "ns3::Packet::TracedCallback")
107 .AddTraceSource (
"MacRxDrop",
108 "Trace source indicating a packet was received, "
109 "but dropped before being forwarded up the stack",
111 "ns3::Packet::TracedCallback")
112 .AddTraceSource (
"Sniffer",
113 "Trace source simulating a non-promiscuous "
114 "packet sniffer attached to the device",
116 "ns3::Packet::TracedCallback")
117 .AddTraceSource (
"PromiscSniffer",
118 "Trace source simulating a promiscuous "
119 "packet sniffer attached to the device",
121 "ns3::Packet::TracedCallback")
122 .AddTraceSource (
"MacStateValue",
123 "The state of LrWpan Mac",
125 "ns3::TracedValueCallback::LrWpanMacState")
126 .AddTraceSource (
"MacIncSuperframeStatus",
127 "The period status of the incoming superframe",
129 "ns3::TracedValueCallback::SuperframeState")
130 .AddTraceSource (
"MacOutSuperframeStatus",
131 "The period status of the outgoing superframe",
133 "ns3::TracedValueCallback::SuperframeState")
134 .AddTraceSource (
"MacState",
135 "The state of LrWpan Mac",
137 "ns3::LrWpanMac::StateTracedCallback")
138 .AddTraceSource (
"MacSentPkt",
139 "Trace source reporting some information about "
142 "ns3::LrWpanMac::SentTracedCallback")
143 .AddTraceSource (
"IfsEnd",
144 "Trace source reporting the end of an "
145 "Interframe space (IFS) ",
147 "ns3::Packet::TracedCallback")
224 for (uint32_t i = 0; i <
m_txQueue.size (); i++)
324 NS_LOG_ERROR (
this <<
" Can not send packet with no Address field" );
339 NS_ABORT_MSG (
"Can not set source address type to ADDR_MODE_RESERVED. Aborting.");
365 NS_ABORT_MSG (
"Can not set destination address type to ADDR_MODE_RESERVED. Aborting.");
400 NS_LOG_LOGIC (
"LrWpanMac::McpsDataRequest: requested an ACK on broadcast or multicast destination (" << shortAddr <<
") - forcefully removing it.");
458 uint64_t unitPeriodSymbols;
473 *
MicroSeconds (unitPeriodSymbols * 1000 * 1000 /
m_phy->GetDataOrSymbolRate (
false));
476 indTxQElement->
txQPkt = p;
480 std::cout <<
"Indirect Transmission Pushed | Elements in the queue: " <<
m_indTxQueue.size ()
481 <<
" " <<
"Element to expire in: " << expireTime.
GetSeconds () <<
"secs\n";
540 NS_LOG_ERROR (
this <<
" One or more parameters are invalid" );
617 uint64_t symbolRate = (uint64_t)
m_phy->GetDataOrSymbolRate (
false);
626 uint64_t searchSymbols;
627 Time searchBeaconTime;
639 searchBeaconTime =
Seconds ((
double) searchSymbols / symbolRate);
706 macTrailer.
SetFcs (beaconPacket);
727 uint64_t capDuration;
731 symbolRate = (uint64_t)
m_phy->GetDataOrSymbolRate (
false);
738 endCapTime =
Seconds ((
double) capDuration / symbolRate);
742 NS_LOG_DEBUG (
"Outgoing superframe CAP duration " << (endCapTime.GetSeconds () * symbolRate) <<
" symbols (" << endCapTime.As (
Time::S) <<
")");
743 NS_LOG_DEBUG (
"Active Slots duration " << activeSlot <<
" symbols");
754 endCapTime =
Seconds ((
double) capDuration / symbolRate);
758 NS_LOG_DEBUG (
"Incoming superframe CAP duration " << (endCapTime.GetSeconds () * symbolRate) <<
" symbols (" << endCapTime.As (
Time::S) <<
")");
759 NS_LOG_DEBUG (
"Active Slots duration " << activeSlot <<
" symbols");
774 uint64_t cfpDuration;
778 symbolRate = (uint64_t)
m_phy->GetDataOrSymbolRate (
false);
784 endCfpTime =
Seconds ((
double) cfpDuration / symbolRate);
790 NS_LOG_DEBUG (
"Incoming superframe CFP duration " << cfpDuration <<
" symbols (" << endCfpTime.As (
Time::S) <<
")");
799 endCfpTime =
Seconds ((
double) cfpDuration / symbolRate);
806 NS_LOG_DEBUG (
"Outgoing superframe CFP duration " << cfpDuration <<
" symbols (" << endCfpTime.As (
Time::S) <<
")");
819 uint64_t inactiveDuration;
820 Time endInactiveTime;
823 symbolRate = (uint64_t)
m_phy->GetDataOrSymbolRate (
false);
828 endInactiveTime =
Seconds ((
double) inactiveDuration / symbolRate);
830 if (inactiveDuration > 0)
835 NS_LOG_DEBUG (
"Incoming superframe Inactive Portion duration " << inactiveDuration <<
" symbols (" << endInactiveTime.
As (
Time::S) <<
")");
841 endInactiveTime =
Seconds ((
double) inactiveDuration / symbolRate);
843 if (inactiveDuration > 0)
848 NS_LOG_DEBUG (
"Outgoing superframe Inactive Portion duration " << inactiveDuration <<
" symbols (" << endInactiveTime.
As (
Time::S) <<
")");
869 uint64_t symbolRate = (uint64_t)
m_phy->GetDataOrSymbolRate (
false);
887 uint64_t searchSymbols;
888 Time searchBeaconTime;
890 searchBeaconTime =
Seconds ((
double) searchSymbols / symbolRate);
928 if (
m_csmaCa->GetBatteryLifeExtension ())
960 return pndAddrFields;
1037 uint64_t symbolRate = (uint64_t)
m_phy->GetDataOrSymbolRate (
false);
1051 if (!receivedMacTrailer.
CheckFcs (p))
1113 NS_LOG_ERROR (
this <<
" Data Indication Callback not initialized");
1123 acceptFrame = (receivedMacHdr.
GetFrameVer () <= 1);
1147 acceptFrame =
false;
1156 acceptFrame =
false;
1243 (originalPkt->
GetSize () *
m_phy->GetPhySymbolsPerOctet ());
1257 NS_LOG_ERROR (
this <<
"The current device is not associated to any coordinator");
1282 m_csmaCa->SetBatteryLifeExtension (
true);
1286 m_csmaCa->SetBatteryLifeExtension (
false);
1289 if (m_incomingBeaconOrder < 15 && !m_csmaCa->IsSlottedCsmaCa ())
1329 uint64_t searchSymbols;
1330 Time searchBeaconTime;
1333 searchBeaconTime =
Seconds ((
double) searchSymbols / symbolRate);
1422 macTrailer.
SetFcs (ackPacket);
1481 uint64_t symbolRate = (uint64_t)
m_phy->GetDataOrSymbolRate (
false);
1485 if (ifsTime == lifsTime)
1489 else if (ifsTime == sifsTime)
1541 uint64_t symbolRate;
1543 symbolRate = (uint64_t)
m_phy->GetDataOrSymbolRate (
false);
1557 uint64_t beaconSymbols =
m_phy->GetPhySHRDuration () + 1 *
m_phy->GetPhySymbolsPerOctet () +
1635 NS_FATAL_ERROR (
"Transmission attempt failed with PHY status " << status);
1639 if (!ifsWaitTime.
IsZero ())
1785 NS_LOG_DEBUG (
"****** PACKET DEFERRED to the next superframe *****");
1826 return m_csmaCa->GetUnitBackoffPeriod () +
m_phy->aTurnaroundTime +
m_phy->GetPhySHRDuration ()
1827 + ceil (6 *
m_phy->GetPhySymbolsPerOctet ());
1862 std::cout <<
"ERROR: Packet not for the coordinator!\n";
1902 return (
m_phy->GetPhySHRDuration () + 1 *
m_phy->GetPhySymbolsPerOctet () +
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
MlmeBeaconNotifyIndicationCallback m_mlmeBeaconNotifyIndicationCallback
This callback is used to notify incoming beacon packets to the upper layers.
LrWpanAssociationStatus m_associationStatus
The current association status of the MAC layer.
bool m_panCoor
On true this device will become coordinator.
EventId m_trackingEvent
Scheduler event to track the incoming beacons.
static const uint32_t aNumSuperframeSlots
Number of a superframe slots per superframe.
void SetFinalCapSlot(uint8_t capSlot)
Set the superframe specification Final CAP slot field.
uint8_t m_dsn
The DSN of the received data frame.
uint8_t m_incomingSuperframeOrder
Used by all devices that have a parent.
uint8_t GetBeaconOrder(void) const
Get the Superframe Specification Beacon Order field.
Time m_macBeaconRxTime
The time that the device received its last bit of the beacon frame.
uint8_t txQMsduHandle
MSDU Handle.
TracedCallback< Ptr< const Packet > > m_macRxDropTrace
The trace source fired for packets successfully received by the device but dropped before being forwa...
bool IsBattLifeExt(void) const
Check if the Battery Life Extension bit is enabled.
IEEE802.15.4-2006 PHY PIB Attributes Table 23 in section 6.4.2.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Mac16Address m_macCoordShortAddress
The short address of the coordinator through which the device is associated.
void AwaitBeacon(void)
Called after the end of an INCOMING superframe to start the moment a device waits for a new incoming ...
void SetBattLifeExt(bool battLifeExt)
Set the Superframe Specification Battery Life Extension (BLE).
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
virtual void DoDispose(void)
Destructor implementation.
static const uint32_t aBaseSuperframeDuration
Length of a superframe in symbols.
uint8_t m_mpduLinkQuality
LQI value measured during reception of the MPDU.
@ MLMESTART_INVALID_PARAMETER
virtual void DoInitialize(void)
Initialize() implementation.
void SetMlmeStartConfirmCallback(MlmeStartConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
Mac64Address m_macCoordExtendedAddress
The extended address of the coordinator through which the device is associated.
@ CFP
Contention Free Period.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
@ IEEE_802_15_4_FRAME_TOO_LONG
@ IEEE_802_15_4_INVALID_ADDRESS
void AddHeader(const Header &header)
Add header to this packet.
bool IsBroadcast(void) const
Checks if the address is a broadcast address according to 802.15.4 scheme (i.e., 0xFFFF).
EventId m_incCfpEvent
Scheduler event for the end of the incoming superframe CFP.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void RemoveFirstTxQElement()
Remove the tip of the transmission queue, including clean up related to the last packet transmission.
SuperframeType
Superframe type.
void SetFcs(Ptr< const Packet > p)
Calculate and set the FCS value based on the given packet.
Mac64Address m_dstExtAddr
Destination extended address.
@ TX_OPTION_ACK
TX_OPTION_ACK.
TracedCallback< Time > m_macIfsEndTrace
The trace source is fired at the end of any Interframe Space (IFS).
void SetSuperframeOrder(uint8_t frmOrder)
Set the superframe specification Superframe Order field.
Represent the Pending Address Specification field.
bool IsNull(void) const
Check for null implementation.
uint32_t m_superframeDuration
Indication of the superframe duration in symbols.
bool m_coorRealgn
True if a realignment request command is to be transmitted prior changing the superframe.
Ptr< LrWpanPhy > m_phy
The PHY associated with this MAC.
uint8_t GetMacMaxFrameRetries(void) const
Get the macMaxFrameRetries attribute value.
bool m_macAutoRequest
Indication of whether a device automatically sends data request command if its address is listed in t...
This class can contain 16 bit addresses.
uint16_t m_macTransactionPersistanceTime
The maximum time (in superframe periods) that a transaction is stored by a coordinator and indicated ...
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
EventId m_incCapEvent
Scheduler event for the end of the incoming superframe CAP.
uint32_t m_ifs
The value of the necessary InterFrame Space after the transmission of a packet.
uint16_t m_dstPanId
Destination PAN identifier.
TracedCallback< Ptr< const Packet > > m_macTxTrace
The trace source fired when packets are being sent down to L1.
EventId m_beaconEvent
Scheduler event for generation of one beacon.
uint32_t phyCurrentPage
Current channel page.
Mac16Address GetShortAddress(void) const
Get the short address of this MAC.
Represent the Mac Trailer with the Frame Check Sequence field.
uint8_t GetFrameOrder(void) const
Get the Superframe Specification Frame Order field.
void SetBeaconOrder(uint8_t bcnOrder)
Set the superframe specification Beacon Order field.
uint32_t m_beaconInterval
Indication of the Interval used by the coordinator to transmit beacon frames expressed in symbols.
MlmePollConfirmCallback m_mlmePollConfirmCallback
This callback is used to report the status after a device send data command request to the coordinato...
void SetMacMaxFrameRetries(uint8_t retries)
Set the macMaxFrameRetries attribute value.
bool CheckFcs(Ptr< const Packet > p)
Check the FCS of a given packet against the FCS value stored in the trailer.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Represent the Superframe Specification information field.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
MLME-START.request params.
bool m_battLifeExt
Flag indicating whether or not the Battery life extension (BLE) features are used.
MLME-BEACON-NOTIFY.indication params.
std::deque< IndTxQueueElement * > m_indTxQueue
The indirect transmit queue used by the MAC pending messages.
uint32_t GetIfsSize()
Get the size of the Interframe Space according to MPDU size (m_txPkt).
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
bool m_panCoor
Indication of whether the current device is the PAN coordinator.
uint8_t m_incomingBeaconOrder
The beaconOrder value of the INCOMING frame.
uint8_t m_txOptions
Tx Options (bitfield)
SequenceNumber< uint8_t, int8_t > SequenceNumber8
8 bit Sequence number.
Mac64Address m_dstExtAddr
Destination extended address.
GtsFields GetGtsFields(void)
Constructs the Guaranteed Time Slots (GTS) Fields from local information.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
static TypeId GetTypeId(void)
Get the type ID.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
uint8_t m_sfrmOrd
Superframe Order, indicates the length of the CAP in time slots.
MLME-POLL.request params.
TracedValue< LrWpanMacState > m_lrWpanMacState
The current state of the MAC layer.
static const uint32_t aMinMPDUOverhead
The minimum number of octets added by the MAC sublayer to the PSDU.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
@ IEEE_802_15_4_PHY_SUCCESS
void SetMlmeBeaconNotifyIndicationCallback(MlmeBeaconNotifyIndicationCallback c)
Set the callback for the indication of an incoming beacon packet.
void SetPhy(Ptr< LrWpanPhy > phy)
Set the underlying PHY for the MAC.
bool m_macRxOnWhenIdle
Indication of whether the MAC sublayer is to enable its receiver during idle periods.
void SetPanCoor(bool panCoor)
Set the Superframe Specification PAN coordinator field.
TracedCallback< Ptr< const Packet > > m_macTxDropTrace
The trace source fired when packets are dropped due to missing ACKs or because of transmission failur...
Helper structure for managing indirect transmission queue elements.
bool isTxAckReq(void)
Check if the packet to transmit requires acknowledgment.
LrWpanPibAttributeIdentifier
IEEE802.15.4-2006 PHY PIB Attribute Identifiers Table 23 in section 6.4.2.
bool IsMulticast(void) const
Checks if the address is a multicast address according to RFC 4944 Section 9 (i.e....
Time m_macBeaconTxTime
The time that the device transmitted its last beacon frame.
Ptr< Packet > m_txPkt
The packet which is currently being sent by the MAC layer.
void SetShortAddress(Mac16Address address)
Set the short address of this MAC.
uint32_t RemoveTrailer(Trailer &trailer)
Remove a deserialized trailer from the internal buffer.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
TracedCallback< LrWpanMacState, LrWpanMacState > m_macStateLogger
A trace source that fires when the LrWpanMac changes states.
Ptr< Packet > txQPkt
Queued packet.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
static const uint32_t aMaxSIFSFrameSize
The maximum size of an MPDU, in octets, that can be followed by a Short InterFrame Spacing (SIFS) per...
MCPS-DATA.confirm params.
void PlmeSetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttributeIdentifier id)
IEEE 802.15.4-2006 section 6.2.2.10 PLME-SET.confirm Set attributes per definition from Table 23 in s...
Mac16Address m_srcAddr
Source address.
void CheckQueue(void)
Check the transmission queue.
@ TX_OPTION_GTS
TX_OPTION_GTS.
uint32_t m_logChPage
Logical channel page on which to start using the new superframe configuration.
uint8_t m_msduHandle
MSDU handle.
@ IEEE_802_15_4_PHY_TRX_OFF
void PlmeSetTRXStateConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.8 PLME-SET-TRX-STATE.confirm Set PHY state.
A base class which provides memory management and object aggregation.
bool IsZero(void) const
Exactly equivalent to t == 0.
uint16_t m_srcPanId
Source PAN identifier.
LrWpanMacState
MAC states.
LrWpanAssociationStatus
table 83 of 802.15.4
@ MLMESYNCLOSS_BEACON_LOST
uint8_t m_bcnOrd
Beacon Order, Used to calculate the beacon interval, a value of 15 indicates no periodic beacons will...
void MlmeStartRequest(MlmeStartRequestParams params)
IEEE 802.15.4-2006, section 7.1.14.1 MLME-START.request Request to allow a PAN coordinator to initiat...
@ MAC_CSMA_DEFERRED
MAC_CSMA_DEFERRED.
uint16_t m_PanId
Pan Identifier used by the device.
void PlmeGetAttributeConfirm(LrWpanPhyEnumeration status, LrWpanPibAttributeIdentifier id, LrWpanPhyPibAttributes *attribute)
IEEE 802.15.4-2006 section 6.2.2.6 PLME-GET.confirm Get attributes per definition from Table 23 in se...
Mac64Address GetExtendedAddress(void) const
Get the extended address of this MAC.
EventId m_ifsEvent
Scheduler event for Interframe spacing wait time.
void SetExtendedAddress(Mac64Address address)
Set the extended address of this MAC.
uint8_t m_bsn
The beacon sequence number.
Helper structure for managing transmission queue elements.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
LrWpanPhyEnumeration
IEEE802.15.4-2006 PHY Emumerations Table 18 in section 6.2.3.
uint32_t m_incomingSuperframeDuration
Indication of the superframe duration in symbols (e.g.
uint8_t m_macBeaconOrder
Used by a PAN coordinator or coordinator.
@ IEEE_802_15_4_PHY_TX_ON
uint64_t GetTxPacketSymbols(void)
Obtain the number of symbols in the packet which is currently being sent by the MAC layer.
uint16_t m_macPanId
16 bits id of PAN on which this device is operating.
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
static bool ChecksumEnabled(void)
std::deque< TxQueueElement * > m_txQueue
The transmit queue used by the MAC.
Mac64Address m_srcExtAddr
Source extended address.
@ IEEE_802_15_4_PHY_RX_ON
EventId m_setMacState
Scheduler event for a deferred MAC state change.
TracedCallback< Ptr< const Packet > > m_macTxEnqueueTrace
The trace source fired when packets come into the "top" of the device at the L3/L2 transition,...
@ CHANNEL_ACCESS_FAILURE
CHANNEL_ACCESS_FAILURE.
@ OUTGOING
Outgoing Superframe.
uint8_t m_numLostBeacons
The number of consecutive loss beacons in a beacon tracking operation.
void SetRxOnWhenIdle(bool rxOnWhenIdle)
Set if the receiver should be enabled when the MAC is idle.
Simulation virtual time values and global simulation resolution.
TracedCallback< Ptr< const Packet > > m_macPromiscRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
Represent the GTS information fields.
uint64_t m_rxBeaconSymbols
The total size of the received beacon in symbols.
TracedCallback< Ptr< const Packet > > m_macRxTrace
The trace source fired for packets successfully received by the device immediately before being forwa...
@ DATA_REQ
Data Request (RFD true: Tx)
Ptr< Packet > txQPkt
Queued packet.
bool isCoordDest(void)
Check if the packet destination is its coordinator.
SuperframeField GetSuperframeField(void)
Constructs a Superframe specification field from the local information, the superframe Specification ...
uint8_t m_deviceCapability
Indication of current device capability (FFD or RFD)
@ INCOMING
Incoming Superframe.
uint8_t m_logCh
Logical channel on which to start using the new superframe configuration.
bool m_trackBcn
True if the mlme sync with the next beacon and attempts to track future beacons.
void MlmePollRequest(MlmePollRequestParams params)
IEEE 802.15.4-2011, section 6.2.14.2 MLME-POLL.request Prompts the device to request data from the co...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void EnableFcs(bool enable)
Enable or disable FCS calculation for this trailer.
MLME-SYNC-LOSS.indication params.
uint8_t m_macMaxFrameRetries
The maximum number of retries allowed after a transmission failure.
bool PrepareRetransmission(void)
Check for remaining retransmissions for the packet currently being sent.
virtual void DoInitialize(void)
Initialize() implementation.
Time expireTime
The expiration time of the packet in the indirect transmission queue.
Ptr< LrWpanPhy > GetPhy(void)
Get the underlying PHY of the MAC.
@ CAP
Contention Access Period.
uint8_t m_numCsmacaRetry
The number of CSMA/CA retries used for sending the current packet.
void SetMcpsDataConfirmCallback(McpsDataConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
void SetMlmePollConfirmCallback(MlmePollConfirmCallback c)
Set the callback for the confirmation of a data transmission request.
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaCa)
Set the CSMA/CA implementation to be used by the MAC.
MlmeStartConfirmCallback m_mlmeStartConfirmCallback
This callback is used to report the start of a new PAN or the begin of a new superframe configuration...
Mac16Address m_shortAddress
The short address used by this MAC.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
uint64_t GetMacAckWaitDuration(void) const
Get the macAckWaitDuration attribute value.
@ BEACON
The Beacon transmission or reception Period.
void IfsWaitTimeout(Time ifsTime)
After a successful transmission of a frame (beacon, data) or an ack frame reception,...
uint8_t txQMsduHandle
MSDU Handle.
@ FFD
Full Functional Device (FFD)
void SetPanId(uint16_t panId)
Set the PAN id used by this MAC.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
void PdDataIndication(uint32_t psduLength, Ptr< Packet > p, uint8_t lqi)
IEEE 802.15.4-2006 section 6.2.1.3 PD-DATA.indication Indicates the transfer of an MPDU from PHY to M...
@ MAC_SENDING
MAC_SENDING.
static const uint32_t aMaxLostBeacons
The number of consecutive lost beacons that will cause the MAC sublayer of a receiving device to decl...
Implements the header for the MAC payload command frame according to the IEEE 802....
void SendAck(uint8_t seqno)
Send an acknowledgment packet for the given sequence number.
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
Mac64Address m_selfExt
The extended address used by this MAC.
Ptr< LrWpanCsmaCa > m_csmaCa
The CSMA/CA implementation used by this MAC.
void SendOneBeacon(void)
Called to send a single beacon frame.
TracedCallback< Ptr< const Packet > > m_macTxDequeueTrace
The trace source fired when packets are dequeued from the L3/l2 transmission queue.
Mac16Address m_dstAddr
Destination address.
@ MAC_ACK_PENDING
MAC_ACK_PENDING.
static Mac64Address Allocate(void)
Allocate a new Mac64Address.
@ MLMESTART_NO_SHORT_ADDRESS
TracedCallback< Ptr< const Packet >, uint8_t, uint8_t > m_sentPktTrace
The trace source fired when packets are considered as successfully sent or the transmission has been ...
void SetMcpsDataIndicationCallback(McpsDataIndicationCallback c)
Set the callback for the indication of an incoming data packet.
TracedCallback< Ptr< const Packet > > m_promiscSnifferTrace
A trace source that emulates a promiscuous mode protocol sniffer connected to the device.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void SetLrWpanMacState(LrWpanMacState macState)
CSMA-CA algorithm calls back the MAC after executing channel assessment.
void AckWaitTimeout(void)
Handle an ACK timeout with a packet retransmission, if there are retransmission left,...
MCPS-DATA.indication params.
void SetAssociationStatus(LrWpanAssociationStatus status)
Set the current association status.
void PlmeEdConfirm(LrWpanPhyEnumeration status, uint8_t energyLevel)
IEEE 802.15.4-2006 section 6.2.2.4 PLME-ED.confirm status and energy level.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint16_t m_panId
The PAN identifier with which the device lost synchronization or to which it was realigned.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint8_t m_dstAddrMode
Destination address mode.
void AddTrailer(const Trailer &trailer)
Add trailer to this packet.
TracedValue< SuperframeStatus > m_outSuperframeStatus
The current period of the outgoing superframe.
LrWpanMcpsDataConfirmStatus m_status
The status of the last MSDU transmission.
EventId m_cfpEvent
Scheduler event for the end of the outgoing superframe CFP.
@ INACTIVE
Inactive Period or unslotted CSMA-CA.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
PendingAddrFields GetPendingAddrFields(void)
Constructs Pending Address Fields from the local information, the Pending Address Fields are part of ...
uint8_t m_srcAddrMode
Source address mode.
LrWpanMac(void)
Default constructor.
void StartCAP(SuperframeType superframeType)
Called to begin the Contention Access Period (CAP) in a beacon-enabled mode.
LrWpanAddressMode m_srcAddrMode
Source address mode.
uint8_t phyCurrentChannel
The RF channel to use.
EventId m_ackWaitTimeout
Scheduler event for the ACK timeout of the currently transmitted data packet.
McpsDataIndicationCallback m_mcpsDataIndicationCallback
This callback is used to notify incoming packets to the upper layers.
static const uint32_t aMaxPhyPacketSize
The maximum packet size accepted by the PHY.
TracedCallback< Ptr< const Packet > > m_macTxOkTrace
The trace source fired when packets where successfully transmitted, that is an acknowledgment was rec...
uint8_t m_fnlCapSlot
Indication of the Slot where the CAP portion of the OUTGOING Superframe ends.
void BeaconSearchTimeout(void)
Called if the device is unable to locate a beacon in the time set by MLME-SYNC.request.
@ TX_OPTION_INDIRECT
TX_OPTION_INDIRECT.
uint16_t GetPanId(void) const
Get the PAN id used by this MAC.
uint8_t m_macSuperframeOrder
Used by a PAN coordinator or coordinator.
@ IEEE_802_15_4_TRANSACTION_OVERFLOW
EventId m_capEvent
Scheduler event for the end of the outgoing superframe CAP.
Mac16Address m_dstAddr
Destination address.
void PdDataConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.1.2 Confirm the end of transmission of an MPDU to MAC.
Hold an unsigned integer type.
MlmeSyncLossIndicationCallback m_mlmeSyncLossIndicationCallback
This callback is used to indicate the loss of synchronization with a coordinator.
void StartInactivePeriod(SuperframeType superframeType)
Start the Inactive Period in a beacon-enabled mode.
SequenceNumber8 m_macBsn
Sequence number added to transmitted beacon frame, 00-ff.
void SetMlmeSyncLossIndicationCallback(MlmeSyncLossIndicationCallback c)
Set the callback for the loss of synchronization with a coordinator.
TracedValue< SuperframeStatus > m_incSuperframeStatus
The current period of the incoming superframe.
MLME-SYNC.request params.
uint8_t GetFinalCapSlot(void) const
Get the the Final CAP Slot.
uint32_t m_macLIFSPeriod
The minimum time forming a Long InterFrame Spacing (LIFS) period.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
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.
LrWpanSyncLossReason m_lossReason
The reason for the lost of synchronization.
bool m_macPromiscuousMode
Indicates if MAC sublayer is in receive all mode.
@ IEEE_802_15_4_PHY_UNSPECIFIED
bool GetRxOnWhenIdle(void)
Check if the receiver will be enabled when the MAC is idle.
void PrintTransmitQueueSize(void)
Print the number of elements in the packet transmit queue.
MCPS-DATA.request params.
Class that implements the LR-WPAN MAC state machine.
LrWpanMlmeStartConfirmStatus m_status
The status of a MLME-start.request.
uint16_t m_dstPanId
Destination PAN identifier.
LrWpanAssociationStatus GetAssociationStatus(void) const
Get the current association status.
@ CHANNEL_IDLE
CHANNEL_IDLE.
uint8_t m_logCh
The channel number on which to attempt coordinator synchronization.
MLME-START.confirm params.
static const uint32_t aBaseSlotDuration
Length of a superframe slot in symbols.
uint8_t m_retransmission
The number of already used retransmission for the currently transmitted packet.
virtual void DoDispose(void)
Destructor implementation.
SequenceNumber8 m_macDsn
Sequence number added to transmitted data or MAC command frame, 00-ff.
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
bool m_beaconTrackingOn
Indication of whether the current device is tracking incoming beacons.
void ChangeMacState(LrWpanMacState newState)
Change the current MAC state to the given new state.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
McpsDataConfirmCallback m_mcpsDataConfirmCallback
This callback is used to report data transmission request status to the upper layers.
@ IEEE_802_15_4_CHANNEL_ACCESS_FAILURE
bool IsExpired(void) const
This method is syntactic sugar for the ns3::Simulator::IsExpired method.
uint32_t m_macSIFSPeriod
The minimum time forming a Short InterFrame Spacing (SIFS) period.
uint32_t m_incomingBeaconInterval
Indication of the interval a node should receive a superframe expressed in symbols.
void MlmeSyncRequest(MlmeSyncRequestParams params)
IEEE 802.15.4-2011, section 6.2.13.1 MLME-SYNC.request Request to synchronize with the coordinator by...
void StartCFP(SuperframeType superframeType)
Called to begin the Contention Free Period (CFP) in a beacon-enabled mode.
uint8_t m_msduHandle
MSDU handle.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
void SetAssociatedCoor(Mac16Address mac)
Check if the packet destination is its coordinator.
TracedCallback< Ptr< const Packet > > m_snifferTrace
A trace source that emulates a non-promiscuous protocol sniffer connected to the device.
uint8_t m_incomingFnlCapSlot
Indication of the Slot where the CAP portion of the INCOMING Superframe ends.