22 #include "ns3/pointer.h" 23 #include "ns3/simulator.h" 24 #include "ns3/random-variable-stream.h" 25 #include "ns3/socket.h" 34 #undef NS_LOG_APPEND_CONTEXT 35 #define NS_LOG_APPEND_CONTEXT if (m_stationManager != 0 && m_stationManager->GetMac () != 0) { std::clog << "[mac=" << m_stationManager->GetMac ()->GetAddress () << "] "; } 48 .SetGroupName (
"Wifi")
49 .AddConstructor<
Txop> ()
50 .AddAttribute (
"MinCw",
"The minimum value of the contention window.",
54 MakeUintegerChecker<uint32_t> ())
55 .AddAttribute (
"MaxCw",
"The maximum value of the contention window.",
59 MakeUintegerChecker<uint32_t> ())
60 .AddAttribute (
"Aifsn",
"The AIFSN: the default value conforms to non-QOS.",
64 MakeUintegerChecker<uint8_t> ())
65 .AddAttribute (
"TxopLimit",
"The TXOP limit: the default value conforms to non-QoS.",
70 .AddAttribute (
"Queue",
"The WifiMacQueue object",
73 MakePointerChecker<WifiMacQueue> ())
74 .AddTraceSource (
"BackoffTrace",
75 "Trace source for backoff values",
77 "ns3::TracedCallback::Uint32Callback")
78 .AddTraceSource (
"CwTrace",
79 "Trace source for contention window values",
81 "ns3::TracedValueCallback::Uint32")
87 : m_channelAccessManager (0),
92 m_access (NOT_REQUESTED),
97 m_queue = CreateObject<WifiMacQueue> ();
98 m_rng = CreateObject<UniformRandomVariable> ();
143 m_queue->TraceConnectWithoutContext (
"DropBeforeEnqueue",
145 m_queue->TraceConnectWithoutContext (
"Expired",
160 bool changed = (
m_cwMin != minCw);
172 bool changed = (
m_cwMax != maxCw);
282 bool ret = (!
m_queue->IsEmpty ());
298 m_queue->Enqueue (Create<WifiMacQueueItem> (packet, hdr));
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
#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.
TracedCallback< uint32_t > m_backoffTrace
backoff trace value
TracedValue< uint32_t > m_cwTrace
CW trace value.
void DoInitialize(void) override
Initialize() implementation.
Time m_txopLimit
the TXOP limit time
virtual void StartAccessIfNeeded(void)
Request access from Txop 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.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
uint32_t m_backoffSlots
the number of backoff slots
virtual bool HasFramesToTransmit(void)
Check if the Txop has frames to transmit.
uint32_t m_backoff
the current backoff
void RequestAccess(void)
Request access to the ChannelAccessManager.
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
#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.
Callback< R, T2, T3, T4, T5, T6, T7, T8, T9 > Bind(T a)
Bind the first arguments.
Ptr< UniformRandomVariable > m_rng
the random stream
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
virtual void GenerateBackoff(void)
Generate a new backoff now.
virtual ChannelAccessStatus GetAccessStatus(void) const
uint32_t GetMinCw(void) const
Return the minimum contention window size.
uint32_t m_cwMax
the maximum contention window
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
ChannelAccessStatus
Enumeration for channel access status.
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
virtual AcIndex GetAccessCategory(void) const
Get the access category.
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...
Hold an unsigned integer type.
indicates whether the socket has a priority set.
virtual void NotifyChannelReleased(void)
Called by the FrameExchangeManager to notify the completion of the transmissions. ...
static TypeId GetTypeId(void)
Get the type ID.
ChannelAccessStatus m_access
channel access status
virtual bool IsQosTxop() const
Check for QoS TXOP.
uint32_t m_cwMin
the minimum contention window
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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 ...
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
void DoDispose(void) override
Destructor implementation.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
static Time Now(void)
Return the current simulation virtual time.
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
virtual void NotifyInternalCollision(void)
Notify the Txop that internal collision has occurred.
virtual void NotifyChannelAccessed(Time txopDuration=Seconds(0))
Called by the FrameExchangeManager to notify that channel access has been granted for the given amoun...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
uint32_t m_cw
the current contention window
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
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...
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
#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.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
virtual void SetWifiRemoteStationManager(const Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this Txop is associated to.
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.
Ptr< WifiRemoteStationManager > m_stationManager
the wifi remote station manager
virtual void Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
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.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void StartBackoffNow(uint32_t nSlots)
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Handle packet fragmentation and retransmissions for data and management frames.
Time GetTxopLimit(void) const
Return the TXOP limit.