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  * Authors: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
20  * Mirko Banchi <mk.banchi@gmail.com>
21  */
22 
23 #include "ns3/log.h"
24 #include "ns3/assert.h"
25 #include "ns3/pointer.h"
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 
53 private:
54  virtual void DoNotifyAccessGranted (void)
55  {
57  }
58  virtual void DoNotifyInternalCollision (void)
59  {
61  }
62  virtual void DoNotifyCollision (void)
63  {
65  }
66  virtual void DoNotifyChannelSwitching (void)
67  {
69  }
70  virtual void DoNotifySleep (void)
71  {
72  m_txop->NotifySleep ();
73  }
74  virtual void DoNotifyWakeUp (void)
75  {
76  m_txop->NotifyWakeUp ();
77  }
78 
80 };
81 
82 
84 {
85 public:
88  m_txop (txop)
89  {
90  }
91 
93  {
94  }
95 
96  virtual void GotCts (double snr, WifiMode txMode)
97  {
98  m_txop->GotCts (snr, txMode);
99  }
100  virtual void MissedCts (void)
101  {
102  m_txop->MissedCts ();
103  }
104  virtual void GotAck (double snr, WifiMode txMode)
105  {
106  m_txop->GotAck (snr, txMode);
107  }
108  virtual void MissedAck (void)
109  {
110  m_txop->MissedAck ();
111  }
112  virtual void GotBlockAck (const CtrlBAckResponseHeader *blockAck, Mac48Address source, WifiMode txMode)
113  {
114  m_txop->GotBlockAck (blockAck, source,txMode);
115  }
116  virtual void MissedBlockAck (void)
117  {
119  }
120  virtual void StartNext (void)
121  {
122  m_txop->StartNext ();
123  }
124  virtual void Cancel (void)
125  {
126  m_txop->Cancel ();
127  }
128  virtual void EndTxNoAck (void)
129  {
130  m_txop->EndTxNoAck ();
131  }
133  {
134  return m_txop->GetEdcaQueue ();
135  }
136 
137 private:
139 };
140 
141 
143 {
144 public:
147  m_txop (txop)
148  {
149  }
151  {
152  }
153 
154  virtual void BlockAckInactivityTimeout (Mac48Address address, uint8_t tid)
155  {
156  m_txop->SendDelbaFrame (address, tid, false);
157  }
159  {
160  return m_txop->GetEdcaQueue ();
161  }
162  virtual void CompleteTransfer (Mac48Address recipient, uint8_t tid)
163  {
164  m_txop->CompleteAmpduTransfer (recipient, tid);
165  }
166  virtual void SetAmpdu (bool ampdu)
167  {
168  return m_txop->SetAmpduExist (ampdu);
169  }
170  virtual void CompleteMpduTx (Ptr<const Packet> packet, WifiMacHeader hdr, Time tstamp)
171  {
172  m_txop->CompleteMpduTx (packet, hdr, tstamp);
173  }
174  virtual uint16_t GetNextSequenceNumberfor (WifiMacHeader *hdr)
175  {
176  return m_txop->GetNextSequenceNumberfor (hdr);
177  }
178  virtual uint16_t PeekNextSequenceNumberfor (WifiMacHeader *hdr)
179  {
180  return m_txop->PeekNextSequenceNumberfor (hdr);
181  }
182  virtual Ptr<const Packet> PeekNextPacketInBaQueue (WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
183  {
184  return m_txop->PeekNextRetransmitPacket (header, recipient, tid, timestamp);
185  }
186  virtual void RemoveFromBaQueue (uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
187  {
188  m_txop->RemoveRetransmitPacket (tid, recipient, seqnumber);
189  }
190  virtual bool GetBlockAckAgreementExists (Mac48Address address, uint8_t tid)
191  {
192  return m_txop->GetBaAgreementExists (address,tid);
193  }
194  virtual uint32_t GetNOutstandingPackets (Mac48Address address, uint8_t tid)
195  {
196  return m_txop->GetNOutstandingPacketsInBa (address, tid);
197  }
198  virtual uint32_t GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const
199  {
200  return m_txop->GetNRetryNeededPackets (recipient, tid);
201  }
203  {
204  return m_txop->GetMsduAggregator ();
205  }
207  {
208  return m_txop->MapSrcAddressForAggregation (hdr);
209  }
211  {
212  return m_txop->MapDestAddressForAggregation (hdr);
213  }
214 
215 private:
217 };
218 
220 
221 TypeId
223 {
224  static TypeId tid = TypeId ("ns3::EdcaTxopN")
225  .SetParent<ns3::Dcf> ()
226  .SetGroupName ("Wifi")
227  .AddConstructor<EdcaTxopN> ()
228  .AddAttribute ("BlockAckThreshold",
229  "If number of packets in this queue reaches this value, "
230  "block ack mechanism is used. If this value is 0, block ack is never used.",
231  UintegerValue (0),
234  MakeUintegerChecker<uint8_t> (0, 64))
235  .AddAttribute ("BlockAckInactivityTimeout",
236  "Represents max time (blocks of 1024 micro seconds) allowed for block ack"
237  "inactivity. If this value isn't equal to 0 a timer start after that a"
238  "block ack setup is completed and will be reset every time that a block"
239  "ack frame is received. If this value is 0, block ack inactivity timeout won't be used.",
240  UintegerValue (0),
242  MakeUintegerChecker<uint16_t> ())
243  .AddAttribute ("Queue",
244  "The WifiMacQueue object",
245  PointerValue (),
247  MakePointerChecker<WifiMacQueue> ())
248  ;
249  return tid;
250 }
251 
253  : m_manager (0),
254  m_currentPacket (0),
255  m_aggregator (0),
256  m_typeOfStation (STA),
257  m_blockAckType (COMPRESSED_BLOCK_ACK),
258  m_ampduExist (false)
259 {
260  NS_LOG_FUNCTION (this);
263  m_dcf = new EdcaTxopN::Dcf (this);
264  m_queue = CreateObject<WifiMacQueue> ();
265  m_rng = new RealRandomStream ();
267  m_baManager = new BlockAckManager ();
272  m_baManager->SetMaxPacketDelay (m_queue->GetMaxDelay ());
275 }
276 
278 {
279  NS_LOG_FUNCTION (this);
280 }
281 
282 void
284 {
285  NS_LOG_FUNCTION (this);
286  m_queue = 0;
287  m_low = 0;
288  m_stationManager = 0;
289  delete m_transmissionListener;
290  delete m_dcf;
291  delete m_rng;
293  delete m_baManager;
294  delete m_blockAckListener;
296  m_dcf = 0;
297  m_rng = 0;
299  m_baManager = 0;
300  m_blockAckListener = 0;
301  m_txMiddle = 0;
302  m_aggregator = 0;
303 }
304 
305 bool
307 {
308  return m_baManager->ExistsAgreement (address, tid);
309 }
310 
311 uint32_t
313 {
314  return m_baManager->GetNBufferedPackets (address, tid);
315 }
316 
317 uint32_t
318 EdcaTxopN::GetNRetryNeededPackets (Mac48Address recipient, uint8_t tid) const
319 {
320  return m_baManager->GetNRetryNeededPackets (recipient, tid);
321 }
322 
323 void
325 {
326  m_baManager->CompleteAmpduExchange (recipient, tid);
327 }
328 
329 void
331 {
332  NS_LOG_FUNCTION (this << manager);
333  m_manager = manager;
334  m_manager->Add (m_dcf);
335 }
336 
337 void
339 {
340  NS_LOG_FUNCTION (this << &callback);
341  m_txOkCallback = callback;
342 }
343 
344 void
346 {
347  NS_LOG_FUNCTION (this << &callback);
348  m_txFailedCallback = callback;
349 }
350 
351 void
353 {
354  NS_LOG_FUNCTION (this << remoteManager);
355  m_stationManager = remoteManager;
357 }
358 
359 void
361 {
362  NS_LOG_FUNCTION (this << static_cast<uint32_t> (type));
363  m_typeOfStation = type;
364 }
365 
366 enum TypeOfStation
368 {
369  NS_LOG_FUNCTION (this);
370  return m_typeOfStation;
371 }
372 
375 {
376  NS_LOG_FUNCTION (this);
377  return m_queue;
378 }
379 
380 void
381 EdcaTxopN::SetMinCw (uint32_t minCw)
382 {
383  NS_LOG_FUNCTION (this << minCw);
384  m_dcf->SetCwMin (minCw);
385 }
386 
387 void
388 EdcaTxopN::SetMaxCw (uint32_t maxCw)
389 {
390  NS_LOG_FUNCTION (this << maxCw);
391  m_dcf->SetCwMax (maxCw);
392 }
393 
394 void
395 EdcaTxopN::SetAifsn (uint32_t aifsn)
396 {
397  NS_LOG_FUNCTION (this << aifsn);
398  m_dcf->SetAifsn (aifsn);
399 }
400 
401 uint32_t
403 {
404  NS_LOG_FUNCTION (this);
405  return m_dcf->GetCwMin ();
406 }
407 
408 uint32_t
410 {
411  NS_LOG_FUNCTION (this);
412  return m_dcf->GetCwMax ();
413 }
414 
415 uint32_t
417 {
418  NS_LOG_FUNCTION (this);
419  return m_dcf->GetAifsn ();
420 }
421 
422 void
424 {
425  NS_LOG_FUNCTION (this << txMiddle);
426  m_txMiddle = txMiddle;
427 }
428 
431 {
432  NS_LOG_FUNCTION (this);
433  return m_low;
434 }
435 
436 void
438 {
439  NS_LOG_FUNCTION (this << low);
440  m_low = low;
441 }
442 
443 bool
445 {
446  NS_LOG_FUNCTION (this);
447  return !m_queue->IsEmpty () || m_currentPacket != 0 || m_baManager->HasPackets ();
448 }
449 
451 {
452  return m_txMiddle->GetNextSequenceNumberfor (hdr);
453 }
454 
456 {
458 }
459 
461 EdcaTxopN::PeekNextRetransmitPacket (WifiMacHeader &header,Mac48Address recipient, uint8_t tid, Time *timestamp)
462 {
463  return m_baManager->PeekNextPacket (header,recipient,tid, timestamp);
464 }
465 
466 void
467 EdcaTxopN::RemoveRetransmitPacket (uint8_t tid, Mac48Address recipient, uint16_t seqnumber)
468 {
469  m_baManager->RemovePacket (tid, recipient, seqnumber);
470 }
471 
472 void
474 {
475  NS_LOG_FUNCTION (this);
476  if (m_currentPacket == 0)
477  {
478  if (m_queue->IsEmpty () && !m_baManager->HasPackets ())
479  {
480  NS_LOG_DEBUG ("queue is empty");
481  return;
482  }
484  {
486  return;
487  }
488  /* check if packets need retransmission are stored in BlockAckManager */
490  if (m_currentPacket == 0)
491  {
492  if (m_queue->PeekFirstAvailable (&m_currentHdr, m_currentPacketTimestamp, m_qosBlockedDestinations) == 0)
493  {
494  NS_LOG_DEBUG ("no available packets in the queue");
495  return;
496  }
498  && m_blockAckThreshold > 0
500  && SetupBlockAckIfNeeded ())
501  {
502  return;
503  }
505  NS_ASSERT (m_currentPacket != 0);
506 
507  uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr);
508  m_currentHdr.SetSequenceNumber (sequence);
513  m_fragmentNumber = 0;
514  NS_LOG_DEBUG ("dequeued size=" << m_currentPacket->GetSize () <<
515  ", to=" << m_currentHdr.GetAddr1 () <<
516  ", seq=" << m_currentHdr.GetSequenceControl ());
518  {
519  VerifyBlockAck ();
520  }
521  }
522  }
524  params.DisableOverrideDurationId ();
525  if (m_currentHdr.GetAddr1 ().IsGroup ())
526  {
527  params.DisableRts ();
528  params.DisableAck ();
529  params.DisableNextData ();
531  &m_currentHdr,
532  params,
534 
535  NS_LOG_DEBUG ("tx broadcast");
536  }
538  {
540  }
541  else
542  {
544  {
545  params.DisableAck ();
546  }
547  else
548  {
549  params.EnableAck ();
550  }
552  && !m_currentHdr.IsQosAmsdu ())
553  ||
554  (m_currentHdr.IsData ()
556  && (m_blockAckThreshold == 0
558  {
559  //With COMPRESSED_BLOCK_ACK fragmentation must be avoided.
560  params.DisableRts ();
561  WifiMacHeader hdr;
562  Ptr<Packet> fragment = GetFragmentPacket (&hdr);
563  if (IsLastFragment ())
564  {
565  NS_LOG_DEBUG ("fragmenting last fragment size=" << fragment->GetSize ());
566  params.DisableNextData ();
567  }
568  else
569  {
570  NS_LOG_DEBUG ("fragmenting size=" << fragment->GetSize ());
572  }
573  m_low->StartTransmission (fragment, &hdr, params,
575  }
576  else
577  {
578  WifiMacHeader peekedHdr;
579  Time tstamp;
580  if (m_currentHdr.IsQosData ()
581  && m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
584  && m_aggregator != 0 && !m_currentHdr.IsRetry ())
585  {
586  /* here is performed aggregation */
587  Ptr<Packet> currentAggregatedPacket = Create<Packet> ();
588  m_aggregator->Aggregate (m_currentPacket, currentAggregatedPacket,
589  MapSrcAddressForAggregation (peekedHdr),
590  MapDestAddressForAggregation (peekedHdr));
591  bool aggregated = false;
592  bool isAmsdu = false;
593  Ptr<const Packet> peekedPacket = m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
595  m_currentHdr.GetAddr1 (), &tstamp);
596  while (peekedPacket != 0)
597  {
598  aggregated = m_aggregator->Aggregate (peekedPacket, currentAggregatedPacket,
599  MapSrcAddressForAggregation (peekedHdr),
600  MapDestAddressForAggregation (peekedHdr));
601  if (aggregated)
602  {
603  isAmsdu = true;
604  m_queue->Remove (peekedPacket);
605  }
606  else
607  {
608  break;
609  }
610  peekedPacket = m_queue->PeekByTidAndAddress (&peekedHdr, m_currentHdr.GetQosTid (),
612  }
613  if (isAmsdu)
614  {
617  m_currentPacket = currentAggregatedPacket;
618  currentAggregatedPacket = 0;
619  NS_LOG_DEBUG ("tx unicast A-MSDU");
620  }
621  }
622  if (NeedRts ())
623  {
624  params.EnableRts ();
625  NS_LOG_DEBUG ("tx unicast rts");
626  }
627  else
628  {
629  params.DisableRts ();
630  NS_LOG_DEBUG ("tx unicast");
631  }
632  params.DisableNextData ();
634  params, m_transmissionListener);
635  if (!GetAmpduExist ())
636  {
637  CompleteTx ();
638  }
639  }
640  }
641 }
642 
644 {
645  NS_LOG_FUNCTION (this);
646  NotifyCollision ();
647 }
648 
649 void
651 {
652  NS_LOG_FUNCTION (this);
655 }
656 
657 void
658 EdcaTxopN::GotCts (double snr, WifiMode txMode)
659 {
660  NS_LOG_FUNCTION (this << snr << txMode);
661  NS_LOG_DEBUG ("got cts");
662 }
663 
664 void
666 {
667  NS_LOG_FUNCTION (this);
668  NS_LOG_DEBUG ("missed cts");
669  if (!NeedRtsRetransmission ())
670  {
671  NS_LOG_DEBUG ("Cts Fail");
672  bool resetCurrentPacket = true;
674  if (!m_txFailedCallback.IsNull ())
675  {
677  }
678  if (GetAmpduExist ())
679  {
681  uint8_t tid = 0;
682  if (m_currentHdr.IsQosData ())
683  {
684  tid = m_currentHdr.GetQosTid ();
685  }
686  else
687  {
688  NS_FATAL_ERROR ("Current packet is not Qos Data");
689  }
690 
692  {
693  NS_LOG_DEBUG ("Transmit Block Ack Request");
694  CtrlBAckRequestHeader reqHdr;
695  reqHdr.SetType (COMPRESSED_BLOCK_ACK);
697  reqHdr.SetTidInfo (tid);
698  reqHdr.SetHtImmediateAck (true);
699  Ptr<Packet> bar = Create<Packet> ();
700  bar->AddHeader (reqHdr);
701  Bar request (bar, m_currentHdr.GetAddr1 (), tid, reqHdr.MustSendHtImmediateAck ());
702  m_currentBar = request;
703  WifiMacHeader hdr;
705  hdr.SetAddr1 (request.recipient);
706  hdr.SetAddr2 (m_low->GetAddress ());
707  hdr.SetAddr3 (m_low->GetBssid ());
708  hdr.SetDsNotTo ();
709  hdr.SetDsNotFrom ();
710  hdr.SetNoRetry ();
711  hdr.SetNoMoreFragments ();
712  m_currentPacket = request.bar;
713  m_currentHdr = hdr;
714  resetCurrentPacket = false;
715  }
716  }
717  //to reset the dcf.
718  if (resetCurrentPacket == true)
719  {
720  m_currentPacket = 0;
721  }
722  m_dcf->ResetCw ();
723  }
724  else
725  {
726  m_dcf->UpdateFailedCw ();
727  }
730 }
731 
732 void
734 {
735  NS_LOG_FUNCTION (this);
736  m_queue->Flush ();
737  m_currentPacket = 0;
738 }
739 
740 void
742 {
743  NS_LOG_FUNCTION (this);
744  if (m_currentPacket != 0)
745  {
746  m_queue->PushFront (m_currentPacket, m_currentHdr);
747  m_currentPacket = 0;
748  }
749 }
750 
751 void
753 {
754  NS_LOG_FUNCTION (this);
756 }
757 
758 void
760 {
761  NS_LOG_FUNCTION (this << packet << &hdr);
762  WifiMacTrailer fcs;
763  uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize ();
765  packet, fullPacketSize);
766  m_queue->Enqueue (packet, hdr);
768 }
769 
770 void
771 EdcaTxopN::GotAck (double snr, WifiMode txMode)
772 {
773  NS_LOG_FUNCTION (this << snr << txMode);
774  if (!NeedFragmentation ()
775  || IsLastFragment ()
776  || m_currentHdr.IsQosAmsdu ())
777  {
778  NS_LOG_DEBUG ("got ack. tx done.");
779  if (!m_txOkCallback.IsNull ())
780  {
782  }
783 
784  if (m_currentHdr.IsAction ())
785  {
786  WifiActionHeader actionHdr;
788  p->RemoveHeader (actionHdr);
789  if (actionHdr.GetCategory () == WifiActionHeader::BLOCK_ACK
791  {
792  MgtDelBaHeader delBa;
793  p->PeekHeader (delBa);
794  if (delBa.IsByOriginator ())
795  {
797  }
798  else
799  {
801  }
802  }
803  }
804  m_currentPacket = 0;
805 
806  m_dcf->ResetCw ();
809  }
810  else
811  {
812  NS_LOG_DEBUG ("got ack. tx not done, size=" << m_currentPacket->GetSize ());
813  }
814 }
815 
816 void
818 {
819  NS_LOG_FUNCTION (this);
820  NS_LOG_DEBUG ("missed ack");
821  if (!NeedDataRetransmission ())
822  {
823  NS_LOG_DEBUG ("Ack Fail");
825  bool resetCurrentPacket = true;
826  if (!m_txFailedCallback.IsNull ())
827  {
829  }
830  if (GetAmpduExist ())
831  {
832  uint8_t tid = 0;
833  if (m_currentHdr.IsQosData ())
834  {
835  tid = m_currentHdr.GetQosTid ();
836  }
837  else
838  {
839  NS_FATAL_ERROR ("Current packet is not Qos Data");
840  }
841 
843  {
844  //send Block ACK Request in order to shift WinStart at the receiver
845  NS_LOG_DEBUG ("Transmit Block Ack Request");
846  CtrlBAckRequestHeader reqHdr;
847  reqHdr.SetType (COMPRESSED_BLOCK_ACK);
849  reqHdr.SetTidInfo (tid);
850  reqHdr.SetHtImmediateAck (true);
851  Ptr<Packet> bar = Create<Packet> ();
852  bar->AddHeader (reqHdr);
853  Bar request (bar, m_currentHdr.GetAddr1 (), tid, reqHdr.MustSendHtImmediateAck ());
854  m_currentBar = request;
855  WifiMacHeader hdr;
857  hdr.SetAddr1 (request.recipient);
858  hdr.SetAddr2 (m_low->GetAddress ());
859  hdr.SetAddr3 (m_low->GetBssid ());
860  hdr.SetDsNotTo ();
861  hdr.SetDsNotFrom ();
862  hdr.SetNoRetry ();
863  hdr.SetNoMoreFragments ();
864  m_currentPacket = request.bar;
865  m_currentHdr = hdr;
866  resetCurrentPacket = false;
867  }
868  }
869  //to reset the dcf.
870  if (resetCurrentPacket == true)
871  {
872  m_currentPacket = 0;
873  }
874  m_dcf->ResetCw ();
875  }
876  else
877  {
878  NS_LOG_DEBUG ("Retransmit");
880  m_dcf->UpdateFailedCw ();
881  }
884 }
885 
886 void
888 {
889  NS_LOG_FUNCTION (this);
890  NS_LOG_DEBUG ("missed block ack");
891  if (NeedBarRetransmission ())
892  {
893  if (!GetAmpduExist ())
894  {
895  //should i report this to station addressed by ADDR1?
896  NS_LOG_DEBUG ("Retransmit block ack request");
898  }
899  else
900  {
901  //standard says when loosing a BlockAck originator may send a BAR page 139
902  NS_LOG_DEBUG ("Transmit Block Ack Request");
903  CtrlBAckRequestHeader reqHdr;
904  reqHdr.SetType (COMPRESSED_BLOCK_ACK);
905  uint8_t tid = 0;
906  if (m_currentHdr.IsQosData ())
907  {
908  tid = m_currentHdr.GetQosTid ();
910  }
911  else if (m_currentHdr.IsBlockAckReq ())
912  {
913  CtrlBAckRequestHeader baReqHdr;
914  m_currentPacket->PeekHeader (baReqHdr);
915  tid = baReqHdr.GetTidInfo ();
916  reqHdr.SetStartingSequence (baReqHdr.GetStartingSequence ());
917  }
918  else if (m_currentHdr.IsBlockAck ())
919  {
920  CtrlBAckResponseHeader baRespHdr;
921  m_currentPacket->PeekHeader (baRespHdr);
922  tid = baRespHdr.GetTidInfo ();
924  }
925  reqHdr.SetTidInfo (tid);
926  reqHdr.SetHtImmediateAck (true);
927  Ptr<Packet> bar = Create<Packet> ();
928  bar->AddHeader (reqHdr);
929  Bar request (bar, m_currentHdr.GetAddr1 (), tid, reqHdr.MustSendHtImmediateAck ());
930  m_currentBar = request;
931  WifiMacHeader hdr;
933  hdr.SetAddr1 (request.recipient);
934  hdr.SetAddr2 (m_low->GetAddress ());
935  hdr.SetAddr3 (m_low->GetBssid ());
936  hdr.SetDsNotTo ();
937  hdr.SetDsNotFrom ();
938  hdr.SetNoRetry ();
939  hdr.SetNoMoreFragments ();
940 
941  m_currentPacket = request.bar;
942  m_currentHdr = hdr;
943  }
944  m_dcf->UpdateFailedCw ();
945  }
946  else
947  {
948  NS_LOG_DEBUG ("Block Ack Request Fail");
949  //to reset the dcf.
950  m_currentPacket = 0;
951  m_dcf->ResetCw ();
952  }
955 }
956 
959 {
960  return m_aggregator;
961 }
962 
963 void
965 {
966  NS_LOG_FUNCTION (this);
967  if ((m_currentPacket != 0
968  || !m_queue->IsEmpty () || m_baManager->HasPackets ())
969  && !m_dcf->IsAccessRequested ())
970  {
972  }
973 }
974 
975 void
977 {
978  NS_LOG_FUNCTION (this);
979  if (m_currentPacket == 0
980  && (!m_queue->IsEmpty () || m_baManager->HasPackets ())
981  && !m_dcf->IsAccessRequested ())
982  {
984  }
985 }
986 
987 bool
989 {
990  NS_LOG_FUNCTION (this);
993 }
994 
995 bool
997 {
998  NS_LOG_FUNCTION (this);
1000  m_currentPacket);
1001 }
1002 
1003 bool
1005 {
1006  NS_LOG_FUNCTION (this);
1008  m_currentPacket);
1009 }
1010 
1011 bool
1013 {
1014  uint8_t tid = 0;
1015  uint16_t seqNumber = 0;
1016  if (m_currentHdr.IsQosData ())
1017  {
1018  tid = m_currentHdr.GetQosTid ();
1019  seqNumber = m_currentHdr.GetSequenceNumber ();
1020  }
1021  else if (m_currentHdr.IsBlockAckReq ())
1022  {
1023  CtrlBAckRequestHeader baReqHdr;
1024  m_currentPacket->PeekHeader (baReqHdr);
1025  tid = baReqHdr.GetTidInfo ();
1026  seqNumber = baReqHdr.GetStartingSequence ();
1027  }
1028  else if (m_currentHdr.IsBlockAck ())
1029  {
1030  CtrlBAckResponseHeader baRespHdr;
1031  m_currentPacket->PeekHeader (baRespHdr);
1032  tid = baRespHdr.GetTidInfo ();
1033  seqNumber = m_currentHdr.GetSequenceNumber ();
1034  }
1035  return m_baManager->NeedBarRetransmission (tid, seqNumber, m_currentHdr.GetAddr1 ());
1036 }
1037 
1038 void
1040 {
1041  NS_LOG_FUNCTION (this);
1042  m_fragmentNumber++;
1043 }
1044 
1045 void
1047 {
1048  NS_LOG_FUNCTION (this);
1049  NS_LOG_DEBUG ("start next packet fragment");
1050  /* this callback is used only for fragments. */
1051  NextFragment ();
1052  WifiMacHeader hdr;
1053  Ptr<Packet> fragment = GetFragmentPacket (&hdr);
1055  params.EnableAck ();
1056  params.DisableRts ();
1057  params.DisableOverrideDurationId ();
1058  if (IsLastFragment ())
1059  {
1060  params.DisableNextData ();
1061  }
1062  else
1063  {
1064  params.EnableNextData (GetNextFragmentSize ());
1065  }
1066  Low ()->StartTransmission (fragment, &hdr, params, m_transmissionListener);
1067 }
1068 
1069 void
1071 {
1072  NS_LOG_FUNCTION (this);
1073  NS_LOG_DEBUG ("transmission cancelled");
1074 }
1075 
1076 void
1078 {
1079  NS_LOG_FUNCTION (this);
1080  NS_LOG_DEBUG ("a transmission that did not require an ACK just finished");
1081  m_currentPacket = 0;
1082  m_dcf->ResetCw ();
1085 }
1086 
1087 bool
1089 {
1090  NS_LOG_FUNCTION (this);
1092  m_currentPacket);
1093 }
1094 
1095 uint32_t
1097 {
1098  NS_LOG_FUNCTION (this);
1101 }
1102 
1103 uint32_t
1105 {
1106  NS_LOG_FUNCTION (this);
1109 }
1110 
1111 uint32_t
1113 {
1114  NS_LOG_FUNCTION (this);
1117 }
1118 
1119 
1120 bool
1122 {
1123  NS_LOG_FUNCTION (this);
1126 }
1127 
1130 {
1131  NS_LOG_FUNCTION (this << hdr);
1132  *hdr = m_currentHdr;
1134  uint32_t startOffset = GetFragmentOffset ();
1135  Ptr<Packet> fragment;
1136  if (IsLastFragment ())
1137  {
1138  hdr->SetNoMoreFragments ();
1139  }
1140  else
1141  {
1142  hdr->SetMoreFragments ();
1143  }
1144  fragment = m_currentPacket->CreateFragment (startOffset,
1145  GetFragmentSize ());
1146  return fragment;
1147 }
1148 
1149 void
1151 {
1152  NS_LOG_FUNCTION (this << static_cast<uint32_t> (ac));
1153  m_ac = ac;
1154 }
1155 
1158 {
1159  NS_LOG_FUNCTION (this << &hdr);
1160  Mac48Address retval;
1162  {
1163  retval = hdr.GetAddr2 ();
1164  }
1165  else
1166  {
1167  retval = hdr.GetAddr3 ();
1168  }
1169  return retval;
1170 }
1171 
1174 {
1175  NS_LOG_FUNCTION (this << &hdr);
1176  Mac48Address retval;
1178  {
1179  retval = hdr.GetAddr1 ();
1180  }
1181  else
1182  {
1183  retval = hdr.GetAddr3 ();
1184  }
1185  return retval;
1186 }
1187 
1188 void
1190 {
1191  NS_LOG_FUNCTION (this << aggr);
1192  m_aggregator = aggr;
1193 }
1194 
1195 void
1197 {
1198  NS_LOG_FUNCTION (this << packet << &hdr);
1199  WifiMacTrailer fcs;
1200  uint32_t fullPacketSize = hdr.GetSerializedSize () + packet->GetSize () + fcs.GetSerializedSize ();
1201  m_stationManager->PrepareForQueue (hdr.GetAddr1 (), &hdr,
1202  packet, fullPacketSize);
1203  m_queue->PushFront (packet, hdr);
1205 }
1206 
1207 void
1209 {
1210  NS_LOG_FUNCTION (this << respHdr << recipient);
1211  NS_LOG_DEBUG ("received ADDBA response from " << recipient);
1212  uint8_t tid = respHdr->GetTid ();
1214  {
1215  if (respHdr->GetStatusCode ().IsSuccess ())
1216  {
1217  NS_LOG_DEBUG ("block ack agreement established with " << recipient);
1218  m_baManager->UpdateAgreement (respHdr, recipient);
1219  }
1220  else
1221  {
1222  NS_LOG_DEBUG ("discard ADDBA response" << recipient);
1223  m_baManager->NotifyAgreementUnsuccessful (recipient, tid);
1224  }
1225  }
1227 }
1228 
1229 void
1231 {
1232  NS_LOG_FUNCTION (this << delBaHdr << recipient);
1233  NS_LOG_DEBUG ("received DELBA frame from=" << recipient);
1234  m_baManager->TearDownBlockAck (recipient, delBaHdr->GetTid ());
1235 }
1236 
1237 void
1239 {
1240  NS_LOG_FUNCTION (this << blockAck << recipient);
1241  NS_LOG_DEBUG ("got block ack from=" << recipient);
1242  m_baManager->NotifyGotBlockAck (blockAck, recipient, txMode);
1243  if (!m_txOkCallback.IsNull ())
1244  {
1246  }
1247  m_currentPacket = 0;
1248  m_dcf->ResetCw ();
1251 }
1252 
1253 void
1255 {
1256  NS_LOG_FUNCTION (this);
1257  uint8_t tid = m_currentHdr.GetQosTid ();
1258  Mac48Address recipient = m_currentHdr.GetAddr1 ();
1259  uint16_t sequence = m_currentHdr.GetSequenceNumber ();
1261  {
1262  m_baManager->SwitchToBlockAckIfNeeded (recipient, tid, sequence);
1263  }
1265  {
1267  }
1268 }
1269 
1271 {
1272  return m_ampduExist;
1273 }
1274 
1275 void EdcaTxopN::SetAmpduExist (bool ampdu)
1276 {
1277  m_ampduExist = ampdu;
1278 }
1279 
1280 void
1282 {
1283  NS_LOG_FUNCTION (this);
1285  {
1286  if (!m_currentHdr.IsRetry ())
1287  {
1289  }
1293  }
1294 }
1295 
1296 void
1298 {
1299  NS_ASSERT (hdr.IsQosData ());
1300  m_baManager->StorePacket (packet, hdr, tstamp);
1304 }
1305 
1306 bool
1308 {
1309  NS_LOG_FUNCTION (this);
1310  uint8_t tid = m_currentHdr.GetQosTid ();
1311  Mac48Address recipient = m_currentHdr.GetAddr1 ();
1312 
1313  uint32_t packets = m_queue->GetNPacketsByTidAndAddress (tid, WifiMacHeader::ADDR1, recipient);
1314 
1315  if (packets >= m_blockAckThreshold)
1316  {
1317  /* Block ack setup */
1318  uint16_t startingSequence = m_txMiddle->GetNextSeqNumberByTidAndAddress (tid, recipient);
1319  SendAddBaRequest (recipient, tid, startingSequence, m_blockAckInactivityTimeout, true);
1320  return true;
1321  }
1322  return false;
1323 }
1324 
1325 void
1327 {
1328  NS_LOG_FUNCTION (this << &bar);
1329  WifiMacHeader hdr;
1331  hdr.SetAddr1 (bar.recipient);
1332  hdr.SetAddr2 (m_low->GetAddress ());
1333  hdr.SetAddr3 (m_low->GetBssid ());
1334  hdr.SetDsNotTo ();
1335  hdr.SetDsNotFrom ();
1336  hdr.SetNoRetry ();
1337  hdr.SetNoMoreFragments ();
1338 
1339  m_currentPacket = bar.bar;
1340  m_currentHdr = hdr;
1341 
1343  params.DisableRts ();
1344  params.DisableNextData ();
1345  params.DisableOverrideDurationId ();
1346  if (bar.immediate)
1347  {
1349  {
1350  params.EnableBasicBlockAck ();
1351  }
1353  {
1354  params.EnableCompressedBlockAck ();
1355  }
1356  else if (m_blockAckType == MULTI_TID_BLOCK_ACK)
1357  {
1358  NS_FATAL_ERROR ("Multi-tid block ack is not supported");
1359  }
1360  }
1361  else
1362  {
1363  //Delayed block ack
1364  params.EnableAck ();
1365  }
1367 }
1368 
1369 void
1371 {
1372  NS_LOG_FUNCTION (this);
1376 }
1377 
1378 void
1380 {
1381  NS_LOG_FUNCTION (this << static_cast<uint32_t> (threshold));
1382  m_blockAckThreshold = threshold;
1383  m_baManager->SetBlockAckThreshold (threshold);
1384 }
1385 
1386 void
1388 {
1389  NS_LOG_FUNCTION (this << timeout);
1391 }
1392 
1393 uint8_t
1395 {
1396  NS_LOG_FUNCTION (this);
1397  return m_blockAckThreshold;
1398 }
1399 
1400 void
1401 EdcaTxopN::SendAddBaRequest (Mac48Address dest, uint8_t tid, uint16_t startSeq,
1402  uint16_t timeout, bool immediateBAck)
1403 {
1404  NS_LOG_FUNCTION (this << dest << static_cast<uint32_t> (tid) << startSeq << timeout << immediateBAck);
1405  NS_LOG_DEBUG ("sent ADDBA request to " << dest);
1406  WifiMacHeader hdr;
1407  hdr.SetAction ();
1408  hdr.SetAddr1 (dest);
1409  hdr.SetAddr2 (m_low->GetAddress ());
1410  hdr.SetAddr3 (m_low->GetAddress ());
1411  hdr.SetDsNotTo ();
1412  hdr.SetDsNotFrom ();
1413 
1414  WifiActionHeader actionHdr;
1417  actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action);
1418 
1419  Ptr<Packet> packet = Create<Packet> ();
1420  /*Setting ADDBARequest header*/
1421  MgtAddBaRequestHeader reqHdr;
1422  reqHdr.SetAmsduSupport (true);
1423  if (immediateBAck)
1424  {
1425  reqHdr.SetImmediateBlockAck ();
1426  }
1427  else
1428  {
1429  reqHdr.SetDelayedBlockAck ();
1430  }
1431  reqHdr.SetTid (tid);
1432  /* For now we don't use buffer size field in the ADDBA request frame. The recipient
1433  * will choose how many packets it can receive under block ack.
1434  */
1435  reqHdr.SetBufferSize (0);
1436  reqHdr.SetTimeout (timeout);
1437  reqHdr.SetStartingSequence (startSeq);
1438 
1439  m_baManager->CreateAgreement (&reqHdr, dest);
1440 
1441  packet->AddHeader (reqHdr);
1442  packet->AddHeader (actionHdr);
1443 
1444  m_currentPacket = packet;
1445  m_currentHdr = hdr;
1446 
1447  uint16_t sequence = m_txMiddle->GetNextSequenceNumberfor (&m_currentHdr);
1448  m_currentHdr.SetSequenceNumber (sequence);
1452 
1454  params.EnableAck ();
1455  params.DisableRts ();
1456  params.DisableNextData ();
1457  params.DisableOverrideDurationId ();
1458 
1461 }
1462 
1463 void
1464 EdcaTxopN::SendDelbaFrame (Mac48Address addr, uint8_t tid, bool byOriginator)
1465 {
1466  NS_LOG_FUNCTION (this << addr << static_cast<uint32_t> (tid) << byOriginator);
1467  WifiMacHeader hdr;
1468  hdr.SetAction ();
1469  hdr.SetAddr1 (addr);
1470  hdr.SetAddr2 (m_low->GetAddress ());
1471  hdr.SetAddr3 (m_low->GetAddress ());
1472  hdr.SetDsNotTo ();
1473  hdr.SetDsNotFrom ();
1474 
1475  MgtDelBaHeader delbaHdr;
1476  delbaHdr.SetTid (tid);
1477  if (byOriginator)
1478  {
1479  delbaHdr.SetByOriginator ();
1480  }
1481  else
1482  {
1483  delbaHdr.SetByRecipient ();
1484  }
1485 
1486  WifiActionHeader actionHdr;
1489  actionHdr.SetAction (WifiActionHeader::BLOCK_ACK, action);
1490 
1491  Ptr<Packet> packet = Create<Packet> ();
1492  packet->AddHeader (delbaHdr);
1493  packet->AddHeader (actionHdr);
1494 
1495  PushFront (packet, hdr);
1496 }
1497 
1498 int64_t
1500 {
1501  NS_LOG_FUNCTION (this << stream);
1502  m_rng->AssignStreams (stream);
1503  return 1;
1504 }
1505 
1506 void
1508 {
1509  NS_LOG_FUNCTION (this);
1510  m_dcf->ResetCw ();
1513 }
1514 
1515 void
1517 {
1518  NS_LOG_FUNCTION (this << hdr);
1519  if (!m_txOkCallback.IsNull ())
1520  {
1522  }
1523 }
1524 
1525 void
1527 {
1528  NS_LOG_FUNCTION (this << hdr);
1529  if (!m_txFailedCallback.IsNull ())
1530  {
1532  }
1533 }
1534 
1535 } //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:178
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:266
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:388
void SetMoreFragments(void)
Set the More Fragment bit in the Frame Control field.
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:346
void SetType(enum BlockAckType type)
Set the block ACK type.
TransmissionListener * m_transmissionListener
Definition: edca-txop-n.h:534
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Ptr< const Packet > m_currentPacket
Definition: edca-txop-n.h:543
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.
Introspection did not find any typical Config paths.
Definition: dcf.h:32
TxFailed m_txFailedCallback
Definition: edca-txop-n.h:531
virtual Mac48Address GetDestAddressForAggregation(const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:210
void NotifyWakeUp(void)
When wake up operation occurs, restart channel access.
Definition: edca-txop-n.cc:752
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:82
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:556
void CreateAgreement(const MgtAddBaRequestHeader *reqHdr, Mac48Address recipient)
virtual uint32_t GetNOutstandingPackets(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:194
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:419
void NotifyCollision(void)
Notify the EDCAF that collision has occurred.
Definition: edca-txop-n.cc:650
void SetTypeOfStation(enum TypeOfStation type)
Set type of station with the given type.
Definition: edca-txop-n.cc:360
void EnableBasicBlockAck(void)
Wait BASICBLOCKACKTimeout for a Basic Block Ack Response frame.
Definition: mac-low.cc:164
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.
void RequestAccess(DcfState *state)
Definition: dcf-manager.cc:479
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:128
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:679
void SetTxFailedCallback(TxFailed callback)
Definition: edca-txop-n.cc:345
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:538
void GotAck(double snr, WifiMode txMode)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:771
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:2699
bool IsNull(void) const
Check for null implementation.
Definition: callback.h:1258
virtual void MissedBlockAck(void)
ns3::MacLow did not receive an expected BLOCK_ACK within BlockAckTimeout.
Definition: edca-txop-n.cc:116
#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.
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:553
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > remoteManager)
Set WifiRemoteStationsManager this EdcaTxopN is associated to.
Definition: edca-txop-n.cc:352
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:786
bool IsBroadcast(void) const
void SetBlockAckType(enum BlockAckType bAckType)
WifiMacHeader m_currentHdr
Definition: edca-txop-n.h:545
void NotifySleep(void)
When sleep operation occurs, re-insert pending packet into front of the queue.
Definition: edca-txop-n.cc:741
void SetAction(enum CategoryValue type, ActionValue action)
Set action for this Action header.
Definition: mgt-headers.cc:619
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:145
void SetHtImmediateAck(bool immediateAck)
Enable or disable HT immediate ACK.
void SetAifsn(uint32_t aifsn)
Definition: dcf-manager.cc:56
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:124
void UpdateFragmentationThreshold(void)
Typically called to update the fragmentation threshold at the start of a new transmission.
bool IsLastFragment(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet, uint32_t fragmentNumber)
virtual Ptr< MsduAggregator > GetMsduAggregator(void) const
Definition: edca-txop-n.cc:202
CategoryValue GetCategory()
Return the category value.
Definition: mgt-headers.cc:653
virtual Ptr< const Packet > PeekNextPacketInBaQueue(WifiMacHeader &header, Mac48Address recipient, uint8_t tid, Time *timestamp)
Definition: edca-txop-n.cc:182
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:94
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:526
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:97
virtual void MissedAck(void)
ns3::MacLow did not receive an expected ACK within AckTimeout.
Definition: edca-txop-n.cc:108
void Add(DcfState *dcf)
Definition: dcf-manager.cc:397
void NextFragment(void)
Continue to the next fragment.
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:338
BlockAckManager * m_baManager
Definition: edca-txop-n.h:549
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:996
void SetAmsduSupport(bool supported)
Enable or disable A-MSDU support.
Definition: mgt-headers.cc:997
struct Bar m_currentBar
Definition: edca-txop-n.h:557
virtual void DoNotifyChannelSwitching(void)
Called by DcfManager to notify a DcfState subclass that a channel switching occured.
Definition: edca-txop-n.cc:66
virtual uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: edca-txop-n.cc:416
virtual bool GetBlockAckAgreementExists(Mac48Address address, uint8_t tid)
Definition: edca-txop-n.cc:190
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:62
void SetTxFailedCallback(TxFailed callback)
DcfManager * m_manager
Definition: edca-txop-n.h:528
void MissedAck(void)
Event handler when an ACK is received.
Definition: edca-txop-n.cc:817
enum TypeOfStation GetTypeOfStation(void) const
Return type of station.
Definition: edca-txop-n.cc:367
void SetLow(Ptr< MacLow > low)
Set MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:437
Ptr< MacLow > Low(void)
Return the MacLow associated with this EdcaTxopN.
Definition: edca-txop-n.cc:430
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:537
uint8_t GetTidInfo(void) const
Return the Traffic ID (TID).
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:2419
This queue contains packets for a particular access class.
Definition: edca-txop-n.h:82
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:473
RandomStream * m_rng
Definition: edca-txop-n.h:536
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:467
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:220
void NotifyInternalCollision(void)
Notify the EDCAF that internal collision has occurred.
Definition: edca-txop-n.cc:643
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:198
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:381
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:461
void SendDelbaFrame(Mac48Address addr, uint8_t tid, bool byOriginator)
virtual void GotAck(double snr, WifiMode txMode)
Definition: edca-txop-n.cc:104
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:306
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:533
void MissedCts(void)
Event handler when a CTS timeout has occurred.
Definition: edca-txop-n.cc:665
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:491
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:455
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:186
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1480
void NotifyChannelSwitching(void)
When a channel switching occurs, enqueued packets are removed.
Definition: edca-txop-n.cc:733
Mac48Address GetAddress(void) const
Return the MAC address of this MacLow.
Definition: mac-low.cc:625
void SetTxMiddle(MacTxMiddle *txMiddle)
bool IsAccessRequested(void) const
Definition: dcf-manager.cc:142
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:112
virtual ~EdcaTxopN()
Definition: edca-txop-n.cc:277
virtual void StartNext(void)
Invoked when ns3::MacLow wants to start a new transmission as configured by MacLowTransmissionParamet...
Definition: edca-txop-n.cc:120
uint32_t GetNRetryNeededPackets(Mac48Address recipient, uint8_t tid) const
Definition: edca-txop-n.cc:318
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:74
uint8_t m_fragmentNumber
Definition: edca-txop-n.h:538
void SetTxOkCallback(TxOk callback)
Time m_currentPacketTimestamp
Definition: edca-txop-n.h:555
uint32_t GetCwMax(void) const
Return the maximum congestion window size.
Definition: dcf-manager.cc:88
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:96
virtual void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, MacLowTransmissionListener *listener)
Definition: mac-low.cc:722
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:276
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:79
virtual uint32_t GetMinCw(void) const
Return the minimum congestion window size.
Definition: edca-txop-n.cc:402
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:887
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:115
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:169
virtual void CompleteTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:162
virtual void MissedCts(void)
ns3::MacLow did not receive an expected CTS within CtsTimeout.
Definition: edca-txop-n.cc:100
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:958
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:184
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.
void StartNext(void)
Start transmission for the next fragment.
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:70
virtual Mac48Address GetSrcAddressForAggregation(const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:206
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:330
void DisableRts(void)
Do not send rts and wait for cts before sending data.
Definition: mac-low.cc:199
void Queue(Ptr< const Packet > packet, const WifiMacHeader &hdr)
Definition: edca-txop-n.cc:759
uint16_t GetNextSequenceNumberfor(WifiMacHeader *hdr)
Return the next sequence number for the given header.
Definition: edca-txop-n.cc:450
void SetMsduAggregator(Ptr< MsduAggregator > aggr)
void SetBlockAckInactivityCallback(Callback< void, Mac48Address, uint8_t, bool > callback)
uint8_t GetTid(void) const
Return the Traffic ID (TID).
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:174
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:158
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:554
void SetCwMax(uint32_t maxCw)
Set the maximum congestion window size.
Definition: dcf-manager.cc:69
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:54
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:154
static TypeId GetTypeId(void)
Definition: edca-txop-n.cc:222
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.
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:194
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:186
uint32_t GetCw(void) const
Definition: dcf-manager.cc:124
uint32_t GetAifsn(void) const
Return the number of slots that make up an AIFS.
Definition: dcf-manager.cc:76
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:964
void SetBlockAckThreshold(uint8_t nPackets)
Implement the header for management frames of type add block ack response.
Definition: mgt-headers.h:670
QosBlockedDestinations * m_qosBlockedDestinations
Definition: edca-txop-n.h:548
void CompleteAmpduExchange(Mac48Address recipient, uint8_t tid)
Implement the header for management frames of type del block ack.
Definition: mgt-headers.h:791
void CompleteAmpduTransfer(Mac48Address recipient, uint8_t tid)
Definition: edca-txop-n.cc:324
#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:532
typedef for union of different ActionValues
Definition: mgt-headers.h:486
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:524
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:44
void SetTxMiddle(MacTxMiddle *txMiddle)
Definition: edca-txop-n.cc:423
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:658
bool NeedFragmentation(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
void EnableNextData(uint32_t size)
Definition: mac-low.cc:139
void DoDispose()
Destructor implementation.
Definition: edca-txop-n.cc:283
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:154
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:144
Ptr< MpduAggregator > GetMpduAggregator(void)
Definition: mac-low.cc:2711
virtual uint32_t GetMaxCw(void) const
Return the maximum congestion window size.
Definition: edca-txop-n.cc:409
bool NeedRtsRetransmission(Mac48Address address, const WifiMacHeader *header, Ptr< const Packet > packet)
Ptr< WifiMacQueue > m_queue
Definition: edca-txop-n.h:529
void StartAccessIfNeeded(void)
Request access from DCF manager if needed.
Definition: edca-txop-n.cc:976
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:988
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:170
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:57
void UpdateFailedCw(void)
Update the value of the CW variable to take into account a transmission failure.
Definition: dcf-manager.cc:100
Ptr< MsduAggregator > m_aggregator
Definition: edca-txop-n.h:546
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:674
Headers for Block ack request.
Definition: ctrl-headers.h:50
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:3130
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:58
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:189
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:312
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:58
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:444
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:826
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:36
uint32_t GetFragmentOffset(void)
Calculate the offset for the current fragment.
AggregationCapableTransmissionListener * m_blockAckListener
Definition: edca-txop-n.h:535
bool IsRetry(void) const
Return if the Retry bit is set.
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:255
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:395
TypeOfStation m_typeOfStation
Definition: edca-txop-n.h:547
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:374
void SetDsNotFrom(void)
Un-set the From DS bit in the Frame Control field.
virtual Ptr< WifiMacQueue > GetQueue(void)
Definition: edca-txop-n.cc:132
uint16_t GetSequenceNumber(void) const
Return the sequence number of the header.
Dcf(EdcaTxopN *txop)
Definition: edca-txop-n.cc:48