25 #include "ns3/boolean.h"
26 #include "ns3/channel-access-manager.h"
27 #include "ns3/double.h"
29 #include "ns3/mac-tx-middle.h"
30 #include "ns3/pointer.h"
31 #include "ns3/qos-txop.h"
32 #include "ns3/random-variable-stream.h"
33 #include "ns3/simulator.h"
34 #include "ns3/socket.h"
35 #include "ns3/trace-source-accessor.h"
36 #include "ns3/wifi-mac-queue-scheduler.h"
37 #include "ns3/wifi-mac-queue.h"
38 #include "ns3/wifi-net-device.h"
39 #include "ns3/wifi-utils.h"
40 #include "ns3/yans-wifi-phy.h"
53 TypeId(
"ns3::MeshWifiInterfaceMac")
57 .AddAttribute(
"BeaconInterval",
63 .AddAttribute(
"RandomStart",
64 "Window when beacon generating starts (uniform random) in seconds",
68 .AddAttribute(
"BeaconGeneration",
69 "Enable/Disable Beaconing.",
168 int64_t currentStream = stream;
172 currentStream += (*i)->AssignStreams(currentStream);
174 return (currentStream - stream);
245 bool drop = !((*i)->UpdateOutcomingFrame(packet, hdr, from, to));
258 for (
const auto& mode :
GetWifiPhy()->GetModeList())
327 for (
const auto& mode :
GetWifiPhy()->GetModeList())
434 (*i)->UpdateBeacon(beacon);
472 uint64_t rate = mode.GetDataRate(
GetWifiPhy()->GetChannelWidth(), gi, 1);
473 if (rates.IsSupportedRate(rate))
476 if (rates.IsBasicRate(rate))
492 bool drop = !((*i)->Receive(packet, *hdr));
574 << recvBytes <<
"\"/>" << std::endl;
590 os <<
"</Interface>" << std::endl;
614 m_txop = CreateObject<Txop>();
void NotifyNavResetNow(Time duration)
void Add(Ptr< Txop > txop)
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 IsRunning() 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
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Send frame.
MeshWifiInterfaceMac()
C-tor.
Time m_beaconInterval
Beaconing interval.
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 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.
WifiStandard m_standard
Current standard: needed to configure metric.
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.
void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from) override
Mac48Address GetMeshPointAddress() const
Get the mesh point address.
void Report(std::ostream &os) const
Report statistics.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Time GetBeaconInterval() const
Get beacon interval.
bool m_beaconEnable
Beaconing interval.
void SetLinkMetricCallback(Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac >> cb)
Set the link metric callback.
void Receive(Ptr< const WifiMpdu > mpdu, uint8_t linkId) override
Frame receive handler.
void SetLinkUpCallback(Callback< void > linkUp) 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 ConfigureStandard(WifiStandard standard) override
Finish configuration based on the WifiStandard being provided.
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.
virtual void SetParent(Ptr< MeshWifiInterfaceMac > parent)=0
Each plugin must be installed on an interface to work.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
bool ReplacePacketTag(Tag &tag)
Replace the value of a packet tag.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
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.
uint8_t GetPriority() const
Get the tag's priority.
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.
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.
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.
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
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
virtual void ConfigureStandard(WifiStandard standard)
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.)
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.
represent a single transmission mode
uint64_t GetDataRate(uint16_t channelWidth, uint16_t guardInterval, uint8_t nss) const
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
WifiPhyBand GetPhyBand() const
Get the configured Wi-Fi band.
uint8_t GetChannelNumber() const
Return current channel number.
std::tuple< uint8_t, uint16_t, WifiPhyBand, uint8_t > ChannelTuple
Tuple identifying an operating channel.
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 ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Maps TID (Traffic ID) to Access classes.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
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)
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr< WifiNetDevice > device)
Convert the guard interval to nanoseconds based on the WifiMode.
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