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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Leonard Tracy <lentracy@gmail.com>
7 */
8
9#ifndef UAN_NET_DEVICE_H
10#define UAN_NET_DEVICE_H
11
12#include "ns3/mac8-address.h"
13#include "ns3/net-device.h"
14#include "ns3/pointer.h"
15#include "ns3/traced-callback.h"
16
17#include <list>
18
19namespace ns3
20{
21
22class UanChannel;
23class UanPhy;
24class UanMac;
25class UanTransducer;
26
27/**
28 * @defgroup uan UAN Models
29 * This section documents the API of the ns-3 UAN module. For a generic functional description,
30 * please refer to the ns-3 manual.
31 */
32
33/**
34 * @ingroup uan
35 *
36 * Net device for UAN models.
37 */
38class UanNetDevice : public NetDevice
39{
40 public:
41 /** List of UanPhy objects. */
42 typedef std::list<Ptr<UanPhy>> UanPhyList;
43 /** List of UanTransducer objects. */
44 typedef std::list<Ptr<UanTransducer>> UanTransducerList;
45
46 /**
47 * Register this type.
48 * @return The TypeId.
49 */
50 static TypeId GetTypeId();
51
52 /** Default constructor */
54 /** Dummy destructor, DoDispose. */
55 ~UanNetDevice() override;
56
57 /**
58 * Set the MAC layer for this device.
59 *
60 * @param mac The MAC layer.
61 */
62 void SetMac(Ptr<UanMac> mac);
63
64 /**
65 * Set the Phy layer for this device.
66 *
67 * @param phy The PHY layer.
68 */
69 void SetPhy(Ptr<UanPhy> phy);
70
71 /**
72 * Attach a channel.
73 *
74 * @param channel The channel.
75 */
76 void SetChannel(Ptr<UanChannel> channel);
77
78 /**
79 * Get the MAC used by this device.
80 *
81 * @return The MAC.
82 */
83 Ptr<UanMac> GetMac() const;
84
85 /**
86 * Get the Phy used by this device.
87 *
88 * @return The Phy.
89 */
90 Ptr<UanPhy> GetPhy() const;
91
92 /**
93 * Get the transducer associated with this device.
94 *
95 * @return The transducer.
96 */
98 /**
99 * Set the transdcuer used by this device.
100 *
101 * @param trans The transducer.
102 */
104
105 /** Clear all pointer references. */
106 void Clear();
107
108 /**
109 * Set the Phy SLEEP mode.
110 *
111 * @param sleep SLEEP on or off.
112 */
113 void SetSleepMode(bool sleep);
114
115 // Inherited methods
116 void SetIfIndex(const uint32_t index) override;
117 uint32_t GetIfIndex() const override;
118 Ptr<Channel> GetChannel() const override;
119 Address GetAddress() const override;
120 bool SetMtu(const uint16_t mtu) override;
121 uint16_t GetMtu() const override;
122 bool IsLinkUp() const override;
123 bool IsBroadcast() const override;
124 Address GetBroadcast() const override;
125 bool IsMulticast() const override;
126 Address GetMulticast(Ipv4Address multicastGroup) const override;
127 Address GetMulticast(Ipv6Address addr) const override;
128 bool IsBridge() const override;
129 bool IsPointToPoint() const override;
130 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
131 bool SendFrom(Ptr<Packet> packet,
132 const Address& source,
133 const Address& dest,
134 uint16_t protocolNumber) override;
135 Ptr<Node> GetNode() const override;
136 void SetNode(Ptr<Node> node) override;
137 bool NeedsArp() const override;
140 bool SupportsSendFrom() const override;
141 void AddLinkChangeCallback(Callback<void> callback) override;
142 void SetAddress(Address address) override;
143
144 /**
145 * Get the Tx mode index (Modulation type).
146 * @return the Tx mode index
147 */
149
150 /**
151 * Set the Tx mode index (Modulation type).
152 * @param txModeIndex the Tx mode index
153 */
154 void SetTxModeIndex(uint32_t txModeIndex);
155
156 /**
157 * TracedCallback signature for MAC send/receive events.
158 *
159 * @param [in] packet The Packet.
160 * @param [in] address The source address.
161 */
162 typedef void (*RxTxTracedCallback)(Ptr<const Packet> packet, Mac8Address address);
163
164 private:
165 /**
166 * Forward the packet to a higher level, set with SetReceiveCallback.
167 *
168 * @param pkt The packet.
169 * @param src The source address.
170 * @param protocolNumber The layer 3 protocol number.
171 */
172 virtual void ForwardUp(Ptr<Packet> pkt, uint16_t protocolNumber, const Mac8Address& src);
173
174 /** @return The channel attached to this device. */
176
177 Ptr<UanTransducer> m_trans; //!< The Transducer attached to this device.
178 Ptr<Node> m_node; //!< The node hosting this device.
179 Ptr<UanChannel> m_channel; //!< The channel attached to this device.
180 Ptr<UanMac> m_mac; //!< The MAC layer attached to this device.
181 Ptr<UanPhy> m_phy; //!< The PHY layer attached to this device.
182
183 // unused: std::string m_name;
184 uint32_t m_ifIndex; //!< The interface index of this device.
185 uint16_t m_mtu; //!< The device MTU value, in bytes.
186 bool m_linkup; //!< The link state, true if up.
187 TracedCallback<> m_linkChanges; //!< Callback to invoke when the link state changes to UP.
188 ReceiveCallback m_forwardUp; //!< The receive callback.
189
190 /** Trace source triggered when forwarding up received payload from the MAC layer. */
192 /** Trace source triggered when sending to the MAC layer */
194
195 /** Flag when we've been cleared. */
197
198 protected:
199 void DoDispose() override;
200 void DoInitialize() override;
201}; // class UanNetDevice
202
203} // namespace ns3
204
205#endif /* UAN_NET_DEVICE_H */
a polymophic address class
Definition address.h:90
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
A class used for addressing MAC8 MAC's.
Network layer to device interface.
Definition net-device.h:87
Smart pointer class similar to boost::intrusive_ptr.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:48
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.