22 #include "ns3/mesh-wifi-interface-mac.h"
23 #include "ns3/mesh-wifi-beacon.h"
25 #include "ns3/boolean.h"
26 #include "ns3/random-variable-stream.h"
27 #include "ns3/simulator.h"
28 #include "ns3/yans-wifi-phy.h"
29 #include "ns3/wifi-utils.h"
30 #include "ns3/pointer.h"
31 #include "ns3/double.h"
32 #include "ns3/trace-source-accessor.h"
33 #include "ns3/socket.h"
34 #include "ns3/wifi-net-device.h"
35 #include "ns3/channel-access-manager.h"
36 #include "ns3/mac-tx-middle.h"
37 #include "ns3/qos-txop.h"
50 .SetGroupName (
"Mesh")
52 .AddAttribute (
"BeaconInterval",
60 .AddAttribute (
"RandomStart",
61 "Window when beacon generating starts (uniform random) in seconds",
67 .AddAttribute (
"BeaconGeneration",
68 "Enable/Disable Beaconing.",
159 int64_t currentStream = stream;
163 currentStream += (*i)->AssignStreams (currentStream);
165 return (currentStream - stream);
231 for (PluginList::const_iterator i =
m_plugins.end () - 1; i !=
m_plugins.begin () - 1; i--)
233 bool drop = !((*i)->UpdateOutcomingFrame (packet, hdr, from, to));
246 for (
const auto & mode :
GetWifiPhy ()->GetModeList ())
276 for (PluginList::const_iterator i =
m_plugins.end () - 1; i !=
m_plugins.begin () - 1; i--)
313 for (
const auto & mode :
GetWifiPhy ()->GetModeList ())
409 (*i)->UpdateBeacon (beacon);
440 for (
const auto & mode :
GetWifiPhy ()->GetModeList ())
443 uint64_t rate = mode.GetDataRate (
GetWifiPhy ()->GetChannelWidth (), gi, 1);
463 bool drop = !((*i)->Receive (packet, *hdr));
525 "rxBeacons=\"" << recvBeacons <<
"\" "
526 "txFrames=\"" << sentFrames <<
"\" "
527 "txBytes=\"" << sentBytes <<
"\" "
528 "rxFrames=\"" << recvFrames <<
"\" "
529 "rxBytes=\"" << recvBytes <<
"\"/>" << std::endl;
537 "Address = \"" <<
GetAddress () <<
"\">" << std::endl;
539 os <<
"</Interface>" << std::endl;
562 m_txop = CreateObject<Txop> ();
AttributeValue implementation for Boolean.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
static Mac48Address GetBroadcast(void)
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.
void ForwardDown(Ptr< Packet > packet, Mac48Address from, Mac48Address to)
Send frame.
MeshWifiInterfaceMac()
C-tor.
bool CheckSupportedRates(SupportedRates rates) const
Check supported rates.
Time m_beaconInterval
Beaconing interval.
void SetLinkMetricCallback(Callback< uint32_t, Mac48Address, Ptr< MeshWifiInterfaceMac > > cb)
Set the link metric callback.
Mac48Address m_mpAddress
Mesh point address.
void SetBeaconInterval(Time interval)
Set interval between two successive beacons.
virtual void SetLinkUpCallback(Callback< void > linkUp)
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.
void ResetStats()
Reset statistics function.
void Receive(Ptr< WifiMacQueueItem > mpdu)
Frame receive handler.
void SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
virtual void ConfigureContentionWindow(uint32_t cwMin, uint32_t cwMax)
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.
virtual ~MeshWifiInterfaceMac()
D-tor.
virtual bool CanForwardPacketsTo(Mac48Address to) const
Return true if packets can be forwarded to the given destination, false otherwise.
uint32_t GetLinkMetric(Mac48Address peerAddress)
Get the link metric.
uint16_t GetFrequencyChannel() const
Current channel Id.
void SetBeaconGeneration(bool enable)
Enable/disable beacons.
bool GetBeaconGeneration() const
Get current beaconing status.
virtual void ConfigureStandard(enum WifiStandard standard)
Finish configuration based on the WifiStandard being provided.
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.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
virtual bool SupportsSendFrom() const
Time GetBeaconInterval() const
bool m_beaconEnable
Beaconing interval.
Time m_randomStart
Maximum delay before first beacon.
static TypeId GetTypeId()
Get the type ID.
virtual void Enqueue(Ptr< Packet > packet, Mac48Address to, Mac48Address from)
PluginList m_plugins
List of all installed plugins.
virtual void DoDispose()
Real d-tor.
void SendBeacon()
Send beacon.
SupportedRates GetSupportedRates() const
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
Time m_tbtt
Time for the next frame.
virtual void DoInitialize()
Initialize() implementation.
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 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.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
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 EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now(void)
Return the current simulation virtual time.
indicates whether the socket has a priority set.
uint8_t GetPriority(void) const
Get the tag's priority.
void SetPriority(uint8_t priority)
Set the tag's priority.
bool IsEqual(const Ssid &o) const
Check if the two SSIDs are equal.
The Supported Rates Information Element.
void SetBasicRate(uint64_t bs)
Set the given rate to basic rates.
bool IsBasicRate(uint64_t bs) const
Check if the given rate is a basic rate.
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.
Simulation virtual time values and global simulation resolution.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
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.
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
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.
virtual void ConfigureStandard(WifiStandard standard)
Mac48Address GetAddress(void) const
void SetTypeOfStation(TypeOfStation type)
This method is invoked by a subclass to specify what type of station it is implementing.
Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager(void) const
Ptr< ChannelAccessManager > m_channelAccessManager
channel access manager
Ptr< MacTxMiddle > m_txMiddle
TX middle (aggregation etc.)
Ptr< WifiPhy > GetWifiPhy(void) const
virtual void SetLinkUpCallback(Callback< void > linkUp)
Ptr< WifiNetDevice > GetDevice(void) const
Return the device this PHY is associated with.
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)
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
uint8_t GetChannelNumber(void) const
Return current channel number.
WifiPhyBand GetPhyBand(void) const
Get the configured Wi-Fi band.
void SetOperatingChannel(const ChannelTuple &channelTuple)
If the standard for this object has not been set yet, store the given channel settings.
std::tuple< uint8_t, uint16_t, int, uint8_t > ChannelTuple
Tuple identifying an operating channel.
void AddBasicMode(WifiMode mode)
Invoked in a STA upon association to store the set of rates which belong to the BSSBasicRateSet of th...
uint8_t GetNBasicModes(void) const
Return the number of basic modes we support.
void AddSupportedMode(Mac48Address address, WifiMode mode)
Invoked in a STA or AP to store the set of modes supported by a destination which is also supported l...
WifiMode GetBasicMode(uint8_t i) const
Return a basic mode from the set of basic modes.
void RecordDisassociated(Mac48Address address)
Records that the STA was disassociated.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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 > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, const Ptr< WifiNetDevice > device)
Convert the guard interval to nanoseconds based on the WifiMode.
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