|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
27 #include <ns3/abort.h>
30 #include <ns3/spectrum-channel.h>
31 #include <ns3/pointer.h>
32 #include <ns3/boolean.h>
33 #include <ns3/mobility-model.h>
34 #include <ns3/packet.h>
48 .SetGroupName (
"LrWpan")
50 .AddAttribute (
"Channel",
"The channel attached to this device",
53 MakePointerChecker<SpectrumChannel> ())
54 .AddAttribute (
"Phy",
"The PHY layer attached to this device.",
58 MakePointerChecker<LrWpanPhy> ())
59 .AddAttribute (
"Mac",
"The MAC layer attached to this device.",
63 MakePointerChecker<LrWpanMac> ())
64 .AddAttribute (
"UseAcks",
"Request acknowledgments for data frames.",
68 .AddAttribute (
"PseudoMacAddressMode",
"Build the pseudo-MAC Address according to RFC 4944 or RFC 6282 (default: RFC 6282).",
78 : m_configComplete (false)
81 m_mac = CreateObject<LrWpanMac> ();
82 m_phy = CreateObject<LrWpanPhy> ();
83 m_csmaca = CreateObject<LrWpanCsmaCa> ();
113 m_phy->Initialize ();
114 m_mac->Initialize ();
139 NS_LOG_WARN (
"LrWpanNetDevice: no Mobility found on the node, probably it's not a good idea.");
143 m_phy->SetErrorModel (model);
144 m_phy->SetDevice (
this);
229 return m_phy->GetChannel ();
252 return m_phy->GetChannel ();
270 m_mac->SetShortAddress (addr16);
275 m_mac->SetPanId (panId);
279 NS_ABORT_MSG (
"LrWpanNetDevice::SetAddress - address is not of a compatible type");
290 return m_mac->GetExtendedAddress ();
295 return pseudoAddress;
344 return pseudoAddress;
368 return pseudoAddress;
397 NS_LOG_ERROR (
"Fragmentation is needed for this packet, drop the packet ");
414 m_mcpsDataRequestParams.
m_dstAddr = dst16;
425 m_mac->McpsDataRequest (m_mcpsDataRequestParams, packet);
474 NS_LOG_WARN (
"Unsupported; use LrWpan MAC APIs instead");
512 buf[1] = panId & 0xff;
527 return pseudoAddress;
534 int64_t streamIndex = stream;
535 streamIndex +=
m_csmaca->AssignStreams (stream);
536 streamIndex +=
m_phy->AssignStreams (stream);
537 NS_LOG_DEBUG (
"Number of assigned RV streams: " << (streamIndex - stream));
538 return (streamIndex - stream);
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
virtual uint32_t GetIfIndex(void) const
@ RFC4944
YYYY:0000:XXXX (with U/L bit set to local)
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual bool NeedsArp(void) const
bool m_useAcks
Configure the NetDevice to request MAC layer acknowledgments when sending packets using the Send() AP...
AttributeValue implementation for Boolean.
void PlmeCcaConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.2 PLME-CCA.confirm status.
virtual void DoDispose(void)
Destructor implementation.
static bool IsMatchingType(const Address &address)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
Ptr< SpectrumChannel > DoGetChannel(void) const
Attribute accessor method for the "Channel" attribute.
ReceiveCallback m_receiveCallback
Upper layer callback used for notification of new data packet arrivals.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetPhy(Ptr< LrWpanPhy > phy)
Set the PHY to be used by the MAC and this NetDevice.
@ TX_OPTION_ACK
TX_OPTION_ACK.
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
PseudoMacAddressMode_e m_pseudoMacMode
How the pseudo MAC address is created.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
void CompleteConfig(void)
Configure PHY, MAC and CSMA/CA.
This class can contain 16 bit addresses.
LrWpanAddressMode m_dstAddrMode
Destination address mode.
uint16_t m_dstPanId
Destination PAN identifier.
Mac48Address BuildPseudoMacAddress(uint16_t panId, Mac16Address shortAddr) const
Builds a "pseudo 48-bit address" from the PanId and Short Address The form is PanId : 0x0 : 0x0 : Sho...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
void SetMac(Ptr< LrWpanMac > mac)
Set the MAC to be used by this NetDevice.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
Hold objects of type Ptr<T>.
void CopyTo(uint8_t buffer[2]) const
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
virtual Address GetAddress(void) const
This method indirects to LrWpanMac::SetShortAddress ()
Ptr< LrWpanCsmaCa > GetCsmaCa(void) const
Get the CSMA/CA implementation used by this NetDevice.
uint8_t m_txOptions
Tx Options (bitfield)
virtual void SetIfIndex(const uint32_t index)
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold variables of type enum.
Ptr< LrWpanMac > m_mac
The MAC for this NetDevice.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
virtual bool IsLinkUp(void) const
static TypeId GetTypeId(void)
Get the type ID.
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.
virtual bool IsBroadcast(void) const
a polymophic address class
void PlmeSetTRXStateConfirm(LrWpanPhyEnumeration status)
IEEE 802.15.4-2006 section 6.2.2.8 PLME-SET-TRX-STATE.confirm Set PHY state.
uint16_t m_srcPanId
Source PAN identifier.
static Mac48Address ConvertFrom(const Address &address)
uint32_t m_ifIndex
The interface index of this NetDevice.
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...
virtual void SetNode(Ptr< Node > node)
static Mac16Address GetBroadcast(void)
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
virtual void DoInitialize(void)
Initialize() implementation.
bool m_configComplete
True if MAC, PHY and CSMA/CA where successfully configured and the NetDevice is ready for being used.
Mac64Address m_srcExtAddr
Source extended address.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
void LinkUp(void)
Mark NetDevice link as up.
virtual bool IsMulticast(void) const
virtual void DoInitialize(void)
Initialize() implementation.
virtual Address GetBroadcast(void) const
static bool IsMatchingType(const Address &address)
void LinkDown(void)
Mark NetDevice link as down.
virtual bool SetMtu(const uint16_t mtu)
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...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< Node > m_node
The node associated with this NetDevice.
#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...
bool m_linkUp
Is the link/device currently up and running?
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#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.
virtual ~LrWpanNetDevice(void)
MCPS-DATA.indication params.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
static Mac16Address GetMulticast(Ipv6Address address)
Returns the multicast address associated with an IPv6 address according to RFC 4944 Section 9.
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
void PlmeEdConfirm(LrWpanPhyEnumeration status, uint8_t energyLevel)
IEEE 802.15.4-2006 section 6.2.2.4 PLME-ED.confirm status and energy level.
static Mac16Address ConvertFrom(const Address &address)
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint8_t m_dstAddrMode
Destination address mode.
Network layer to device interface.
void McpsDataIndication(McpsDataIndicationParams params, Ptr< Packet > pkt)
The callback used by the MAC to hand over incoming packets to the NetDevice.
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
TracedCallback m_linkChanges
Trace source for link up/down changes.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Keep track of the current position and velocity of an object.
LrWpanAddressMode m_srcAddrMode
Source address mode.
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.
void CopyTo(uint8_t buffer[6]) const
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
virtual Ptr< Channel > GetChannel(void) const
void CopyFrom(const uint8_t buffer[2])
MCPS-DATA.request params.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
void CopyFrom(const uint8_t buffer[6])
virtual bool SupportsSendFrom(void) const
virtual void AddLinkChangeCallback(Callback< void > callback)
virtual void DoDispose(void)
Destructor implementation.
Ptr< LrWpanCsmaCa > m_csmaca
The CSMA/CA implementation for this NetDevice.
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaca)
Set the CSMA/CA implementation to be used by the MAC and this NetDevice.
virtual uint16_t GetMtu(void) const
virtual Ptr< Node > GetNode(void) const
Network layer to device interface.
Ptr< LrWpanPhy > m_phy
The PHY for this NetDevice.
uint8_t m_msduHandle
MSDU handle.
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.