A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
wifi-net-device.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2005,2006 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef WIFI_NET_DEVICE_H
21#define WIFI_NET_DEVICE_H
22
23#include "wifi-standards.h"
24
25#include "ns3/net-device.h"
26#include "ns3/traced-callback.h"
27
28#include <optional>
29#include <vector>
30
31namespace ns3
32{
33
34class WifiRemoteStationManager;
35class WifiPhy;
36class WifiMac;
37class HtConfiguration;
38class VhtConfiguration;
39class HeConfiguration;
40class EhtConfiguration;
41
42/// This value conforms to the 802.11 specification
43static const uint16_t MAX_MSDU_SIZE = 2304;
44
45/**
46 * \defgroup wifi Wifi Models
47 *
48 * This section documents the API of the ns-3 Wifi module. For a generic functional description,
49 * please refer to the ns-3 manual.
50 */
51
52/**
53 * \brief Hold together all Wifi-related objects.
54 * \ingroup wifi
55 *
56 * This class holds together ns3::Channel, ns3::WifiPhy,
57 * ns3::WifiMac, and, ns3::WifiRemoteStationManager.
58 */
60{
61 public:
62 /**
63 * \brief Get the type ID.
64 * \return the object TypeId
65 */
66 static TypeId GetTypeId();
67
69 ~WifiNetDevice() override;
70
71 // Delete copy constructor and assignment operator to avoid misuse
72 WifiNetDevice(const WifiNetDevice& o) = delete;
74
75 /**
76 * Set the Wifi standard.
77 *
78 * \param standard the Wifi standard
79 */
80 void SetStandard(WifiStandard standard);
81 /**
82 * Get the Wifi standard.
83 *
84 * \return the Wifi standard
85 */
87
88 /**
89 * \param mac the MAC layer to use.
90 */
91 void SetMac(const Ptr<WifiMac> mac);
92 /**
93 * \param phy the PHY layer to use.
94 */
95 void SetPhy(const Ptr<WifiPhy> phy);
96 /**
97 * \param phys the PHY layers to use (for 11be multi-link devices only)
98 */
99 void SetPhys(const std::vector<Ptr<WifiPhy>>& phys);
100 /**
101 * \param manager the manager to use.
102 */
104 /**
105 * \param managers the managers to use (for 11be multi-link devices only)
106 */
107 void SetRemoteStationManagers(const std::vector<Ptr<WifiRemoteStationManager>>& managers);
108 /**
109 * \returns the MAC we are currently using.
110 */
111 Ptr<WifiMac> GetMac() const;
112 /**
113 * \returns the PHY we are currently using.
114 *
115 * This GetPhy variant is needed to keep using "Phy" in the path names.
116 */
117 Ptr<WifiPhy> GetPhy() const;
118 /**
119 * \param i the index (starting at 0) of the PHY object to retrieve
120 * \returns the requested PHY object
121 */
122 virtual Ptr<WifiPhy> GetPhy(uint8_t i) const;
123 /**
124 * \returns a const reference to the vector of PHY objects
125 */
126 virtual const std::vector<Ptr<WifiPhy>>& GetPhys() const;
127 /**
128 * \returns the number of PHY objects
129 */
130 uint8_t GetNPhys() const;
131 /**
132 * \returns the remote station manager we are currently using.
133 *
134 * This GetRemoteStationManager variant is needed to keep using "RemoteStationManager"
135 * in the path names.
136 */
138 /**
139 * \param linkId the ID (starting at 0) of the link of the RemoteStationManager
140 * object to retrieve
141 * \returns the requested remote station manager
142 */
144 /**
145 * \returns a const reference to the vector of remote station managers
146 */
147 virtual const std::vector<Ptr<WifiRemoteStationManager>>& GetRemoteStationManagers() const;
148 /**
149 * \returns the number of remote station managers
150 */
151 uint8_t GetNRemoteStationManagers() const;
152
153 /**
154 * \param htConfiguration pointer to HtConfiguration
155 */
156 void SetHtConfiguration(Ptr<HtConfiguration> htConfiguration);
157 /**
158 * \return pointer to HtConfiguration if it exists
159 */
161 /**
162 * \param vhtConfiguration pointer to VhtConfiguration
163 */
164 void SetVhtConfiguration(Ptr<VhtConfiguration> vhtConfiguration);
165 /**
166 * \return pointer to VhtConfiguration if it exists
167 */
169 /**
170 * \param heConfiguration pointer to HeConfiguration
171 */
172 void SetHeConfiguration(Ptr<HeConfiguration> heConfiguration);
173 /**
174 * \return pointer to HeConfiguration if it exists
175 */
177 /**
178 * \param ehtConfiguration pointer to EhtConfiguration
179 */
180 void SetEhtConfiguration(Ptr<EhtConfiguration> ehtConfiguration);
181 /**
182 * \return pointer to EhtConfiguration if it exists
183 */
185
186 void SetIfIndex(const uint32_t index) override;
187 uint32_t GetIfIndex() const override;
188 Ptr<Channel> GetChannel() const override;
189 void SetAddress(Address address) override;
190 Address GetAddress() const override;
191 bool SetMtu(const uint16_t mtu) override;
192 uint16_t GetMtu() const override;
193 bool IsLinkUp() const override;
194 void AddLinkChangeCallback(Callback<void> callback) override;
195 bool IsBroadcast() const override;
196 Address GetBroadcast() const override;
197 bool IsMulticast() const override;
198 Address GetMulticast(Ipv4Address multicastGroup) const override;
199 bool IsPointToPoint() const override;
200 bool IsBridge() const override;
201 bool Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber) override;
202 Ptr<Node> GetNode() const override;
203 void SetNode(const Ptr<Node> node) override;
204 bool NeedsArp() const override;
206 Address GetMulticast(Ipv6Address addr) const override;
207 bool SendFrom(Ptr<Packet> packet,
208 const Address& source,
209 const Address& dest,
210 uint16_t protocolNumber) override;
212 bool SupportsSendFrom() const override;
213
214 protected:
215 void DoDispose() override;
216 void DoInitialize() override;
217 /**
218 * Receive a packet from the lower layer and pass the
219 * packet up the stack.
220 *
221 * \param packet the packet to forward up
222 * \param from the source address
223 * \param to the destination address
224 */
226
227 private:
228 /**
229 * Set that the link is up. A link is always up in ad-hoc mode.
230 * For a STA, a link is up when the STA is associated with an AP.
231 */
232 void LinkUp();
233 /**
234 * Set that the link is down (i.e. STA is not associated).
235 */
236 void LinkDown();
237 /**
238 * Complete the configuration of this Wi-Fi device by
239 * connecting all lower components (e.g. MAC, WifiRemoteStation) together.
240 */
241 void CompleteConfig();
242
243 /**
244 * Send a packet
245 *
246 * \param packet packet sent from upper layers
247 * \param source source mac address (if provided)
248 * \param dest destination mac address
249 * \param protocolNumber type of payload contained in this packet
250 * \returns true if successful, false otherwise
251 */
252 bool DoSend(Ptr<Packet> packet,
253 std::optional<Address> source,
254 const Address& dest,
255 uint16_t protocolNumber);
256
257 Ptr<Node> m_node; //!< the node
258 std::vector<Ptr<WifiPhy>> m_phys; //!< the phy objects
259 Ptr<WifiMac> m_mac; //!< the MAC
260 std::vector<Ptr<WifiRemoteStationManager>> m_stationManagers; //!< the station managers
261 Ptr<HtConfiguration> m_htConfiguration; //!< the HtConfiguration
262 Ptr<VhtConfiguration> m_vhtConfiguration; //!< the VhtConfiguration
263 Ptr<HeConfiguration> m_heConfiguration; //!< the HeConfiguration
264 Ptr<EhtConfiguration> m_ehtConfiguration; //!< the EhtConfiguration
265 NetDevice::ReceiveCallback m_forwardUp; //!< forward up callback
266 NetDevice::PromiscReceiveCallback m_promiscRx; //!< promiscuous receive callback
267
270
271 WifiStandard m_standard; //!< Wifi standard
272 uint32_t m_ifIndex; //!< IF index
273 bool m_linkUp; //!< link up
274 TracedCallback<> m_linkChanges; //!< link change callback
275 mutable uint16_t m_mtu; //!< MTU
276 bool m_configComplete; //!< configuration complete
277};
278
279} // namespace ns3
280
281#endif /* WIFI_NET_DEVICE_H */
a polymophic address class
Definition: address.h:101
Callback template class.
Definition: callback.h:438
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
Describes an IPv6 address.
Definition: ipv6-address.h:49
an EUI-48 address
Definition: mac48-address.h:46
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
Hold together all Wifi-related objects.
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Receive a packet from the lower layer and pass the packet up the stack.
static TypeId GetTypeId()
Get the type ID.
bool NeedsArp() const override
bool SupportsSendFrom() const override
void SetMac(const Ptr< WifiMac > mac)
Ptr< HtConfiguration > m_htConfiguration
the HtConfiguration
bool IsBroadcast() const override
bool SendFrom(Ptr< Packet > packet, const Address &source, const Address &dest, uint16_t protocolNumber) override
void LinkDown()
Set that the link is down (i.e.
Ptr< EhtConfiguration > m_ehtConfiguration
the EhtConfiguration
virtual const std::vector< Ptr< WifiPhy > > & GetPhys() const
void SetPhys(const std::vector< Ptr< WifiPhy > > &phys)
void SetHeConfiguration(Ptr< HeConfiguration > heConfiguration)
void SetHtConfiguration(Ptr< HtConfiguration > htConfiguration)
Address GetBroadcast() const override
std::vector< Ptr< WifiPhy > > m_phys
the phy objects
bool SetMtu(const uint16_t mtu) override
virtual const std::vector< Ptr< WifiRemoteStationManager > > & GetRemoteStationManagers() const
bool IsBridge() const override
Return true if the net device is acting as a bridge.
Ptr< WifiMac > GetMac() const
uint32_t m_ifIndex
IF index.
Ptr< VhtConfiguration > m_vhtConfiguration
the VhtConfiguration
Ptr< VhtConfiguration > GetVhtConfiguration() const
bool m_configComplete
configuration complete
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
void SetIfIndex(const uint32_t index) override
TracedCallback< Ptr< const Packet >, Mac48Address > m_txLogger
transmit trace callback
NetDevice::ReceiveCallback m_forwardUp
forward up callback
bool Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber) override
Ptr< HeConfiguration > m_heConfiguration
the HeConfiguration
Ptr< EhtConfiguration > GetEhtConfiguration() const
bool IsMulticast() const override
void DoDispose() override
Destructor implementation.
uint8_t GetNRemoteStationManagers() const
void SetVhtConfiguration(Ptr< VhtConfiguration > vhtConfiguration)
void DoInitialize() override
Initialize() implementation.
NetDevice::PromiscReceiveCallback m_promiscRx
promiscuous receive callback
WifiNetDevice & operator=(const WifiNetDevice &)=delete
TracedCallback m_linkChanges
link change callback
Ptr< HtConfiguration > GetHtConfiguration() const
void SetRemoteStationManager(const Ptr< WifiRemoteStationManager > manager)
Ptr< Channel > GetChannel() const override
WifiStandard GetStandard() const
Get the Wifi standard.
void SetNode(const Ptr< Node > node) override
void SetRemoteStationManagers(const std::vector< Ptr< WifiRemoteStationManager > > &managers)
bool IsPointToPoint() const override
Return true if the net device is on a point-to-point link.
void SetReceiveCallback(NetDevice::ReceiveCallback cb) override
uint8_t GetNPhys() const
bool IsLinkUp() const override
std::vector< Ptr< WifiRemoteStationManager > > m_stationManagers
the station managers
Ptr< HeConfiguration > GetHeConfiguration() const
void SetAddress(Address address) override
Set the address of this interface.
Ptr< WifiRemoteStationManager > GetRemoteStationManager() const
void SetStandard(WifiStandard standard)
Set the Wifi standard.
Address GetMulticast(Ipv4Address multicastGroup) const override
Make and return a MAC multicast address using the provided multicast group.
WifiNetDevice(const WifiNetDevice &o)=delete
Ptr< Node > m_node
the node
void SetEhtConfiguration(Ptr< EhtConfiguration > ehtConfiguration)
WifiStandard m_standard
Wifi standard.
Ptr< WifiPhy > GetPhy() const
uint32_t GetIfIndex() const override
void SetPhy(const Ptr< WifiPhy > phy)
Ptr< WifiMac > m_mac
the MAC
void CompleteConfig()
Complete the configuration of this Wi-Fi device by connecting all lower components (e....
TracedCallback< Ptr< const Packet >, Mac48Address > m_rxLogger
receive trace callback
bool DoSend(Ptr< Packet > packet, std::optional< Address > source, const Address &dest, uint16_t protocolNumber)
Send a packet.
Address GetAddress() const override
void AddLinkChangeCallback(Callback< void > callback) override
uint16_t GetMtu() const override
void LinkUp()
Set that the link is up.
Ptr< Node > GetNode() const override
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint16_t MAX_MSDU_SIZE
This value conforms to the 802.11 specification.