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