22 #include "ns3/mesh-wifi-interface-mac.h"
23 #include "ns3/mesh-wifi-beacon.h"
25 #include "ns3/boolean.h"
26 #include "ns3/wifi-phy.h"
27 #include "ns3/dcf-manager.h"
28 #include "ns3/mac-rx-middle.h"
29 #include "ns3/mac-low.h"
30 #include "ns3/dca-txop.h"
31 #include "ns3/random-variable-stream.h"
32 #include "ns3/simulator.h"
33 #include "ns3/yans-wifi-phy.h"
34 #include "ns3/pointer.h"
35 #include "ns3/double.h"
36 #include "ns3/trace-source-accessor.h"
37 #include "ns3/qos-tag.h"
43 NS_OBJECT_ENSURE_REGISTERED (MeshWifiInterfaceMac);
50 .AddConstructor<MeshWifiInterfaceMac> ()
51 .AddAttribute (
"BeaconInterval",
59 .AddAttribute (
"RandomStart",
60 "Window when beacon generating starts (uniform random) in seconds",
66 .AddAttribute (
"BeaconGeneration",
67 "Enable/Disable Beaconing.",
105 MeshWifiInterfaceMac::SupportsSendFrom ()
const
152 int64_t currentStream = stream;
156 currentStream += (*i)->AssignStreams (currentStream);
158 return (currentStream - stream);
228 hdr.SetQosAckPolicy (WifiMacHeader::NORMAL_ACK);
230 hdr.SetQosNoAmsdu ();
231 hdr.SetQosTxopLimit (0);
235 for (PluginList::const_iterator i =
m_plugins.end () - 1; i !=
m_plugins.begin () - 1; i--)
237 bool drop = !((*i)->UpdateOutcomingFrame (packet, hdr, from, to));
246 if (m_stationManager->IsBrandNew (hdr.GetAddr1 ()))
250 for (uint32_t i = 0; i < m_phy->
GetNModes (); i++)
252 m_stationManager->AddSupportedMode (hdr.GetAddr1 (), m_phy->
GetMode (i));
254 m_stationManager->RecordDisassociated (hdr.GetAddr1 ());
262 hdr.SetType (WIFI_MAC_QOSDATA);
263 hdr.SetQosTid (tag.GetTid ());
269 m_stats.sentFrames++;
270 m_stats.sentBytes += packet->
GetSize ();
272 m_edca[ac]->Queue (packet, hdr);
279 for (PluginList::const_iterator i =
m_plugins.end () - 1; i !=
m_plugins.begin () - 1; i--)
287 m_stats.sentFrames++;
288 m_stats.sentBytes += packet->
GetSize ();
316 for (uint32_t i = 0; i < m_phy->
GetNModes (); i++)
322 for (uint32_t j = 0; j < m_stationManager->GetNBasicModes (); j++)
324 WifiMode mode = m_stationManager->GetBasicMode (j);
332 for (uint32_t i = 0; i < m_stationManager->GetNBasicModes (); i++)
334 WifiMode mode = m_stationManager->GetBasicMode (i);
410 (*i)->UpdateBeacon (beacon);
412 m_dca->Queue (beacon.CreatePacket (), beacon.CreateHeader (
GetAddress (), GetMeshPointAddress ()));
424 if (hdr->IsBeacon ())
426 m_stats.recvBeacons++;
435 if (beacon_hdr.GetSsid ().IsEqual (
GetSsid ()))
439 for (uint32_t i = 0; i < m_phy->
GetNModes (); i++)
444 m_stationManager->AddSupportedMode (hdr->GetAddr2 (), mode);
447 m_stationManager->AddBasicMode (mode);
455 m_stats.recvBytes += packet->
GetSize ();
456 m_stats.recvFrames++;
461 bool drop = !((*i)->Receive (packet, *hdr));
468 if (hdr->IsQosData ())
475 ForwardUp (packet, hdr->GetAddr4 (), hdr->GetAddr3 ());
483 MeshWifiInterfaceMac::GetLinkMetric (
Mac48Address peerAddress)
486 if (!m_linkMetricCallback.IsNull ())
488 metric = m_linkMetricCallback (peerAddress,
this);
493 MeshWifiInterfaceMac::SetLinkMetricCallback (Callback<uint32_t, Mac48Address, Ptr<MeshWifiInterfaceMac> > cb)
495 m_linkMetricCallback = cb;
498 MeshWifiInterfaceMac::SetMeshPointAddress (Mac48Address a)
503 MeshWifiInterfaceMac::GetMeshPointAddress ()
const
508 MeshWifiInterfaceMac::Statistics::Statistics () :
509 recvBeacons (0), sentFrames (0), sentBytes (0), recvFrames (0), recvBytes (0)
513 MeshWifiInterfaceMac::Statistics::Print (std::ostream & os)
const
517 "rxBeacons=\"" << recvBeacons <<
"\" "
518 "txFrames=\"" << sentFrames <<
"\" "
519 "txBytes=\"" << sentBytes <<
"\" "
520 "rxFrames=\"" << recvFrames <<
"\" "
521 "rxBytes=\"" << recvBytes <<
"\"/>" << std::endl;
529 "Address = \"" <<
GetAddress () <<
"\">" << std::endl;
531 os <<
"</Interface>" << std::endl;
534 MeshWifiInterfaceMac::ResetStats ()
536 m_stats = Statistics ();
553 MeshWifiInterfaceMac::GetPhyStandard ()
const
MeshWifiInterfaceMac()
C-tor.
#define NS_LOG_FUNCTION(parameters)
void SetStream(int64_t stream)
Specifies the stream number for this RNG stream.
Time GetBeaconInterval() const
Ptr< UniformRandomVariable > m_coefficient
Add randomness to beacon generation.
bool m_beaconEnable
whether beaconing is enabled
virtual ~MeshWifiInterfaceMac()
D-tor.
virtual uint32_t GetNModes(void) const =0
SupportedRates GetSupportedRates() const
void AddPacketTag(const Tag &tag) const
bool CheckSupportedRates(SupportedRates rates) const
virtual void DoDispose()
Real d-tor.
#define NS_ASSERT(condition)
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSize(void) const
uint16_t GetChannelNumber() const
Return current channel number, see SetChannelNumber()
static void Cancel(const EventId &id)
void SetChannelNumber(uint16_t id)
Set channel number.
bool IsRunning(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
void SwitchFrequencyChannel(uint16_t new_id)
Switch channel.
void SendBeacon()
Send beacon.
virtual Ssid GetSsid(void) const
The Supported Rates Information ElementThis class knows how to serialise and deserialise the Supporte...
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
WifiPhyStandard m_standard
Current PHY standard: needed to configure metric.
virtual void Enqueue(Ptr< const Packet > packet, Mac48Address to, Mac48Address from)
Time GetTbtt() const
Next beacon frame time.
#define NS_FATAL_ERROR(msg)
fatal error handling
void SendManagementFrame(Ptr< Packet > frame, const WifiMacHeader &hdr)
To be used by plugins sending management frames.
void NotifyNavResetNow(Time duration)
void ScheduleNextBeacon()
Schedule next beacon.
virtual void DoInitialize()
double GetSeconds(void) const
base class for all MAC-level wifi objects.This class encapsulates all the low-level MAC functionality...
void SetTypeOfStation(TypeOfStation type)
int64_t GetMicroSeconds(void) const
hold objects of type ns3::Time
AcIndex QosUtilsMapTidToAc(uint8_t tid)
static Mac48Address GetBroadcast(void)
uint16_t GetFrequencyChannel() const
Current channel Id.
virtual void FinishConfigureStandard(enum WifiPhyStandard standard)
bool GetBeaconGeneration() const
Get current beaconing status.
PluginList m_plugins
List of all installed plugins.
Ptr< Packet > Copy(void) const
uint32_t PeekHeader(Header &header) const
Mac48Address m_mpAddress
Mesh point address.
virtual void SetLinkUpCallback(Callback< void > linkUp)
802.11 PHY layer modelThis PHY implements a model of 802.11a. The model implemented here is based on ...
Time m_beaconInterval
Beaconing interval.
virtual WifiMode GetMode(uint32_t mode) const =0
void Receive(Ptr< Packet > packet, WifiMacHeader const *hdr)
Frame receive handler.
Time m_randomStart
Maximum delay before first beacon.
Beacon is beacon header + list of arbitrary information elements.
static TypeId GetTypeId()
Never forget to support typeid.
virtual void SetLinkUpCallback(Callback< void > linkUp)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
void ForwardDown(Ptr< const Packet > packet, Mac48Address from, Mac48Address to)
Send frame. Frame is supposed to be tagged by routing information. TODO: clarify this point...
void SetRandomStartDelay(Time interval)
Set maximum initial random delay before first beacon.
void InstallPlugin(Ptr< MeshWifiInterfaceMacPlugin > plugin)
Install plugin. TODO return unique ID to allow unregister plugins.
bool RemovePacketTag(Tag &tag)
#define NS_LOG_DEBUG(msg)
virtual Mac48Address GetAddress(void) const
void Report(std::ostream &) const
Statistics:
void SetBeaconGeneration(bool enable)
Enable/disable beacons.
EventId m_beaconSendEvent
"Timer" for the next beacon
void SetBeaconInterval(Time interval)
Set interval between two successive beacons.
Time m_tbtt
Time for the next frame.
void ShiftTbtt(Time shift)
Shift TBTT.
Hold an floating point type.
void SetAttribute(std::string name, const AttributeValue &value)
Ptr< T > GetObject(void) const
a unique identifier for an interface.
uint64_t GetDataRate(void) const
TypeId SetParent(TypeId tid)
int64_t AssignStreams(int64_t stream)
virtual void SetParent(Ptr< MeshWifiInterfaceMac > parent)=0
Each plugin must be installed on interface to work.
virtual void FinishConfigureStandard(enum WifiPhyStandard standard)