15#include "ns3/channel.h"
16#include "ns3/eht-configuration.h"
17#include "ns3/he-configuration.h"
18#include "ns3/ht-configuration.h"
19#include "ns3/llc-snap-header.h"
22#include "ns3/object-vector.h"
23#include "ns3/pointer.h"
24#include "ns3/uinteger.h"
25#include "ns3/vht-configuration.h"
38 TypeId(
"ns3::WifiNetDevice")
40 .AddConstructor<WifiNetDevice>()
43 "The MAC-level Maximum Transmission Unit",
47 .AddAttribute(
"Channel",
48 "The channel attached to this device",
53 "class WifiNetDevice; use the Channel "
54 "attribute of WifiPhy")
56 "The PHY layer attached to this device.",
64 "The PHY layers attached to this device (11be multi-link devices only).",
69 "The MAC layer attached to this device.",
74 "RemoteStationManager",
75 "The station manager attached to this device.",
81 .AddAttribute(
"RemoteStationManagers",
82 "The remote station managers attached to this device (11be multi-link "
88 .AddAttribute(
"HtConfiguration",
89 "The HtConfiguration object.",
93 .AddAttribute(
"VhtConfiguration",
94 "The VhtConfiguration object.",
98 .AddAttribute(
"HeConfiguration",
99 "The HeConfiguration object.",
103 .AddAttribute(
"EhtConfiguration",
104 "The EhtConfiguration object.",
113 m_configComplete(false)
146 stationManager->Dispose();
147 stationManager =
nullptr;
179 for (
const auto& phy :
m_phys)
194 stationManager->Initialize();
255 "Multiple PHYs only allowed for 11be multi-link devices");
257 for (std::size_t
id = 0;
id < phys.size(); ++id)
259 m_phys.at(
id)->SetPhyId(
id);
277 "Multiple remote station managers only allowed for 11be multi-link devices");
301const std::vector<Ptr<WifiPhy>>&
326const std::vector<Ptr<WifiRemoteStationManager>>&
353 for (uint8_t i = 1; i <
GetNPhys(); i++)
357 NS_ABORT_MSG(
"Do not call WifiNetDevice::GetChannel() when using multiple channels");
374 std::set<uint8_t> linkIds;
388 if (
m_mac->GetTypeOfStation() ==
STA &&
390 (linkIds = staMac->GetSetupLinkIds()).size() == 1 &&
391 !
m_mac->GetWifiRemoteStationManager(*linkIds.begin())
392 ->GetMldAddress(
m_mac->GetBssid(*linkIds.begin())))
394 return m_mac->GetFrameExchangeManager(*linkIds.begin())->GetAddress();
397 return m_mac->GetAddress();
475 return DoSend(packet, std::nullopt, dest, protocolNumber);
529 m_mac->NotifyRx(packet);
530 copy->RemoveHeader(llc);
535 copy->RemoveHeader(llc);
540 m_mac->NotifyPromiscRx(copy);
563 uint16_t protocolNumber)
566 return DoSend(packet, source, dest, protocolNumber);
571 std::optional<Address> source,
573 uint16_t protocolNumber)
580 *source <<
" is not compatible with a Mac48Address");
583 dest <<
" is not compatible with a Mac48Address");
589 packet->AddHeader(llc);
591 m_mac->NotifyTx(packet);
595 m_mac->Enqueue(packet, realTo, realFrom);
599 m_mac->Enqueue(packet, realTo);
615 return m_mac->SupportsSendFrom();
a polymophic address class
bool IsNull() const
Check for null implementation.
Ipv4 addresses are stored in host order in this class.
Describes an IPv6 address.
static Mac48Address GetMulticast(Ipv4Address address)
static bool IsMatchingType(const Address &address)
static Mac48Address ConvertFrom(const Address &address)
static Mac48Address GetBroadcast()
Network layer to device interface.
PacketType
Packet types are used as they are in Linux.
@ PACKET_HOST
Packet addressed to us.
@ PACKET_OTHERHOST
Packet addressed to someone else.
@ PACKET_BROADCAST
Packet addressed to all.
@ PACKET_MULTICAST
Packet addressed to multicast group.
virtual void DoInitialize()
Initialize() implementation.
void Dispose()
Dispose of this Object.
virtual void DoDispose()
Destructor implementation.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
void ConnectWithoutContext(const CallbackBase &callback)
Append a Callback to the chain (without a context).
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
@ DEPRECATED
Attribute or trace source is deprecated; user is warned.
Hold an unsigned integer type.
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
~WifiNetDevice() override
Ptr< VhtConfiguration > GetVhtConfiguration() const
bool m_configComplete
configuration complete
void SetPromiscReceiveCallback(PromiscReceiveCallback cb) override
void SetIfIndex(const uint32_t index) override
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
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
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.
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....
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
virtual Ptr< Channel > GetChannel() const =0
Return the Channel this WifiPhy is connected to.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeObjectVectorChecker()
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< AttributeChecker > MakePointerChecker()
Create a PointerChecker for a type.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
@ WIFI_STANDARD_UNSPECIFIED
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static constexpr uint8_t SINGLE_LINK_OP_ID
Link ID for single link operations (helps tracking places where correct link ID is to be used to supp...
Ptr< T1 > StaticCast(const Ptr< T2 > &p)
Cast a Ptr.
static const uint16_t MAX_MSDU_SIZE
This value conforms to the 802.11 specification.
static const uint16_t LLC_SNAP_HEADER_LENGTH
The length in octets of the LLC/SNAP header.