22 #include "ns3/pointer.h" 23 #include "ns3/simulator.h" 24 #include "ns3/random-variable-stream.h" 32 #undef NS_LOG_APPEND_CONTEXT 33 #define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; } 46 .SetGroupName (
"Wifi")
47 .AddConstructor<
Txop> ()
48 .AddAttribute (
"MinCw",
"The minimum value of the contention window.",
52 MakeUintegerChecker<uint32_t> ())
53 .AddAttribute (
"MaxCw",
"The maximum value of the contention window.",
57 MakeUintegerChecker<uint32_t> ())
58 .AddAttribute (
"Aifsn",
"The AIFSN: the default value conforms to non-QOS.",
62 MakeUintegerChecker<uint8_t> ())
63 .AddAttribute (
"TxopLimit",
"The TXOP limit: the default value conforms to non-QoS.",
68 .AddAttribute (
"Queue",
"The WifiMacQueue object",
71 MakePointerChecker<WifiMacQueue> ())
77 : m_channelAccessManager (0),
81 m_accessRequested (false),
87 m_queue = CreateObject<WifiMacQueue> ();
88 m_rng = CreateObject<UniformRandomVariable> ();
178 bool changed = (
m_cwMin != minCw);
190 bool changed = (
m_cwMax != maxCw);
300 m_queue->Enqueue (Create<WifiMacQueueItem> (packet, hdr));
720 NS_LOG_DEBUG (
"a transmission that did not require an ACK just finished");
818 NS_LOG_WARN (
"StartNext should not be called for non QoS!");
824 NS_LOG_WARN (
"GotBlockAck should not be called for non QoS!");
830 NS_LOG_WARN (
"MissedBlockAck should not be called for non QoS!");
TxFailed m_txFailedCallback
the transmit failed callback
Simulation virtual time values and global simulation resolution.
void SendCfFrame(WifiMacType frameType, Mac48Address addr)
Sends CF frame to sta with address addr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Time m_txopLimit
the txop limit time
virtual void RestartAccessIfNeeded(void)
Restart access request if needed.
virtual void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header, uint32_t packetSize)
Should be invoked after calling ReportDataFailed if NeedRetransmission returns false.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
virtual void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
virtual void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
uint32_t m_backoffSlots
the backoff slots
virtual void StartNextFragment(void)
Start transmission for the next fragment.
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
virtual void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
virtual void MissedAck(void)
Event handler when an ACK is missed.
void SetTxDroppedCallback(TxDropped callback)
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
virtual void DoInitialize(void)
Initialize() implementation.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#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.
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
bool IsBusy(void) const
Check if the device is busy sending or receiving, or NAV or CCA busy.
Mac48Address GetBssid(void) const
Return the Basic Service Set Identification.
virtual void Cancel(void)
Cancel the transmission.
void UpdateFragmentationThreshold(void)
Typically called to update the fragmentation threshold at the start of a new transmission.
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
Ptr< UniformRandomVariable > m_rng
the random stream
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
bool CanStartNextPolling(void) const
Check if the next PCF transmission can fit in the remaining CFP duration.
void PrepareForQueue(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
virtual void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, Ptr< Txop > txop)
uint32_t GetMinCw(void) const
Return the minimum contention window size.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
uint32_t m_cwMax
the CW maximum
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
virtual uint32_t GetInteger(void)=0
Get the next random value as an integer drawn from the distribution.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
AttributeValue implementation for Time.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
WifiMacType
Combination of valid MAC header type/subtype.
Hold an unsigned integer type.
virtual bool IsCfPeriod(void) const
This function indicates whether it is the CF period.
void NextFragment(void)
Continue to the next fragment.
static TypeId GetTypeId(void)
Get the type ID.
bool NeedRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
virtual bool IsAccessRequested(void) const
virtual bool IsQosTxop() const
Check for QoS TXOP.
virtual uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
uint32_t m_cwMin
the CW minimum
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
bool NeedRtsRetransmission(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Check if RTS should be re-transmitted if CTS was missed.
Ptr< MacLow > GetLow(void) const
Return the MacLow associated with this Txop.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void GotCfEnd(void)
Event handler when a CF-END frame is received.
uint32_t GetCw(void) const
Hold objects of type Ptr<T>.
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
void EnableAck(void)
Wait ACKTimeout for an ACK.
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
virtual void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
uint32_t GetFragmentSize(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
virtual void DoDispose(void)
Destructor implementation.
bool NeedDataRetransmission(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Check if DATA should be re-transmitted if ACK was missed.
Ptr< const Packet > m_currentPacket
the current packet
void SetMacLow(const Ptr< MacLow > low)
Set MacLow associated with this Txop.
virtual bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
void DisableRts(void)
Do not send rts and wait for cts before sending data.
static Time Now(void)
Return the current simulation virtual time.
virtual void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Ptr< MacLow > m_low
the MacLow
virtual bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
void TxDroppedPacket(Ptr< const WifiMacQueueItem > item)
Pass the packet included in the wifi MAC queue item to the packet dropped callback.
uint32_t m_cw
the current CW
MacLowTransmissionParameters m_currentParams
current transmission parameters
virtual void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
bool m_accessRequested
flag whether channel access is already requested
bool CanTransmitNextCfFrame(void) const
This function decides if a CF frame can be transmitted in the current CFP.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Time m_backoffStart
the backoffStart variable is used to keep track of the time at which a backoff was started or the tim...
virtual void GotAck(void)
Event handler when an ACK is received.
virtual void MissedCts(void)
Event handler when a CTS timeout has occurred.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
virtual void NotifyCollision(void)
Notify the DCF that collision has occurred.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
void MissedCfPollResponse(bool expectedCfAck)
Event handler when a response to a CF-POLL frame is missed.
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
void EnableNextData(uint32_t size)
TxOk m_txOkCallback
the transmit OK callback
void DisableNextData(void)
Do not attempt to send data burst after current transmission.
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this Txop is associated to.
void Add(Ptr< Txop > dcf)
uint8_t m_fragmentNumber
the fragment number
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
A base class which provides memory management and object aggregation.
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
WifiMacHeader m_currentHdr
the current header
void SetTxFailedCallback(TxFailed callback)
bool IsNull(void) const
Check for null implementation.
Ptr< WifiRemoteStationManager > m_stationManager
the wifi remote station manager
virtual uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
void SetTxOkCallback(TxOk callback)
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
void DisableAck(void)
Do not wait for Ack after data transmission.
virtual uint32_t GetFragmentSize(void) const
Calculate the size of the current fragment.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
a unique identifier for an interface.
void ReportFinalRtsFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportRtsFailed if NeedRetransmission returns false.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void StartBackoffNow(uint32_t nSlots)
void RequestAccess(Ptr< Txop > state, bool isCfPeriod=false)
virtual bool HasTxop(void) const
Check if the station has TXOP granted for the next MPDU.
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
TxDropped m_txDroppedCallback
the packet dropped callback
Handle packet fragmentation and retransmissions for data and management frames.
Time GetTxopLimit(void) const
Return the TXOP limit.