A Discrete-Event Network Simulator
API
uan-net-device.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
18  */
19 
20 #ifndef UAN_NET_DEVICE_H
21 #define UAN_NET_DEVICE_H
22 
23 #include "ns3/mac8-address.h"
24 #include "ns3/net-device.h"
25 #include "ns3/pointer.h"
26 #include "ns3/traced-callback.h"
27 
28 #include <list>
29 
30 namespace ns3
31 {
32 
33 class UanChannel;
34 class UanPhy;
35 class UanMac;
36 class UanTransducer;
37 
49 class UanNetDevice : public NetDevice
50 {
51  public:
53  typedef std::list<Ptr<UanPhy>> UanPhyList;
55  typedef std::list<Ptr<UanTransducer>> UanTransducerList;
56 
61  static TypeId GetTypeId();
62 
64  UanNetDevice();
66  ~UanNetDevice() override;
67 
73  void SetMac(Ptr<UanMac> mac);
74 
80  void SetPhy(Ptr<UanPhy> phy);
81 
88 
94  Ptr<UanMac> GetMac() const;
95 
101  Ptr<UanPhy> GetPhy() const;
102 
114  void SetTransducer(Ptr<UanTransducer> trans);
115 
117  void Clear();
118 
124  void SetSleepMode(bool sleep);
125 
126  // Inherited methods
127  void SetIfIndex(const uint32_t index) override;
128  uint32_t GetIfIndex() const override;
129  Ptr<Channel> GetChannel() const override;
130  Address GetAddress() const override;
131  bool SetMtu(const uint16_t mtu) override;
132  uint16_t GetMtu() const override;
133  bool IsLinkUp() const override;
134  bool IsBroadcast() const override;
135  Address GetBroadcast() const override;
136  bool IsMulticast() const override;
137  Address GetMulticast(Ipv4Address multicastGroup) const override;
138  Address GetMulticast(Ipv6Address addr) const override;
139  bool IsBridge() const override;
140  bool IsPointToPoint() const override;
141  bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
142  bool SendFrom(Ptr<Packet> packet,
143  const Address& source,
144  const Address& dest,
145  uint16_t protocolNumber) override;
146  Ptr<Node> GetNode() const override;
147  void SetNode(Ptr<Node> node) override;
148  bool NeedsArp() const override;
151  bool SupportsSendFrom() const override;
152  void AddLinkChangeCallback(Callback<void> callback) override;
153  void SetAddress(Address address) override;
154 
159  uint32_t GetTxModeIndex();
160 
165  void SetTxModeIndex(uint32_t txModeIndex);
166 
174 
175  private:
183  virtual void ForwardUp(Ptr<Packet> pkt, uint16_t protocolNumber, const Mac8Address& src);
184 
187 
193 
194  // unused: std::string m_name;
195  uint32_t m_ifIndex;
196  uint16_t m_mtu;
197  bool m_linkup;
200 
205 
207  bool m_cleared;
208 
209  protected:
210  void DoDispose() override;
211  void DoInitialize() override;
212 }; // class UanNetDevice
213 
214 } // namespace ns3
215 
216 #endif /* UAN_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
A class used for addressing MAC8 MAC's.
Definition: mac8-address.h:44
Network layer to device interface.
Definition: net-device.h:98
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
Net device for UAN models.
bool SupportsSendFrom() const override
bool SetMtu(const uint16_t mtu) override
Ptr< UanTransducer > GetTransducer() const
Get the transducer associated with this device.
void SetTxModeIndex(uint32_t txModeIndex)
Set the Tx mode index (Modulation type).
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
Address GetAddress() const override
UanNetDevice()
Default constructor.
uint32_t m_ifIndex
The interface index of this device.
void AddLinkChangeCallback(Callback< void > callback) override
uint32_t GetTxModeIndex()
Get the Tx mode index (Modulation type).
bool IsLinkUp() const override
void DoDispose() override
Destructor implementation.
void DoInitialize() override
Initialize() implementation.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
void Clear()
Clear all pointer references.
bool IsBridge() const override
Return true if the net device is acting as a bridge.
~UanNetDevice() override
Dummy destructor, DoDispose.
TracedCallback< Ptr< const Packet >, Mac8Address > m_txLogger
Trace source triggered when sending to the MAC layer.
void SetMac(Ptr< UanMac > mac)
Set the MAC layer for this device.
Ptr< Node > m_node
The node hosting this device.
bool IsBroadcast() const override
uint32_t GetIfIndex() const override
std::list< Ptr< UanTransducer > > UanTransducerList
List of UanTransducer objects.
Ptr< UanPhy > m_phy
The PHY layer attached to this device.
bool IsMulticast() const override
Ptr< Node > GetNode() const override
void SetAddress(Address address) override
Set the address of this interface.
void SetSleepMode(bool sleep)
Set the Phy SLEEP mode.
bool m_cleared
Flag when we've been cleared.
virtual void ForwardUp(Ptr< Packet > pkt, uint16_t protocolNumber, const Mac8Address &src)
Forward the packet to a higher level, set with SetReceiveCallback.
Ptr< UanTransducer > m_trans
The Transducer attached to this device.
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
bool m_linkup
The link state, true if up.
void SetChannel(Ptr< UanChannel > channel)
Attach a channel.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
void SetNode(Ptr< Node > node) override
Ptr< UanMac > GetMac() const
Get the MAC used by this device.
void SetIfIndex(const uint32_t index) override
TracedCallback m_linkChanges
Callback to invoke when the link state changes to UP.
Ptr< UanChannel > m_channel
The channel attached to this device.
Ptr< Channel > GetChannel() const override
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Ptr< UanChannel > DoGetChannel() const
TracedCallback< Ptr< const Packet >, Mac8Address > m_rxLogger
Trace source triggered when forwarding up received payload from the MAC layer.
uint16_t GetMtu() const override
Address GetBroadcast() const override
void(* RxTxTracedCallback)(Ptr< const Packet > packet, Mac8Address address)
TracedCallback signature for MAC send/receive events.
void SetTransducer(Ptr< UanTransducer > trans)
Set the transdcuer used by this device.
uint16_t m_mtu
The device MTU value, in bytes.
bool NeedsArp() const override
Ptr< UanPhy > GetPhy() const
Get the Phy used by this device.
ReceiveCallback m_forwardUp
The receive callback.
Ptr< UanMac > m_mac
The MAC layer attached to this device.
static TypeId GetTypeId()
Register this type.
std::list< Ptr< UanPhy > > UanPhyList
List of UanPhy objects.
void SetPhy(Ptr< UanPhy > phy)
Set the Phy layer for this device.
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