20 #include "regular-wifi-mac.h"
23 #include "ns3/boolean.h"
24 #include "ns3/pointer.h"
25 #include "ns3/uinteger.h"
26 #include "ns3/trace-source-accessor.h"
28 #include "mac-rx-middle.h"
29 #include "mac-tx-middle.h"
32 #include "dcf-manager.h"
35 #include "msdu-aggregator.h"
41 NS_OBJECT_ENSURE_REGISTERED (RegularWifiMac);
43 RegularWifiMac::RegularWifiMac ()
46 m_rxMiddle =
new MacRxMiddle ();
49 m_txMiddle =
new MacTxMiddle ();
51 m_low = CreateObject<MacLow> ();
54 m_dcfManager =
new DcfManager ();
55 m_dcfManager->SetupLowListener (m_low);
57 m_dca = CreateObject<DcaTxop> ();
58 m_dca->SetLow (m_low);
59 m_dca->SetManager (m_dcfManager);
63 m_spectrumManager = NULL;
73 RegularWifiMac::~RegularWifiMac ()
85 for (EdcaQueues::iterator i =
m_edca.begin (); i !=
m_edca.end (); ++i)
87 i->second->Initialize ();
108 m_stationManager = NULL;
113 if (m_spectrumManager != NULL)
115 delete m_spectrumManager;
116 m_spectrumManager = NULL;
119 for (EdcaQueues::iterator i =
m_edca.begin (); i !=
m_edca.end (); ++i)
129 m_stationManager = stationManager;
130 m_low->SetWifiRemoteStationManager (stationManager);
132 m_dca->SetWifiRemoteStationManager (stationManager);
134 for (EdcaQueues::iterator i =
m_edca.begin (); i !=
m_edca.end (); ++i)
136 i->second->SetWifiRemoteStationManager (stationManager);
143 return m_stationManager;
156 edca->SetLow (m_low);
157 edca->SetManager (m_dcfManager);
158 edca->SetTxMiddle (m_txMiddle);
159 edca->SetTxOkCallback (
MakeCallback (&RegularWifiMac::TxOk,
this));
160 edca->SetTxFailedCallback (
MakeCallback (&RegularWifiMac::TxFailed,
this));
161 edca->SetAccessCategory (ac);
162 edca->CompleteConfig ();
163 m_edca.insert (std::make_pair (ac, edca));
170 for (EdcaQueues::iterator i =
m_edca.begin (); i !=
m_edca.end (); ++i)
172 i->second->SetTypeOfStation (type);
211 m_dcfManager->SetupPhyListener (phy);
225 m_forwardUp = upCallback;
239 m_linkDown = linkDown;
259 m_dcfManager->
SetSlot (slotTime);
260 m_low->SetSlotTime (slotTime);
266 return m_low->GetSlotTime ();
274 m_low->SetSifs (sifs);
280 return m_low->GetSifs ();
300 m_low->SetPifs (pifs);
306 return m_low->GetPifs ();
313 m_low->SetAckTimeout (ackTimeout);
319 return m_low->GetAckTimeout ();
326 m_low->SetCtsTimeout (ctsTimeout);
332 return m_low->GetCtsTimeout ();
336 RegularWifiMac::SetBasicBlockAckTimeout (
Time blockAckTimeout)
339 m_low->SetBasicBlockAckTimeout (blockAckTimeout);
343 RegularWifiMac::GetBasicBlockAckTimeout (
void)
const
345 return m_low->GetBasicBlockAckTimeout ();
349 RegularWifiMac::SetCompressedBlockAckTimeout (Time blockAckTimeout)
352 m_low->SetCompressedBlockAckTimeout (blockAckTimeout);
356 RegularWifiMac::GetCompressedBlockAckTimeout (
void)
const
358 return m_low->GetCompressedBlockAckTimeout ();
365 m_low->SetAddress (address);
371 return m_low->GetAddress ();
391 m_low->SetBssid (bssid);
397 return m_low->GetBssid ();
403 m_low->SetPromisc ();
415 <<
") does not support Enqueue() with from address");
419 RegularWifiMac::SupportsSendFrom (
void)
const
425 RegularWifiMac::ForwardUp (Ptr<Packet> packet, Mac48Address from, Mac48Address to)
428 m_forwardUp (packet, from, to);
450 if (hdr->IsMgt () && hdr->IsAction ())
459 switch (actionHdr.GetCategory ())
461 case WifiActionHeader::BLOCK_ACK:
463 switch (actionHdr.GetAction ().blockAck)
465 case WifiActionHeader::BLOCK_ACK_ADDBA_REQUEST:
478 case WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE:
490 m_edca[ac]->GotAddBaResponse (&respHdr, from);
495 case WifiActionHeader::BLOCK_ACK_DELBA:
500 if (delBaHdr.IsByOriginator ())
506 m_low->DestroyBlockAckAgreement (from, delBaHdr.GetTid ());
514 m_edca[ac]->GotDelBaFrame (&delBaHdr, from);
521 NS_FATAL_ERROR (
"Unsupported Action field in Block Ack Action frame");
528 NS_FATAL_ERROR (
"Don't know how to handle frame (type=" << hdr->GetType ());
535 m_dca->RestartAccessIfNeeded();
542 MsduAggregator::DeaggregatedMsdus packets =
543 MsduAggregator::Deaggregate (aggregatedPacket);
545 for (MsduAggregator::DeaggregatedMsdusCI i = packets.begin ();
546 i != packets.end (); ++i)
548 ForwardUp ((*i).first, (*i).second.GetSourceAddr (),
549 (*i).second.GetDestinationAddr ());
560 hdr.SetAddr1 (originator);
569 respHdr.SetStatusCode (code);
571 respHdr.SetAmsduSupport (reqHdr->IsAmsduSupported ());
573 if (reqHdr->IsImmediateBlockAck ())
575 respHdr.SetImmediateBlockAck ();
579 respHdr.SetDelayedBlockAck ();
581 respHdr.SetTid (reqHdr->GetTid ());
589 respHdr.SetBufferSize (1023);
590 respHdr.SetTimeout (reqHdr->GetTimeout ());
594 action.blockAck = WifiActionHeader::BLOCK_ACK_ADDBA_RESPONSE;
595 actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action);
603 m_low->CreateBlockAckAgreement (&respHdr, originator,
604 reqHdr->GetStartingSequence ());
613 RegularWifiMac::GetTypeId (
void)
617 .AddAttribute (
"QosSupported",
618 "This Boolean attribute is set to enable 802.11e/WMM-style QoS support at this STA",
622 MakeBooleanChecker ())
623 .AddAttribute (
"DcaTxop",
"The DcaTxop object",
626 MakePointerChecker<DcaTxop> ())
627 .AddAttribute (
"VO_EdcaTxopN",
628 "Queue that manages packets belonging to AC_VO access class",
631 MakePointerChecker<EdcaTxopN> ())
632 .AddAttribute (
"VI_EdcaTxopN",
633 "Queue that manages packets belonging to AC_VI access class",
636 MakePointerChecker<EdcaTxopN> ())
637 .AddAttribute (
"BE_EdcaTxopN",
638 "Queue that manages packets belonging to AC_BE access class",
641 MakePointerChecker<EdcaTxopN> ())
642 .AddAttribute (
"BK_EdcaTxopN",
643 "Queue that manages packets belonging to AC_BK access class",
646 MakePointerChecker<EdcaTxopN> ())
647 .AddAttribute (
"SensingTime",
648 "The sensing time of the node",
650 MakeTimeAccessor(&RegularWifiMac::m_snsInterval),
652 .AddAttribute (
"TransmissionTime",
653 "The transmission time of the node",
655 MakeTimeAccessor(&RegularWifiMac::m_txInterval),
657 .AddAttribute (
"ProbabilityMisDetect",
658 "The probability that a node mis-detects a Primary User",
660 MakeDoubleAccessor(&RegularWifiMac::m_probMisdetect),
661 MakeDoubleChecker<double>())
662 .AddTraceSource (
"TxOkHeader",
663 "The header of successfully transmitted packet",
665 .AddTraceSource (
"TxErrHeader",
666 "The header of unsuccessfully transmitted packet",
702 NS_FATAL_ERROR (
"Unsupported WifiPhyStandard in RegularWifiMac::FinishConfigureStandard ()");
710 for (EdcaQueues::iterator i =
m_edca.begin (); i !=
m_edca.end (); ++i)
715 ConfigureCCHDcf (i->second, cwmin, cwmax, i->first);
719 ConfigureDcf (i->second, cwmin, cwmax, i->first);
728 m_txOkCallback (hdr);
732 RegularWifiMac::TxFailed (
const WifiMacHeader &hdr)
735 m_txErrCallback (hdr);
739 RegularWifiMac::IsTxRadio()
741 return m_low->IsTxRadio();
745 RegularWifiMac::SetTxRadio(
bool isTx)
747 m_low->SetTxRadio(isTx);
751 RegularWifiMac::IsRxRadio()
753 return m_low->IsRxRadio();
757 RegularWifiMac::SetRxRadio(
bool isRx, Ptr<Node> node, Ptr<Repository> repo,
758 Ptr<PUModel> puModel, Ptr<WifiPhy> wifiPhy)
761 if (m_spectrumManager == NULL)
763 m_spectrumManager =
new SpectrumManager(
this, wifiPhy, m_node->
GetId(), m_snsInterval, m_txInterval);
764 m_spectrumManager->
SetPuModel(m_probMisdetect, puModel);
766 m_spectrumManager->
Start();
768 m_low->SetRxRadio(isRx);
void SetQosSupported(bool enable)
uint32_t RemoveHeader(Header &header)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
virtual void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > stationManager)
#define NS_ASSERT(condition)
void SetPuModel(double prob, Ptr< PUModel > p)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual void SetSsid(Ssid ssid)
void SetSlot(Time slotTime)
bool GetQosSupported() const
virtual void DeaggregateAmsduAndForward(Ptr< Packet > aggregatedPacket, const WifiMacHeader *hdr)
virtual void SetLinkDownCallback(Callback< void > linkDown)
virtual Ssid GetSsid(void) const
virtual void Enqueue(Ptr< const Packet > packet, Mac48Address to, Mac48Address from)
virtual void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
#define NS_FATAL_ERROR(msg)
fatal error handling
void Receive(Ptr< Packet > packet, const WifiMacHeader *hdr)
virtual Ptr< WifiRemoteStationManager > GetWifiRemoteStationManager() const
virtual void SetBssid(Mac48Address bssid)
Ptr< EdcaTxopN > GetVOQueue(void) const
Time GetCtsTimeout(void) const
virtual void SetForwardUpCallback(ForwardUpCallback upCallback)
void SetEifsNoDifs(Time eifsNoDifs)
virtual void SetWifiPhy(Ptr< WifiPhy > phy)
void SetTypeOfStation(TypeOfStation type)
hold objects of type ns3::Time
Ptr< EdcaTxopN > GetBEQueue(void) const
Ptr< DcaTxop > GetDcaTxop(void) const
base class for all MAC-level wifi objects.This class encapsulates all the low-level MAC functionality...
Time GetAckTimeout(void) const
AcIndex QosUtilsMapTidToAc(uint8_t tid)
virtual void SetAddress(Mac48Address address)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
virtual void SendAddBaResponse(const MgtAddBaRequestHeader *reqHdr, Mac48Address originator)
Ptr< EdcaTxopN > GetVIQueue(void) const
virtual void SetLinkUpCallback(Callback< void > linkUp)
hold objects of type Ptr<T>
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void SetEifsNoDifs(Time eifsNoDifs)
void SetCtsTimeout(Time ctsTimeout)
virtual Ptr< WifiPhy > GetWifiPhy() const
virtual Mac48Address GetBssid(void) const
void SetSlot(Time slotTime)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Ptr< EdcaTxopN > GetBKQueue(void) const
uint32_t GetId(void) const
void SetRepository(Ptr< Repository > rep)
virtual Mac48Address GetAddress(void) const
Time GetEifsNoDifs() const
virtual void DoInitialize()
Time MilliSeconds(uint64_t ms)
create ns3::Time instances in units of milliseconds.
virtual void SetPromisc(void)
Sets the interface in promiscuous mode.
Hold an floating point type.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void SetAckTimeout(Time ackTimeout)
void AddHeader(const Header &header)
virtual void FinishConfigureStandard(enum WifiPhyStandard standard)
Time GetEifsNoDifs(void) const
void SetupEdcaQueue(enum AcIndex ac)