|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/pointer.h"
23 #include "ns3/simulator.h"
24 #include "ns3/random-variable-stream.h"
25 #include "ns3/socket.h"
33 #undef NS_LOG_APPEND_CONTEXT
34 #define NS_LOG_APPEND_CONTEXT if (m_mac != 0) { std::clog << "[mac=" << m_mac->GetAddress () << "] "; }
47 .SetGroupName (
"Wifi")
48 .AddConstructor<
Txop> ()
49 .AddAttribute (
"MinCw",
"The minimum value of the contention window.",
53 MakeUintegerChecker<uint32_t> ())
54 .AddAttribute (
"MaxCw",
"The maximum value of the contention window.",
58 MakeUintegerChecker<uint32_t> ())
59 .AddAttribute (
"Aifsn",
"The AIFSN: the default value conforms to non-QOS.",
63 MakeUintegerChecker<uint8_t> ())
64 .AddAttribute (
"TxopLimit",
"The TXOP limit: the default value conforms to non-QoS.",
69 .AddAttribute (
"Queue",
"The WifiMacQueue object",
72 MakePointerChecker<WifiMacQueue> ())
73 .AddTraceSource (
"BackoffTrace",
74 "Trace source for backoff values",
76 "ns3::TracedCallback::Uint32Callback")
77 .AddTraceSource (
"CwTrace",
78 "Trace source for contention window values",
80 "ns3::TracedValueCallback::Uint32")
91 : m_channelAccessManager (0),
97 m_access (NOT_REQUESTED),
102 m_rng = CreateObject<UniformRandomVariable> ();
147 m_queue->TraceConnectWithoutContext (
"DropBeforeEnqueue",
149 m_queue->TraceConnectWithoutContext (
"Expired",
164 bool changed = (
m_cwMin != minCw);
176 bool changed = (
m_cwMax != maxCw);
288 bool ret = (!
m_queue->IsEmpty ());
304 m_queue->Enqueue (Create<WifiMacQueueItem> (packet, hdr));
virtual void SetDroppedMpduCallback(DroppedMpdu callback)
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
uint32_t m_cw
the current contention window
This queue implements the timeout procedure described in (Section 9.19.2.6 "Retransmit procedures" pa...
virtual void NotifyChannelReleased(void)
Called by the FrameExchangeManager to notify the completion of the transmissions.
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
TracedValue< uint32_t > m_cwTrace
CW trace value.
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
virtual ChannelAccessStatus GetAccessStatus(void) const
uint32_t m_backoff
the current backoff
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
@ WIFI_MAC_DROP_EXPIRED_LIFETIME
Hold objects of type Ptr<T>.
uint32_t m_cwMin
the minimum contention window
uint32_t m_cwMax
the maximum contention window
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
void StartBackoffNow(uint32_t nSlots)
Ptr< UniformRandomVariable > m_rng
the random stream
Time GetTxopLimit(void) const
Return the TXOP limit.
virtual void NotifyChannelAccessed(Time txopDuration=Seconds(0))
Called by the FrameExchangeManager to notify that channel access has been granted for the given amoun...
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Ptr< RegularWifiMac > m_mac
the wifi MAC
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
virtual void GenerateBackoff(void)
Generate a new backoff now.
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
Smart pointer class similar to boost::intrusive_ptr.
uint32_t m_backoffSlots
the number of backoff slots
virtual void NotifyOn(void)
When on operation occurs, channel access will be started.
virtual uint32_t GetMinCw(void) const
Return the minimum contention window size.
virtual void StartAccessIfNeeded(void)
Request access from Txop if needed.
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
A base class which provides memory management and object aggregation.
Callback< R, T2, T3, T4, T5, T6, T7, T8, T9 > Bind(T a)
Bind the first arguments.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
static TypeId GetTypeId(void)
Get the type ID.
Simulation virtual time values and global simulation resolution.
virtual bool IsQosTxop() const
Check for QoS TXOP.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
@ WIFI_MAC_DROP_FAILED_ENQUEUE
virtual uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
DroppedMpdu m_droppedMpduCallback
the dropped MPDU callback
indicates whether the socket has a priority set.
Time m_txopLimit
the TXOP limit time
void DoDispose(void) override
Destructor implementation.
ChannelAccessStatus
Enumeration for channel access status.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
virtual void SetWifiMac(const Ptr< RegularWifiMac > mac)
Set the wifi MAC this Txop is associated to.
void DoInitialize(void) override
Initialize() implementation.
Time Seconds(double value)
Construct a Time in the indicated unit.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
AttributeValue implementation for Time.
TracedCallback< uint32_t > m_backoffTrace
backoff trace value
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
virtual uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
uint32_t GetCw(void) const
ChannelAccessStatus m_access
channel access status
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Hold an unsigned integer type.
virtual bool HasFramesToTransmit(void)
Check if the Txop has frames to transmit.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void RequestAccess(void)
Request access to the ChannelAccessManager.
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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 Queue(Ptr< Packet > packet, const WifiMacHeader &hdr)
static EventId ScheduleNow(FUNC f, Ts &&... args)
Schedule an event to expire Now.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Handle packet fragmentation and retransmissions for data and management frames.