A Discrete-Event Network Simulator
API
edca-txop-n.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006, 2009 INRIA
4  * Copyright (c) 2009 MIRKO BANCHI
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Author: Mirko Banchi <mk.banchi@gmail.com>
21  */
22 #include "ns3/log.h"
23 #include "ns3/assert.h"
24 #include "ns3/pointer.h"
25 
26 #include "edca-txop-n.h"
27 #include "mac-low.h"
28 #include "dcf-manager.h"
29 #include "mac-tx-middle.h"
30 #include "wifi-mac-trailer.h"
31 #include "wifi-mac.h"
32 #include "random-stream.h"
33 #include "wifi-mac-queue.h"
34 #include "msdu-aggregator.h"
35 #include "mgt-headers.h"
37 
38 #undef NS_LOG_APPEND_CONTEXT
39 #define NS_LOG_APPEND_CONTEXT if (m_low != 0) { std::clog << "[mac=" << m_low->GetAddress () << "] "; }
40 
41 namespace ns3 {
42 
43 NS_LOG_COMPONENT_DEFINE ("EdcaTxopN");
44 
45 class EdcaTxopN::Dcf : public DcfState
46 {
47 public:
48  Dcf (EdcaTxopN * txop)
49  : m_txop (txop)
50  {
51  }
52 private:
53  virtual void DoNotifyAccessGranted (void)
54  {
56  }
57  virtual void DoNotifyInternalCollision (void)
58  {
60  }
61  virtual void DoNotifyCollision (void)
62  {
64  }
65  virtual void DoNotifyChannelSwitching (void)
66  {
68  }
69  virtual void DoNotifySleep (void)
70  {
71  m_txop->NotifySleep ();
72  }
73  virtual void DoNotifyWakeUp (void)
74  {
75  m_txop->NotifyWakeUp ();
76  }
78 };
79 
81 {
82 public:
85  m_txop (txop) {
86  }
87 
88  virtual ~TransmissionListener () {}
89 
90  virtual void GotCts (double snr, WifiMode txMode)
91  {
92  m_txop->GotCts (snr, txMode);
93  }
94  virtual void MissedCts (void)
95  {
96  m_txop->MissedCts ();
97  }
98  virtual void GotAck (double snr, WifiMode txMode)
99  {
100  m_txop->GotAck (snr, txMode);
101  }
102  virtual void MissedAck (void)
103  {
104  m_txop->MissedAck ();
105  }
106  virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address source, WifiMode txMode)
107  {
108  m_txop->GotBlockAck (blockAck, source,txMode);
109  }
110  virtual void MissedBlockAck (void)
111  {
113  }
114  virtual void StartNext (void)
115  {
116  m_txop->StartNext ();
117  }
118  virtual void Cancel (void)
119  {
120  m_txop->Cancel ();
121  }
122  virtual void EndTxNoAck (void)
123  {
124  m_txop->EndTxNoAck ();
125  }
127  {
128  return m_txop->GetEdcaQueue ();
129  }
130 
131 private:
133 };
134 
136 {
137 public:
140  m_txop (txop) {
141  }
143 
144  virtual void BlockAckInactivityTimeout (Mac48Address address, uint8_t tid)
145  {
146  m_txop->SendDelbaFrame (address, tid, false);
147  }
149  {
150  return m_txop->GetEdcaQueue ();
151  }
152  virtual void CompleteTransfer (Mac48Address recipient, uint8_t tid)
153  {
154  m_txop->CompleteAmpduTransfer (recipient, tid);
155  }
156  virtual void SetAmpdu(bool ampdu)
157  {
158  return m_txop->SetAmpduExist (ampdu);
159  }
160  virtual void CompleteMpduTx(Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp)
161  {
162  m_txop->CompleteMpduTx (packet, hdr, tstamp);
163  }
164  virtual uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr)
165  {
166  return m_txop->GetNextSequenceNumberfor (hdr);
167  }
168  virtual uint16_t PeekNextSequenceNumberfor (WifiMacHeader *hdr)
169  {
170  return m_txop->PeekNextSequenceNumberfor (hdr);
171  }
172  virtual Ptr<const Packet> PeekNextPacketInBaQueue (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
173  {
174  return m_txop->PeekNextRetransmitPacket (header, recipient, tid, timestamp);
175  }
176  virtual void RemoveFromBaQueue (uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
177  {
178  m_txop->RemoveRetransmitPacket(tid, recipient, seqnumber);
179  }
180  virtual bool GetBlockAckAgreementExists (Mac48Address address, uint8_t tid)
181  {
182  return m_txop->GetBaAgreementExists (address,tid);
183  }
184  virtual uint32_t GetNOutstandingPackets (Mac48Address address, uint8_t tid)
185  {
186  return m_txop->GetNOutstandingPacketsInBa (address, tid);
187  }
188  virtual uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const
189  {
190  return m_txop->GetNRetryNeededPackets (recipient, tid);
191  }
193  {
194  return m_txop->GetMsduAggregator ();
195  }
197  {
198  return m_txop->MapSrcAddressForAggregation (hdr);
199  }
201  {
202  return m_txop->MapDestAddressForAggregation (hdr);
203  }
204 
205 private:
207 };
208 
210 
211 TypeId
213 {
214  static TypeId tid = TypeId ("ns3::EdcaTxopN")
216  .SetGroupName ("Wifi")
218  .AddAttribute ("BlockAckThreshold", "If number of packets in this queue reaches this value,\
219  block ack mechanism is used. If this value is 0, block ack is never used.",
220  UintegerValue (0),
223  MakeUintegerChecker<uint8_t> (0, 64))
224  .AddAttribute ("BlockAckInactivityTimeout", "Represents max time (blocks of 1024 micro seconds) allowed for block ack\
225  inactivity. If this value isn't equal to 0 a timer start after that a\
226  block ack setup is completed and will be reset every time that a block\
227  ack frame is received. If this value is 0, block ack inactivity timeout won't be used.",
228  UintegerValue (0),
230  MakeUintegerChecker<uint16_t> ())
231  .AddAttribute ("Queue", "The WifiMacQueue object",
232  PointerValue (),
234  MakePointerChecker<WifiMacQueue> ())
235  ;
236  return tid;
237 }
238 
240  : m_manager (0),
241  m_currentPacket (0),
242  m_aggregator (0),
243  m_typeOfStation (STA),
244  m_blockAckType (COMPRESSED_BLOCK_ACK),
245  m_ampduExist (false)
246 {
247  NS_LOG_FUNCTION (this);
250  m_dcf = new EdcaTxopN::Dcf (this);
251  m_queue = CreateObject<WifiMacQueue> ();
252  m_rng = new RealRandomStream ();
254  m_baManager = new BlockAckManager ();
259  m_baManager->SetMaxPacketDelay (m_queue->GetMaxDelay ());
262 }
263 
265 {
266  NS_LOG_FUNCTION (this);
267 }
268 
269 void
271 {
272  NS_LOG_FUNCTION (this);
273  m_queue = 0;
274  m_low = 0;
275  m_stationManager = 0;
276  delete m_transmissionListener;
277  delete m_dcf;
278  delete m_rng;
280  delete m_baManager;
281  delete m_blockAckListener;
283  m_dcf = 0;
284  m_rng = 0;
286  m_baManager = 0;
287  m_blockAckListener = 0;
288  m_txMiddle = 0;
289  m_aggregator = 0;
290 }
291 
292 bool
294 {
295  return m_baManager->ExistsAgreement (address, tid);
296 }
297 
298 uint32_t
300 {
301  return m_baManager->GetNBufferedPackets (address, tid);
302 }
303 
304 uint32_t
305 EdcaTxopN::GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const
306 {
307  return m_baManager->GetNRetryNeededPackets (recipient, tid);
308 }
309 
310 void
312 {
313  m_baManager->CompleteAmpduExchange (recipient, tid);
314 }
315 
316 void
318 {
319  NS_LOG_FUNCTION (this << manager);
320  m_manager = manager;
321  m_manager->Add (m_dcf);
322 }
323 
324 void
326 {
327  NS_LOG_FUNCTION (this << &callback);
328  m_txOkCallback = callback;
329 }
330 
331 void
333 {
334  NS_LOG_FUNCTION (this << &callback);
335  m_txFailedCallback = callback;
336 }
337 
338 void
340 {
341  NS_LOG_FUNCTION (this << remoteManager);
342  m_stationManager = remoteManager;
344 }
345 void
347 {
348  NS_LOG_FUNCTION (this << static_cast<uint32_t> (type));
349  m_typeOfStation = type;
350 }
351 
352 enum TypeOfStation
354 {
355  NS_LOG_FUNCTION (this);
356  return m_typeOfStation;
357 }
358 
361 {
362  NS_LOG_FUNCTION (this);
363  return m_queue;
364 }
365 
366 void
367 EdcaTxopN::SetMinCw (uint32_t minCw)
368 {
369  NS_LOG_FUNCTION (this << minCw);
370  m_dcf->SetCwMin (minCw);
371 }
372 
373 void
374 EdcaTxopN::SetMaxCw (uint32_t maxCw)
375 {
376  NS_LOG_FUNCTION (this << maxCw);
377  m_dcf->SetCwMax (maxCw);
378 }
379 
380 void
381 EdcaTxopN::SetAifsn (uint32_t aifsn)
382 {
383  NS_LOG_FUNCTION (this << aifsn);
384  m_dcf->SetAifsn (aifsn);
385 }
386 
387 uint32_t
389 {
390  NS_LOG_FUNCTION (this);
391  return m_dcf->GetCwMin ();
392 }
393 
394 uint32_t
396 {
397  NS_LOG_FUNCTION (this);
398  return m_dcf->GetCwMax ();
399 }
400 
401 uint32_t
403 {
404  NS_LOG_FUNCTION (this);
405  return m_dcf->GetAifsn ();
406 }
407 
408 void
410 {
411  NS_LOG_FUNCTION (this << txMiddle);
412  m_txMiddle = txMiddle;
413 }
414 
417 {
418  NS_LOG_FUNCTION (this);
419  return m_low;
420 }
421 
422 void
424 {
425  NS_LOG_FUNCTION (this << low);
426  m_low = low;
427 }
428 
429 bool
431 {
432  NS_LOG_FUNCTION (this);
433  return !m_queue->IsEmpty () || m_currentPacket != 0 || m_baManager->HasPackets ();
434 }
435 
437 {
438  return m_txMiddle->GetNextSequenceNumberfor (hdr);
439 }
440 
442 {
444 }
445 
447 EdcaTxopN::PeekNextRetransmitPacket (WifiMacHeader &header,Mac48Address recipient, uint8_t tid, Time *timestamp)
448 {
449  return m_baManager->PeekNextPacket (header,recipient,tid, timestamp);
450 }
451 
452 void
453 EdcaTxopN::RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
454 {
455  m_baManager->RemovePacket (tid, recipient, seqnumber);
456 }
457 
458 void
460 {
461  NS_LOG_FUNCTION (this);
462  if (m_currentPacket == 0)
463  {
464  if (m_queue->IsEmpty () && !m_baManager->HasPackets ())
465  {
466  NS_LOG_DEBUG ("queue is empty");
467  return;
468  }
470  {
472  return;
473  }
474  /* check if packets need retransmission are stored in BlockAckManager */
476  if (m_currentPacket == 0)
477  {
478  if (m_queue->PeekFirstAvailable (&m_currentHdr, m_currentPacketTimestamp, m_qosBlockedDestinations) == 0)
479  {
480  NS_LOG_DEBUG ("no available packets in the queue");
481  return;
482  }
484  && m_blockAckThreshold > 0
486  && SetupBlockAckIfNeeded ())
487  {
488  return;
489  }
491  NS_ASSERT (m_currentPacket != 0);
492 
493  uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr);
494  m_currentHdr.SetSequenceNumber (sequence);
498  m_fragmentNumber = 0;
499  NS_LOG_DEBUG ("dequeued size=" << m_currentPacket->GetSize () <<
500  ", to=" << m_currentHdr.GetAddr1 () <<
501  ", seq=" << m_currentHdr.GetSequenceControl ());
503  {
504  VerifyBlockAck ();
505  }
506  }
507  }
509  params.DisableOverrideDurationId ();
510  if (m_currentHdr.GetAddr1 ().IsGroup ())
511  {
512  params.DisableRts ();
513  params.DisableAck ();
514  params.DisableNextData ();
516  &m_currentHdr,
517  params,
519 
520  NS_LOG_DEBUG ("tx broadcast");
521  }
523  {
525  }
526  else
527  {
529  {
530  params.DisableAck ();
531  }
532  else
533  {
534  params.EnableAck ();
535  }
537  && !m_currentHdr.IsQosAmsdu ())
538  ||
539  (m_currentHdr.IsData ()
541  && (m_blockAckThreshold == 0
543  {
544  //With COMPRESSED_BLOCK_ACK fragmentation must be avoided.
545  params.DisableRts ();
546  WifiMacHeader hdr;
547  Ptr<Packet> fragment = GetFragmentPacket (&hdr);
548  if (IsLastFragment ())
549  {
550  NS_LOG_DEBUG ("fragmenting last fragment size=" << fragment->GetSize ());
551  params.DisableNextData ();
552  }
553  else
554  {
555  NS_LOG_DEBUG ("fragmenting size=" << fragment->GetSize ());
557  }
558  m_low->StartTransmission (fragment, &hdr, params,
560  }
561  else
562  {
563  WifiMacHeader peekedHdr;
564  Time tstamp;
565  if (m_currentHdr.IsQosData ()
566  && m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
569  && m_aggregator != 0 && !m_currentHdr.IsRetry ())
570  {
571  /* here is performed aggregation */
572  Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
573  m_aggregator->Aggregate (m_currentPacket, currentAggregatedPacket,
574  MapSrcAddressForAggregation (peekedHdr),
575  MapDestAddressForAggregation (peekedHdr));
576  bool aggregated = false;
577  bool isAmsdu = false;
578  Ptr<const Packet> peekedPacket = m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
580  m_currentHdr.GetAddr1 (), &tstamp);
581  while (peekedPacket != 0)
582  {
583  aggregated = m_aggregator->Aggregate (peekedPacket, currentAggregatedPacket,
584  MapSrcAddressForAggregation (peekedHdr),
585  MapDestAddressForAggregation (peekedHdr));
586  if (aggregated)
587  {
588  isAmsdu = true;
589  m_queue->Remove (peekedPacket);
590  }
591  else
592  {
593  break;
594  }
595  peekedPacket = m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
597  }
598  if (isAmsdu)
599  {
602  m_currentPacket = currentAggregatedPacket;
603  currentAggregatedPacket = 0;
604  NS_LOG_DEBUG ("tx unicast A-MSDU");
605  }
606  }
607  if (NeedRts ())
608  {
609  params.EnableRts ();
610  NS_LOG_DEBUG ("tx unicast rts");
611  }
612  else
613  {
614  params.DisableRts ();
615  NS_LOG_DEBUG ("tx unicast");
616  }
617  params.DisableNextData ();
619  params, m_transmissionListener);
620  if(!GetAmpduExist())
621  CompleteTx ();
622  }
623  }
624 }
625 
627 {
628  NS_LOG_FUNCTION (this);
629  NotifyCollision ();
630 }
631 
632 void
634 {
635  NS_LOG_FUNCTION (this);
638 }
639 
640 void
641 EdcaTxopN::GotCts (double snr, WifiMode txMode)
642 {
643  NS_LOG_FUNCTION (this << snr << txMode);
644  NS_LOG_DEBUG ("got cts");
645 }
646 
647 void
649 {
650  NS_LOG_FUNCTION (this);
651  NS_LOG_DEBUG ("missed cts");
652  if (!NeedRtsRetransmission ())
653  {
654  NS_LOG_DEBUG ("Cts Fail");
656  if (!m_txFailedCallback.IsNull ())
657  {
659  }
660  if (GetAmpduExist())
661  {
663 
664  NS_LOG_DEBUG ("Transmit Block Ack Request");
665  CtrlBAckRequestHeader reqHdr;
666  reqHdr.SetType (COMPRESSED_BLOCK_ACK);
667  uint8_t tid = m_currentHdr.GetQosTid ();
669  reqHdr.SetTidInfo (tid);
670  reqHdr.SetHtImmediateAck(true);
671  Ptr<Packet> bar = Create<Packet> ();
672  bar->AddHeader (reqHdr);
673  Bar request (bar, m_currentHdr.GetAddr1 (), tid, reqHdr.MustSendHtImmediateAck());
674  m_currentBar = request;
675  WifiMacHeader hdr;
677  hdr.SetAddr1 (request.recipient);
678  hdr.SetAddr2 (m_low->GetAddress ());
679  hdr.SetAddr3 (m_low->GetBssid ());
680  hdr.SetDsNotTo ();
681  hdr.SetDsNotFrom ();
682  hdr.SetNoRetry ();
683  hdr.SetNoMoreFragments ();
684  m_currentPacket = request.bar;
685  m_currentHdr = hdr;
686  }
687  else
688  {
689  m_currentPacket = 0;
690  }
691  // to reset the dcf.
692  m_dcf->ResetCw ();
693  }
694  else
695  {
696  m_dcf->UpdateFailedCw ();
697  }
700 }
701 
702 void
704 {
705  NS_LOG_FUNCTION (this);
706  m_queue->Flush ();
707  m_currentPacket = 0;
708 }
709 void
711 {
712  NS_LOG_FUNCTION (this);
713  if (m_currentPacket != 0)
714  {
715  m_queue->PushFront (m_currentPacket, m_currentHdr);
716  m_currentPacket = 0;
717  }
718 }
719 void
721 {
722  NS_LOG_FUNCTION (this);
724 }
725 
726 void
728 {
729  NS_LOG_FUNCTION (this << packet << &hdr);
730  WifiMacTrailer fcs;
731  uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize ();
733  packet, fullPacketSize);
734  m_queue->Enqueue (packet, hdr);
736 }
737 
738 void
739 EdcaTxopN::GotAck (double snr, WifiMode txMode)
740 {
741  NS_LOG_FUNCTION (this << snr << txMode);
742  if (!NeedFragmentation ()
743  || IsLastFragment ()
744  || m_currentHdr.IsQosAmsdu ())
745  {
746  NS_LOG_DEBUG ("got ack. tx done.");
747  if (!m_txOkCallback.IsNull ())
748  {
750  }
751 
752  if (m_currentHdr.IsAction ())
753  {
754  WifiActionHeader actionHdr;
756  p->RemoveHeader (actionHdr);
757  if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK
759  {
760  MgtDelBaHeader delBa;
761  p->PeekHeader (delBa);
762  if (delBa.IsByOriginator ())
763  {
765  }
766  else
767  {
769  }
770  }
771  }
772  m_currentPacket = 0;
773 
774  m_dcf->ResetCw ();
777  }
778  else
779  {
780  NS_LOG_DEBUG ("got ack. tx not done, size=" << m_currentPacket->GetSize ());
781  }
782 }
783 
784 void
786 {
787  NS_LOG_FUNCTION (this);
788  NS_LOG_DEBUG ("missed ack");
789  if (!NeedDataRetransmission ())
790  {
791  NS_LOG_DEBUG ("Ack Fail");
793  if (!m_txFailedCallback.IsNull ())
794  {
796  }
797  if (!GetAmpduExist())
798  {
799  // to reset the dcf.
800  m_currentPacket = 0;
801  }
802  else
803  {
804  NS_LOG_DEBUG ("Transmit Block Ack Request");
805  CtrlBAckRequestHeader reqHdr;
806  reqHdr.SetType (COMPRESSED_BLOCK_ACK);
807  uint8_t tid = m_currentHdr.GetQosTid ();
809  reqHdr.SetTidInfo (tid);
810  reqHdr.SetHtImmediateAck(true);
811  Ptr<Packet> bar = Create<Packet> ();
812  bar->AddHeader (reqHdr);
813  Bar request (bar, m_currentHdr.GetAddr1 (), tid, reqHdr.MustSendHtImmediateAck());
814  m_currentBar = request;
815  WifiMacHeader hdr;
817  hdr.SetAddr1 (request.recipient);
818  hdr.SetAddr2 (m_low->GetAddress ());
819  hdr.SetAddr3 (m_low->GetBssid ());
820  hdr.SetDsNotTo ();
821  hdr.SetDsNotFrom ();
822  hdr.SetNoRetry ();
823  hdr.SetNoMoreFragments ();
824  m_currentPacket = request.bar;
825  m_currentHdr = hdr;
826  }
827  m_dcf->ResetCw ();
828  }
829  else
830  {
831  NS_LOG_DEBUG ("Retransmit");
833  m_dcf->UpdateFailedCw ();
834  }
837 }
838 
839 void
841 {
842  NS_LOG_FUNCTION (this);
843  NS_LOG_DEBUG ("missed block ack");
844  if (NeedBarRetransmission())
845  {
846  if (!GetAmpduExist())
847  {
848  //should i report this to station addressed by ADDR1?
849  NS_LOG_DEBUG ("Retransmit block ack request");
851  }
852  else
853  {
854  //standard says when loosing a BlockAck originator may send a BAR page 139
855  NS_LOG_DEBUG ("Transmit Block Ack Request");
856  CtrlBAckRequestHeader reqHdr;
857  reqHdr.SetType (COMPRESSED_BLOCK_ACK);
858  uint8_t tid = 0;
859  if (m_currentHdr.IsQosData())
860  {
861  tid = m_currentHdr.GetQosTid ();
863  }
864  else if (m_currentHdr.IsBlockAckReq())
865  {
866  CtrlBAckRequestHeader baReqHdr;
867  m_currentPacket->PeekHeader (baReqHdr);
868  tid = baReqHdr.GetTidInfo ();
869  reqHdr.SetStartingSequence (baReqHdr.GetStartingSequence ());
870  }
871  else if (m_currentHdr.IsBlockAck())
872  {
873  CtrlBAckResponseHeader baRespHdr;
874  m_currentPacket->PeekHeader (baRespHdr);
875  tid = baRespHdr.GetTidInfo();
877  }
878  reqHdr.SetTidInfo (tid);
879  reqHdr.SetHtImmediateAck (true);
880  Ptr<Packet> bar = Create<Packet> ();
881  bar->AddHeader (reqHdr);
882  Bar request (bar, m_currentHdr.GetAddr1 (), tid, reqHdr.MustSendHtImmediateAck ());
883  m_currentBar = request;
884  WifiMacHeader hdr;
886  hdr.SetAddr1 (request.recipient);
887  hdr.SetAddr2 (m_low->GetAddress ());
888  hdr.SetAddr3 (m_low->GetBssid ());
889  hdr.SetDsNotTo ();
890  hdr.SetDsNotFrom ();
891  hdr.SetNoRetry ();
892  hdr.SetNoMoreFragments ();
893 
894  m_currentPacket = request.bar;
895  m_currentHdr = hdr;
896  }
897  m_dcf->UpdateFailedCw ();
898  }
899  else
900  {
901  NS_LOG_DEBUG ("Block Ack Request Fail");
902  // to reset the dcf.
903  m_currentPacket = 0;
904  m_dcf->ResetCw ();
905  }
908 }
909 
912 {
913  return m_aggregator;
914 }
915 
916 void
918 {
919  NS_LOG_FUNCTION (this);
920  if ((m_currentPacket != 0
921  || !m_queue->IsEmpty () || m_baManager->HasPackets ())
922  && !m_dcf->IsAccessRequested ())
923  {
925  }
926 }
927 
928 void
930 {
931  NS_LOG_FUNCTION (this);
932  if (m_currentPacket == 0
933  && (!m_queue->IsEmpty () || m_baManager->HasPackets ())
934  && !m_dcf->IsAccessRequested ())
935  {
937  }
938 }
939 
940 bool
942 {
943  NS_LOG_FUNCTION (this);
946 }
947 
948 bool
950 {
951  NS_LOG_FUNCTION (this);
954 }
955 
956 bool
958 {
959  NS_LOG_FUNCTION (this);
962 }
963 
964 bool
966 {
967  uint8_t tid = 0;
968  uint16_t seqNumber = 0;
969  if (m_currentHdr.IsQosData ())
970  {
971  tid = m_currentHdr.GetQosTid ();
972  seqNumber = m_currentHdr.GetSequenceNumber ();
973  }
974  else if (m_currentHdr.IsBlockAckReq ())
975  {
976  CtrlBAckRequestHeader baReqHdr;
977  m_currentPacket->PeekHeader (baReqHdr);
978  tid = baReqHdr.GetTidInfo ();
979  seqNumber = baReqHdr.GetStartingSequence ();
980  }
981  else if (m_currentHdr.IsBlockAck ())
982  {
983  CtrlBAckResponseHeader baRespHdr;
984  m_currentPacket->PeekHeader (baRespHdr);
985  tid = baRespHdr.GetTidInfo ();
986  seqNumber = m_currentHdr.GetSequenceNumber ();
987  }
988  return m_baManager->NeedBarRetransmission (tid, seqNumber, m_currentHdr.GetAddr1 ());
989 }
990 
991 void
993 {
994  NS_LOG_FUNCTION (this);
996 }
997 
998 void
1000 {
1001  NS_LOG_FUNCTION (this);
1002  NS_LOG_DEBUG ("start next packet fragment");
1003  /* this callback is used only for fragments. */
1004  NextFragment ();
1005  WifiMacHeader hdr;
1006  Ptr<Packet> fragment = GetFragmentPacket (&hdr);
1008  params.EnableAck ();
1009  params.DisableRts ();
1010  params.DisableOverrideDurationId ();
1011  if (IsLastFragment ())
1012  {
1013  params.DisableNextData ();
1014  }
1015  else
1016  {
1017  params.EnableNextData (GetNextFragmentSize ());
1018  }
1019  Low ()->StartTransmission (fragment, &hdr, params, m_transmissionListener);
1020 }
1021 
1022 void
1024 {
1025  NS_LOG_FUNCTION (this);
1026  NS_LOG_DEBUG ("transmission cancelled");
1027 }
1028 
1029 void
1031 {
1032  NS_LOG_FUNCTION (this);
1033  NS_LOG_DEBUG ("a transmission that did not require an ACK just finished");
1034  m_currentPacket = 0;
1035  m_dcf->ResetCw ();
1038 }
1039 
1040 bool
1042 {
1043  NS_LOG_FUNCTION (this);
1045  m_currentPacket);
1046 }
1047 
1048 uint32_t
1050 {
1051  NS_LOG_FUNCTION (this);
1054 }
1055 
1056 uint32_t
1058 {
1059  NS_LOG_FUNCTION (this);
1062 }
1063 
1064 uint32_t
1066 {
1067  NS_LOG_FUNCTION (this);
1070 }
1071 
1072 
1073 bool
1075 {
1076  NS_LOG_FUNCTION (this);
1079 }
1080 
1083 {
1084  NS_LOG_FUNCTION (this << hdr);
1085  *hdr = m_currentHdr;
1087  uint32_t startOffset = GetFragmentOffset ();
1088  Ptr<Packet> fragment;
1089  if (IsLastFragment ())
1090  {
1091  hdr->SetNoMoreFragments ();
1092  }
1093  else
1094  {
1095  hdr->SetMoreFragments ();
1096  }
1097  fragment = m_currentPacket->CreateFragment (startOffset,
1098  GetFragmentSize ());
1099  return fragment;
1100 }
1101 
1102 void
1104 {
1105  NS_LOG_FUNCTION (this << static_cast<uint32_t> (ac));
1106  m_ac = ac;
1107 }
1108 
1111 {
1112  NS_LOG_FUNCTION (this << &hdr);
1113  Mac48Address retval;
1115  {
1116  retval = hdr.GetAddr2 ();
1117  }
1118  else
1119  {
1120  retval = hdr.GetAddr3 ();
1121  }
1122  return retval;
1123 }
1124 
1127 {
1128  NS_LOG_FUNCTION (this << &hdr);
1129  Mac48Address retval;
1131  {
1132  retval = hdr.GetAddr1 ();
1133  }
1134  else
1135  {
1136  retval = hdr.GetAddr3 ();
1137  }
1138  return retval;
1139 }
1140 
1141 void
1143 {
1144  NS_LOG_FUNCTION (this << aggr);
1145  m_aggregator = aggr;
1146 }
1147 
1148 void
1150 {
1151  NS_LOG_FUNCTION (this << packet << &hdr);
1152  WifiMacTrailer fcs;
1153  uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize ();
1154  m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr,
1155  packet, fullPacketSize);
1156  m_queue->PushFront (packet, hdr);
1158 }
1159 
1160 void
1162 {
1163  NS_LOG_FUNCTION (this << respHdr << recipient);
1164  NS_LOG_DEBUG ("received ADDBA response from " << recipient);
1165  uint8_t tid = respHdr->GetTid ();
1167  {
1168  if (respHdr->GetStatusCode ().IsSuccess ())
1169  {
1170  NS_LOG_DEBUG ("block ack agreement established with " << recipient);
1171  m_baManager->UpdateAgreement (respHdr, recipient);
1172  }
1173  else
1174  {
1175  NS_LOG_DEBUG ("discard ADDBA response" << recipient);
1176  m_baManager->NotifyAgreementUnsuccessful (recipient, tid);
1177  }
1178  }
1180 }
1181 
1182 void
1184 {
1185  NS_LOG_FUNCTION (this << delBaHdr << recipient);
1186  NS_LOG_DEBUG ("received DELBA frame from=" << recipient);
1187  m_baManager->TearDownBlockAck (recipient, delBaHdr->GetTid ());
1188 }
1189 
1190 void
1192 {
1193  NS_LOG_FUNCTION (this << blockAck << recipient);
1194  NS_LOG_DEBUG ("got block ack from=" << recipient);
1195  m_baManager->NotifyGotBlockAck (blockAck, recipient, txMode);
1196  if (!m_txOkCallback.IsNull ())
1197  {
1199  }
1200  m_currentPacket = 0;
1201  m_dcf->ResetCw ();
1204 }
1205 
1206 void
1208 {
1209  NS_LOG_FUNCTION (this);
1210  uint8_t tid = m_currentHdr.GetQosTid ();
1211  Mac48Address recipient = m_currentHdr.GetAddr1 ();
1212  uint16_t sequence = m_currentHdr.GetSequenceNumber ();
1214  {
1215  m_baManager->SwitchToBlockAckIfNeeded (recipient, tid, sequence);
1216  }
1218  {
1220  }
1221 }
1222 
1224 {
1225  return m_ampduExist;
1226 }
1227 
1229 {
1230  m_ampduExist = ampdu;
1231 }
1232 
1233 void
1235 {
1236  NS_LOG_FUNCTION (this);
1238  {
1239  if (!m_currentHdr.IsRetry ())
1240  {
1242  }
1246  }
1247 }
1248 
1249 void
1251 {
1252  m_baManager->StorePacket (packet, hdr, tstamp);
1256 }
1257 
1258 bool
1260 {
1261  NS_LOG_FUNCTION (this);
1262  uint8_t tid = m_currentHdr.GetQosTid ();
1263  Mac48Address recipient = m_currentHdr.GetAddr1 ();
1264 
1265  uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, recipient);
1266 
1267  if (packets >= m_blockAckThreshold)
1268  {
1269  /* Block ack setup */
1270  uint16_t startingSequence = m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, recipient);
1271  SendAddBaRequest (recipient, tid, startingSequence, m_blockAckInactivityTimeout, true);
1272  return true;
1273  }
1274  return false;
1275 }
1276 
1277 void
1279 {
1280  NS_LOG_FUNCTION (this << &bar);
1281  WifiMacHeader hdr;
1283  hdr.SetAddr1 (bar.recipient);
1284  hdr.SetAddr2 (m_low->GetAddress ());
1285  hdr.SetAddr3 (m_low->GetBssid ());
1286  hdr.SetDsNotTo ();
1287  hdr.SetDsNotFrom ();
1288  hdr.SetNoRetry ();
1289  hdr.SetNoMoreFragments ();
1290 
1291  m_currentPacket = bar.bar;
1292  m_currentHdr = hdr;
1293 
1295  params.DisableRts ();
1296  params.DisableNextData ();
1297  params.DisableOverrideDurationId ();
1298  if (bar.immediate)
1299  {
1301  {
1302  params.EnableBasicBlockAck ();
1303  }
1305  {
1306  params.EnableCompressedBlockAck ();
1307  }
1308  else if (m_blockAckType == MULTI_TID_BLOCK_ACK)
1309  {
1310  NS_FATAL_ERROR ("Multi-tid block ack is not supported");
1311  }
1312  }
1313  else
1314  {
1315  //Delayed block ack
1316  params.EnableAck ();
1317  }
1319 }
1320 
1321 void
1323 {
1324  NS_LOG_FUNCTION (this);
1328 }
1329 
1330 void
1332 {
1333  NS_LOG_FUNCTION (this << static_cast<uint32_t> (threshold));
1334  m_blockAckThreshold = threshold;
1335  m_baManager->SetBlockAckThreshold (threshold);
1336 }
1337 
1338 void
1340 {
1341  NS_LOG_FUNCTION (this << timeout);
1343 }
1344 
1345 uint8_t
1347 {
1348  NS_LOG_FUNCTION (this);
1349  return m_blockAckThreshold;
1350 }
1351 
1352 void
1353 EdcaTxopN::SendAddBaRequest (Mac48Address dest, uint8_t tid, uint16_t startSeq,
1354  uint16_t timeout, bool immediateBAck)
1355 {
1356  NS_LOG_FUNCTION (this << dest << static_cast<uint32_t> (tid) << startSeq << timeout << immediateBAck);
1357  NS_LOG_DEBUG ("sent ADDBA request to " << dest);
1358  WifiMacHeader hdr;
1359  hdr.SetAction ();
1360  hdr.SetAddr1 (dest);
1361  hdr.SetAddr2 (m_low->GetAddress ());
1362  hdr.SetAddr3 (m_low->GetAddress ());
1363  hdr.SetDsNotTo ();
1364  hdr.SetDsNotFrom ();
1365 
1366  WifiActionHeader actionHdr;
1369  actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action);
1370 
1371  Ptr<Packet> packet = Create<Packet> ();
1372  /*Setting ADDBARequest header*/
1373  MgtAddBaRequestHeader reqHdr;
1374  reqHdr.SetAmsduSupport (true);
1375  if (immediateBAck)
1376  {
1377  reqHdr.SetImmediateBlockAck ();
1378  }
1379  else
1380  {
1381  reqHdr.SetDelayedBlockAck ();
1382  }
1383  reqHdr.SetTid (tid);
1384  /* For now we don't use buffer size field in the ADDBA request frame. The recipient
1385  * will choose how many packets it can receive under block ack.
1386  */
1387  reqHdr.SetBufferSize (0);
1388  reqHdr.SetTimeout (timeout);
1389  reqHdr.SetStartingSequence (startSeq);
1390 
1391  m_baManager->CreateAgreement (&reqHdr, dest);
1392 
1393  packet->AddHeader (reqHdr);
1394  packet->AddHeader (actionHdr);
1395 
1396  m_currentPacket = packet;
1397  m_currentHdr = hdr;
1398 
1399  uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr);
1400  m_currentHdr.SetSequenceNumber (sequence);
1404 
1406  params.EnableAck ();
1407  params.DisableRts ();
1408  params.DisableNextData ();
1409  params.DisableOverrideDurationId ();
1410 
1413 }
1414 
1415 void
1416 EdcaTxopN::SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator)
1417 {
1418  NS_LOG_FUNCTION (this << addr << static_cast<uint32_t> (tid) << byOriginator);
1419  WifiMacHeader hdr;
1420  hdr.SetAction ();
1421  hdr.SetAddr1 (addr);
1422  hdr.SetAddr2 (m_low->GetAddress ());
1423  hdr.SetAddr3 (m_low->GetAddress ());
1424  hdr.SetDsNotTo ();
1425  hdr.SetDsNotFrom ();
1426 
1427  MgtDelBaHeader delbaHdr;
1428  delbaHdr.SetTid (tid);
1429  if (byOriginator)
1430  {
1431  delbaHdr.SetByOriginator ();
1432  }
1433  else
1434  {
1435  delbaHdr.SetByRecipient ();
1436  }
1437 
1438  WifiActionHeader actionHdr;
1441  actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action);
1442 
1443  Ptr<Packet> packet = Create<Packet> ();
1444  packet->AddHeader (delbaHdr);
1445  packet->AddHeader (actionHdr);
1446 
1447  PushFront (packet, hdr);
1448 }
1449 
1450 int64_t
1452 {
1453  NS_LOG_FUNCTION (this << stream);
1454  m_rng->AssignStreams (stream);
1455  return 1;
1456 }
1457 
1458 void
1460 {
1461  NS_LOG_FUNCTION (this);
1462  m_dcf->ResetCw ();
1465 }
1466 
1467 void
1469 {
1470  NS_LOG_FUNCTION (this << hdr);
1471  if (!m_txOkCallback.IsNull ())
1472  {
1474  }
1475 }
1476 
1477 void
1479 {
1480  NS_LOG_FUNCTION (this << hdr);
1481  if (!m_txFailedCallback.IsNull ())
1482  {
1484  }
1485 }
1486 
1487 } // namespace ns3
virtual uint16_t PeekNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i...
Definition: edca-txop-n.cc:168
Keep track of destination address - TID pairs that are waiting for a block ACK response.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:268
void SetAction()
Set Type/Subtype values for an action header.
void SetRetry(void)
Set the Retry bit in the Frame Control field.
void SetUnblockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
virtual void SetMaxCw(uint32_t maxCw)
Set the maximum congestion window size.
Definition: edca-txop-n.cc:374
void SetMoreFragments(void)
Set the More Fragment bit in the Frame Control field.
void SetType(enum BlockAckType type)
Set the block ACK type.
TransmissionListener * m_transmissionListener
Definition: edca-txop-n.h:520
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:529
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void DoInitialize()
Initialize() implementation.
void SetQosAckPolicy(enum QosAckPolicy policy)
Set the QoS ACK policy in the QoS control field.
TypeId AddConstructor(void)
Definition: type-id.h:460
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:517
virtual Mac48Address GetDestAddressForAggregation(const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:200
void NotifyWakeUp(void)
When wake up operation occurs, restart channel access.
Definition: edca-txop-n.cc:720
void SetBlockAckInactivityTimeout(uint16_t timeout)
bool NeedDataRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
uint32_t GetCwMin(void) const
Return the minimum congestion window size.
Definition: dcf-manager.cc:79
uint32_t GetFragmentSize(void)
Calculate the size of the current fragment.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
uint16_t m_blockAckInactivityTimeout
Definition: edca-txop-n.h:542
void CreateAgreement(const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient)
virtual uint32_t GetNOutstandingPackets(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:184
virtual bool Aggregate(Ptr< const Packet > packet, Ptr< Packet > aggregatedPacket, Mac48Address src, Mac48Address dest)=0
void VerifyBlockAck(void)
Verifies if dequeued packet has to be transmitted with ack policy Block Ack.
See IEEE 802.11 chapter 7.3.1.11 Header format: | category: 1 | action value: 1 |.
Definition: mgt-headers.h:336
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: edca-txop-n.cc:633
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:346
void EnableBasicBlockAck(void)
Wait BASICBLOCKACKTimeout for a Basic Block Ack Response frame.
Definition: mac-low.cc:167
void StorePacket(Ptr< const Packet > packet, const WifiMacHeader &hdr, Time tStamp)
bool NeedDataRetransmission(void)
Check if DATA should be re-transmitted if ACK was missed.
Definition: edca-txop-n.cc:957
void RequestAccess(DcfState *state)
Definition: dcf-manager.cc:455
void CompleteMpduTx(Ptr< const Packet > packet, WifiMacHeader hdr, Time tstamp)
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).
Definition: edca-txop-n.cc:122
bool IsAction() const
Return true if the header is an Action header.
Mac48Address GetBssid(void) const
Return the Basic Service Set Identification.
Definition: mac-low.cc:644
void SetTxFailedCallback(TxFailed callback)
Definition: edca-txop-n.cc:332
Mac48Address GetAddr3(void) const
Return the address in the Address 3 field.
Implement the header for management frames of type add block ack request.
Definition: mgt-headers.h:444
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:739
void SetNoMoreFragments(void)
Un-set the More Fragment bit in the Frame Control Field.
void RegisterBlockAckListenerForAc(enum AcIndex ac, MacLowAggregationCapableTransmissionListener *listener)
Definition: mac-low.cc:2507
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1078
virtual void MissedBlockAck(void)
ns3::MacLow did not receive an expected BLOCK_ACK within BlockAckTimeout.
Definition: edca-txop-n.cc:110
#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
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
Definition: edca-txop-n.cc:965
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model...
bool GetAmpduExist(void)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
enum WifiMacType GetType(void) const
Return the type (enum WifiMacType)
uint8_t m_blockAckThreshold
Definition: edca-txop-n.h:539
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:339
bool HasBar(struct Bar &bar)
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:766
bool IsBroadcast(void) const
void SetBlockAckType(enum BlockAckType bAckType)
WifiMacHeader m_currentHdr
Definition: edca-txop-n.h:531
void NotifySleep(void)
When sleep operation occurs, re-insert pending packet into front of the queue.
Definition: edca-txop-n.cc:710
void SetAction(enum CategoryValue type, ActionValue action)
Set action for this Action header.
Definition: mgt-headers.cc:482
#define NS_FATAL_ERROR(msg)
Fatal error handling.
Definition: fatal-error.h:100
void SetHtImmediateAck(bool immediateAck)
Enable or disable HT immediate ACK.
void SetAifsn(uint32_t aifsn)
Definition: dcf-manager.cc:57
bool IsBlockAck(void) const
Return true if the header is a Block ACK header.
virtual void Cancel(void)
Invoked if this transmission was canceled one way or another.
Definition: edca-txop-n.cc:118
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
virtual Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: edca-txop-n.cc:192
CategoryValue GetCategory()
Return the category value.
Definition: mgt-headers.cc:515
virtual Ptr< const Packet > PeekNextPacketInBaQueue(WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
Definition: edca-txop-n.cc:172
bool HasPackets(void) const
Returns true if there are packets that need of retransmission or at least a BAR is scheduled...
void ResetCw(void)
Update the value of the CW variable to take into account a transmission success or a transmission abo...
Definition: dcf-manager.cc:90
ns3::Time timeout
void SetTid(uint8_t)
Set Traffic ID (TID).
void SetAmpduExist(bool ampdu)
Block Ack Request.
friend class TransmissionListener
Definition: edca-txop-n.h:512
listen to events coming from ns3::MacLow.
Definition: mac-low.h:61
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:93
virtual void MissedAck(void)
ns3::MacLow did not receive an expected ACK within AckTimeout.
Definition: edca-txop-n.cc:102
void Add(DcfState *dcf)
Definition: dcf-manager.cc:375
void NextFragment(void)
Continue to the next fragment.
Definition: edca-txop-n.cc:992
bool IsQosAmsdu(void) const
Check if the A-MSDU present bit is set in the QoS control field.
void SetTxOkCallback(TxOk callback)
Definition: edca-txop-n.cc:325
BlockAckManager * m_baManager
Definition: edca-txop-n.h:535
control how a packet is transmitted.
Definition: mac-low.h:296
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: edca-txop-n.cc:949
void SetAmsduSupport(bool supported)
Enable or disable A-MSDU support.
Definition: mgt-headers.cc:784
struct Bar m_currentBar
Definition: edca-txop-n.h:543
virtual void DoNotifyChannelSwitching(void)
Called by DcfManager to notify a DcfState subclass that a channel switching occured.
Definition: edca-txop-n.cc:65
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: edca-txop-n.cc:402
virtual bool GetBlockAckAgreementExists(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:180
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
Ptr< const Packet > PeekNextPacket(WifiMacHeader &hdr, Mac48Address recipient, uint8_t tid, Time *timestamp)
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.
Definition: edca-txop-n.cc:61
void SetTxFailedCallback(TxFailed callback)
DcfManager * m_manager
Definition: edca-txop-n.h:514
void MissedAck(void)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:785
enum TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:353
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:423
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:416
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:228
uint8_t GetQosTid(void) const
Return the Traffic ID of a QoS header.
Ptr< WifiRemoteStationManager > m_stationManager
Definition: edca-txop-n.h:523
uint8_t GetTidInfo(void) const
Return the Traffic ID (TID).
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2227
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:84
void GotDelBaFrame(const MgtDelBaHeader *delBaHdr, Mac48Address recipient)
virtual uint32_t GetSerializedSize(void) const
void SetQueue(Ptr< WifiMacQueue > queue)
void NotifyAccessGranted(void)
Notify the EDCAF that access has been granted.
Definition: edca-txop-n.cc:459
RandomStream * m_rng
Definition: edca-txop-n.h:522
void RemoveRetransmitPacket(uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
Remove a packet after you peek in the retransmit queue and get it.
Definition: edca-txop-n.cc:453
void ReportFinalDataFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportDataFailed if NeedDataRetransmission returns false...
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:210
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:626
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
virtual uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:188
void UpdateAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
void SetDsNotTo(void)
Un-set the To DS bit in the Frame Control field.
void SetAddr3(Mac48Address address)
Fill the Address 3 field with the given address.
virtual void SetMinCw(uint32_t minCw)
Set the minimum congestion window size.
Definition: edca-txop-n.cc:367
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
void SendAddBaRequest(Mac48Address recipient, uint8_t tid, uint16_t startSeq, uint16_t timeout, bool immediateBAck)
Sends an ADDBA Request to establish a block ack agreement with sta addressed by recipient for tid tid...
Ptr< const Packet > PeekNextRetransmitPacket(WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
Definition: edca-txop-n.cc:447
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
virtual void GotAck(double snr, WifiMode txMode)
Definition: edca-txop-n.cc:98
uint16_t GetSequenceControl(void) const
Return the raw Sequence Control field.
Hold an unsigned integer type.
Definition: uinteger.h:44
bool GetBaAgreementExists(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:293
void SetBlockAckThreshold(uint8_t threshold)
Set threshold for block ACK mechanism.
void NotifyAgreementUnsuccessful(Mac48Address recipient, uint8_t tid)
MacTxMiddle * m_txMiddle
Definition: edca-txop-n.h:519
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: edca-txop-n.cc:648
Manage a set of ns3::DcfStateHandle a set of independent ns3::DcfState, each of which represents a si...
Definition: dcf-manager.h:252
enum BlockAckActionValue blockAck
Definition: mgt-headers.h:407
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
Set up WifiRemoteStationManager associated with this BlockAckManager.
uint16_t PeekNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i...
Definition: edca-txop-n.cc:441
keep track of the state needed for a single DCF function.
Definition: dcf-manager.h:46
bool IsQosBlockAck(void) const
Return if the QoS ACK policy is Block ACK.
Headers for Block ack response.
Definition: ctrl-headers.h:183
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1296
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: edca-txop-n.cc:703
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:599
void SetTxMiddle(MacTxMiddle *txMiddle)
bool IsAccessRequested(void) const
Definition: dcf-manager.cc:133
void SetBlockDestinationCallback(Callback< void, Mac48Address, uint8_t > callback)
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< Packet > GetFragmentPacket(WifiMacHeader *hdr)
Get the next fragment from the packet with appropriate Wifi header for the fragment.
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address source, WifiMode txMode)
Definition: edca-txop-n.cc:106
virtual ~EdcaTxopN()
Definition: edca-txop-n.cc:264
virtual void StartNext(void)
Invoked when ns3::MacLow wants to start a new transmission as configured by MacLowTransmissionParamet...
Definition: edca-txop-n.cc:114
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:305
virtual void DoNotifyWakeUp(void)
Called by DcfManager to notify a DcfState subclass that the device has begun to wake up...
Definition: edca-txop-n.cc:73
uint8_t m_fragmentNumber
Definition: edca-txop-n.h:524
void SetTxOkCallback(TxOk callback)
Time m_currentPacketTimestamp
Definition: edca-txop-n.h:541
uint32_t GetCwMax(void) const
Return the maximum congestion window size.
Definition: dcf-manager.cc:84
TypeId SetGroupName(std::string groupName)
Definition: type-id.cc:645
void SetCwMin(uint32_t minCw)
Set the minimum congestion window size.
Definition: dcf-manager.cc:62
virtual void GotCts(double snr, WifiMode txMode)
Definition: edca-txop-n.cc:90
virtual void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, MacLowTransmissionListener *listener)
Definition: mac-low.cc:683
Mac48Address recipient
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:122
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:277
void SetByOriginator(void)
Set the initiator bit in the DELBA.
void SetTidInfo(uint8_t tid)
Set Traffic ID (TID).
uint16_t GetStartingSequence(void) const
Return the starting sequence number.
uint32_t GetFragmentOffset(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
EdcaTxopN * m_txop
Definition: edca-txop-n.cc:77
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
Definition: edca-txop-n.cc:388
void SetByRecipient(void)
Un-set the initiator bit in the DELBA.
void MissedBlockAck(void)
Event handler when a Block ACK timeout has occurred.
Definition: edca-txop-n.cc:840
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
void StartBackoffNow(uint32_t nSlots)
Definition: dcf-manager.cc:109
void PrepareForQueue(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fullPacketSize)
void SetNoRetry(void)
Un-set the Retry bit in the Frame Control field.
bool NeedFragmentation(void) const
Check if the current packet should be fragmented.
void EnableCompressedBlockAck(void)
Wait COMPRESSEDBLOCKACKTimeout for a Compressed Block Ack Response frame.
Definition: mac-low.cc:172
virtual void CompleteTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:152
virtual void MissedCts(void)
ns3::MacLow did not receive an expected CTS within CtsTimeout.
Definition: edca-txop-n.cc:94
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.
Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: edca-txop-n.cc:911
Hold objects of type Ptr.
Definition: pointer.h:36
void SetAccessCategory(enum AcIndex ac)
Set the access category of this EDCAF.
bool IsGroup(void) const
void EnableAck(void)
Wait ACKTimeout for an ACK.
Definition: mac-low.cc:187
uint16_t PeekNextSequenceNumberfor(const WifiMacHeader *hdr)
Return the next sequence number for the Traffic ID and destination, but do not pick it (i...
bool RemovePacket(uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
Remove a packet after you peek in the queue and get it.
void SetAddr2(Mac48Address address)
Fill the Address 2 field with the given address.
uint32_t GetFragmentSize(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
uint8_t GetTid(void) const
Return the Traffic ID (TID).
Mac48Address MapDestAddressForAggregation(const WifiMacHeader &hdr)
bool ExistsAgreementInState(Mac48Address recipient, uint8_t tid, enum OriginatorBlockAckAgreement::State state) const
bool SetupBlockAckIfNeeded()
If number of packets in the queue reaches m_blockAckThreshold value, an ADDBA Request frame is sent t...
StatusCode GetStatusCode(void) const
Return the status code.
Definition: mgt-headers.cc:969
void StartNext(void)
Start transmission for the next fragment.
Definition: edca-txop-n.cc:999
an EUI-48 address
Definition: mac48-address.h:43
bool IsByOriginator(void) const
Check if the initiator bit in the DELBA is setted.
virtual void DoNotifySleep(void)
Called by DcfManager to notify a DcfState subclass that the device has begun to sleep.
Definition: edca-txop-n.cc:69
virtual Mac48Address GetSrcAddressForAggregation(const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:196
Ptr< const Packet > GetNextPacket(WifiMacHeader &hdr)
void Cancel(void)
Cancel the transmission.
void BaTxOk(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
void SetManager(DcfManager *manager)
Set DcfManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:317
void DisableRts(void)
Do not send rts and wait for cts before sending data.
Definition: mac-low.cc:202
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:727
uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:436
void SetMsduAggregator(Ptr< MsduAggregator > aggr)
void SetBlockAckInactivityCallback(Callback< void, Mac48Address, uint8_t, bool > callback)
uint8_t GetTid(void) const
Return the Traffic ID (TID).
Definition: mgt-headers.cc:975
uint8_t GetTidInfo(void) const
Return the Traffic ID (TID).
virtual uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:164
void SetMaxPacketDelay(Time maxDelay)
void NotifyMpduTransmission(Mac48Address recipient, uint8_t tid, uint16_t nextSeqNumber, WifiMacHeader::QosAckPolicy policy)
virtual Ptr< WifiMacQueue > GetQueue(void)
Returns the EDCA queue to check if there are packets that can be aggregated with a Block Ack...
Definition: edca-txop-n.cc:148
bool NeedBarRetransmission(uint8_t tid, uint16_t seqNumber, Mac48Address recipient)
This function returns true if the lifetime of the packets a BAR refers to didn't expire yet else it r...
void PushFront(Ptr< const Packet > packet, const WifiMacHeader &hdr)
bool SwitchToBlockAckIfNeeded(Mac48Address recipient, uint8_t tid, uint16_t startingSeq)
enum BlockAckType m_blockAckType
Definition: edca-txop-n.h:540
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dcf-manager.cc:68
virtual void DoNotifyAccessGranted(void)
Called by DcfManager to notify a DcfState subclass that access to the medium is granted and can start...
Definition: edca-txop-n.cc:53
virtual void BlockAckInactivityTimeout(Mac48Address address, uint8_t tid)
Typically is called in order to notify EdcaTxopN that a block ack inactivity timeout occurs for the b...
Definition: edca-txop-n.cc:144
static TypeId GetTypeId(void)
Definition: edca-txop-n.cc:212
void BaTxFailed(const WifiMacHeader &hdr)
The packet we sent was successfully received by the receiver.
uint32_t GetNBufferedPackets(Mac48Address recipient, uint8_t tid) const
bool MustSendHtImmediateAck(void) const
Check if the current ACK policy is immediate.
static TypeId GetTypeId(void)
Definition: dcf.cc:31
uint32_t GetNextFragmentSize(void)
Calculate the size of the next fragment.
void SetSequenceNumber(uint16_t seq)
Set the sequence number of the header.
bool IsData(void) const
Return true if the Type is DATA.
bool IsQosData(void) const
Return true if the Type is DATA and Subtype is one of the possible values for QoS DATA...
void EnableRts(void)
Send a RTS, and wait CTSTimeout for a CTS.
Definition: mac-low.cc:197
void CompleteConfig(void)
Complete block ACK configuration.
virtual void RemoveFromBaQueue(uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
Remove a packet after you peek in the retransmit queue and get it.
Definition: edca-txop-n.cc:176
uint32_t GetCw(void) const
Definition: dcf-manager.cc:118
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dcf-manager.cc:74
void Unblock(Mac48Address dest, uint8_t tid)
Un-block the given destination address and TID (e.g.
bool IsBlockAckReq(void) const
Return true if the header is a Block ACK Request header.
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: edca-txop-n.cc:917
void SetBlockAckThreshold(uint8_t nPackets)
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:572
QosBlockedDestinations * m_qosBlockedDestinations
Definition: edca-txop-n.h:534
void CompleteAmpduExchange(Mac48Address recipient, uint8_t tid)
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:688
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:311
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:236
Ptr< MacLow > m_low
Definition: edca-txop-n.h:518
typedef for union of different ActionValues
Definition: mgt-headers.h:402
Ptr< const Packet > bar
uint8_t GetBlockAckThreshold(void) const
Return the current threshold for block ACK mechanism.
friend class Dcf
Definition: edca-txop-n.h:510
void CompleteTx(void)
For now is typically invoked to complete transmission of a packets sent with ack policy Block Ack: th...
bool IsSuccess(void) const
Return whether the status code is success.
Definition: status-code.cc:42
void SetTxMiddle(MacTxMiddle *txMiddle)
Definition: edca-txop-n.cc:409
void NotifyGotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, WifiMode txMode)
void GotCts(double snr, WifiMode txMode)
Event handler when a CTS is received.
Definition: edca-txop-n.cc:641
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
void EnableNextData(uint32_t size)
Definition: mac-low.cc:142
void DoDispose()
Destructor implementation.
Definition: edca-txop-n.cc:270
void DisableOverrideDurationId(void)
Do not force the duration/id field of the packet: its value is automatically calculated by the MacLow...
Definition: mac-low.cc:157
bool IsLastFragment(void) const
Check if the current fragment is the last fragment.
void Block(Mac48Address dest, uint8_t tid)
Block the given destination address and TID from sending (e.g.
void DisableNextData(void)
Do not attempt to send data burst after current transmission.
Definition: mac-low.cc:147
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Definition: edca-txop-n.cc:395
bool NeedRtsRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
Ptr< WifiMacQueue > m_queue
Definition: edca-txop-n.h:515
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: edca-txop-n.cc:929
void SetType(enum WifiMacType type)
Set Type/Subtype values with the correct values depending on the given type.
virtual uint32_t GetNext(uint32_t min, uint32_t max)=0
Get integer between min and max (including min and max).
Mac48Address GetAddr1(void) const
Return the address in the Address 1 field.
bool NeedRts(void)
Check if the current packet should be sent with a RTS protection.
Definition: edca-txop-n.cc:941
tuple address
Definition: first.py:37
virtual void CompleteMpduTx(Ptr< const Packet > packet, WifiMacHeader hdr, Time tstamp)
This function stores an MPDU (part of an A-MPDU) in blockackagreement (i.e.
Definition: edca-txop-n.cc:160
void SendBlockAckRequest(const struct Bar &bar)
After that all packets, for which a block ack agreement was established, have been transmitted...
TypeOfStation
Enumeration for type of station.
Definition: edca-txop-n.h:59
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: dcf-manager.cc:95
Ptr< MsduAggregator > m_aggregator
Definition: edca-txop-n.h:532
Manages all block ack agreements for an originator station.
bool NeedRts(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
ActionValue GetAction()
Return the action value.
Definition: mgt-headers.cc:535
Headers for Block ack request.
Definition: ctrl-headers.h:49
bool ExistsAgreement(Mac48Address recipient, uint8_t tid) const
void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address recipient, WifiMode txMode)
Event handler when a Block ACK is received.
void FlushAggregateQueue(void)
This function is called to flush the aggregate queue, which is used for A-MPDU.
Definition: mac-low.cc:2848
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.
Definition: edca-txop-n.cc:57
void SetFragmentNumber(uint8_t frag)
Set the fragment number of the header.
void DisableAck(void)
Do not wait for Ack after data transmission.
Definition: mac-low.cc:192
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
uint32_t GetNOutstandingPacketsInBa(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:299
uint16_t GetNextSeqNumberByTidAndAddress(uint8_t tid, Mac48Address addr) const
Return the next sequence number for the Traffic ID and destination.
a unique identifier for an interface.
Definition: type-id.h:57
void ReportFinalRtsFailed(Mac48Address address, const WifiMacHeader *header)
Should be invoked after calling ReportRtsFailed if NeedRtsRetransmission returns false.
void SetStartingSequence(uint16_t seq)
Set the starting sequence number from the given raw sequence control field.
bool NeedsAccess(void) const
Check if the EDCAF requires access.
Definition: edca-txop-n.cc:430
TypeId SetParent(TypeId tid)
Definition: type-id.cc:638
void SetQosAmsdu(void)
Set that A-MSDU is present.
AcIndex
This enumeration defines the Access Categories as an enumeration with values corresponding to the AC ...
Definition: qos-utils.h:35
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
AggregationCapableTransmissionListener * m_blockAckListener
Definition: edca-txop-n.h:521
bool IsRetry(void) const
Return if the Retry bit is set.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:253
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:346
Implements the IEEE 802.11 MAC header.
Mac48Address GetAddr2(void) const
Return the address in the Address 2 field.
void GotAddBaResponse(const MgtAddBaResponseHeader *respHdr, Mac48Address recipient)
void TearDownBlockAck(Mac48Address recipient, uint8_t tid)
Implements the IEEE 802.11 MAC trailer.
virtual void SetAifsn(uint32_t aifsn)
Definition: edca-txop-n.cc:381
TypeOfStation m_typeOfStation
Definition: edca-txop-n.h:533
Mac48Address MapSrcAddressForAggregation(const WifiMacHeader &hdr)
This functions are used only to correctly set addresses in a-msdu subframe.
virtual uint32_t GetSerializedSize(void) const
Ptr< WifiMacQueue > GetEdcaQueue() const
Return the packet queue associated with this EdcaTxopN.
Definition: edca-txop-n.cc:360
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
virtual Ptr< WifiMacQueue > GetQueue(void)
Definition: edca-txop-n.cc:126
uint16_t GetSequenceNumber(void) const
Return the sequence number of the header.
Dcf(EdcaTxopN *txop)
Definition: edca-txop-n.cc:48