A Discrete-Event Network Simulator
API
txop.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/pointer.h"
23 #include "ns3/simulator.h"
24 #include "ns3/random-variable-stream.h"
25 #include "txop.h"
26 #include "channel-access-manager.h"
27 #include "wifi-mac-queue.h"
28 #include "mac-tx-middle.h"
29 #include "mac-low.h"
31 
32 #undef NS_LOG_APPEND_CONTEXT
33 #define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; }
34 
35 namespace ns3 {
36 
38 
40 
41 TypeId
43 {
44  static TypeId tid = TypeId ("ns3::Txop")
46  .SetGroupName ("Wifi")
47  .AddConstructor<Txop> ()
48  .AddAttribute ("MinCw", "The minimum value of the contention window.",
49  UintegerValue (15),
52  MakeUintegerChecker<uint32_t> ())
53  .AddAttribute ("MaxCw", "The maximum value of the contention window.",
54  UintegerValue (1023),
57  MakeUintegerChecker<uint32_t> ())
58  .AddAttribute ("Aifsn", "The AIFSN: the default value conforms to non-QOS.",
59  UintegerValue (2),
62  MakeUintegerChecker<uint8_t> ())
63  .AddAttribute ("TxopLimit", "The TXOP limit: the default value conforms to non-QoS.",
64  TimeValue (MilliSeconds (0)),
67  MakeTimeChecker ())
68  .AddAttribute ("Queue", "The WifiMacQueue object",
69  PointerValue (),
71  MakePointerChecker<WifiMacQueue> ())
72  ;
73  return tid;
74 }
75 
77  : m_channelAccessManager (0),
78  m_cwMin (0),
79  m_cwMax (0),
80  m_cw (0),
81  m_accessRequested (false),
82  m_backoffSlots (0),
83  m_backoffStart (Seconds (0.0)),
84  m_currentPacket (0)
85 {
86  NS_LOG_FUNCTION (this);
87  m_queue = CreateObject<WifiMacQueue> ();
88  m_rng = CreateObject<UniformRandomVariable> ();
89 }
90 
92 {
93  NS_LOG_FUNCTION (this);
94 }
95 
96 void
98 {
99  NS_LOG_FUNCTION (this);
100  m_queue = 0;
101  m_low = 0;
102  m_stationManager = 0;
103  m_rng = 0;
104  m_txMiddle = 0;
106 }
107 
108 void
110 {
111  NS_LOG_FUNCTION (this << manager);
112  m_channelAccessManager = manager;
113  m_channelAccessManager->Add (this);
114 }
115 
116 void Txop::SetTxMiddle (const Ptr<MacTxMiddle> txMiddle)
117 {
118  NS_LOG_FUNCTION (this);
119  m_txMiddle = txMiddle;
120 }
121 
122 void
124 {
125  NS_LOG_FUNCTION (this << low);
126  m_low = low;
127 }
128 
129 void
131 {
132  NS_LOG_FUNCTION (this << remoteManager);
133  m_stationManager = remoteManager;
134 }
135 
136 void
138 {
139  NS_LOG_FUNCTION (this << &callback);
140  m_txOkCallback = callback;
141 }
142 
143 void
145 {
146  NS_LOG_FUNCTION (this << &callback);
147  m_txFailedCallback = callback;
148 }
149 
150 void
152 {
153  NS_LOG_FUNCTION (this << &callback);
154  m_txDroppedCallback = callback;
155  m_queue->TraceConnectWithoutContext ("Drop", MakeCallback (&Txop::TxDroppedPacket, this));
156 }
157 
158 void
160 {
161  if (!m_txDroppedCallback.IsNull ())
162  {
163  m_txDroppedCallback (item->GetPacket ());
164  }
165 }
166 
169 {
170  NS_LOG_FUNCTION (this);
171  return m_queue;
172 }
173 
174 void
175 Txop::SetMinCw (uint32_t minCw)
176 {
177  NS_LOG_FUNCTION (this << minCw);
178  bool changed = (m_cwMin != minCw);
179  m_cwMin = minCw;
180  if (changed == true)
181  {
182  ResetCw ();
183  }
184 }
185 
186 void
187 Txop::SetMaxCw (uint32_t maxCw)
188 {
189  NS_LOG_FUNCTION (this << maxCw);
190  bool changed = (m_cwMax != maxCw);
191  m_cwMax = maxCw;
192  if (changed == true)
193  {
194  ResetCw ();
195  }
196 }
197 
198 uint32_t
199 Txop::GetCw (void) const
200 {
201  return m_cw;
202 }
203 
204 void
206 {
207  NS_LOG_FUNCTION (this);
208  m_cw = m_cwMin;
209 }
210 
211 void
213 {
214  NS_LOG_FUNCTION (this);
215  //see 802.11-2012, section 9.19.2.5
216  m_cw = std::min ( 2 * (m_cw + 1) - 1, m_cwMax);
217 }
218 
219 uint32_t
221 {
222  return m_backoffSlots;
223 }
224 
225 Time
227 {
228  return m_backoffStart;
229 }
230 
231 void
232 Txop::UpdateBackoffSlotsNow (uint32_t nSlots, Time backoffUpdateBound)
233 {
234  NS_LOG_FUNCTION (this << nSlots << backoffUpdateBound);
235  m_backoffSlots -= nSlots;
236  m_backoffStart = backoffUpdateBound;
237  NS_LOG_DEBUG ("update slots=" << nSlots << " slots, backoff=" << m_backoffSlots);
238 }
239 
240 void
241 Txop::StartBackoffNow (uint32_t nSlots)
242 {
243  NS_LOG_FUNCTION (this << nSlots);
244  if (m_backoffSlots != 0)
245  {
246  NS_LOG_DEBUG ("reset backoff from " << m_backoffSlots << " to " << nSlots << " slots");
247  }
248  else
249  {
250  NS_LOG_DEBUG ("start backoff=" << nSlots << " slots");
251  }
252  m_backoffSlots = nSlots;
254 }
255 
256 void
257 Txop::SetAifsn (uint8_t aifsn)
258 {
259  NS_LOG_FUNCTION (this << +aifsn);
260  m_aifsn = aifsn;
261 }
262 
263 void
265 {
266  NS_LOG_FUNCTION (this << txopLimit);
267  NS_ASSERT_MSG ((txopLimit.GetMicroSeconds () % 32 == 0), "The TXOP limit must be expressed in multiple of 32 microseconds!");
268  m_txopLimit = txopLimit;
269 }
270 
271 uint32_t
272 Txop::GetMinCw (void) const
273 {
274  return m_cwMin;
275 }
276 
277 uint32_t
278 Txop::GetMaxCw (void) const
279 {
280  return m_cwMax;
281 }
282 
283 uint8_t
284 Txop::GetAifsn (void) const
285 {
286  return m_aifsn;
287 }
288 
289 Time
290 Txop::GetTxopLimit (void) const
291 {
292  return m_txopLimit;
293 }
294 
295 void
297 {
298  NS_LOG_FUNCTION (this << packet << &hdr);
299  m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr, packet);
300  m_queue->Enqueue (Create<WifiMacQueueItem> (packet, hdr));
302 }
303 
304 int64_t
305 Txop::AssignStreams (int64_t stream)
306 {
307  NS_LOG_FUNCTION (this << stream);
308  m_rng->SetStream (stream);
309  return 1;
310 }
311 
312 void
314 {
315  NS_LOG_FUNCTION (this);
316  if ((m_currentPacket != 0
317  || !m_queue->IsEmpty ())
318  && !IsAccessRequested ()
319  && !m_low->IsCfPeriod ())
320  {
322  }
323 }
324 
325 void
327 {
328  NS_LOG_FUNCTION (this);
329  if (m_currentPacket == 0
330  && !m_queue->IsEmpty ()
331  && !IsAccessRequested ()
332  && !m_low->IsCfPeriod ())
333  {
335  }
336 }
337 
339 Txop::GetLow (void) const
340 {
341  return m_low;
342 }
343 
344 void
346 {
347  NS_LOG_FUNCTION (this);
348  ResetCw ();
350 }
351 
352 bool
354 {
355  NS_LOG_FUNCTION (this);
356  return m_stationManager->NeedRetransmission (hdr.GetAddr1 (), &hdr, packet);
357 }
358 
359 bool
361 {
362  NS_LOG_FUNCTION (this);
363  return m_stationManager->NeedRetransmission (hdr.GetAddr1 (), &hdr, packet);
364 }
365 
366 bool
368 {
369  NS_LOG_FUNCTION (this);
372 }
373 
374 void
376 {
377  NS_LOG_FUNCTION (this);
379 }
380 
381 uint32_t
383 {
384  NS_LOG_FUNCTION (this);
387 }
388 
389 bool
391 {
392  NS_LOG_FUNCTION (this);
395 }
396 
397 uint32_t
399 {
400  NS_LOG_FUNCTION (this);
403 }
404 
405 uint32_t
407 {
408  NS_LOG_FUNCTION (this);
411 }
412 
415 {
416  NS_LOG_FUNCTION (this << hdr);
417  *hdr = m_currentHdr;
419  uint32_t startOffset = GetFragmentOffset ();
420  Ptr<Packet> fragment;
421  if (IsLastFragment ())
422  {
423  hdr->SetNoMoreFragments ();
424  }
425  else
426  {
427  hdr->SetMoreFragments ();
428  }
429  fragment = m_currentPacket->CreateFragment (startOffset,
430  GetFragmentSize ());
431  return fragment;
432 }
433 
434 bool
436 {
437  return m_accessRequested;
438 }
439 
440 void
442 {
443  NS_LOG_FUNCTION (this);
444  m_accessRequested = true;
445 }
446 
447 void
449 {
450  NS_LOG_FUNCTION (this);
452  m_accessRequested = false;
453  if (m_currentPacket == 0)
454  {
455  if (m_queue->IsEmpty ())
456  {
457  NS_LOG_DEBUG ("queue empty");
458  return;
459  }
460  Ptr<WifiMacQueueItem> item = m_queue->Dequeue ();
461  NS_ASSERT (item != 0);
462  m_currentPacket = item->GetPacket ();
463  m_currentHdr = item->GetHeader ();
464  NS_ASSERT (m_currentPacket != 0);
465  uint16_t sequence = m_txMiddle->GetNextSequenceNumberFor (&m_currentHdr);
466  m_currentHdr.SetSequenceNumber (sequence);
471  m_fragmentNumber = 0;
472  NS_LOG_DEBUG ("dequeued size=" << m_currentPacket->GetSize () <<
473  ", to=" << m_currentHdr.GetAddr1 () <<
474  ", seq=" << m_currentHdr.GetSequenceControl ());
475  }
476  if (m_currentHdr.GetAddr1 ().IsGroup ())
477  {
481  NS_LOG_DEBUG ("tx broadcast");
483  }
484  else
485  {
487  if (NeedFragmentation ())
488  {
489  WifiMacHeader hdr;
490  Ptr<Packet> fragment = GetFragmentPacket (&hdr);
491  if (IsLastFragment ())
492  {
493  NS_LOG_DEBUG ("fragmenting last fragment size=" << fragment->GetSize ());
495  }
496  else
497  {
498  NS_LOG_DEBUG ("fragmenting size=" << fragment->GetSize ());
500  }
501  GetLow ()->StartTransmission (fragment, &hdr, m_currentParams, this);
502  }
503  else
504  {
507  }
508  }
509 }
510 
511 void
513 {
514  NS_LOG_FUNCTION (this);
515  NotifyCollision ();
516 }
517 
518 void
520 {
521  NS_LOG_FUNCTION (this);
524 }
525 
526 void
528 {
529  NS_LOG_FUNCTION (this);
530  m_queue->Flush ();
531  m_currentPacket = 0;
532 }
533 
534 void
536 {
537  NS_LOG_FUNCTION (this);
538  if (m_currentPacket != 0)
539  {
540  m_queue->PushFront (Create<WifiMacQueueItem> (m_currentPacket, m_currentHdr));
541  m_currentPacket = 0;
542  }
543 }
544 
545 void
547 {
548  NS_LOG_FUNCTION (this);
549  m_queue->Flush ();
550  m_currentPacket = 0;
551 }
552 
553 void
555 {
556  NS_LOG_FUNCTION (this);
558 }
559 
560 void
562 {
563  NS_LOG_FUNCTION (this);
565 }
566 
567 void
569 {
570  NS_LOG_FUNCTION (this);
571  NS_LOG_DEBUG ("missed cts");
573  {
574  NS_LOG_DEBUG ("Cts Fail");
576  if (!m_txFailedCallback.IsNull ())
577  {
579  }
580  //to reset the dcf.
581  m_currentPacket = 0;
582  ResetCw ();
583  }
584  else
585  {
586  UpdateFailedCw ();
587  }
590 }
591 
592 void
594 {
595  NS_LOG_FUNCTION (this);
596  if (!NeedFragmentation ()
597  || IsLastFragment ())
598  {
599  NS_LOG_DEBUG ("got ack. tx done.");
600  if (!m_txOkCallback.IsNull ())
601  {
603  }
604 
605  /* we are not fragmenting or we are done fragmenting
606  * so we can get rid of that packet now.
607  */
608  m_currentPacket = 0;
609  ResetCw ();
612  }
613  else
614  {
615  NS_LOG_DEBUG ("got ack. tx not done, size=" << m_currentPacket->GetSize ());
616  }
617 }
618 
619 void
621 {
622  NS_LOG_FUNCTION (this);
623  NS_LOG_DEBUG ("missed ack");
625  {
626  NS_LOG_DEBUG ("Ack Fail");
629  if (!m_txFailedCallback.IsNull ())
630  {
632  }
633  //to reset the dcf.
634  m_currentPacket = 0;
635  ResetCw ();
636  }
637  else
638  {
639  NS_LOG_DEBUG ("Retransmit");
641  UpdateFailedCw ();
642  }
645 }
646 
647 void
649 {
650  NS_LOG_FUNCTION (this);
651  if (m_currentPacket != 0)
652  {
654  }
655  else
656  {
658  }
659 }
660 
661 void
662 Txop::MissedCfPollResponse (bool expectedCfAck)
663 {
664  NS_LOG_FUNCTION (this);
665  NS_LOG_DEBUG ("missed response to CF-POLL");
666  if (expectedCfAck)
667  {
669  {
670  NS_LOG_DEBUG ("Ack Fail");
673  m_currentPacket = 0;
674  }
675  else
676  {
677  NS_LOG_DEBUG ("Retransmit");
679  }
680  }
681  if (!m_txFailedCallback.IsNull ())
682  {
684  }
685 }
686 
687 void
689 {
690  NS_LOG_FUNCTION (this);
691  NS_LOG_DEBUG ("start next packet fragment");
692  /* this callback is used only for fragments. */
693  NextFragment ();
694  WifiMacHeader hdr;
695  Ptr<Packet> fragment = GetFragmentPacket (&hdr);
698  if (IsLastFragment ())
699  {
701  }
702  else
703  {
705  }
706  GetLow ()->StartTransmission (fragment, &hdr, m_currentParams, this);
707 }
708 
709 void
711 {
712  NS_LOG_FUNCTION (this);
713  NS_LOG_DEBUG ("transmission cancelled");
714 }
715 
716 void
718 {
719  NS_LOG_FUNCTION (this);
720  NS_LOG_DEBUG ("a transmission that did not require an ACK just finished");
721  m_currentPacket = 0;
722  ResetCw ();
724  if (!m_txOkCallback.IsNull ())
725  {
727  }
729 }
730 
731 void
733 {
734  NS_LOG_FUNCTION (this << frameType << addr);
735  NS_ASSERT (m_low->IsCfPeriod ());
736  if (m_currentPacket != 0 && frameType != WIFI_MAC_CTL_END)
737  {
739  {
742  m_currentPacket = 0;
743  }
744  else
745  {
747  }
748  }
749  else if ((m_queue->GetNPacketsByAddress (addr) > 0) && (frameType != WIFI_MAC_CTL_END)) //if no packet for that dest, send to another dest?
750  {
751  Ptr<WifiMacQueueItem> item = m_queue->DequeueByAddress (addr);
752  NS_ASSERT (item != 0);
753  m_currentPacket = item->GetPacket ();
754  m_currentHdr = item->GetHeader ();
755  uint16_t sequence = m_txMiddle->GetNextSequenceNumberFor (&m_currentHdr);
756  m_currentHdr.SetSequenceNumber (sequence);
760  }
761  else
762  {
763  m_currentPacket = Create<Packet> ();
765  }
766 
767  if (m_currentPacket->GetSize () > 0)
768  {
769  switch (frameType)
770  {
773  break;
774  case WIFI_MAC_DATA_NULL:
776  break;
777  default:
778  NS_ASSERT (false);
779  break;
780  }
781  }
782  else
783  {
784  m_currentHdr.SetType (frameType);
785  }
786  m_currentHdr.SetAddr1 (addr);
788  if (frameType == WIFI_MAC_DATA_NULL)
789  {
793  }
794  else
795  {
799  }
801 }
802 
803 bool
805 {
807 }
808 
809 bool
811 {
812  return false;
813 }
814 
815 void
817 {
818  NS_LOG_WARN ("StartNext should not be called for non QoS!");
819 }
820 
821 void
822 Txop::GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
823 {
824  NS_LOG_WARN ("GotBlockAck should not be called for non QoS!");
825 }
826 
827 void
828 Txop::MissedBlockAck (uint8_t nMpdus)
829 {
830  NS_LOG_WARN ("MissedBlockAck should not be called for non QoS!");
831 }
832 
833 bool
834 Txop::HasTxop (void) const
835 {
836  return false;
837 }
838 
839 } //namespace ns3
TxFailed m_txFailedCallback
the transmit failed callback
Definition: txop.h:498
void SetRetry(void)
Set the Retry bit in the Frame Control field.
void SetMoreFragments(void)
Set the More Fragment bit in the Frame Control field.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
void SendCfFrame(WifiMacType frameType, Mac48Address addr)
Sends CF frame to sta with address addr.
Definition: txop.cc:732
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint8_t m_aifsn
the AIFSN
Definition: txop.h:518
Ptr< MacTxMiddle > m_txMiddle
the MacTxMiddle
Definition: txop.h:501
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Callback template class.
Definition: callback.h:1176
Time m_txopLimit
the txop limit time
Definition: txop.h:519
virtual void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: txop.cc:313
virtual void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: txop.cc:326
uint8_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: txop.cc:284
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:831
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")
#define min(a, b)
Definition: 80211b.c:42
virtual void StartNextPacket(void)
Start transmission for the next packet if allowed by the TxopLimit.
Definition: txop.cc:816
virtual void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: txop.cc:717
uint32_t m_backoffSlots
the backoff slots
Definition: txop.h:510
virtual void StartNextFragment(void)
Start transmission for the next fragment.
Definition: txop.cc:688
void SetChannelAccessManager(const Ptr< ChannelAccessManager > manager)
Set ChannelAccessManager this Txop is associated to.
Definition: txop.cc:109
void SetNoMoreFragments(void)
Un-set the More Fragment bit in the Frame Control Field.
Ptr< ChannelAccessManager > m_channelAccessManager
the channel access manager
Definition: txop.h:496
virtual void NotifyAccessGranted(void)
Notify the DCF that access has been granted.
Definition: txop.cc:448
virtual void MissedAck(void)
Event handler when an ACK is missed.
Definition: txop.cc:620
void SetTxDroppedCallback(TxDropped callback)
Definition: txop.cc:151
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
Definition: packet.cc:227
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
virtual void DoInitialize(void)
Initialize() implementation.
Definition: txop.cc:345
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1022
Time GetBackoffStart(void) const
Return the time when the backoff procedure started.
Definition: txop.cc:226
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.
Definition: mac-low.cc:426
virtual void Cancel(void)
Cancel the transmission.
Definition: txop.cc:710
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
Definition: txop.h:504
void UpdateBackoffSlotsNow(uint32_t nSlots, Time backoffUpdateBound)
Update backoff slots that nSlots has passed.
Definition: txop.cc:232
bool CanStartNextPolling(void) const
Check if the next PCF transmission can fit in the remaining CFP duration.
Definition: txop.cc:804
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)
Definition: mac-low.cc:478
uint32_t GetMinCw(void) const
Return the minimum contention window size.
Definition: txop.cc:272
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:97
uint32_t m_cwMax
the CW maximum
Definition: txop.h:507
virtual void NotifyOff(void)
When off operation occurs, the queue gets cleaned up.
Definition: txop.cc:546
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: txop.cc:212
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...
Definition: pointer.h:220
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:370
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
uint16_t GetNextSequenceNumberFor(const WifiMacHeader *hdr)
Return the next sequence number for the given header.
AttributeValue implementation for Time.
Definition: nstime.h:1076
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: txop.cc:305
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
WifiMacType
Combination of valid MAC header type/subtype.
Hold an unsigned integer type.
Definition: uinteger.h:44
virtual bool IsCfPeriod(void) const
This function indicates whether it is the CF period.
Definition: mac-low.cc:2969
void NextFragment(void)
Continue to the next fragment.
Definition: txop.cc:375
static TypeId GetTypeId(void)
Get the type ID.
Definition: txop.cc:42
bool NeedRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
Headers for Block ack response.
Definition: ctrl-headers.h:181
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
virtual bool IsAccessRequested(void) const
Definition: txop.cc:435
virtual bool IsQosTxop() const
Check for QoS TXOP.
Definition: txop.cc:810
virtual uint32_t GetNextFragmentSize(void) const
Calculate the size of the next fragment.
Definition: txop.cc:398
uint32_t m_cwMin
the CW minimum
Definition: txop.h:506
int64_t GetMicroSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:363
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.
Definition: txop.cc:353
void SetNoRetry(void)
Un-set the Retry bit in the Frame Control field.
Ptr< MacLow > GetLow(void) const
Return the MacLow associated with this Txop.
Definition: txop.cc:339
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.
Definition: txop.cc:648
uint32_t GetCw(void) const
Definition: txop.cc:199
Hold objects of type Ptr<T>.
Definition: pointer.h:36
virtual void NotifySleep(void)
When sleep operation occurs, if there is a pending packet transmission, it will be reinserted to the ...
Definition: txop.cc:535
void EnableAck(void)
Wait ACKTimeout for an ACK.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
uint32_t GetMaxCw(void) const
Return the maximum contention window size.
Definition: txop.cc:278
virtual void MissedBlockAck(uint8_t nMpdus)
Event handler when a Block ACK timeout has occurred.
Definition: txop.cc:828
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.
Definition: txop.cc:561
Ptr< WifiMacQueue > m_queue
the wifi MAC queue
Definition: txop.h:500
virtual void DoDispose(void)
Destructor implementation.
Definition: txop.cc:97
an EUI-48 address
Definition: mac48-address.h:43
bool NeedDataRetransmission(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Check if DATA should be re-transmitted if ACK was missed.
Definition: txop.cc:360
Ptr< const Packet > m_currentPacket
the current packet
Definition: txop.h:521
void SetMacLow(const Ptr< MacLow > low)
Set MacLow associated with this Txop.
Definition: txop.cc:123
virtual bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
Definition: txop.cc:367
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: nstime.h:1077
virtual Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
Definition: txop.cc:414
virtual void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: txop.cc:527
bool IsGroup(void) const
void DisableRts(void)
Do not send rts and wait for cts before sending data.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
virtual void NotifyInternalCollision(void)
Notify the DCF that internal collision has occurred.
Definition: txop.cc:512
Ptr< MacLow > m_low
the MacLow
Definition: txop.h:502
virtual bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
Definition: txop.cc:390
void TxDroppedPacket(Ptr< const WifiMacQueueItem > item)
Pass the packet included in the wifi MAC queue item to the packet dropped callback.
Definition: txop.cc:159
void SetType(WifiMacType type, bool resetToDsFromDs=true)
Set Type/Subtype values with the correct values depending on the given type.
uint32_t m_cw
the current CW
Definition: txop.h:508
Txop()
Definition: txop.cc:76
MacLowTransmissionParameters m_currentParams
current transmission parameters
Definition: txop.h:523
virtual void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: txop.cc:296
void SetSequenceNumber(uint16_t seq)
Set the sequence number of the header.
void SetMinCw(uint32_t minCw)
Set the minimum contention window size.
Definition: txop.cc:175
void SetMaxCw(uint32_t maxCw)
Set the maximum contention window size.
Definition: txop.cc:187
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:262
bool m_accessRequested
flag whether channel access is already requested
Definition: txop.h:509
bool CanTransmitNextCfFrame(void) const
This function decides if a CF frame can be transmitted in the current CFP.
Definition: mac-low.cc:2975
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
Definition: txop.cc:264
Time m_backoffStart
the backoffStart variable is used to keep track of the time at which a backoff was started or the tim...
Definition: txop.h:516
virtual void GotAck(void)
Event handler when an ACK is received.
Definition: txop.cc:593
virtual void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: txop.cc:568
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
void SetTxMiddle(const Ptr< MacTxMiddle > txMiddle)
Set MacTxMiddle this Txop is associated to.
Definition: txop.cc:116
virtual void NotifyCollision(void)
Notify the DCF that collision has occurred.
Definition: txop.cc:519
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
uint32_t GetBackoffSlots(void) const
Return the current number of backoff slots.
Definition: txop.cc:220
Ptr< WifiMacQueue > GetWifiMacQueue() const
Return the packet queue associated with this Txop.
Definition: txop.cc:168
void MissedCfPollResponse(bool expectedCfAck)
Event handler when a response to a CF-POLL frame is missed.
Definition: txop.cc:662
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
void SetDsTo(void)
Set the To DS bit in the Frame Control field.
TxOk m_txOkCallback
the transmit OK callback
Definition: txop.h:497
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.
Definition: txop.cc:130
void SetDsFrom(void)
Set the From DS bit in the Frame Control field.
uint8_t m_fragmentNumber
the fragment number
Definition: txop.h:524
void SetAifsn(uint8_t aifsn)
Set the number of slots that make up an AIFS.
Definition: txop.cc:257
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual void NotifyAccessRequested(void)
Notify that access request has been received.
Definition: txop.cc:441
WifiMacHeader m_currentHdr
the current header
Definition: txop.h:522
void SetTxFailedCallback(TxFailed callback)
Definition: txop.cc:144
virtual ~Txop()
Definition: txop.cc:91
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1270
Ptr< WifiRemoteStationManager > m_stationManager
the wifi remote station manager
Definition: txop.h:503
virtual uint32_t GetFragmentOffset(void) const
Calculate the offset for the current fragment.
Definition: txop.cc:406
void SetTxOkCallback(TxOk callback)
Definition: txop.cc:137
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, double rxSnr, WifiMode txMode, double dataSnr)
Event handler when a Block ACK is received.
Definition: txop.cc:822
void SetFragmentNumber(uint8_t frag)
Set the fragment number of the header.
void DisableAck(void)
Do not wait for Ack after data transmission.
virtual uint32_t GetFragmentSize(void) const
Calculate the size of the current fragment.
Definition: txop.cc:382
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: uinteger.h:45
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
Definition: txop.cc:205
a unique identifier for an interface.
Definition: type-id.h:58
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.
Definition: type-id.cc:915
void StartBackoffNow(uint32_t nSlots)
Definition: txop.cc:241
void RequestAccess(Ptr< Txop > state, bool isCfPeriod=false)
virtual bool HasTxop(void) const
Check if the station has TXOP granted for the next MPDU.
Definition: txop.cc:834
virtual void NotifyWakeUp(void)
When wake up operation occurs, channel access will be restarted.
Definition: txop.cc:554
Implements the IEEE 802.11 MAC header.
TxDropped m_txDroppedCallback
the packet dropped callback
Definition: txop.h:499
uint16_t GetSequenceControl(void) const
Return the raw Sequence Control field.
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
Handle packet fragmentation and retransmissions for data and management frames.
Definition: txop.h:64
Time GetTxopLimit(void) const
Return the TXOP limit.
Definition: txop.cc:290