21 #include "ns3/assert.h"
22 #include "ns3/packet.h"
24 #include "ns3/simulator.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/pointer.h"
38 #undef NS_LOG_APPEND_CONTEXT
39 #define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; }
139 .AddAttribute (
"Queue",
"The WifiMacQueue object",
142 MakePointerChecker<WifiMacQueue> ())
154 m_queue = CreateObject<WifiMacQueue> ();
268 packet, fullPacketSize);
269 m_queue->Enqueue (packet, hdr);
479 Low ()->StartTransmission (fragment, &hdr, params,
682 NS_LOG_DEBUG (
"a transmission that did not require an ACK just finished");
void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Smart pointer class similar to boost::intrusive_ptr.
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
TypeId AddConstructor(void)
virtual void DoNotifyInternalCollision(void)
Called by DcfManager to notify a DcfState subclass that an 'internal' collision occured, that is, that the backoff timer of a higher priority DcfState expired at the same time and that access was granted to this higher priority DcfState.
void SetTxFailedCallback(TxFailed callback)
uint32_t GetCwMin(void) const
Return the minimum congestion window size.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
virtual void MissedAck(void)
ns3::MacLow did not receive an expected ACK within AckTimeout.
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum congestion window size.
void StartNext(void)
Start transmission for the next fragment.
void RequestAccess(DcfState *state)
TransmissionListener(DcaTxop *txop)
Create a TransmissionListener for the given DcaTxop.
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 int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Ptr< MacLow > Low(void)
Return the MacLow associated with this DcaTxop.
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
void SetAifsn(uint32_t aifsn)
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...
listen to events coming from ns3::MacLow.
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
virtual void GotCts(double snr, WifiMode txMode)
static TypeId GetTypeId(void)
control how a packet is transmitted.
void SetTxOkCallback(TxOk callback)
void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Handles sequence numbering of IEEE 802.11 data frames.
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
virtual void GotAck(double snr, WifiMode txMode)
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this DcaTxop.
bool NeedFragmentation(void)
Check if the current packet should be fragmented.
Ptr< WifiMacQueue > m_queue
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
void Cancel(void)
Cancel the transmission.
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
void MissedCts(void)
Event handler when a CTS timeout has occurred.
virtual void DoNotifySleep(void)
Called by DcfManager to notify a DcfState subclass that the device has begun to sleep.
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
bool IsLastFragment(void)
Check if the curren fragment is the last fragment.
keep track of the state needed for a single DCF function.
bool IsAccessRequested(void) const
Ptr< WifiRemoteStationManager > m_stationManager
virtual void DoNotifyChannelSwitching(void)
Called by DcfManager to notify a DcfState subclass that a channel switching occured.
uint32_t GetCwMax(void) const
Return the maximum congestion window size.
bool NeedRts(Ptr< const Packet > packet, const WifiMacHeader *header)
Check if the current packet should be sent with a RTS protection.
void SetCwMin(uint32_t minCw)
Set the minimum congestion window size.
virtual void SetAifsn(uint32_t aifsn)
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this DcaTxop is associated to.
void StartBackoffNow(uint32_t nSlots)
uint16_t GetNextSequenceNumberfor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr.
void DoInitialize()
Initialize() implementation.
bool NeedsAccess(void) const
Check if the DCF requires access.
WifiMacHeader m_currentHdr
void EnableAck(void)
Wait ACKTimeout for an ACK.
virtual void EndTxNoAck(void)
Invoked upon the end of the transmission of a frame that does not require an ACK (e.g., broadcast and multicast frames).
Ptr< WifiMacQueue > GetQueue() const
Return the packet queue associated with this DcaTxop.
virtual void Cancel(void)
Invoked if this transmission was canceled one way or another.
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
void DisableRts(void)
Do not send rts and wait for cts before sending data.
friend class TransmissionListener
void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Ptr< const Packet > m_currentPacket
virtual void MissedCts(void)
ns3::MacLow did not receive an expected CTS within CtsTimeout.
Listener for MacLow events.
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size.
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size.
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
virtual void DoNotifyCollision(void)
Called by DcfManager to notify a DcfState subclass that a normal collision occured, that is, that the medium was busy when access was requested.
static TypeId GetTypeId(void)
virtual ~TransmissionListener()
void EnableRts(void)
Send a RTS, and wait CTSTimeout for a CTS.
uint32_t GetCw(void) const
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
void SetManager(DcfManager *manager)
Set DcfManager this DcaTxop is associated to.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
virtual void StartNext(void)
Invoked when ns3::MacLow wants to start a new transmission as configured by MacLowTransmissionParamet...
virtual void DoDispose(void)
Destructor implementation.
void EnableNextData(uint32_t size)
void NotifyCollision(void)
Notify the DCF that collision has occurred.
void DisableOverrideDurationId(void)
Do not force the duration/id field of the packet: its value is automatically calculated by the MacLow...
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.
TransmissionListener * m_transmissionListener
virtual void DoNotifyAccessGranted(void)
Called by DcfManager to notify a DcfState subclass that access to the medium is granted and can start...
void RestartAccessIfNeeded(void)
Restart access request if needed.
virtual void DoNotifyWakeUp(void)
Called by DcfManager to notify a DcfState subclass that the device has begun to wake up...
void SetTxMiddle(MacTxMiddle *txMiddle)
Set MacTxMiddle this DcaTxop is associated to.
virtual uint32_t GetNext(uint32_t min, uint32_t max)=0
Get integer between min and max (including min and max).
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
void MissedAck(void)
Event handler when an ACK is received.
handle packet fragmentation and retransmissions.
void DisableAck(void)
Do not wait for Ack after data transmission.
bool NeedDataRetransmission(void)
Check if DATA should be re-transmitted if ACK was missed.
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
virtual void DoInitialize(void)
Initialize() implementation.
Implements the IEEE 802.11 MAC trailer.
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
virtual uint32_t GetSerializedSize(void) const
TxFailed m_txFailedCallback