A Discrete-Event Network Simulator
API
lr-wpan-net-device.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2011 The Boeing Company
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author:
19  * Tom Henderson <thomas.r.henderson@boeing.com>
20  * Tommaso Pecorella <tommaso.pecorella@unifi.it>
21  * Margherita Filippetti <morag87@gmail.com>
22  */
23 #ifndef LR_WPAN_NET_DEVICE_H
24 #define LR_WPAN_NET_DEVICE_H
25 
26 #include <ns3/net-device.h>
27 #include <ns3/traced-callback.h>
28 #include <ns3/lr-wpan-mac.h>
29 
30 namespace ns3 {
31 
32 class LrWpanPhy;
33 class LrWpanCsmaCa;
34 class SpectrumChannel;
35 class Node;
36 
49 class LrWpanNetDevice : public NetDevice
50 {
51 public:
57  static TypeId GetTypeId (void);
58 
59  LrWpanNetDevice (void);
60  virtual ~LrWpanNetDevice (void);
61 
67  void SetMac (Ptr<LrWpanMac> mac);
68 
74  void SetPhy (Ptr<LrWpanPhy> phy);
75 
81  void SetCsmaCa (Ptr<LrWpanCsmaCa> csmaca);
82 
90 
96  Ptr<LrWpanMac> GetMac (void) const;
97 
103  Ptr<LrWpanPhy> GetPhy (void) const;
104 
110  Ptr<LrWpanCsmaCa> GetCsmaCa (void) const;
111 
112  // From class NetDevice
113  virtual void SetIfIndex (const uint32_t index);
114  virtual uint32_t GetIfIndex (void) const;
115  virtual Ptr<Channel> GetChannel (void) const;
120  virtual void SetAddress (Address address);
125  virtual Address GetAddress (void) const;
126  virtual bool SetMtu (const uint16_t mtu);
127  virtual uint16_t GetMtu (void) const;
128  virtual bool IsLinkUp (void) const;
129  virtual void AddLinkChangeCallback (Callback<void> callback);
130  virtual bool IsBroadcast (void) const;
131  virtual Address GetBroadcast (void) const;
132  virtual bool IsMulticast (void) const;
133  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
134  virtual Address GetMulticast (Ipv6Address addr) const;
135  virtual bool IsBridge (void) const;
136  virtual bool IsPointToPoint (void) const;
137  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
138  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
139  virtual Ptr<Node> GetNode (void) const;
140  virtual void SetNode (Ptr<Node> node);
141  virtual bool NeedsArp (void) const;
142 
145  virtual bool SupportsSendFrom (void) const;
146 
156 
164  int64_t AssignStreams (int64_t stream);
165 
166 private:
167  // Inherited from NetDevice/Object
168  virtual void DoDispose (void);
169  virtual void DoInitialize (void);
170 
174  void LinkUp (void);
175 
179  void LinkDown (void);
180 
186  Ptr<SpectrumChannel> DoGetChannel (void) const;
187 
191  void CompleteConfig (void);
192 
197 
202 
207 
212 
218 
223  bool m_useAcks;
224 
228  bool m_linkUp;
229 
233  uint32_t m_ifIndex;
234 
239 
244 };
245 
246 } // namespace ns3
247 
248 #endif /* LR_WPAN_NET_DEVICE_H */
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual uint16_t GetMtu(void) const
virtual void SetNode(Ptr< Node > node)
virtual void AddLinkChangeCallback(Callback< void > callback)
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
bool m_useAcks
Configure the NetDevice to request MAC layer acknowledgments when sending packets using the Send() AP...
virtual Address GetBroadcast(void) const
ReceiveCallback m_receiveCallback
Upper layer callback used for notification of new data packet arrivals.
static TypeId GetTypeId(void)
Get the type ID.
TracedCallback m_linkChanges
Trace source for link up/down changes.
virtual uint32_t GetIfIndex(void) const
Forward calls to a chain of Callback.
virtual bool SupportsSendFrom(void) const
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual Address GetAddress(void) const
This method indirects to LrWpanMac::SetShortAddress ()
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual void DoDispose(void)
Destructor implementation.
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Network layer to device interface.
a polymophic address class
Definition: address.h:90
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
channel
Definition: third.py:85
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
phy
Definition: third.py:86
virtual Ptr< Channel > GetChannel(void) const
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...
Ptr< LrWpanMac > m_mac
The MAC for this NetDevice.
virtual void SetIfIndex(const uint32_t index)
void SetChannel(Ptr< SpectrumChannel > channel)
Set the channel to which the NetDevice, and therefore the PHY, should be attached to...
Ptr< LrWpanCsmaCa > m_csmaca
The CSMA/CA implementation for this NetDevice.
virtual void DoInitialize(void)
Initialize() implementation.
virtual bool IsMulticast(void) const
mac
Definition: third.py:92
void LinkDown(void)
Mark NetDevice link as down.
void SetMac(Ptr< LrWpanMac > mac)
Set the MAC to be used by this NetDevice.
bool m_linkUp
Is the link/device currently up and running?
Every class exported by the ns3 library is enclosed in the ns3 namespace.
address
Definition: first.py:37
Ptr< LrWpanPhy > m_phy
The PHY for this NetDevice.
void CompleteConfig(void)
Configure PHY, MAC and CSMA/CA.
Ptr< SpectrumChannel > DoGetChannel(void) const
Attribute accessor method for the "Channel" attribute.
uint32_t m_ifIndex
The interface index of this NetDevice.
void McpsDataIndication(McpsDataIndicationParams params, Ptr< Packet > pkt)
The callback used by the MAC to hand over incoming packets to the NetDevice.
virtual ~LrWpanNetDevice(void)
Describes an IPv6 address.
Definition: ipv6-address.h:49
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:40
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Network layer to device interface.
Definition: net-device.h:95
void LinkUp(void)
Mark NetDevice link as up.
Ptr< LrWpanCsmaCa > GetCsmaCa(void) const
Get the CSMA/CA implementation used by this NetDevice.
Ptr< Node > m_node
The node associated with this NetDevice.
virtual Ptr< Node > GetNode(void) const
virtual bool IsLinkUp(void) const
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.
bool m_configComplete
True if MAC, PHY and CSMA/CA where successfully configured and the NetDevice is ready for being used...
void SetCsmaCa(Ptr< LrWpanCsmaCa > csmaca)
Set the CSMA/CA implementation to be used by the MAC and this NetDevice.
a unique identifier for an interface.
Definition: type-id.h:58
virtual bool SetMtu(const uint16_t mtu)
virtual bool IsBroadcast(void) const
MCPS-DATA.indication params.
Definition: lr-wpan-mac.h:182
virtual bool NeedsArp(void) const