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