22 #include "ns3/pointer.h"
29 #undef NS_LOG_APPEND_CONTEXT
30 #define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; }
43 .SetGroupName (
"Wifi")
45 .AddAttribute (
"MinCw",
"The minimum value of the contention window.",
49 MakeUintegerChecker<uint32_t> ())
50 .AddAttribute (
"MaxCw",
"The maximum value of the contention window.",
54 MakeUintegerChecker<uint32_t> ())
55 .AddAttribute (
"Aifsn",
"The AIFSN: the default value conforms to simple DCA.",
59 MakeUintegerChecker<uint32_t> ())
60 .AddAttribute (
"TxopLimit",
"The TXOP limit: the default value conforms to simple DCA.",
65 .AddAttribute (
"Queue",
"The WifiMacQueue object",
68 MakePointerChecker<WifiMacQueue> ())
78 m_dcf = CreateObject<DcfState> (
this);
79 m_queue = CreateObject<WifiMacQueue> ();
80 m_rng = CreateObject<UniformRandomVariable> ();
223 m_queue->Enqueue (Create<WifiMacQueueItem> (packet, hdr));
587 NS_LOG_DEBUG (
"a transmission that did not require an ACK just finished");
603 NS_LOG_WARN (
"StartNext should not be called for non QoS!");
609 NS_LOG_WARN (
"GotBlockAck should not be called for non QoS!");
615 NS_LOG_WARN (
"MissedBlockAck should not be called for non QoS!");
virtual uint32_t GetFragmentSize(void) const
Calculate the size of the current fragment.
MacLowTransmissionParameters m_currentParams
current transmission parameters
virtual void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
bool NeedRtsRetransmission(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Check if RTS should be re-transmitted if CTS was missed.
Simulation virtual time values and global simulation resolution.
Ptr< DcfState > m_dcf
the DCF state
void SetTxDroppedCallback(TxDropped callback)
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
uint8_t m_fragmentNumber
the fragment number
void SetTxFailedCallback(TxFailed callback)
bool NeedDataRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
uint32_t GetCwMin(void) const
Return the minimum contention window size.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, Ptr< DcaTxop > dca)
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
virtual uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
Ptr< MacLow > m_low
the MacLow
bool IsNull(void) const
Check for null implementation.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
virtual void StartNextFragment(void)
Start transmission for the next fragment.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
TxOk m_txOkCallback
the transmit OK callback
bool NeedDataRetransmission(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Check if DATA should be re-transmitted if ACK was missed.
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
void SetAifsn(uint32_t aifsn)
void UpdateFragmentationThreshold(void)
Typically called to update the fragmentation threshold at the start of a new transmission.
void SetManager(const Ptr< DcfManager > manager)
Set DcfManager this DcaTxop is associated to.
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void PrepareForQueue(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Time GetTxopLimit(void) const
Return the TXOP limit.
static TypeId GetTypeId(void)
Get the type ID.
void SetTxOkCallback(TxOk callback)
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
virtual Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
virtual void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Time GetTxopLimit(void) const
Return the TXOP limit.
TxDropped m_txDroppedCallback
the packet dropped callback
virtual bool IsEdca()
Check for EDCA.
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution.
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportDataFailed if NeedDataRetransmission returns false...
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void Cancel(void)
Cancel the transmission.
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
AttributeValue implementation for Time.
virtual bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Hold an unsigned integer type.
virtual void DoInitialize(void)
Initialize() implementation.
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
virtual void MissedCts(void)
Event handler when a CTS timeout has occurred.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
bool IsAccessRequested(void) const
virtual void GotAck(void)
Event handler when an ACK is received.
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
Ptr< WifiRemoteStationManager > m_stationManager
the wifi remote station manager
uint32_t GetCwMax(void) const
Return the maximum contention window size.
void SetCwMin(uint32_t minCw)
Set the minimum contention window size.
void SetAifsn(uint32_t aifsn)
Set the number of slots that make up an AIFS.
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
void StartBackoffNow(uint32_t nSlots)
Ptr< UniformRandomVariable > m_rng
the random stream
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
WifiMacHeader m_currentHdr
the current header
void EnableAck(void)
Wait ACKTimeout for an ACK.
void Add(Ptr< DcfState > dcf)
uint32_t GetFragmentSize(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
Ptr< WifiMacQueue > GetQueue() const
Return the packet queue associated with this DcaTxop.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void DisableRts(void)
Do not send rts and wait for cts before sending data.
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Ptr< const Packet > m_currentPacket
the current packet
Ptr< MacLow > GetLow(void) const
Return the MacLow associated with this DcaTxop.
virtual void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
void SetLow(const Ptr< MacLow > low)
Set MacLow associated with this DcaTxop.
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this DcaTxop is associated to.
void SetCwMax(uint32_t maxCw)
Set the maximum contention window size.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
virtual bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
uint32_t GetCw(void) const
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void TxDroppedPacket(Ptr< const WifiMacQueueItem > item)
Pass the packet included in the wifi MAC queue item to the packet dropped callback.
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
virtual void DoDispose(void)
Destructor implementation.
void RequestAccess(Ptr< DcfState > state)
void EnableNextData(uint32_t size)
virtual void NotifyCollision(void)
Notify the DCF that collision has occurred.
virtual void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
void NextFragment(void)
Continue to the next fragment.
void DisableNextData(void)
Do not attempt to send data burst after current transmission.
virtual bool HasTxop(void) const
Check if the station has TXOP granted for the next MPDU.
bool NeedRtsRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
virtual void RestartAccessIfNeeded(void)
Restart access request if needed.
A base class which provides memory management and object aggregation.
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
virtual void MissedAck(void)
Event handler when an ACK is missed.
handle packet fragmentation and retransmissions.
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
void DisableAck(void)
Do not wait for Ack after data transmission.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint32_t GetMinCw(void) const
Return the minimum contention window size.
a unique identifier for an interface.
void ReportFinalRtsFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportRtsFailed if NeedRtsRetransmission returns false.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
virtual void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
virtual void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this DcaTxop is associated to.
virtual void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
virtual uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
TxFailed m_txFailedCallback
the transmit failed callback
Ptr< DcfManager > m_manager
the DCF manager