A Discrete-Event Network Simulator
API
lr-wpan-net-device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 The Boeing Company
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author:
18  * Tom Henderson <thomas.r.henderson@boeing.com>
19  * Tommaso Pecorella <tommaso.pecorella@unifi.it>
20  * Margherita Filippetti <morag87@gmail.com>
21  */
22 #ifndef LR_WPAN_NET_DEVICE_H
23 #define LR_WPAN_NET_DEVICE_H
24 
25 #include "lr-wpan-mac.h"
26 
27 #include <ns3/net-device.h>
28 #include <ns3/traced-callback.h>
29 
30 namespace ns3
31 {
32 
33 class LrWpanPhy;
34 class LrWpanCsmaCa;
35 class SpectrumChannel;
36 class Node;
37 
50 class LrWpanNetDevice : public NetDevice
51 {
52  public:
58  static TypeId GetTypeId();
59 
61  ~LrWpanNetDevice() override;
62 
70  {
72  RFC6282
73  };
74 
81 
88 
94  void SetCsmaCa(Ptr<LrWpanCsmaCa> csmaca);
95 
103 
109  Ptr<LrWpanMac> GetMac() const;
110 
116  Ptr<LrWpanPhy> GetPhy() const;
117 
124 
125  // From class NetDevice
126  void SetIfIndex(const uint32_t index) override;
127  uint32_t GetIfIndex() const override;
128  Ptr<Channel> GetChannel() const override;
133  void SetAddress(Address address) override;
138  Address GetAddress() const override;
139 
164  void SetPanAssociation(uint16_t panId,
165  Mac64Address coordExtAddr,
166  Mac16Address coordShortAddr,
167  Mac16Address assignedShortAddr);
168 
169  bool SetMtu(const uint16_t mtu) override;
170  uint16_t GetMtu() const override;
171  bool IsLinkUp() const override;
172  void AddLinkChangeCallback(Callback<void> callback) override;
173  bool IsBroadcast() const override;
174  Address GetBroadcast() const override;
175  bool IsMulticast() const override;
176  Address GetMulticast(Ipv4Address multicastGroup) const override;
177  Address GetMulticast(Ipv6Address addr) const override;
178  bool IsBridge() const override;
179  bool IsPointToPoint() const override;
180  bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
181  bool SendFrom(Ptr<Packet> packet,
182  const Address& source,
183  const Address& dest,
184  uint16_t protocolNumber) override;
185  Ptr<Node> GetNode() const override;
186  void SetNode(Ptr<Node> node) override;
187  bool NeedsArp() const override;
188 
191  bool SupportsSendFrom() const override;
192 
202 
210  int64_t AssignStreams(int64_t stream);
211 
212  private:
213  // Inherited from NetDevice/Object
214  void DoDispose() override;
215  void DoInitialize() override;
216 
220  void LinkUp();
221 
225  void LinkDown();
226 
233 
237  void CompleteConfig();
238 
256  Mac48Address BuildPseudoMacAddress(uint16_t panId, Mac16Address shortAddr) const;
257 
262 
267 
272 
277 
283 
288  bool m_useAcks;
289 
293  bool m_linkUp;
294 
298  uint32_t m_ifIndex;
299 
304 
309 
317 };
318 
319 } // namespace ns3
320 
321 #endif /* LR_WPAN_NET_DEVICE_H */
a polymophic address class
Definition: address.h:101
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
Network layer to device interface.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
static TypeId GetTypeId()
Get the type ID.
PseudoMacAddressMode_e m_pseudoMacMode
How the pseudo MAC address is created.
PseudoMacAddressMode_e
How the pseudo-MAC address is built from the short address (XXXX) and the PanId (YYYY).
@ RFC4944
YYYY:0000:XXXX (with U/L bit set to local)
@ RFC6282
0200:0000:XXXX
Ptr< LrWpanMac > m_mac
The MAC for this NetDevice.
Address GetAddress() const override
This method indirects to LrWpanMac::SetShortAddress ()
Ptr< Node > GetNode() const override
bool m_useAcks
Configure the NetDevice to request MAC layer acknowledgments when sending packets using the Send() AP...
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaca)
Set the CSMA/CA implementation to be used by the MAC and this NetDevice.
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to.
Ptr< SpectrumChannel > DoGetChannel() const
Attribute accessor method for the "Channel" attribute.
Ptr< LrWpanMac > GetMac() const
Get the MAC used by this NetDevice.
bool SupportsSendFrom() const override
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
void AddLinkChangeCallback(Callback< void > callback) override
void SetNode(Ptr< Node > node) override
Ptr< Node > m_node
The node associated with this NetDevice.
void SetPhy(Ptr< LrWpanPhy > phy)
Set the PHY to be used by the MAC and this NetDevice.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
bool IsBroadcast() const override
bool SetMtu(const uint16_t mtu) override
uint16_t GetMtu() const override
bool IsMulticast() const override
void McpsDataIndication(McpsDataIndicationParams params, Ptr< Packet > pkt)
The callback used by the MAC to hand over incoming packets to the NetDevice.
ReceiveCallback m_receiveCallback
Upper layer callback used for notification of new data packet arrivals.
bool m_linkUp
Is the link/device currently up and running?
Ptr< LrWpanPhy > GetPhy() const
Get the PHY used by this NetDevice.
uint32_t GetIfIndex() const override
bool IsLinkUp() const override
Ptr< LrWpanPhy > m_phy
The PHY for this NetDevice.
void SetAddress(Address address) override
This method indirects to LrWpanMac::SetShortAddress ()
void SetPanAssociation(uint16_t panId, Mac64Address coordExtAddr, Mac16Address coordShortAddr, Mac16Address assignedShortAddr)
This method is use to manually configure the coordinator through which the device or coordinator is a...
Ptr< LrWpanCsmaCa > GetCsmaCa() const
Get the CSMA/CA implementation used by this NetDevice.
Address GetBroadcast() const override
void SetMac(Ptr< LrWpanMac > mac)
Set the MAC to be used by this NetDevice.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
void SetIfIndex(const uint32_t index) override
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
bool m_configComplete
True if MAC, PHY and CSMA/CA where successfully configured and the NetDevice is ready for being used.
bool NeedsArp() const override
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
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< LrWpanCsmaCa > m_csmaca
The CSMA/CA implementation for this NetDevice.
TracedCallback m_linkChanges
Trace source for link up/down changes.
void CompleteConfig()
Configure PHY, MAC and CSMA/CA.
void DoDispose() override
Destructor implementation.
void LinkUp()
Mark NetDevice link as up.
Ptr< Channel > GetChannel() const override
void DoInitialize() override
Initialize() implementation.
void LinkDown()
Mark NetDevice link as down.
uint32_t m_ifIndex
The interface index of this NetDevice.
This class can contain 16 bit addresses.
Definition: mac16-address.h:44
an EUI-48 address
Definition: mac48-address.h:46
an EUI-64 address
Definition: mac64-address.h:46
Network layer to device interface.
Definition: net-device.h:98
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, PacketType > PromiscReceiveCallback
Definition: net-device.h:352
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
channel
Definition: third.py:88
mac
Definition: third.py:92
phy
Definition: third.py:89
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
MCPS-DATA.indication params.