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  }
192 
193 private:
195 };
196 
198 
199 TypeId
201 {
202  static TypeId tid = TypeId ("ns3::EdcaTxopN")
205  .AddAttribute ("BlockAckThreshold", "If number of packets in this queue reaches this value,\
206  block ack mechanism is used. If this value is 0, block ack is never used.",
207  UintegerValue (0),
210  MakeUintegerChecker<uint8_t> (0, 64))
211  .AddAttribute ("BlockAckInactivityTimeout", "Represents max time (blocks of 1024 micro seconds) allowed for block ack\
212  inactivity. If this value isn't equal to 0 a timer start after that a\
213  block ack setup is completed and will be reset every time that a block\
214  ack frame is received. If this value is 0, block ack inactivity timeout won't be used.",
215  UintegerValue (0),
217  MakeUintegerChecker<uint16_t> ())
218  .AddAttribute ("Queue", "The WifiMacQueue object",
219  PointerValue (),
221  MakePointerChecker<WifiMacQueue> ())
222  ;
223  return tid;
224 }
225 
227  : m_manager (0),
228  m_currentPacket (0),
229  m_aggregator (0),
230  m_blockAckType (COMPRESSED_BLOCK_ACK),
231  m_ampduExist (false)
232 {
233  NS_LOG_FUNCTION (this);
236  m_dcf = new EdcaTxopN::Dcf (this);
237  m_queue = CreateObject<WifiMacQueue> ();
238  m_rng = new RealRandomStream ();
240  m_baManager = new BlockAckManager ();
245  m_baManager->SetMaxPacketDelay (m_queue->GetMaxDelay ());
248 }
249 
251 {
252  NS_LOG_FUNCTION (this);
253 }
254 
255 void
257 {
258  NS_LOG_FUNCTION (this);
259  m_queue = 0;
260  m_low = 0;
261  m_stationManager = 0;
262  delete m_transmissionListener;
263  delete m_dcf;
264  delete m_rng;
266  delete m_baManager;
267  delete m_blockAckListener;
269  m_dcf = 0;
270  m_rng = 0;
272  m_baManager = 0;
273  m_blockAckListener = 0;
274  m_txMiddle = 0;
275  m_aggregator = 0;
276 }
277 
278 bool
280 {
281  return m_baManager->ExistsAgreement (address, tid);
282 }
283 
284 uint32_t
286 {
287  return m_baManager->GetNBufferedPackets (address, tid);
288 }
289 
290 uint32_t
291 EdcaTxopN::GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const
292 {
293  return m_baManager->GetNRetryNeededPackets (recipient, tid);
294 }
295 
296 void
298 {
299  m_baManager->CompleteAmpduExchange (recipient, tid);
300 }
301 
302 void
304 {
305  NS_LOG_FUNCTION (this << manager);
306  m_manager = manager;
307  m_manager->Add (m_dcf);
308 }
309 
310 void
312 {
313  NS_LOG_FUNCTION (this << &callback);
314  m_txOkCallback = callback;
315 }
316 
317 void
319 {
320  NS_LOG_FUNCTION (this << &callback);
321  m_txFailedCallback = callback;
322 }
323 
324 void
326 {
327  NS_LOG_FUNCTION (this << remoteManager);
328  m_stationManager = remoteManager;
330 }
331 void
333 {
334  NS_LOG_FUNCTION (this << static_cast<uint32_t> (type));
335  m_typeOfStation = type;
336 }
337 
338 enum TypeOfStation
340 {
341  NS_LOG_FUNCTION (this);
342  return m_typeOfStation;
343 }
344 
347 {
348  NS_LOG_FUNCTION (this);
349  return m_queue;
350 }
351 
352 void
353 EdcaTxopN::SetMinCw (uint32_t minCw)
354 {
355  NS_LOG_FUNCTION (this << minCw);
356  m_dcf->SetCwMin (minCw);
357 }
358 
359 void
360 EdcaTxopN::SetMaxCw (uint32_t maxCw)
361 {
362  NS_LOG_FUNCTION (this << maxCw);
363  m_dcf->SetCwMax (maxCw);
364 }
365 
366 void
367 EdcaTxopN::SetAifsn (uint32_t aifsn)
368 {
369  NS_LOG_FUNCTION (this << aifsn);
370  m_dcf->SetAifsn (aifsn);
371 }
372 
373 uint32_t
375 {
376  NS_LOG_FUNCTION (this);
377  return m_dcf->GetCwMin ();
378 }
379 
380 uint32_t
382 {
383  NS_LOG_FUNCTION (this);
384  return m_dcf->GetCwMax ();
385 }
386 
387 uint32_t
389 {
390  NS_LOG_FUNCTION (this);
391  return m_dcf->GetAifsn ();
392 }
393 
394 void
396 {
397  NS_LOG_FUNCTION (this << txMiddle);
398  m_txMiddle = txMiddle;
399 }
400 
403 {
404  NS_LOG_FUNCTION (this);
405  return m_low;
406 }
407 
408 void
410 {
411  NS_LOG_FUNCTION (this << low);
412  m_low = low;
413 }
414 
415 bool
417 {
418  NS_LOG_FUNCTION (this);
419  return !m_queue->IsEmpty () || m_currentPacket != 0 || m_baManager->HasPackets ();
420 }
421 
423 {
424  return m_txMiddle->GetNextSequenceNumberfor (hdr);
425 }
426 
428 {
430 }
431 
433 EdcaTxopN::PeekNextRetransmitPacket (WifiMacHeader &header,Mac48Address recipient, uint8_t tid, Time *timestamp)
434 {
435  return m_baManager->PeekNextPacket (header,recipient,tid, timestamp);
436 }
437 
438 void
439 EdcaTxopN::RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
440 {
441  m_baManager->RemovePacket (tid, recipient, seqnumber);
442 }
443 
444 void
446 {
447  NS_LOG_FUNCTION (this);
448  if (m_currentPacket == 0)
449  {
450  if (m_queue->IsEmpty () && !m_baManager->HasPackets ())
451  {
452  NS_LOG_DEBUG ("queue is empty");
453  return;
454  }
456  {
458  return;
459  }
460  /* check if packets need retransmission are stored in BlockAckManager */
462  if (m_currentPacket == 0)
463  {
464  if (m_queue->PeekFirstAvailable (&m_currentHdr, m_currentPacketTimestamp, m_qosBlockedDestinations) == 0)
465  {
466  NS_LOG_DEBUG ("no available packets in the queue");
467  return;
468  }
470  && m_blockAckThreshold > 0
472  && SetupBlockAckIfNeeded ())
473  {
474  return;
475  }
477  NS_ASSERT (m_currentPacket != 0);
478 
479  uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr);
480  m_currentHdr.SetSequenceNumber (sequence);
484  m_fragmentNumber = 0;
485  NS_LOG_DEBUG ("dequeued size=" << m_currentPacket->GetSize () <<
486  ", to=" << m_currentHdr.GetAddr1 () <<
487  ", seq=" << m_currentHdr.GetSequenceControl ());
489  {
490  VerifyBlockAck ();
491  }
492  }
493  }
495  params.DisableOverrideDurationId ();
496  if (m_currentHdr.GetAddr1 ().IsGroup ())
497  {
498  params.DisableRts ();
499  params.DisableAck ();
500  params.DisableNextData ();
501  m_low->StartTransmission (m_currentPacket,
502  &m_currentHdr,
503  params,
505 
506  NS_LOG_DEBUG ("tx broadcast");
507  }
509  {
511  }
512  else
513  {
515  {
516  params.DisableAck ();
517  }
518  else
519  {
520  params.EnableAck ();
521  }
523  && !m_currentHdr.IsQosAmsdu ())
524  ||
525  (m_currentHdr.IsData ()
527  && (m_blockAckThreshold == 0
529  {
530  //With COMPRESSED_BLOCK_ACK fragmentation must be avoided.
531  params.DisableRts ();
532  WifiMacHeader hdr;
533  Ptr<Packet> fragment = GetFragmentPacket (&hdr);
534  if (IsLastFragment ())
535  {
536  NS_LOG_DEBUG ("fragmenting last fragment size=" << fragment->GetSize ());
537  params.DisableNextData ();
538  }
539  else
540  {
541  NS_LOG_DEBUG ("fragmenting size=" << fragment->GetSize ());
543  }
544  m_low->StartTransmission (fragment, &hdr, params,
546  }
547  else
548  {
549  WifiMacHeader peekedHdr;
550  Time tstamp;
551  if (m_currentHdr.IsQosData ()
552  && m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
555  && m_aggregator != 0 && !m_currentHdr.IsRetry ())
556  {
557  /* here is performed aggregation */
558  Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
559  m_aggregator->Aggregate (m_currentPacket, currentAggregatedPacket,
560  MapSrcAddressForAggregation (peekedHdr),
561  MapDestAddressForAggregation (peekedHdr));
562  bool aggregated = false;
563  bool isAmsdu = false;
564  Ptr<const Packet> peekedPacket = m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
566  m_currentHdr.GetAddr1 (), &tstamp);
567  while (peekedPacket != 0)
568  {
569  aggregated = m_aggregator->Aggregate (peekedPacket, currentAggregatedPacket,
570  MapSrcAddressForAggregation (peekedHdr),
571  MapDestAddressForAggregation (peekedHdr));
572  if (aggregated)
573  {
574  isAmsdu = true;
575  m_queue->Remove (peekedPacket);
576  }
577  else
578  {
579  break;
580  }
581  peekedPacket = m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
583  }
584  if (isAmsdu)
585  {
587  m_currentHdr.SetAddr3 (m_low->GetBssid ());
588  m_currentPacket = currentAggregatedPacket;
589  currentAggregatedPacket = 0;
590  NS_LOG_DEBUG ("tx unicast A-MSDU");
591  }
592  }
593  if (NeedRts ())
594  {
595  params.EnableRts ();
596  NS_LOG_DEBUG ("tx unicast rts");
597  }
598  else
599  {
600  params.DisableRts ();
601  NS_LOG_DEBUG ("tx unicast");
602  }
603  params.DisableNextData ();
604  m_low->StartTransmission (m_currentPacket, &m_currentHdr,
605  params, m_transmissionListener);
606  if(!GetAmpduExist())
607  CompleteTx ();
608  }
609  }
610 }
611 
613 {
614  NS_LOG_FUNCTION (this);
615  NotifyCollision ();
616 }
617 
618 void
620 {
621  NS_LOG_FUNCTION (this);
624 }
625 
626 void
627 EdcaTxopN::GotCts (double snr, WifiMode txMode)
628 {
629  NS_LOG_FUNCTION (this << snr << txMode);
630  NS_LOG_DEBUG ("got cts");
631 }
632 
633 void
635 {
636  NS_LOG_FUNCTION (this);
637  NS_LOG_DEBUG ("missed cts");
638  if (!NeedRtsRetransmission ())
639  {
640  NS_LOG_DEBUG ("Cts Fail");
641  m_stationManager->ReportFinalRtsFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
642  if (!m_txFailedCallback.IsNull ())
643  {
645  }
646  if (GetAmpduExist())
647  {
648  m_low->FlushAggregateQueue ();
649  }
650  // to reset the dcf.
651  m_currentPacket = 0;
652  m_dcf->ResetCw ();
653  }
654  else
655  {
656  m_dcf->UpdateFailedCw ();
657  }
660 }
661 
662 void
664 {
665  NS_LOG_FUNCTION (this);
666  m_queue->Flush ();
667  m_currentPacket = 0;
668 }
669 void
671 {
672  NS_LOG_FUNCTION (this);
673  if (m_currentPacket != 0)
674  {
675  m_queue->PushFront (m_currentPacket, m_currentHdr);
676  m_currentPacket = 0;
677  }
678 }
679 void
681 {
682  NS_LOG_FUNCTION (this);
684 }
685 
686 void
688 {
689  NS_LOG_FUNCTION (this << packet << &hdr);
690  WifiMacTrailer fcs;
691  uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize ();
692  m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr,
693  packet, fullPacketSize);
694  m_queue->Enqueue (packet, hdr);
696 }
697 
698 void
699 EdcaTxopN::GotAck (double snr, WifiMode txMode)
700 {
701  NS_LOG_FUNCTION (this << snr << txMode);
702  if (!NeedFragmentation ()
703  || IsLastFragment ()
704  || m_currentHdr.IsQosAmsdu ())
705  {
706  NS_LOG_DEBUG ("got ack. tx done.");
707  if (!m_txOkCallback.IsNull ())
708  {
710  }
711 
712  if (m_currentHdr.IsAction ())
713  {
714  WifiActionHeader actionHdr;
716  p->RemoveHeader (actionHdr);
717  if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK
719  {
720  MgtDelBaHeader delBa;
721  p->PeekHeader (delBa);
722  if (delBa.IsByOriginator ())
723  {
725  }
726  else
727  {
728  m_low->DestroyBlockAckAgreement (m_currentHdr.GetAddr1 (), delBa.GetTid ());
729  }
730  }
731  }
732  m_currentPacket = 0;
733 
734  m_dcf->ResetCw ();
737  }
738  else
739  {
740  NS_LOG_DEBUG ("got ack. tx not done, size=" << m_currentPacket->GetSize ());
741  }
742 }
743 
744 void
746 {
747  NS_LOG_FUNCTION (this);
748  NS_LOG_DEBUG ("missed ack");
749  if (!NeedDataRetransmission ())
750  {
751  NS_LOG_DEBUG ("Ack Fail");
752  m_stationManager->ReportFinalDataFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
753  if (!m_txFailedCallback.IsNull ())
754  {
756  }
757  if (!GetAmpduExist())
758  {
759  // to reset the dcf.
760  m_currentPacket = 0;
761  }
762  else
763  {
764  NS_LOG_DEBUG ("Transmit Block Ack Request");
765  CtrlBAckRequestHeader reqHdr;
766  reqHdr.SetType (COMPRESSED_BLOCK_ACK);
767  uint8_t tid = m_currentHdr.GetQosTid ();
769  reqHdr.SetTidInfo (tid);
770  reqHdr.SetHtImmediateAck(true);
771  Ptr<Packet> bar = Create<Packet> ();
772  bar->AddHeader (reqHdr);
773  Bar request (bar, m_currentHdr.GetAddr1 (), tid, reqHdr.MustSendHtImmediateAck());
774  m_currentBar = request;
775  WifiMacHeader hdr;
777  hdr.SetAddr1 (request.recipient);
778  hdr.SetAddr2 (m_low->GetAddress ());
779  hdr.SetAddr3 (m_low->GetBssid ());
780  hdr.SetDsNotTo ();
781  hdr.SetDsNotFrom ();
782  hdr.SetNoRetry ();
783  hdr.SetNoMoreFragments ();
784  m_currentPacket = request.bar;
785  m_currentHdr = hdr;
786  }
787  m_dcf->ResetCw ();
788  }
789  else
790  {
791  NS_LOG_DEBUG ("Retransmit");
793  m_dcf->UpdateFailedCw ();
794  }
797 }
798 
799 void
801 {
802  NS_LOG_FUNCTION (this);
803  NS_LOG_DEBUG ("missed block ack");
804  if (NeedBarRetransmission())
805  {
806  if (!GetAmpduExist())
807  {
808  //should i report this to station addressed by ADDR1?
809  NS_LOG_DEBUG ("Retransmit block ack request");
811  }
812  else
813  {
814  //standard says when loosing a BlockAck originator may send a BAR page 139
815  NS_LOG_DEBUG ("Transmit Block Ack Request");
816  CtrlBAckRequestHeader reqHdr;
817  reqHdr.SetType (COMPRESSED_BLOCK_ACK);
818  uint8_t tid = 0;
819  if (m_currentHdr.IsQosData())
820  {
821  tid = m_currentHdr.GetQosTid ();
823  }
824  else if (m_currentHdr.IsBlockAckReq())
825  {
826  CtrlBAckRequestHeader baReqHdr;
827  m_currentPacket->PeekHeader (baReqHdr);
828  tid = baReqHdr.GetTidInfo ();
829  reqHdr.SetStartingSequence (baReqHdr.GetStartingSequence ());
830  }
831  else if (m_currentHdr.IsBlockAck())
832  {
833  CtrlBAckResponseHeader baRespHdr;
834  m_currentPacket->PeekHeader (baRespHdr);
835  tid = baRespHdr.GetTidInfo();
837  }
838  reqHdr.SetTidInfo (tid);
839  reqHdr.SetHtImmediateAck (true);
840  Ptr<Packet> bar = Create<Packet> ();
841  bar->AddHeader (reqHdr);
842  Bar request (bar, m_currentHdr.GetAddr1 (), tid, reqHdr.MustSendHtImmediateAck ());
843  m_currentBar = request;
844  WifiMacHeader hdr;
846  hdr.SetAddr1 (request.recipient);
847  hdr.SetAddr2 (m_low->GetAddress ());
848  hdr.SetAddr3 (m_low->GetBssid ());
849  hdr.SetDsNotTo ();
850  hdr.SetDsNotFrom ();
851  hdr.SetNoRetry ();
852  hdr.SetNoMoreFragments ();
853 
854  m_currentPacket = request.bar;
855  m_currentHdr = hdr;
856  }
857  m_dcf->UpdateFailedCw ();
858  }
859  else
860  {
861  NS_LOG_DEBUG ("Block Ack Request Fail");
862  // to reset the dcf.
863  m_currentPacket = 0;
864  m_dcf->ResetCw ();
865  }
868 }
869 
872 {
873  return m_aggregator;
874 }
875 
876 void
878 {
879  NS_LOG_FUNCTION (this);
880  if ((m_currentPacket != 0
881  || !m_queue->IsEmpty () || m_baManager->HasPackets ())
882  && !m_dcf->IsAccessRequested ())
883  {
885  }
886 }
887 
888 void
890 {
891  NS_LOG_FUNCTION (this);
892  if (m_currentPacket == 0
893  && (!m_queue->IsEmpty () || m_baManager->HasPackets ())
894  && !m_dcf->IsAccessRequested ())
895  {
897  }
898 }
899 
900 bool
902 {
903  NS_LOG_FUNCTION (this);
904  return m_stationManager->NeedRts (m_currentHdr.GetAddr1 (), &m_currentHdr,
906 }
907 
908 bool
910 {
911  NS_LOG_FUNCTION (this);
912  return m_stationManager->NeedRtsRetransmission (m_currentHdr.GetAddr1 (), &m_currentHdr,
914 }
915 
916 bool
918 {
919  NS_LOG_FUNCTION (this);
920  return m_stationManager->NeedDataRetransmission (m_currentHdr.GetAddr1 (), &m_currentHdr,
922 }
923 
924 bool
926 {
927  uint8_t tid = 0;
928  uint16_t seqNumber = 0;
929  if (m_currentHdr.IsQosData ())
930  {
931  tid = m_currentHdr.GetQosTid ();
932  seqNumber = m_currentHdr.GetSequenceNumber ();
933  }
934  else if (m_currentHdr.IsBlockAckReq ())
935  {
936  CtrlBAckRequestHeader baReqHdr;
937  m_currentPacket->PeekHeader (baReqHdr);
938  tid = baReqHdr.GetTidInfo ();
939  seqNumber = baReqHdr.GetStartingSequence ();
940  }
941  else if (m_currentHdr.IsBlockAck ())
942  {
943  CtrlBAckResponseHeader baRespHdr;
944  m_currentPacket->PeekHeader (baRespHdr);
945  tid = baRespHdr.GetTidInfo ();
946  seqNumber = m_currentHdr.GetSequenceNumber ();
947  }
948  return m_baManager->NeedBarRetransmission (tid, seqNumber, m_currentHdr.GetAddr1 ());
949 }
950 
951 void
953 {
954  NS_LOG_FUNCTION (this);
956 }
957 
958 void
960 {
961  NS_LOG_FUNCTION (this);
962  NS_LOG_DEBUG ("start next packet fragment");
963  /* this callback is used only for fragments. */
964  NextFragment ();
965  WifiMacHeader hdr;
966  Ptr<Packet> fragment = GetFragmentPacket (&hdr);
968  params.EnableAck ();
969  params.DisableRts ();
970  params.DisableOverrideDurationId ();
971  if (IsLastFragment ())
972  {
973  params.DisableNextData ();
974  }
975  else
976  {
978  }
979  Low ()->StartTransmission (fragment, &hdr, params, m_transmissionListener);
980 }
981 
982 void
984 {
985  NS_LOG_FUNCTION (this);
986  NS_LOG_DEBUG ("transmission cancelled");
987 }
988 
989 void
991 {
992  NS_LOG_FUNCTION (this);
993  NS_LOG_DEBUG ("a transmission that did not require an ACK just finished");
994  m_currentPacket = 0;
995  m_dcf->ResetCw ();
998 }
999 
1000 bool
1002 {
1003  NS_LOG_FUNCTION (this);
1004  return m_stationManager->NeedFragmentation (m_currentHdr.GetAddr1 (), &m_currentHdr,
1005  m_currentPacket);
1006 }
1007 
1008 uint32_t
1010 {
1011  NS_LOG_FUNCTION (this);
1012  return m_stationManager->GetFragmentSize (m_currentHdr.GetAddr1 (), &m_currentHdr,
1014 }
1015 
1016 uint32_t
1018 {
1019  NS_LOG_FUNCTION (this);
1020  return m_stationManager->GetFragmentSize (m_currentHdr.GetAddr1 (), &m_currentHdr,
1022 }
1023 
1024 uint32_t
1026 {
1027  NS_LOG_FUNCTION (this);
1028  return m_stationManager->GetFragmentOffset (m_currentHdr.GetAddr1 (), &m_currentHdr,
1030 }
1031 
1032 
1033 bool
1035 {
1036  NS_LOG_FUNCTION (this);
1037  return m_stationManager->IsLastFragment (m_currentHdr.GetAddr1 (), &m_currentHdr,
1039 }
1040 
1043 {
1044  NS_LOG_FUNCTION (this << hdr);
1045  *hdr = m_currentHdr;
1047  uint32_t startOffset = GetFragmentOffset ();
1048  Ptr<Packet> fragment;
1049  if (IsLastFragment ())
1050  {
1051  hdr->SetNoMoreFragments ();
1052  }
1053  else
1054  {
1055  hdr->SetMoreFragments ();
1056  }
1057  fragment = m_currentPacket->CreateFragment (startOffset,
1058  GetFragmentSize ());
1059  return fragment;
1060 }
1061 
1062 void
1064 {
1065  NS_LOG_FUNCTION (this << static_cast<uint32_t> (ac));
1066  m_ac = ac;
1067 }
1068 
1071 {
1072  NS_LOG_FUNCTION (this << &hdr);
1073  Mac48Address retval;
1075  {
1076  retval = hdr.GetAddr2 ();
1077  }
1078  else
1079  {
1080  retval = hdr.GetAddr3 ();
1081  }
1082  return retval;
1083 }
1084 
1087 {
1088  NS_LOG_FUNCTION (this << &hdr);
1089  Mac48Address retval;
1091  {
1092  retval = hdr.GetAddr1 ();
1093  }
1094  else
1095  {
1096  retval = hdr.GetAddr3 ();
1097  }
1098  return retval;
1099 }
1100 
1101 void
1103 {
1104  NS_LOG_FUNCTION (this << aggr);
1105  m_aggregator = aggr;
1106 }
1107 
1108 void
1110 {
1111  NS_LOG_FUNCTION (this << packet << &hdr);
1112  WifiMacTrailer fcs;
1113  uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize ();
1114  m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr,
1115  packet, fullPacketSize);
1116  m_queue->PushFront (packet, hdr);
1118 }
1119 
1120 void
1122 {
1123  NS_LOG_FUNCTION (this << respHdr << recipient);
1124  NS_LOG_DEBUG ("received ADDBA response from " << recipient);
1125  uint8_t tid = respHdr->GetTid ();
1127  {
1128  if (respHdr->GetStatusCode ().IsSuccess ())
1129  {
1130  NS_LOG_DEBUG ("block ack agreement established with " << recipient);
1131  m_baManager->UpdateAgreement (respHdr, recipient);
1132  }
1133  else
1134  {
1135  NS_LOG_DEBUG ("discard ADDBA response" << recipient);
1136  m_baManager->NotifyAgreementUnsuccessful (recipient, tid);
1137  }
1138  }
1140 }
1141 
1142 void
1144 {
1145  NS_LOG_FUNCTION (this << delBaHdr << recipient);
1146  NS_LOG_DEBUG ("received DELBA frame from=" << recipient);
1147  m_baManager->TearDownBlockAck (recipient, delBaHdr->GetTid ());
1148 }
1149 
1150 void
1152 {
1153  NS_LOG_FUNCTION (this << blockAck << recipient);
1154  NS_LOG_DEBUG ("got block ack from=" << recipient);
1155  m_baManager->NotifyGotBlockAck (blockAck, recipient, txMode);
1156  if (!m_txOkCallback.IsNull ())
1157  {
1159  }
1160  m_currentPacket = 0;
1161  m_dcf->ResetCw ();
1164 }
1165 
1166 void
1168 {
1169  NS_LOG_FUNCTION (this);
1170  uint8_t tid = m_currentHdr.GetQosTid ();
1171  Mac48Address recipient = m_currentHdr.GetAddr1 ();
1172  uint16_t sequence = m_currentHdr.GetSequenceNumber ();
1174  {
1175  m_baManager->SwitchToBlockAckIfNeeded (recipient, tid, sequence);
1176  }
1178  {
1180  }
1181 }
1182 
1184 {
1185  return m_ampduExist;
1186 }
1187 
1189 {
1190  m_ampduExist = ampdu;
1191 }
1192 
1193 void
1195 {
1196  NS_LOG_FUNCTION (this);
1198  {
1199  if (!m_currentHdr.IsRetry ())
1200  {
1202  }
1206  }
1207 }
1208 
1209 void
1211 {
1212  m_baManager->StorePacket (packet, hdr, tstamp);
1216 }
1217 
1218 bool
1220 {
1221  NS_LOG_FUNCTION (this);
1222  uint8_t tid = m_currentHdr.GetQosTid ();
1223  Mac48Address recipient = m_currentHdr.GetAddr1 ();
1224 
1225  uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, recipient);
1226 
1227  if (packets >= m_blockAckThreshold)
1228  {
1229  /* Block ack setup */
1230  uint16_t startingSequence = m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, recipient);
1231  SendAddBaRequest (recipient, tid, startingSequence, m_blockAckInactivityTimeout, true);
1232  return true;
1233  }
1234  return false;
1235 }
1236 
1237 void
1239 {
1240  NS_LOG_FUNCTION (this << &bar);
1241  WifiMacHeader hdr;
1243  hdr.SetAddr1 (bar.recipient);
1244  hdr.SetAddr2 (m_low->GetAddress ());
1245  hdr.SetAddr3 (m_low->GetBssid ());
1246  hdr.SetDsNotTo ();
1247  hdr.SetDsNotFrom ();
1248  hdr.SetNoRetry ();
1249  hdr.SetNoMoreFragments ();
1250 
1251  m_currentPacket = bar.bar;
1252  m_currentHdr = hdr;
1253 
1255  params.DisableRts ();
1256  params.DisableNextData ();
1257  params.DisableOverrideDurationId ();
1258  if (bar.immediate)
1259  {
1261  {
1262  params.EnableBasicBlockAck ();
1263  }
1265  {
1266  params.EnableCompressedBlockAck ();
1267  }
1268  else if (m_blockAckType == MULTI_TID_BLOCK_ACK)
1269  {
1270  NS_FATAL_ERROR ("Multi-tid block ack is not supported");
1271  }
1272  }
1273  else
1274  {
1275  //Delayed block ack
1276  params.EnableAck ();
1277  }
1278  m_low->StartTransmission (m_currentPacket, &m_currentHdr, params, m_transmissionListener);
1279 }
1280 
1281 void
1283 {
1284  NS_LOG_FUNCTION (this);
1286  m_low->RegisterBlockAckListenerForAc (m_ac, m_blockAckListener);
1288 }
1289 
1290 void
1292 {
1293  NS_LOG_FUNCTION (this << static_cast<uint32_t> (threshold));
1294  m_blockAckThreshold = threshold;
1295  m_baManager->SetBlockAckThreshold (threshold);
1296 }
1297 
1298 void
1300 {
1301  NS_LOG_FUNCTION (this << timeout);
1303 }
1304 
1305 uint8_t
1307 {
1308  NS_LOG_FUNCTION (this);
1309  return m_blockAckThreshold;
1310 }
1311 
1312 void
1313 EdcaTxopN::SendAddBaRequest (Mac48Address dest, uint8_t tid, uint16_t startSeq,
1314  uint16_t timeout, bool immediateBAck)
1315 {
1316  NS_LOG_FUNCTION (this << dest << static_cast<uint32_t> (tid) << startSeq << timeout << immediateBAck);
1317  NS_LOG_DEBUG ("sent ADDBA request to " << dest);
1318  WifiMacHeader hdr;
1319  hdr.SetAction ();
1320  hdr.SetAddr1 (dest);
1321  hdr.SetAddr2 (m_low->GetAddress ());
1322  hdr.SetAddr3 (m_low->GetAddress ());
1323  hdr.SetDsNotTo ();
1324  hdr.SetDsNotFrom ();
1325 
1326  WifiActionHeader actionHdr;
1329  actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action);
1330 
1331  Ptr<Packet> packet = Create<Packet> ();
1332  /*Setting ADDBARequest header*/
1333  MgtAddBaRequestHeader reqHdr;
1334  reqHdr.SetAmsduSupport (true);
1335  if (immediateBAck)
1336  {
1337  reqHdr.SetImmediateBlockAck ();
1338  }
1339  else
1340  {
1341  reqHdr.SetDelayedBlockAck ();
1342  }
1343  reqHdr.SetTid (tid);
1344  /* For now we don't use buffer size field in the ADDBA request frame. The recipient
1345  * will choose how many packets it can receive under block ack.
1346  */
1347  reqHdr.SetBufferSize (0);
1348  reqHdr.SetTimeout (timeout);
1349  reqHdr.SetStartingSequence (startSeq);
1350 
1351  m_baManager->CreateAgreement (&reqHdr, dest);
1352 
1353  packet->AddHeader (reqHdr);
1354  packet->AddHeader (actionHdr);
1355 
1356  m_currentPacket = packet;
1357  m_currentHdr = hdr;
1358 
1359  uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr);
1360  m_currentHdr.SetSequenceNumber (sequence);
1364 
1366  params.EnableAck ();
1367  params.DisableRts ();
1368  params.DisableNextData ();
1369  params.DisableOverrideDurationId ();
1370 
1371  m_low->StartTransmission (m_currentPacket, &m_currentHdr, params,
1373 }
1374 
1375 void
1376 EdcaTxopN::SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator)
1377 {
1378  NS_LOG_FUNCTION (this << addr << static_cast<uint32_t> (tid) << byOriginator);
1379  WifiMacHeader hdr;
1380  hdr.SetAction ();
1381  hdr.SetAddr1 (addr);
1382  hdr.SetAddr2 (m_low->GetAddress ());
1383  hdr.SetAddr3 (m_low->GetAddress ());
1384  hdr.SetDsNotTo ();
1385  hdr.SetDsNotFrom ();
1386 
1387  MgtDelBaHeader delbaHdr;
1388  delbaHdr.SetTid (tid);
1389  if (byOriginator)
1390  {
1391  delbaHdr.SetByOriginator ();
1392  }
1393  else
1394  {
1395  delbaHdr.SetByRecipient ();
1396  }
1397 
1398  WifiActionHeader actionHdr;
1401  actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action);
1402 
1403  Ptr<Packet> packet = Create<Packet> ();
1404  packet->AddHeader (delbaHdr);
1405  packet->AddHeader (actionHdr);
1406 
1407  PushFront (packet, hdr);
1408 }
1409 
1410 int64_t
1412 {
1413  NS_LOG_FUNCTION (this << stream);
1414  m_rng->AssignStreams (stream);
1415  return 1;
1416 }
1417 
1418 void
1420 {
1421  NS_LOG_FUNCTION (this);
1422  m_dcf->ResetCw ();
1425 }
1426 
1427 void
1429 {
1430  NS_LOG_FUNCTION (this << hdr);
1431  if (!m_txOkCallback.IsNull ())
1432  {
1434  }
1435 }
1436 
1437 void
1439 {
1440  NS_LOG_FUNCTION (this << hdr);
1441  if (!m_txFailedCallback.IsNull ())
1442  {
1444  }
1445 }
1446 
1447 } // namespace ns3
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.
virtual uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:164
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:360
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:95
virtual bool GetBlockAckAgreementExists(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:180
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:529
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
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:454
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:517
void NotifyWakeUp(void)
When wake up operation occurs, restart channel access.
Definition: edca-txop-n.cc:680
void SetBlockAckInactivityTimeout(uint16_t timeout)
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
virtual void CompleteTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:152
uint16_t m_blockAckInactivityTimeout
Definition: edca-txop-n.h:542
void CreateAgreement(const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient)
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:619
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:332
void EnableBasicBlockAck(void)
Wait BASICBLOCKACKTimeout for a Basic Block Ack Response frame.
Definition: mac-low.cc:151
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:917
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.
void SetTxFailedCallback(TxFailed callback)
Definition: edca-txop-n.cc:318
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:454
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:699
void SetNoMoreFragments(void)
Un-set the More Fragment bit in the Frame Control Field.
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1072
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:61
bool NeedBarRetransmission(void)
Check if Block ACK Request should be re-transmitted.
Definition: edca-txop-n.cc:925
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:325
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:670
void SetAction(enum CategoryValue type, ActionValue action)
Set action for this Action header.
Definition: mgt-headers.cc:478
#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
CategoryValue GetCategory()
Return the category value.
Definition: mgt-headers.cc:509
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).
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
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:58
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:952
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:311
BlockAckManager * m_baManager
Definition: edca-txop-n.h:535
control how a packet is transmitted.
Definition: mac-low.h:285
bool NeedRtsRetransmission(void)
Check if RTS should be re-transmitted if CTS was missed.
Definition: edca-txop-n.cc:909
void SetAmsduSupport(bool supported)
Enable or disable A-MSDU support.
Definition: mgt-headers.cc:739
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:388
Handles sequence numbering of IEEE 802.11 data frames.
Definition: mac-tx-middle.h:39
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
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:745
enum TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:339
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:409
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:402
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).
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:445
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:439
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:612
void SetAddr1(Mac48Address address)
Fill the Address 1 field with the given address.
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:353
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:433
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:279
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:634
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:417
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:427
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:1290
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: edca-txop-n.cc:663
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:250
virtual void StartNext(void)
Invoked when ns3::MacLow wants to start a new transmission as configured by MacLowTransmissionParamet...
Definition: edca-txop-n.cc:114
virtual void SetAmpdu(bool ampdu)
Definition: edca-txop-n.cc:156
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:291
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
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
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.
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:374
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:800
void EndTxNoAck(void)
Event handler when a transmission that does not require an ACK has completed.
Definition: edca-txop-n.cc:990
void StartBackoffNow(uint32_t nSlots)
Definition: dcf-manager.cc:109
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.
virtual uint32_t GetNOutstandingPackets(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:184
void EnableCompressedBlockAck(void)
Wait COMPRESSEDBLOCKACKTimeout for a Compressed Block Ack Response frame.
Definition: mac-low.cc:156
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:871
Hold objects of type Ptr.
Definition: pointer.h:36
listen for block ack events.
Definition: mac-low.h:191
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:171
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.
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:923
void StartNext(void)
Start transmission for the next fragment.
Definition: edca-txop-n.cc:959
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 Ptr< const Packet > PeekNextPacketInBaQueue(WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
Definition: edca-txop-n.cc:172
Ptr< const Packet > GetNextPacket(WifiMacHeader &hdr)
void Cancel(void)
Cancel the transmission.
Definition: edca-txop-n.cc:983
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:303
void DisableRts(void)
Do not send rts and wait for cts before sending data.
Definition: mac-low.cc:186
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:687
uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:422
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:929
uint8_t GetTidInfo(void) const
Return the Traffic ID (TID).
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
static TypeId GetTypeId(void)
Definition: edca-txop-n.cc:200
BlockAckEventListener * m_blockAckListener
Definition: edca-txop-n.h:521
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:181
void CompleteConfig(void)
Complete block ACK configuration.
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.
virtual uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:188
void RestartAccessIfNeeded(void)
Restart access request if needed.
Definition: edca-txop-n.cc:877
void SetBlockAckThreshold(uint8_t nPackets)
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:582
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:698
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:297
#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:410
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
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
void SetTxMiddle(MacTxMiddle *txMiddle)
Definition: edca-txop-n.cc:395
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:627
void EnableNextData(uint32_t size)
Definition: mac-low.cc:126
void DoDispose()
Destructor implementation.
Definition: edca-txop-n.cc:256
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:141
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:131
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Definition: edca-txop-n.cc:381
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:889
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:901
tuple address
Definition: first.py:37
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.
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.
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:176
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:285
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:51
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:416
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
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.
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:345
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:367
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:346
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