A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
89  void SetChannel (Ptr<SpectrumChannel> channel);
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;
119  virtual void SetAddress (Address address);
123  virtual Address GetAddress (void) const;
124  virtual bool SetMtu (const uint16_t mtu);
125  virtual uint16_t GetMtu (void) const;
126  virtual bool IsLinkUp (void) const;
127  virtual void AddLinkChangeCallback (Callback<void> callback);
128  virtual bool IsBroadcast (void) const;
129  virtual Address GetBroadcast (void) const;
130  virtual bool IsMulticast (void) const;
131  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
132  virtual Address GetMulticast (Ipv6Address addr) const;
133  virtual bool IsBridge (void) const;
134  virtual bool IsPointToPoint (void) const;
135  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
136  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
137  virtual Ptr<Node> GetNode (void) const;
138  virtual void SetNode (Ptr<Node> node);
139  virtual bool NeedsArp (void) const;
140 
141  virtual void SetReceiveCallback (ReceiveCallback cb);
143  virtual bool SupportsSendFrom (void) const;
144 
154 
162  int64_t AssignStreams (int64_t stream);
163 
164 private:
165  // Inherited from NetDevice/Object
166  virtual void DoDispose (void);
167  virtual void DoInitialize (void);
168 
172  void LinkUp (void);
173 
177  void LinkDown (void);
178 
184  Ptr<SpectrumChannel> DoGetChannel (void) const;
185 
189  void CompleteConfig (void);
190 
195 
200 
205 
210 
216 
221  bool m_useAcks;
222 
226  bool m_linkUp;
227 
231  uint32_t m_ifIndex;
232 
237 
242 };
243 
244 } // namespace ns3
245 
246 #endif /* LR_WPAN_NET_DEVICE_H */
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
virtual void SetNode(Ptr< Node > node)
virtual void AddLinkChangeCallback(Callback< void > callback)
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
virtual void SetReceiveCallback(ReceiveCallback cb)
bool m_useAcks
Configure the NetDevice to request MAC layer acknowledgements when sending packets using the Send() A...
ReceiveCallback m_receiveCallback
Upper layer callback used for notification of new data packet arrivals.
Ptr< LrWpanPhy > GetPhy(void) const
Get the PHY used by this NetDevice.
static TypeId GetTypeId(void)
Get the type ID.
TracedCallback m_linkChanges
Trace source for link up/down changes.
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition: net-device.h:296
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
virtual bool NeedsArp(void) const
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
virtual Ptr< Node > GetNode(void) const
Ptr< SpectrumChannel > DoGetChannel(void) const
Attribute accessor method for the "Channel" attribute.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
virtual Ptr< Channel > GetChannel(void) const
Network layer to device interface.
virtual bool IsMulticast(void) const
a polymophic address class
Definition: address.h:86
virtual void SetAddress(Address address)
This method indirects to LrWpanMac::SetShortAddress ()
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)
This method is called only once by Object::Initialize.
void LinkDown(void)
Mark NetDevice link as down.
void SetMac(Ptr< LrWpanMac > mac)
Set the MAC to be used by this NetDevice.
virtual uint32_t GetIfIndex(void) const
bool m_linkUp
Is the link/device currently up and running?
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
virtual bool SupportsSendFrom(void) const
Ptr< LrWpanPhy > m_phy
The PHY for this NetDevice.
void CompleteConfig(void)
Configure PHY, MAC and CSMA/CA.
uint32_t m_ifIndex
The interface index of this NetDevice.
virtual Address GetBroadcast(void) const
virtual Address GetAddress(void) const
This method indirects to LrWpanMac::SetShortAddress ()
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:46
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Network layer to device interface.
Definition: net-device.h:75
void LinkUp(void)
Mark NetDevice link as up.
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Ptr< Node > m_node
The node associated with this NetDevice.
virtual uint16_t GetMtu(void) const
virtual bool IsBroadcast(void) const
tuple address
Definition: first.py:37
virtual bool IsLinkUp(void) const
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:49
virtual bool SetMtu(const uint16_t mtu)
Ptr< LrWpanCsmaCa > GetCsmaCa(void) const
Get the CSMA/CA implementation used by this NetDevice.
Ptr< LrWpanMac > GetMac(void) const
Get the MAC used by this NetDevice.