A Discrete-Event Network Simulator
API
uan-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) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19  */
20 
21 #ifndef UAN_NET_DEVICE_H
22 #define UAN_NET_DEVICE_H
23 
24 #include "ns3/net-device.h"
25 #include "ns3/pointer.h"
26 #include "ns3/traced-callback.h"
27 #include "ns3/mac8-address.h"
28 #include <list>
29 
30 namespace ns3 {
31 
32 class UanChannel;
33 class UanPhy;
34 class UanMac;
35 class UanTransducer;
36 
47 class UanNetDevice : public NetDevice
48 {
49 public:
51  typedef std::list<Ptr<UanPhy> > UanPhyList;
53  typedef std::list<Ptr<UanTransducer> > UanTransducerList;
54 
59  static TypeId GetTypeId (void);
60 
62  UanNetDevice ();
64  virtual ~UanNetDevice ();
65 
71  void SetMac (Ptr<UanMac> mac);
72 
78  void SetPhy (Ptr<UanPhy> phy);
79 
86 
92  Ptr<UanMac> GetMac (void) const;
93 
99  Ptr<UanPhy> GetPhy (void) const;
100 
106  Ptr<UanTransducer> GetTransducer (void) const;
112  void SetTransducer (Ptr<UanTransducer> trans);
113 
115  void Clear (void);
116 
122  void SetSleepMode (bool sleep);
123 
124  // Inherited methods
125  virtual void SetIfIndex (const uint32_t index);
126  virtual uint32_t GetIfIndex (void) const;
127  virtual Ptr<Channel> GetChannel (void) const;
128  virtual Address GetAddress (void) const;
129  virtual bool SetMtu (const uint16_t mtu);
130  virtual uint16_t GetMtu (void) const;
131  virtual bool IsLinkUp (void) const;
132  virtual bool IsBroadcast (void) const;
133  virtual Address GetBroadcast (void) const;
134  virtual bool IsMulticast (void) const;
135  virtual Address GetMulticast (Ipv4Address multicastGroup) const;
136  virtual Address GetMulticast (Ipv6Address addr) const;
137  virtual bool IsBridge (void) const;
138  virtual bool IsPointToPoint (void) const;
139  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
140  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
141  virtual Ptr<Node> GetNode (void) const;
142  virtual void SetNode (Ptr<Node> node);
143  virtual bool NeedsArp (void) const;
146  virtual bool SupportsSendFrom (void) const;
147  virtual void AddLinkChangeCallback (Callback<void> callback);
148  virtual void SetAddress (Address address);
149 
154  uint32_t GetTxModeIndex ();
155 
160  void SetTxModeIndex (uint32_t txModeIndex);
161 
168  typedef void (* RxTxTracedCallback)
170 
171 private:
179  virtual void ForwardUp (Ptr<Packet> pkt, uint16_t protocolNumber, const Mac8Address &src);
180 
182  Ptr<UanChannel> DoGetChannel (void) const;
183 
189 
190  //unused: std::string m_name;
191  uint32_t m_ifIndex;
192  uint16_t m_mtu;
193  bool m_linkup;
196 
201 
203  bool m_cleared;
204 
205 protected:
206  virtual void DoDispose (void);
207  virtual void DoInitialize (void);
208 }; // class UanNetDevice
209 
210 } // namespace ns3
211 
212 #endif /* UAN_NET_DEVICE_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::UanNetDevice::GetNode
virtual Ptr< Node > GetNode(void) const
Definition: uan-net-device.cc:322
ns3::UanNetDevice::m_ifIndex
uint32_t m_ifIndex
The interface index of this device.
Definition: uan-net-device.h:191
ns3::Mac8Address
A class used for addressing MAC8 MAC's.
Definition: mac8-address.h:43
ns3::UanNetDevice::SetMtu
virtual bool SetMtu(const uint16_t mtu)
Definition: uan-net-device.cc:239
ns3::UanNetDevice::SetMac
void SetMac(Ptr< UanMac > mac)
Set the MAC layer for this device.
Definition: uan-net-device.cc:133
ns3::UanNetDevice::~UanNetDevice
virtual ~UanNetDevice()
Dummy destructor, DoDispose.
Definition: uan-net-device.cc:46
ns3::UanNetDevice::m_mtu
uint16_t m_mtu
The device MTU value, in bytes.
Definition: uan-net-device.h:192
ns3::UanNetDevice::AddLinkChangeCallback
virtual void AddLinkChangeCallback(Callback< void > callback)
Definition: uan-net-device.cc:384
ns3::Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & >
ns3::UanNetDevice::GetBroadcast
virtual Address GetBroadcast(void) const
Definition: uan-net-device.cc:266
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::UanNetDevice::GetTransducer
Ptr< UanTransducer > GetTransducer(void) const
Get the transducer associated with this device.
Definition: uan-net-device.cc:355
ns3::UanNetDevice::m_linkChanges
TracedCallback m_linkChanges
Callback to invoke when the link state changes to UP.
Definition: uan-net-device.h:194
ns3::UanNetDevice::m_trans
Ptr< UanTransducer > m_trans
The Transducer attached to this device.
Definition: uan-net-device.h:184
ns3::UanNetDevice::DoInitialize
virtual void DoInitialize(void)
Initialize() implementation.
Definition: uan-net-device.cc:82
third.channel
channel
Definition: third.py:92
ns3::UanNetDevice::m_forwardUp
ReceiveCallback m_forwardUp
The receive callback.
Definition: uan-net-device.h:195
ns3::UanNetDevice::GetIfIndex
virtual uint32_t GetIfIndex(void) const
Definition: uan-net-device.cc:221
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
ns3::Ipv6Address
Describes an IPv6 address.
Definition: ipv6-address.h:50
ns3::UanNetDevice::DoGetChannel
Ptr< UanChannel > DoGetChannel(void) const
Definition: uan-net-device.cc:197
ns3::UanNetDevice::IsLinkUp
virtual bool IsLinkUp(void) const
Definition: uan-net-device.cc:254
third.mac
mac
Definition: third.py:99
ns3::UanNetDevice::GetMulticast
virtual Address GetMulticast(Ipv4Address multicastGroup) const
Make and return a MAC multicast address using the provided multicast group.
Definition: uan-net-device.cc:278
ns3::UanNetDevice::SetChannel
void SetChannel(Ptr< UanChannel > channel)
Attach a channel.
Definition: uan-net-device.cc:175
ns3::UanNetDevice::Send
virtual bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Definition: uan-net-device.cc:302
ns3::UanNetDevice::IsMulticast
virtual bool IsMulticast(void) const
Definition: uan-net-device.cc:272
ns3::UanNetDevice::NeedsArp
virtual bool NeedsArp(void) const
Definition: uan-net-device.cc:334
ns3::UanNetDevice::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: uan-net-device.cc:93
ns3::UanNetDevice::GetMac
Ptr< UanMac > GetMac(void) const
Get the MAC used by this device.
Definition: uan-net-device.cc:203
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
ns3::UanNetDevice::SetTxModeIndex
void SetTxModeIndex(uint32_t txModeIndex)
Set the Tx mode index (Modulation type).
Definition: uan-net-device.cc:417
ns3::UanNetDevice::m_linkup
bool m_linkup
The link state, true if up.
Definition: uan-net-device.h:193
ns3::UanNetDevice::m_phy
Ptr< UanPhy > m_phy
The PHY layer attached to this device.
Definition: uan-net-device.h:188
ns3::UanNetDevice::RxTxTracedCallback
void(* RxTxTracedCallback)(Ptr< const Packet > packet, Mac8Address address)
TracedCallback signature for MAC send/receive events.
Definition: uan-net-device.h:169
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::NetDevice::ReceiveCallback
Callback< bool, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address & > ReceiveCallback
Definition: net-device.h:318
ns3::UanNetDevice::SetPhy
void SetPhy(Ptr< UanPhy > phy)
Set the Phy layer for this device.
Definition: uan-net-device.cc:152
ns3::UanNetDevice
Net device for UAN models.
Definition: uan-net-device.h:48
ns3::UanNetDevice::SetTransducer
void SetTransducer(Ptr< UanTransducer > trans)
Set the transdcuer used by this device.
Definition: uan-net-device.cc:360
ns3::UanNetDevice::UanTransducerList
std::list< Ptr< UanTransducer > > UanTransducerList
List of UanTransducer objects.
Definition: uan-net-device.h:53
ns3::UanNetDevice::m_cleared
bool m_cleared
Flag when we've been cleared.
Definition: uan-net-device.h:203
ns3::UanNetDevice::UanPhyList
std::list< Ptr< UanPhy > > UanPhyList
List of UanPhy objects.
Definition: uan-net-device.h:51
first.address
address
Definition: first.py:44
ns3::UanNetDevice::ForwardUp
virtual void ForwardUp(Ptr< Packet > pkt, uint16_t protocolNumber, const Mac8Address &src)
Forward the packet to a higher level, set with SetReceiveCallback.
Definition: uan-net-device.cc:346
ns3::UanNetDevice::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: uan-net-device.cc:100
ns3::UanNetDevice::IsPointToPoint
virtual bool IsPointToPoint(void) const
Return true if the net device is on a point-to-point link.
Definition: uan-net-device.cc:296
ns3::UanNetDevice::GetMtu
virtual uint16_t GetMtu(void) const
Definition: uan-net-device.cc:248
ns3::UanNetDevice::UanNetDevice
UanNetDevice()
Default constructor.
Definition: uan-net-device.cc:39
ns3::UanNetDevice::m_txLogger
TracedCallback< Ptr< const Packet >, Mac8Address > m_txLogger
Trace source triggered when sending to the MAC layer.
Definition: uan-net-device.h:200
ns3::UanNetDevice::GetTxModeIndex
uint32_t GetTxModeIndex()
Get the Tx mode index (Modulation type).
Definition: uan-net-device.cc:423
ns3::UanNetDevice::GetAddress
virtual Address GetAddress(void) const
Definition: uan-net-device.cc:233
ns3::UanNetDevice::SetIfIndex
virtual void SetIfIndex(const uint32_t index)
Definition: uan-net-device.cc:215
ns3::UanNetDevice::SetSleepMode
void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
Definition: uan-net-device.cc:411
ns3::UanNetDevice::GetPhy
Ptr< UanPhy > GetPhy(void) const
Get the Phy used by this device.
Definition: uan-net-device.cc:209
ns3::UanNetDevice::SetPromiscReceiveCallback
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)
Definition: uan-net-device.cc:391
ns3::UanNetDevice::SetAddress
virtual void SetAddress(Address address)
Set the address of this interface.
Definition: uan-net-device.cc:404
ns3::UanNetDevice::m_rxLogger
TracedCallback< Ptr< const Packet >, Mac8Address > m_rxLogger
Trace source triggered when forwarding up received payload from the MAC layer.
Definition: uan-net-device.h:198
ns3::UanNetDevice::SendFrom
virtual bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber)
Definition: uan-net-device.cc:312
ns3::UanNetDevice::m_channel
Ptr< UanChannel > m_channel
The channel attached to this device.
Definition: uan-net-device.h:186
ns3::UanNetDevice::IsBridge
virtual bool IsBridge(void) const
Return true if the net device is acting as a bridge.
Definition: uan-net-device.cc:291
ns3::UanNetDevice::GetChannel
virtual Ptr< Channel > GetChannel(void) const
Definition: uan-net-device.cc:227
ns3::UanNetDevice::SetNode
virtual void SetNode(Ptr< Node > node)
Definition: uan-net-device.cc:328
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::UanNetDevice::m_mac
Ptr< UanMac > m_mac
The MAC layer attached to this device.
Definition: uan-net-device.h:187
ns3::UanNetDevice::m_node
Ptr< Node > m_node
The node hosting this device.
Definition: uan-net-device.h:185
ns3::UanNetDevice::IsBroadcast
virtual bool IsBroadcast(void) const
Definition: uan-net-device.cc:260
third.phy
phy
Definition: third.py:93
ns3::UanNetDevice::Clear
void Clear(void)
Clear all pointer references.
Definition: uan-net-device.cc:51
ns3::NetDevice
Network layer to device interface.
Definition: net-device.h:96
ns3::UanNetDevice::SupportsSendFrom
virtual bool SupportsSendFrom(void) const
Definition: uan-net-device.cc:398
ns3::UanNetDevice::SetReceiveCallback
virtual void SetReceiveCallback(NetDevice::ReceiveCallback cb)
Definition: uan-net-device.cc:340