14#include "ns3/boolean.h"
15#include "ns3/channel-access-manager.h"
16#include "ns3/double.h"
18#include "ns3/mac-tx-middle.h"
19#include "ns3/pointer.h"
20#include "ns3/qos-txop.h"
21#include "ns3/random-variable-stream.h"
22#include "ns3/simulator.h"
23#include "ns3/socket.h"
24#include "ns3/string.h"
25#include "ns3/trace-source-accessor.h"
26#include "ns3/wifi-mac-queue-scheduler.h"
27#include "ns3/wifi-mac-queue.h"
28#include "ns3/wifi-net-device.h"
29#include "ns3/wifi-utils.h"
30#include "ns3/yans-wifi-phy.h"
43 TypeId(
"ns3::MeshWifiInterfaceMac")
47 .AddAttribute(
"BeaconInterval",
53 .AddAttribute(
"RandomStart",
54 "Window when beacon generating starts (uniform random) in seconds",
58 .AddAttribute(
"BeaconGeneration",
59 "Enable/Disable Beaconing.",
147 currentStream += (*i)->AssignStreams(currentStream);
149 return (currentStream - stream);
160 plugin->SetParent(
this);
205 auto& hdr = mpdu->GetHeader();
206 auto packet = mpdu->GetPacket()->Copy();
218 bool drop = !((*i)->UpdateOutcomingFrame(packet, hdr, from, to));
240 auto tid = hdr.GetQosTid();
395 (*i)->UpdateBeacon(beacon);
418 packet->PeekHeader(beacon_hdr);
434 const auto rate = mode.GetDataRate(
GetWifiPhy()->GetChannelWidth(), gi, 1);
435 if (rates.IsSupportedRate(rate))
438 if (rates.IsBasicRate(rate))
454 bool drop = !((*i)->Receive(packet, *hdr));
465 packet->ReplacePacketTag(priorityTag);
536 << recvBytes <<
"\"/>" << std::endl;
552 os <<
"</Interface>" << std::endl;
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsPending() const
This method is syntactic sugar for !IsExpired().
The Extended Supported Rates Information Element.
static Mac48Address GetBroadcast()
Beacon is beacon header + list of arbitrary information elements.
WifiMacHeader CreateHeader(Mac48Address address, Mac48Address mpAddress)
Create Wifi header for beacon frame.
Ptr< Packet > CreatePacket()
Create frame = { beacon header + all information elements sorted by ElementId () }...
Basic MAC of mesh point Wi-Fi interface.
bool SupportsSendFrom() const override
MeshWifiInterfaceMac()
C-tor.
Time m_beaconInterval
Beaconing interval.
void SetLinkMetricCallback(Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > cb)
Set the link metric callback.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Mac48Address m_mpAddress
Mesh point address.
void SetBeaconInterval(Time interval)
Set interval between two successive beacons.
void SwitchFrequencyChannel(uint16_t new_id)
Switch frequency channel.
void ShiftTbtt(Time shift)
Shift TBTT.
Statistics m_stats
statistics
Time GetTbtt() const
Next beacon frame time.
void SetRandomStartDelay(Time interval)
Set maximum initial random delay before first beacon.
bool CanForwardPacketsTo(Mac48Address to) const override
Return true if packets can be forwarded to the given destination, false otherwise.
void ResetStats()
Reset statistics function.
void DoCompleteConfig() override
Allow subclasses to complete the configuration of the MAC layer components.
void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax) override
~MeshWifiInterfaceMac() override
D-tor.
void SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > m_linkMetricCallback
linkMetricCallback
EventId m_beaconSendEvent
"Timer" for the next beacon
void InstallPlugin(Ptr< MeshWifiInterfaceMacPlugin > plugin)
Install plugin.
void ScheduleNextBeacon()
Schedule next beacon.
uint32_t GetLinkMetric(Mac48Address peerAddress)
Get the link metric.
uint16_t GetFrequencyChannel() const
Current channel Id.
void SetBeaconGeneration(bool enable)
Enable/disable beacons.
void DoInitialize() override
Initialize() implementation.
bool GetBeaconGeneration() const
Get current beaconing status.
AllSupportedRates GetSupportedRates() const
Get supported rates.
void SetMeshPointAddress(Mac48Address addr)
Set the mesh point address.
Mac48Address GetMeshPointAddress() const
Get the mesh point address.
void Report(std::ostream &os) const
Report statistics.
Time GetBeaconInterval() const
Get beacon interval.
void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId) override
Frame receive handler.
void SetLinkUpCallback(Callback< void > linkUp) override
void Enqueue(Ptr< WifiMpdu > mpdu, Mac48Address to, Mac48Address from) override
Time m_randomStart
Maximum delay before first beacon.
static TypeId GetTypeId()
Get the type ID.
PluginList m_plugins
List of all installed plugins.
void SendBeacon()
Send beacon.
bool CheckSupportedRates(AllSupportedRates rates) const
Check supported rates.
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
Time m_tbtt
Time for the next frame.
void DoDispose() override
Real d-tor.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
static Time Now()
Return the current simulation virtual time.
indicates whether the socket has a priority set.
void SetPriority(uint8_t priority)
Set the tag's priority.
The IEEE 802.11 SSID Information Element.
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
Hold variables of type string.
The Supported Rates Information Element.
Simulation virtual time values and global simulation resolution.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
virtual void SetWifiMac(const Ptr< WifiMac > mac)
Set the wifi MAC this Txop is associated to.
virtual void Queue(Ptr< WifiMpdu > mpdu)
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
base class for all MAC-level wifi objects.
bool GetQosSupported() const
Return whether the device supports QoS.
Ptr< Txop > m_txop
TXOP used for transmission of frames to non-QoS peers.
Ptr< WifiMacQueueScheduler > m_scheduler
wifi MAC queue scheduler
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Ptr< WifiPhy > GetWifiPhy(uint8_t linkId=SINGLE_LINK_OP_ID) const
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< WifiNetDevice > GetDevice() const
Return the device this PHY is associated with.
virtual void SetLinkUpCallback(Callback< void > linkUp)
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(uint8_t linkId=0) const
void ForwardUp(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Forward the packet up to the device.
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
Mac48Address GetAddress() const
LinkEntity & GetLink(uint8_t linkId) const
Get a reference to the link associated with the given ID.
Ptr< QosTxop > GetQosTxop(AcIndex ac) const
Accessor for a specified EDCA object.
void DoDispose() override
Destructor implementation.
std::tuple< uint8_t, MHz_u, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying a segment of an operating channel.
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
uint8_t GetChannelNumber() const
Return current channel number.
void SetOperatingChannel(const WifiPhyOperatingChannel &channel)
If the standard for this object has not been set yet, store the channel settings corresponding to the...
std::list< WifiMode > GetModeList() const
The WifiPhy::GetModeList() method is used (e.g., by a WifiRemoteStationManager) to determine the set ...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#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_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Time GetGuardIntervalForMode(WifiMode mode, const Ptr< WifiNetDevice > device)
Get the guard interval for a given WifiMode.
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< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Struct containing all supported rates.
void SetBasicRate(uint64_t bs)
Set the given rate to basic rates.
void AddSupportedRate(uint64_t bs)
Add the given rate to the supported rates.
bool IsSupportedRate(uint64_t bs) const
Check if the given rate is supported.
uint32_t sentFrames
sent frames
uint32_t recvBytes
receive bytes
uint32_t sentBytes
sent bytes
uint32_t recvFrames
receive frames
void Print(std::ostream &os) const
Print statistics.
uint16_t recvBeacons
receive beacons
Ptr< ChannelAccessManager > channelAccessManager
channel access manager object