A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
30namespace ns3
31{
32
33class UanChannel;
34class UanPhy;
35class UanMac;
36class UanTransducer;
37
38/**
39 * \defgroup uan UAN Models
40 * This section documents the API of the ns-3 UAN module. For a generic functional description,
41 * please refer to the ns-3 manual.
42 */
43
44/**
45 * \ingroup uan
46 *
47 * Net device for UAN models.
48 */
49class UanNetDevice : public NetDevice
50{
51 public:
52 /** List of UanPhy objects. */
53 typedef std::list<Ptr<UanPhy>> UanPhyList;
54 /** List of UanTransducer objects. */
55 typedef std::list<Ptr<UanTransducer>> UanTransducerList;
56
57 /**
58 * Register this type.
59 * \return The TypeId.
60 */
61 static TypeId GetTypeId();
62
63 /** Default constructor */
65 /** Dummy destructor, DoDispose. */
66 ~UanNetDevice() override;
67
68 /**
69 * Set the MAC layer for this device.
70 *
71 * \param mac The MAC layer.
72 */
73 void SetMac(Ptr<UanMac> mac);
74
75 /**
76 * Set the Phy layer for this device.
77 *
78 * \param phy The PHY layer.
79 */
80 void SetPhy(Ptr<UanPhy> phy);
81
82 /**
83 * Attach a channel.
84 *
85 * \param channel The channel.
86 */
87 void SetChannel(Ptr<UanChannel> channel);
88
89 /**
90 * Get the MAC used by this device.
91 *
92 * \return The MAC.
93 */
94 Ptr<UanMac> GetMac() const;
95
96 /**
97 * Get the Phy used by this device.
98 *
99 * \return The Phy.
100 */
101 Ptr<UanPhy> GetPhy() const;
102
103 /**
104 * Get the transducer associated with this device.
105 *
106 * \return The transducer.
107 */
109 /**
110 * Set the transdcuer used by this device.
111 *
112 * \param trans The transducer.
113 */
115
116 /** Clear all pointer references. */
117 void Clear();
118
119 /**
120 * Set the Phy SLEEP mode.
121 *
122 * \param sleep SLEEP on or off.
123 */
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
155 /**
156 * Get the Tx mode index (Modulation type).
157 * \return the Tx mode index
158 */
160
161 /**
162 * Set the Tx mode index (Modulation type).
163 * \param txModeIndex the Tx mode index
164 */
165 void SetTxModeIndex(uint32_t txModeIndex);
166
167 /**
168 * TracedCallback signature for MAC send/receive events.
169 *
170 * \param [in] packet The Packet.
171 * \param [in] address The source address.
172 */
173 typedef void (*RxTxTracedCallback)(Ptr<const Packet> packet, Mac8Address address);
174
175 private:
176 /**
177 * Forward the packet to a higher level, set with SetReceiveCallback.
178 *
179 * \param pkt The packet.
180 * \param src The source address.
181 * \param protocolNumber The layer 3 protocol number.
182 */
183 virtual void ForwardUp(Ptr<Packet> pkt, uint16_t protocolNumber, const Mac8Address& src);
184
185 /** \return The channel attached to this device. */
187
188 Ptr<UanTransducer> m_trans; //!< The Transducer attached to this device.
189 Ptr<Node> m_node; //!< The node hosting this device.
190 Ptr<UanChannel> m_channel; //!< The channel attached to this device.
191 Ptr<UanMac> m_mac; //!< The MAC layer attached to this device.
192 Ptr<UanPhy> m_phy; //!< The PHY layer attached to this device.
193
194 // unused: std::string m_name;
195 uint32_t m_ifIndex; //!< The interface index of this device.
196 uint16_t m_mtu; //!< The device MTU value, in bytes.
197 bool m_linkup; //!< The link state, true if up.
198 TracedCallback<> m_linkChanges; //!< Callback to invoke when the link state changes to UP.
199 ReceiveCallback m_forwardUp; //!< The receive callback.
200
201 /** Trace source triggered when forwarding up received payload from the MAC layer. */
203 /** Trace source triggered when sending to the MAC layer */
205
206 /** Flag when we've been 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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.