A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
mac-low.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2005,2006 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 
23 #include "ns3/assert.h"
24 #include "ns3/packet.h"
25 #include "ns3/simulator.h"
26 #include "ns3/tag.h"
27 #include "ns3/log.h"
28 #include "ns3/node.h"
29 #include "ns3/double.h"
30 
31 #include "mac-low.h"
32 #include "wifi-phy.h"
33 #include "wifi-mac-trailer.h"
34 #include "qos-utils.h"
35 #include "edca-txop-n.h"
36 #include "snr-tag.h"
37 
38 NS_LOG_COMPONENT_DEFINE ("MacLow");
39 
40 #undef NS_LOG_APPEND_CONTEXT
41 #define NS_LOG_APPEND_CONTEXT std::clog << "[mac=" << m_self << "] "
42 
43 
44 namespace ns3 {
45 
47 {
48 }
50 {
51 }
52 void
54  Mac48Address source)
55 {
56 }
57 void
59 {
60 }
62 {
63 }
65 {
66 }
67 
69 {
70 }
72 {
73 }
74 
76  : m_nextSize (0),
77  m_waitAck (ACK_NONE),
78  m_sendRts (false),
79  m_overrideDurationId (Seconds (0))
80 {
81 }
82 void
84 {
85  m_nextSize = size;
86 }
87 void
89 {
90  m_nextSize = 0;
91 }
92 void
94 {
95  m_overrideDurationId = durationId;
96 }
97 void
99 {
100  m_overrideDurationId = Seconds (0);
101 }
102 void
104 {
106 }
107 void
109 {
111 }
112 void
114 {
116 }
117 void
119 {
121 }
122 void
124 {
126 }
127 void
129 {
131 }
132 void
134 {
136 }
137 void
139 {
140  m_sendRts = true;
141 }
142 void
144 {
145  m_sendRts = false;
146 }
147 bool
149 {
150  return (m_waitAck != ACK_NONE);
151 }
152 bool
154 {
155  return (m_waitAck == ACK_NORMAL);
156 }
157 bool
159 {
160  return (m_waitAck == ACK_FAST);
161 }
162 bool
164 {
165  return (m_waitAck == ACK_SUPER_FAST);
166 }
167 bool
169 {
170  return (m_waitAck == BLOCK_ACK_BASIC) ? true : false;
171 }
172 bool
174 {
175  return (m_waitAck == BLOCK_ACK_COMPRESSED) ? true : false;
176 }
177 bool
179 {
180  return (m_waitAck == BLOCK_ACK_MULTI_TID) ? true : false;
181 }
182 bool
184 {
185  return m_sendRts;
186 }
187 bool
189 {
190  return (m_overrideDurationId != Seconds (0));
191 }
192 Time
194 {
195  NS_ASSERT (m_overrideDurationId != Seconds (0));
196  return m_overrideDurationId;
197 }
198 bool
200 {
201  return (m_nextSize != 0);
202 }
203 uint32_t
205 {
207  return m_nextSize;
208 }
209 
210 std::ostream &operator << (std::ostream &os, const MacLowTransmissionParameters &params)
211 {
212  os << "["
213  << "send rts=" << params.m_sendRts << ", "
214  << "next size=" << params.m_nextSize << ", "
215  << "dur=" << params.m_overrideDurationId << ", "
216  << "ack=";
217  switch (params.m_waitAck)
218  {
220  os << "none";
221  break;
223  os << "normal";
224  break;
226  os << "fast";
227  break;
229  os << "super-fast";
230  break;
232  os << "basic-block-ack";
233  break;
235  os << "compressed-block-ack";
236  break;
238  os << "multi-tid-block-ack";
239  break;
240  }
241  os << "]";
242  return os;
243 }
244 
245 
246 /***************************************************************
247  * Listener for PHY events. Forwards to MacLow
248  ***************************************************************/
249 
250 
252 {
253 public:
255  : m_macLow (macLow)
256  {
257  }
259  {
260  }
261  virtual void NotifyRxStart (Time duration)
262  {
263  }
264  virtual void NotifyRxEndOk (void)
265  {
266  }
267  virtual void NotifyRxEndError (void)
268  {
269  }
270  virtual void NotifyTxStart (Time duration)
271  {
272  }
273  virtual void NotifyMaybeCcaBusyStart (Time duration)
274  {
275  }
276  virtual void NotifySwitchingStart (Time duration)
277  {
278  m_macLow->NotifySwitchingStartNow (duration);
279  }
280 private:
282 };
283 
284 
286  : m_normalAckTimeoutEvent (),
287  m_fastAckTimeoutEvent (),
288  m_superFastAckTimeoutEvent (),
289  m_fastAckFailedTimeoutEvent (),
290  m_blockAckTimeoutEvent (),
291  m_ctsTimeoutEvent (),
292  m_sendCtsEvent (),
293  m_sendAckEvent (),
294  m_sendDataEvent (),
295  m_waitSifsEvent (),
296  m_endTxNoAckEvent (),
297  m_currentPacket (0),
298  m_listener (0)
299 {
300  NS_LOG_FUNCTION (this);
301  m_lastNavDuration = Seconds (0);
302  m_lastNavStart = Seconds (0);
303  m_promisc = false;
304 }
305 
307 {
308  NS_LOG_FUNCTION (this);
309 }
310 
311 void
313 {
316 }
317 
318 
319 void
321 {
322  NS_LOG_FUNCTION (this);
335  m_phy = 0;
336  m_stationManager = 0;
337  delete m_phyMacLowListener;
339 }
340 
341 void
343 {
344  NS_LOG_FUNCTION (this);
345  bool oneRunning = false;
347  {
349  oneRunning = true;
350  }
352  {
354  oneRunning = true;
355  }
357  {
359  oneRunning = true;
360  }
362  {
364  oneRunning = true;
365  }
367  {
369  oneRunning = true;
370  }
372  {
374  oneRunning = true;
375  }
376  if (m_sendCtsEvent.IsRunning ())
377  {
379  oneRunning = true;
380  }
381  if (m_sendAckEvent.IsRunning ())
382  {
384  oneRunning = true;
385  }
386  if (m_sendDataEvent.IsRunning ())
387  {
389  oneRunning = true;
390  }
391  if (m_waitSifsEvent.IsRunning ())
392  {
394  oneRunning = true;
395  }
396  if (m_waitRifsEvent.IsRunning ())
397  {
399  oneRunning = true;
400  }
402  {
404  oneRunning = true;
405  }
406  if (oneRunning && m_listener != 0)
407  {
408  m_listener->Cancel ();
409  m_listener = 0;
410  }
411 }
412 
413 void
415 {
416  m_phy = phy;
420 }
421 void
423 {
424  m_stationManager = manager;
425 }
426 
427 void
429 {
430  m_self = ad;
431 }
432 void
434 {
435  m_ackTimeout = ackTimeout;
436 }
437 void
439 {
440  m_basicBlockAckTimeout = blockAckTimeout;
441 }
442 void
444 {
445  m_compressedBlockAckTimeout = blockAckTimeout;
446 }
447 void
449 {
450  m_ctsToSelfSupported = enable;
451 }
452 bool
454 {
455  return m_ctsToSelfSupported;
456 }
457 void
459 {
460  m_ctsTimeout = ctsTimeout;
461 }
462 void
464 {
465  m_sifs = sifs;
466 }
467 void
469 {
470  m_slotTime = slotTime;
471 }
472 void
474 {
475  m_pifs = pifs;
476 }
477 void
479 {
480  m_rifs = rifs;
481 }
482 void
484 {
485  m_bssid = bssid;
486 }
487 void
489 {
490  m_promisc = true;
491 }
493 MacLow::GetAddress (void) const
494 {
495  return m_self;
496 }
497 Time
499 {
500  return m_ackTimeout;
501 }
502 Time
504 {
505  return m_basicBlockAckTimeout;
506 }
507 Time
509 {
511 }
512 Time
514 {
515  return m_ctsTimeout;
516 }
517 Time
518 MacLow::GetSifs (void) const
519 {
520  return m_sifs;
521 }
522 Time
523 MacLow::GetRifs (void) const
524 {
525  return m_rifs;
526 }
527 Time
529 {
530  return m_slotTime;
531 }
532 Time
533 MacLow::GetPifs (void) const
534 {
535  return m_pifs;
536 }
538 MacLow::GetBssid (void) const
539 {
540  return m_bssid;
541 }
542 
543 void
545 {
546  m_rxCallback = callback;
547 }
548 void
550 {
551  m_dcfListeners.push_back (listener);
552 }
553 
554 
555 void
557  const WifiMacHeader* hdr,
559  MacLowTransmissionListener *listener)
560 {
561  NS_LOG_FUNCTION (this << packet << hdr << params << listener);
562  /* m_currentPacket is not NULL because someone started
563  * a transmission and was interrupted before one of:
564  * - ctsTimeout
565  * - sendDataAfterCTS
566  * expired. This means that one of these timers is still
567  * running. They are all cancelled below anyway by the
568  * call to CancelAllEvents (because of at least one
569  * of these two timer) which will trigger a call to the
570  * previous listener's cancel method.
571  *
572  * This typically happens because the high-priority
573  * QapScheduler has taken access to the channel from
574  * one of the Edca of the QAP.
575  */
576  m_currentPacket = packet->Copy ();
577  m_currentHdr = *hdr;
578  CancelAllEvents ();
579  m_listener = listener;
580  m_txParams = params;
581 
582  //NS_ASSERT (m_phy->IsStateIdle ());
583 
584  NS_LOG_DEBUG ("startTx size=" << GetSize (m_currentPacket, &m_currentHdr) <<
585  ", to=" << m_currentHdr.GetAddr1 () << ", listener=" << m_listener);
586 
587  if (m_txParams.MustSendRts ())
588  {
589  SendRtsForPacket ();
590  }
591  else
592  {
594  {
595  SendCtsToSelf();
596  }
597  else
598  {
599  SendDataPacket ();
600  }
601  }
602 
603  /* When this method completes, we have taken ownership of the medium. */
604  NS_ASSERT (m_phy->IsStateTx ());
605 }
606 bool
608 {
610  return m_stationManager->NeedCtsToSelf (dataTxVector);
611 }
612 void
614 {
615  NS_LOG_FUNCTION (this << packet << rxSnr);
616  NS_LOG_DEBUG ("rx failed ");
618  {
622  }
623  return;
624 }
625 
626 void
628 {
629  NS_LOG_DEBUG ("switching channel. Cancelling MAC pending events");
630  m_stationManager->Reset ();
631  CancelAllEvents ();
633  {
635  }
637  m_lastNavDuration = Seconds (0);
638  m_currentPacket = 0;
639  m_listener = 0;
640 }
641 
642 void
643 MacLow::ReceiveOk (Ptr<Packet> packet, double rxSnr, WifiMode txMode, WifiPreamble preamble)
644 {
645  NS_LOG_FUNCTION (this << packet << rxSnr << txMode << preamble);
646  /* A packet is received from the PHY.
647  * When we have handled this packet,
648  * we handle any packet present in the
649  * packet queue.
650  */
651  WifiMacHeader hdr;
652  packet->RemoveHeader (hdr);
653 
654  bool isPrevNavZero = IsNavZero ();
655  NS_LOG_DEBUG ("duration/id=" << hdr.GetDuration ());
656  NotifyNav (packet,hdr, txMode, preamble);
657  if (hdr.IsRts ())
658  {
659  /* see section 9.2.5.7 802.11-1999
660  * A STA that is addressed by an RTS frame shall transmit a CTS frame after a SIFS
661  * period if the NAV at the STA receiving the RTS frame indicates that the medium is
662  * idle. If the NAV at the STA receiving the RTS indicates the medium is not idle,
663  * that STA shall not respond to the RTS frame.
664  */
665  if (isPrevNavZero
666  && hdr.GetAddr1 () == m_self)
667  {
668  NS_LOG_DEBUG ("rx RTS from=" << hdr.GetAddr2 () << ", schedule CTS");
670  m_stationManager->ReportRxOk (hdr.GetAddr2 (), &hdr,
671  rxSnr, txMode);
674  hdr.GetAddr2 (),
675  hdr.GetDuration (),
676  txMode,
677  rxSnr);
678  }
679  else
680  {
681  NS_LOG_DEBUG ("rx RTS from=" << hdr.GetAddr2 () << ", cannot schedule CTS");
682  }
683  }
684  else if (hdr.IsCts ()
685  && hdr.GetAddr1 () == m_self
687  && m_currentPacket != 0)
688  {
689  NS_LOG_DEBUG ("receive cts from=" << m_currentHdr.GetAddr1 ());
690  SnrTag tag;
691  packet->RemovePacketTag (tag);
693  rxSnr, txMode);
695  rxSnr, txMode, tag.Get ());
696 
699  m_listener->GotCts (rxSnr, txMode);
703  hdr.GetAddr1 (),
704  hdr.GetDuration (),
705  txMode);
706  }
707  else if (hdr.IsAck ()
708  && hdr.GetAddr1 () == m_self
712  && m_txParams.MustWaitAck ())
713  {
714  NS_LOG_DEBUG ("receive ack from=" << m_currentHdr.GetAddr1 ());
715  SnrTag tag;
716  packet->RemovePacketTag (tag);
718  rxSnr, txMode);
720  rxSnr, txMode, tag.Get ());
721  bool gotAck = false;
724  {
727  gotAck = true;
728  }
731  {
734  gotAck = true;
735  }
736  if (gotAck)
737  {
738  m_listener->GotAck (rxSnr, txMode);
739  }
740  if (m_txParams.HasNextPacket ())
741  {
744  }
745  }
746  else if (hdr.IsBlockAck () && hdr.GetAddr1 () == m_self
749  {
750  NS_LOG_DEBUG ("got block ack from " << hdr.GetAddr2 ());
751  CtrlBAckResponseHeader blockAck;
752  packet->RemoveHeader (blockAck);
754  m_listener->GotBlockAck (&blockAck, hdr.GetAddr2 ());
755  }
756  else if (hdr.IsBlockAckReq () && hdr.GetAddr1 () == m_self)
757  {
758  CtrlBAckRequestHeader blockAckReq;
759  packet->RemoveHeader (blockAckReq);
760  if (!blockAckReq.IsMultiTid ())
761  {
762  uint8_t tid = blockAckReq.GetTidInfo ();
763  AgreementsI it = m_bAckAgreements.find (std::make_pair (hdr.GetAddr2 (), tid));
764  if (it != m_bAckAgreements.end ())
765  {
766  //Update block ack cache
767  BlockAckCachesI i = m_bAckCaches.find (std::make_pair (hdr.GetAddr2 (), tid));
768  NS_ASSERT (i != m_bAckCaches.end ());
769  (*i).second.UpdateWithBlockAckReq (blockAckReq.GetStartingSequence ());
770 
772  /* See section 11.5.3 in IEEE802.11 for mean of this timer */
773  ResetBlockAckInactivityTimerIfNeeded (it->second.first);
774  if ((*it).second.first.IsImmediateBlockAck ())
775  {
776  NS_LOG_DEBUG ("rx blockAckRequest/sendImmediateBlockAck from=" << hdr.GetAddr2 ());
779  blockAckReq,
780  hdr.GetAddr2 (),
781  hdr.GetDuration (),
782  txMode);
783  }
784  else
785  {
786  NS_FATAL_ERROR ("Delayed block ack not supported.");
787  }
788  }
789  else
790  {
791  NS_LOG_DEBUG ("There's not a valid agreement for this block ack request.");
792  }
793  }
794  else
795  {
796  NS_FATAL_ERROR ("Multi-tid block ack is not supported.");
797  }
798  }
799  else if (hdr.IsCtl ())
800  {
801  NS_LOG_DEBUG ("rx drop " << hdr.GetTypeString ());
802  }
803  else if (hdr.GetAddr1 () == m_self)
804  {
805  m_stationManager->ReportRxOk (hdr.GetAddr2 (), &hdr,
806  rxSnr, txMode);
807 
808  if (hdr.IsQosData () && StoreMpduIfNeeded (packet, hdr))
809  {
810  /* From section 9.10.4 in IEEE802.11:
811  Upon the receipt of a QoS data frame from the originator for which
812  the Block Ack agreement exists, the recipient shall buffer the MSDU
813  regardless of the value of the Ack Policy subfield within the
814  QoS Control field of the QoS data frame. */
815  if (hdr.IsQosAck ())
816  {
817  AgreementsI it = m_bAckAgreements.find (std::make_pair (hdr.GetAddr2 (), hdr.GetQosTid ()));
818  RxCompleteBufferedPacketsWithSmallerSequence (it->second.first.GetStartingSequence (),
819  hdr.GetAddr2 (), hdr.GetQosTid ());
824  hdr.GetAddr2 (),
825  hdr.GetDuration (),
826  txMode,
827  rxSnr);
828  }
829  else if (hdr.IsQosBlockAck ())
830  {
831  AgreementsI it = m_bAckAgreements.find (std::make_pair (hdr.GetAddr2 (), hdr.GetQosTid ()));
832  /* See section 11.5.3 in IEEE802.11 for mean of this timer */
833  ResetBlockAckInactivityTimerIfNeeded (it->second.first);
834  }
835  return;
836  }
837  else if (hdr.IsQosData () && hdr.IsQosBlockAck ())
838  {
839  /* This happens if a packet with ack policy Block Ack is received and a block ack
840  agreement for that packet doesn't exist.
841 
842  From section 11.5.3 in IEEE802.11e:
843  When a recipient does not have an active Block ack for a TID, but receives
844  data MPDUs with the Ack Policy subfield set to Block Ack, it shall discard
845  them and shall send a DELBA frame using the normal access
846  mechanisms. */
847  AcIndex ac = QosUtilsMapTidToAc (hdr.GetQosTid ());
848  m_edcaListeners[ac]->BlockAckInactivityTimeout (hdr.GetAddr2 (), hdr.GetQosTid ());
849  return;
850  }
851  else if (hdr.IsQosData () && hdr.IsQosNoAck ())
852  {
853  NS_LOG_DEBUG ("rx unicast/noAck from=" << hdr.GetAddr2 ());
854  }
855  else if (hdr.IsData () || hdr.IsMgt ())
856  {
857  NS_LOG_DEBUG ("rx unicast/sendAck from=" << hdr.GetAddr2 ());
861  hdr.GetAddr2 (),
862  hdr.GetDuration (),
863  txMode,
864  rxSnr);
865  }
866  goto rxPacket;
867  }
868  else if (hdr.GetAddr1 ().IsGroup ())
869  {
870  if (hdr.IsData () || hdr.IsMgt ())
871  {
872  NS_LOG_DEBUG ("rx group from=" << hdr.GetAddr2 ());
873  goto rxPacket;
874  }
875  else
876  {
877  // DROP
878  }
879  }
880  else if (m_promisc)
881  {
882  NS_ASSERT (hdr.GetAddr1 () != m_self);
883  if (hdr.IsData ())
884  {
885  goto rxPacket;
886  }
887  }
888  else
889  {
890  //NS_LOG_DEBUG_VERBOSE ("rx not-for-me from %d", GetSource (packet));
891  }
892  return;
893 rxPacket:
894  WifiMacTrailer fcs;
895  packet->RemoveTrailer (fcs);
896  m_rxCallback (packet, &hdr);
897  return;
898 }
899 
900 uint32_t
901 MacLow::GetAckSize (void) const
902 {
903  WifiMacHeader ack;
905  return ack.GetSize () + 4;
906 }
907 uint32_t
909 {
910  WifiMacHeader hdr;
912  CtrlBAckResponseHeader blockAck;
913  if (type == BASIC_BLOCK_ACK)
914  {
915  blockAck.SetType (BASIC_BLOCK_ACK);
916  }
917  else if (type == COMPRESSED_BLOCK_ACK)
918  {
919  blockAck.SetType (COMPRESSED_BLOCK_ACK);
920  }
921  else if (type == MULTI_TID_BLOCK_ACK)
922  {
923  //Not implemented
924  NS_ASSERT (false);
925  }
926  return hdr.GetSize () + blockAck.GetSerializedSize () + 4;
927 }
928 uint32_t
929 MacLow::GetRtsSize (void) const
930 {
931  WifiMacHeader rts;
933  return rts.GetSize () + 4;
934 }
935 Time
937 {
938  WifiTxVector ackTxVector = GetAckTxVectorForData (to, dataTxVector.GetMode());
939  return GetAckDuration (ackTxVector);
940 }
941 Time
943 {
944  WifiPreamble preamble;
945  if (ackTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
946  preamble= WIFI_PREAMBLE_HT_MF;
947  else
948  preamble=WIFI_PREAMBLE_LONG;
949  return m_phy->CalculateTxDuration (GetAckSize (), ackTxVector, preamble);
950 }
951 Time
952 MacLow::GetBlockAckDuration (Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const
953 {
954  /*
955  * For immediate BlockAck we should transmit the frame with the same WifiMode
956  * as the BlockAckReq.
957  *
958  * from section 9.6 in IEEE802.11e:
959  * The BlockAck control frame shall be sent at the same rate and modulation class as
960  * the BlockAckReq frame if it is sent in response to a BlockAckReq frame.
961  */
962  WifiPreamble preamble;
963  if (blockAckReqTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
964  preamble= WIFI_PREAMBLE_HT_MF;
965  else
966  preamble=WIFI_PREAMBLE_LONG;
967  return m_phy->CalculateTxDuration (GetBlockAckSize (type), blockAckReqTxVector, preamble);
968 }
969 Time
971 {
972  WifiTxVector ctsTxVector = GetCtsTxVectorForRts (to, rtsTxVector.GetMode());
973  return GetCtsDuration (ctsTxVector);
974 }
975 
976 Time
978 {
979  WifiPreamble preamble;
980  if (ctsTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
981  preamble= WIFI_PREAMBLE_HT_MF;
982  else
983  preamble=WIFI_PREAMBLE_LONG;
984  return m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, preamble);
985 }
986 uint32_t
987 MacLow::GetCtsSize (void) const
988 {
989  WifiMacHeader cts;
991  return cts.GetSize () + 4;
992 }
993 uint32_t
995 {
996  WifiMacTrailer fcs;
997  return packet->GetSize () + hdr->GetSize () + fcs.GetSerializedSize ();
998 }
999 
1002 {
1003  return m_stationManager->GetCtsToSelfTxVector (hdr, packet);
1004 }
1005 
1008 {
1009  Mac48Address to = hdr->GetAddr1 ();
1010  return m_stationManager->GetRtsTxVector (to, hdr, packet);
1011 }
1014 {
1015  Mac48Address to = hdr->GetAddr1 ();
1016  WifiMacTrailer fcs;
1017  uint32_t size = packet->GetSize ()+ hdr->GetSize () + fcs.GetSerializedSize ();
1018  //size is not used in anything!! will not worry about aggregation
1019  return m_stationManager->GetDataTxVector (to, hdr, packet, size);
1020 }
1023 {
1024  return m_stationManager->GetCtsTxVector (to, rtsTxMode);
1025 }
1028 {
1029  return m_stationManager->GetAckTxVector (to, dataTxMode);
1030 }
1033 {
1034  return m_stationManager->GetBlockAckTxVector (to, dataTxMode);
1035 }
1036 
1039 {
1040  return GetCtsTxVector (to, rtsTxMode);
1041 }
1044 {
1045  return GetAckTxVector (to, dataTxMode);
1046 }
1047 
1048 
1049 Time
1051  const WifiMacHeader* hdr,
1052  const MacLowTransmissionParameters& params) const
1053 {
1054  WifiPreamble preamble;
1055  Time txTime = Seconds (0);
1056  if (params.MustSendRts ())
1057  {
1058  WifiTxVector rtsTxVector = GetRtsTxVector (packet, hdr);
1059  //standard says RTS packets can have GF format sec 9.6.0e.1 page 110 bullet b 2
1060  if (m_phy->GetGreenfield () && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
1061  {
1062  preamble = WIFI_PREAMBLE_HT_GF;
1063  }
1064  else if (rtsTxVector.GetMode ().GetModulationClass () == WIFI_MOD_CLASS_HT)
1065  {
1066  preamble = WIFI_PREAMBLE_HT_MF;
1067  }
1068  else
1069  {
1070  preamble = WIFI_PREAMBLE_LONG;
1071  }
1072  txTime += m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble);
1073  txTime += GetCtsDuration (hdr->GetAddr1 (), rtsTxVector);
1074  txTime += Time (GetSifs () * 2);
1075  }
1076  WifiTxVector dataTxVector = GetDataTxVector (packet, hdr);
1077  //standard says RTS packets can have GF format sec 9.6.0e.1 page 110 bullet b 2
1078  if ( m_phy->GetGreenfield()&& m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
1079  preamble= WIFI_PREAMBLE_HT_GF;
1080  else if (dataTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1081  preamble= WIFI_PREAMBLE_HT_MF;
1082  else
1083  preamble=WIFI_PREAMBLE_LONG;
1084  uint32_t dataSize = GetSize (packet, hdr);
1085  txTime += m_phy->CalculateTxDuration (dataSize, dataTxVector, preamble);
1086  if (params.MustWaitAck ())
1087  {
1088  txTime += GetSifs ();
1089  txTime += GetAckDuration (hdr->GetAddr1 (), dataTxVector);
1090  }
1091  return txTime;
1092 }
1093 
1094 Time
1096  const WifiMacHeader* hdr,
1097  const MacLowTransmissionParameters& params) const
1098 {
1099  Time txTime = CalculateOverallTxTime (packet, hdr, params);
1100  if (params.HasNextPacket ())
1101  {
1102  WifiTxVector dataTxVector = GetDataTxVector (packet, hdr);
1103  WifiPreamble preamble;
1104  //standard says RTS packets can have GF format sec 9.6.0e.1 page 110 bullet b 2
1105  if ( m_phy->GetGreenfield()&& m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
1106  preamble= WIFI_PREAMBLE_HT_GF;
1107  else if (dataTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1108  preamble= WIFI_PREAMBLE_HT_MF;
1109  else
1110  preamble=WIFI_PREAMBLE_LONG;
1111  txTime += GetSifs ();
1112  txTime += m_phy->CalculateTxDuration (params.GetNextPacketSize (), dataTxVector, preamble);
1113  }
1114  return txTime;
1115 }
1116 
1117 void
1119 {
1121  Time duration = hdr.GetDuration ();
1122 
1123  if (hdr.IsCfpoll ()
1124  && hdr.GetAddr2 () == m_bssid)
1125  {
1126  // see section 9.3.2.2 802.11-1999
1127  DoNavResetNow (duration);
1128  return;
1129  }
1132  else if (hdr.GetAddr1 () != m_self)
1133  {
1134  // see section 9.2.5.4 802.11-1999
1135  bool navUpdated = DoNavStartNow (duration);
1136  if (hdr.IsRts () && navUpdated)
1137  {
1146  WifiMacHeader cts;
1147  cts.SetType (WIFI_MAC_CTL_CTS);
1148  WifiTxVector txVector=GetRtsTxVector (packet, &hdr);
1149  Time navCounterResetCtsMissedDelay =
1150  m_phy->CalculateTxDuration (cts.GetSerializedSize (), txVector, preamble) +
1151  Time (2 * GetSifs ()) + Time (2 * GetSlotTime ());
1152  m_navCounterResetCtsMissed = Simulator::Schedule (navCounterResetCtsMissedDelay,
1154  Simulator::Now ());
1155  }
1156  }
1157 }
1158 
1159 void
1161 {
1162  if (m_phy->GetLastRxStartTime () < rtsEndRxTime)
1163  {
1164  DoNavResetNow (Seconds (0.0));
1165  }
1166 }
1167 
1168 void
1170 {
1171  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++)
1172  {
1173  (*i)->NavReset (duration);
1174  }
1176  m_lastNavStart = duration;
1177 }
1178 bool
1180 {
1181  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++)
1182  {
1183  (*i)->NavStart (duration);
1184  }
1185  Time newNavEnd = Simulator::Now () + duration;
1186  Time oldNavEnd = m_lastNavStart + m_lastNavDuration;
1187  if (newNavEnd > oldNavEnd)
1188  {
1190  m_lastNavDuration = duration;
1191  return true;
1192  }
1193  return false;
1194 }
1195 void
1197 {
1198  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++)
1199  {
1200  (*i)->AckTimeoutStart (duration);
1201  }
1202 }
1203 void
1205 {
1206  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++)
1207  {
1208  (*i)->AckTimeoutReset ();
1209  }
1210 }
1211 void
1213 {
1214  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++)
1215  {
1216  (*i)->CtsTimeoutStart (duration);
1217  }
1218 }
1219 void
1221 {
1222  for (DcfListenersCI i = m_dcfListeners.begin (); i != m_dcfListeners.end (); i++)
1223  {
1224  (*i)->CtsTimeoutReset ();
1225  }
1226 }
1227 
1228 void
1230  WifiTxVector txVector, WifiPreamble preamble)
1231 {
1232  NS_LOG_FUNCTION (this << packet << hdr << txVector);
1233  NS_LOG_DEBUG ("send " << hdr->GetTypeString () <<
1234  ", to=" << hdr->GetAddr1 () <<
1235  ", size=" << packet->GetSize () <<
1236  ", mode=" << txVector.GetMode() <<
1237  ", duration=" << hdr->GetDuration () <<
1238  ", seq=0x" << std::hex << m_currentHdr.GetSequenceControl () << std::dec);
1239  m_phy->SendPacket (packet, txVector.GetMode(), preamble, txVector);
1240 }
1241 
1242 void
1244 {
1245  NS_LOG_FUNCTION (this);
1246  NS_LOG_DEBUG ("cts timeout");
1250  m_stationManager->ReportRtsFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
1251  m_currentPacket = 0;
1253  m_listener = 0;
1254  listener->MissedCts ();
1255 }
1256 void
1258 {
1259  NS_LOG_FUNCTION (this);
1260  NS_LOG_DEBUG ("normal ack timeout");
1264  m_stationManager->ReportDataFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
1266  m_listener = 0;
1267  listener->MissedAck ();
1268 }
1269 void
1271 {
1272  NS_LOG_FUNCTION (this);
1273  m_stationManager->ReportDataFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
1275  m_listener = 0;
1276  if (m_phy->IsStateIdle ())
1277  {
1278  NS_LOG_DEBUG ("fast Ack idle missed");
1279  listener->MissedAck ();
1280  }
1281  else
1282  {
1283  NS_LOG_DEBUG ("fast Ack ok");
1284  }
1285 }
1286 void
1288 {
1289  NS_LOG_FUNCTION (this);
1290  NS_LOG_DEBUG ("block ack timeout");
1291 
1292  m_stationManager->ReportDataFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
1294  m_listener = 0;
1295  listener->MissedBlockAck ();
1296 }
1297 void
1299 {
1300  NS_LOG_FUNCTION (this);
1301  m_stationManager->ReportDataFailed (m_currentHdr.GetAddr1 (), &m_currentHdr);
1303  m_listener = 0;
1304  if (m_phy->IsStateIdle ())
1305  {
1306  NS_LOG_DEBUG ("super fast Ack failed");
1307  listener->MissedAck ();
1308  }
1309  else
1310  {
1311  NS_LOG_DEBUG ("super fast Ack ok");
1312  listener->GotAck (0.0, WifiMode ());
1313  }
1314 }
1315 
1316 void
1318 {
1319  NS_LOG_FUNCTION (this);
1320  /* send an RTS for this packet. */
1321  WifiMacHeader rts;
1322  rts.SetType (WIFI_MAC_CTL_RTS);
1323  rts.SetDsNotFrom ();
1324  rts.SetDsNotTo ();
1325  rts.SetNoRetry ();
1326  rts.SetNoMoreFragments ();
1327  rts.SetAddr1 (m_currentHdr.GetAddr1 ());
1328  rts.SetAddr2 (m_self);
1330  Time duration = Seconds (0);
1331 
1332  WifiPreamble preamble;
1333  //standard says RTS packets can have GF format sec 9.6.0e.1 page 110 bullet b 2
1334  if ( m_phy->GetGreenfield()&& m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
1335  preamble= WIFI_PREAMBLE_HT_GF;
1336  else if (rtsTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1337  preamble= WIFI_PREAMBLE_HT_MF;
1338  else
1339  preamble=WIFI_PREAMBLE_LONG;
1340 
1341  if (m_txParams.HasDurationId ())
1342  {
1343  duration += m_txParams.GetDurationId ();
1344  }
1345  else
1346  {
1348  duration += GetSifs ();
1349  duration += GetCtsDuration (m_currentHdr.GetAddr1 (), rtsTxVector);
1350  duration += GetSifs ();
1352  dataTxVector, preamble);
1353  duration += GetSifs ();
1354  duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1355  }
1356  rts.SetDuration (duration);
1357 
1358  Time txDuration = m_phy->CalculateTxDuration (GetRtsSize (), rtsTxVector, preamble);
1359  Time timerDelay = txDuration + GetCtsTimeout ();
1360 
1362  NotifyCtsTimeoutStartNow (timerDelay);
1364 
1365  Ptr<Packet> packet = Create<Packet> ();
1366  packet->AddHeader (rts);
1367  WifiMacTrailer fcs;
1368  packet->AddTrailer (fcs);
1369 
1370  ForwardDown (packet, &rts, rtsTxVector,preamble);
1371 }
1372 
1373 void
1375 {
1376  WifiPreamble preamble;
1377 
1378  //Since it is data then it can have format = GF
1379  if (m_phy->GetGreenfield() && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
1380  preamble= WIFI_PREAMBLE_HT_GF;
1381  else if (dataTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1382  preamble= WIFI_PREAMBLE_HT_MF;
1383  else
1384  preamble=WIFI_PREAMBLE_LONG;
1385 
1386  Time txDuration = m_phy->CalculateTxDuration (GetSize (m_currentPacket, &m_currentHdr), dataTxVector, preamble);
1388  {
1389  Time timerDelay = txDuration + GetAckTimeout ();
1391  NotifyAckTimeoutStartNow (timerDelay);
1393  }
1394  else if (m_txParams.MustWaitFastAck ())
1395  {
1396  Time timerDelay = txDuration + GetPifs ();
1398  NotifyAckTimeoutStartNow (timerDelay);
1400  }
1401  else if (m_txParams.MustWaitSuperFastAck ())
1402  {
1403  Time timerDelay = txDuration + GetPifs ();
1405  NotifyAckTimeoutStartNow (timerDelay);
1408  }
1409  else if (m_txParams.MustWaitBasicBlockAck ())
1410  {
1411  Time timerDelay = txDuration + GetBasicBlockAckTimeout ();
1414  }
1416  {
1417  Time timerDelay = txDuration + GetCompressedBlockAckTimeout ();
1420  }
1421  else if (m_txParams.HasNextPacket ())
1422  {
1423  if (m_stationManager->HasHtSupported())
1424  {
1425  Time delay = txDuration + GetRifs ();
1428  }
1429  else
1430  {
1431  Time delay = txDuration + GetSifs ();
1434  }
1435  }
1436  else
1437  {
1438  // since we do not expect any timer to be triggered.
1439  Simulator::Schedule(txDuration, &MacLow::EndTxNoAck, this);
1440  }
1441 }
1442 
1443 void
1445 {
1446  NS_LOG_FUNCTION (this);
1447  /* send this packet directly. No RTS is needed. */
1449  WifiPreamble preamble;
1450 
1451  if (m_phy->GetGreenfield() && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
1452  //In the future has to make sure that receiver has greenfield enabled
1453  preamble= WIFI_PREAMBLE_HT_GF;
1454  else if (dataTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1455  preamble= WIFI_PREAMBLE_HT_MF;
1456  else
1457  preamble=WIFI_PREAMBLE_LONG;
1458 
1459  StartDataTxTimers (dataTxVector);
1460 
1461  Time duration = Seconds (0.0);
1462  if (m_txParams.HasDurationId ())
1463  {
1464  duration += m_txParams.GetDurationId ();
1465  }
1466  else
1467  {
1469  {
1470  duration += GetSifs ();
1471  duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector, BASIC_BLOCK_ACK);
1472  }
1474  {
1475  duration += GetSifs ();
1476  duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector, COMPRESSED_BLOCK_ACK);
1477  }
1478  else if (m_txParams.MustWaitAck ())
1479  {
1480  duration += GetSifs ();
1481  duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1482  }
1483  if (m_txParams.HasNextPacket ())
1484  {
1485  duration += GetSifs ();
1487  dataTxVector, preamble);
1488  if (m_txParams.MustWaitAck ())
1489  {
1490  duration += GetSifs ();
1491  duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1492  }
1493  }
1494  }
1495  m_currentHdr.SetDuration (duration);
1496 
1498  WifiMacTrailer fcs;
1499  m_currentPacket->AddTrailer (fcs);
1500 
1501  ForwardDown (m_currentPacket, &m_currentHdr, dataTxVector,preamble);
1502  m_currentPacket = 0;
1503 }
1504 
1505 bool
1506 MacLow::IsNavZero (void) const
1507 {
1509  {
1510  return true;
1511  }
1512  else
1513  {
1514  return false;
1515  }
1516 }
1517 void
1519 {
1520  WifiMacHeader cts;
1521  cts.SetType (WIFI_MAC_CTL_CTS);
1522  cts.SetDsNotFrom ();
1523  cts.SetDsNotTo ();
1524  cts.SetNoMoreFragments ();
1525  cts.SetNoRetry ();
1526  cts.SetAddr1 (m_self);
1527 
1529 
1530  WifiPreamble preamble;
1531  if (ctsTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1532  preamble= WIFI_PREAMBLE_HT_MF;
1533  else
1534  preamble=WIFI_PREAMBLE_LONG;
1535 
1536  Time duration = Seconds (0);
1537 
1538  if (m_txParams.HasDurationId ())
1539  {
1540  duration += m_txParams.GetDurationId ();
1541  }
1542  else
1543  {
1545  duration += GetSifs ();
1547  dataTxVector, preamble);
1549  {
1550 
1551  duration += GetSifs ();
1552  duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector, BASIC_BLOCK_ACK);
1553  }
1555  {
1556  duration += GetSifs ();
1557  duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector, COMPRESSED_BLOCK_ACK);
1558  }
1559  else if (m_txParams.MustWaitAck ())
1560  {
1561  duration += GetSifs ();
1562  duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1563  }
1564  if (m_txParams.HasNextPacket ())
1565  {
1566  duration += GetSifs ();
1568  dataTxVector, preamble);
1570  {
1571  duration += GetSifs ();
1572  duration += GetBlockAckDuration (m_currentHdr.GetAddr1 (), dataTxVector, COMPRESSED_BLOCK_ACK);
1573  }
1574  else if (m_txParams.MustWaitAck ())
1575  {
1576  duration += GetSifs ();
1577  duration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1578  }
1579  }
1580  }
1581 
1582  cts.SetDuration (duration);
1583 
1584  Ptr<Packet> packet = Create<Packet> ();
1585  packet->AddHeader (cts);
1586  WifiMacTrailer fcs;
1587  packet->AddTrailer (fcs);
1588 
1589  ForwardDown (packet, &cts, ctsTxVector,preamble);
1590 
1591  Time txDuration = m_phy->CalculateTxDuration (GetCtsSize (), ctsTxVector, preamble);
1592  txDuration += GetSifs ();
1594 
1595  m_sendDataEvent = Simulator::Schedule (txDuration,
1596  &MacLow::SendDataAfterCts, this,
1597  cts.GetAddr1 (),
1598  duration,
1599  ctsTxVector.GetMode());
1600 }
1601 void
1602 MacLow::SendCtsAfterRts (Mac48Address source, Time duration, WifiMode rtsTxMode, double rtsSnr)
1603 {
1604  NS_LOG_FUNCTION (this << source << duration << rtsTxMode << rtsSnr);
1605  /* send a CTS when you receive a RTS
1606  * right after SIFS.
1607  */
1608  WifiTxVector ctsTxVector = GetCtsTxVector (source, rtsTxMode);
1609  WifiMacHeader cts;
1610  cts.SetType (WIFI_MAC_CTL_CTS);
1611  cts.SetDsNotFrom ();
1612  cts.SetDsNotTo ();
1613  cts.SetNoMoreFragments ();
1614  cts.SetNoRetry ();
1615  cts.SetAddr1 (source);
1616  duration -= GetCtsDuration (source, ctsTxVector);
1617  duration -= GetSifs ();
1618  NS_ASSERT (duration >= MicroSeconds (0));
1619  cts.SetDuration (duration);
1620 
1621  Ptr<Packet> packet = Create<Packet> ();
1622  packet->AddHeader (cts);
1623  WifiMacTrailer fcs;
1624  packet->AddTrailer (fcs);
1625 
1626  SnrTag tag;
1627  tag.Set (rtsSnr);
1628  packet->AddPacketTag (tag);
1629 
1630  WifiPreamble preamble;
1631  if (ctsTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1632  preamble= WIFI_PREAMBLE_HT_MF;
1633  else
1634  preamble=WIFI_PREAMBLE_LONG;
1635  ForwardDown (packet, &cts, ctsTxVector,preamble);
1636 }
1637 
1638 void
1640 {
1641  NS_LOG_FUNCTION (this);
1642  /* send the third step in a
1643  * RTS/CTS/DATA/ACK hanshake
1644  */
1645  NS_ASSERT (m_currentPacket != 0);
1647 
1648  WifiPreamble preamble;
1649  if (m_phy->GetGreenfield() && m_stationManager->GetGreenfieldSupported (m_currentHdr.GetAddr1 ()))
1650  //In the future has to make sure that receiver has greenfield enabled
1651  preamble= WIFI_PREAMBLE_HT_GF;
1652  else if (dataTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1653  preamble= WIFI_PREAMBLE_HT_MF;
1654  else
1655  preamble=WIFI_PREAMBLE_LONG;
1656 
1657  StartDataTxTimers (dataTxVector);
1658  Time newDuration = Seconds (0);
1659  newDuration += GetSifs ();
1660  newDuration += GetAckDuration (m_currentHdr.GetAddr1 (), dataTxVector);
1662  dataTxVector, preamble);
1663  duration -= txDuration;
1664  duration -= GetSifs ();
1665 
1666  duration = std::max (duration, newDuration);
1667  NS_ASSERT (duration >= MicroSeconds (0));
1668  m_currentHdr.SetDuration (duration);
1669 
1671  WifiMacTrailer fcs;
1672  m_currentPacket->AddTrailer (fcs);
1673 
1674  ForwardDown (m_currentPacket, &m_currentHdr, dataTxVector,preamble);
1675  m_currentPacket = 0;
1676 }
1677 
1678 void
1680 {
1681  m_listener->StartNext ();
1682 }
1683 
1684 void
1686 {
1688  m_listener = 0;
1689  listener->EndTxNoAck ();
1690 }
1691 
1692 void
1694 {
1695  NS_LOG_FUNCTION (this);
1697  m_listener = 0;
1698  listener->MissedAck ();
1699  NS_LOG_DEBUG ("fast Ack busy but missed");
1700 }
1701 
1702 void
1703 MacLow::SendAckAfterData (Mac48Address source, Time duration, WifiMode dataTxMode, double dataSnr)
1704 {
1705  NS_LOG_FUNCTION (this);
1706  /* send an ACK when you receive
1707  * a packet after SIFS.
1708  */
1709  WifiTxVector ackTxVector = GetAckTxVector (source, dataTxMode);
1710  WifiMacHeader ack;
1711  ack.SetType (WIFI_MAC_CTL_ACK);
1712  ack.SetDsNotFrom ();
1713  ack.SetDsNotTo ();
1714  ack.SetNoRetry ();
1715  ack.SetNoMoreFragments ();
1716  ack.SetAddr1 (source);
1717  duration -= GetAckDuration (ackTxVector);
1718  duration -= GetSifs ();
1719  NS_ASSERT (duration >= MicroSeconds (0));
1720  ack.SetDuration (duration);
1721 
1722  Ptr<Packet> packet = Create<Packet> ();
1723  packet->AddHeader (ack);
1724  WifiMacTrailer fcs;
1725  packet->AddTrailer (fcs);
1726 
1727  SnrTag tag;
1728  tag.Set (dataSnr);
1729  packet->AddPacketTag (tag);
1730 
1731  //since ACK is a control response it can't have Fomat =GF
1732  WifiPreamble preamble;
1733  if (ackTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1734  preamble= WIFI_PREAMBLE_HT_MF;
1735  else
1736  preamble=WIFI_PREAMBLE_LONG;
1737  ForwardDown (packet, &ack, ackTxVector, preamble);
1738 }
1739 
1740 bool
1742 {
1743  AgreementsI it = m_bAckAgreements.find (std::make_pair (hdr.GetAddr2 (), hdr.GetQosTid ()));
1744  if (it != m_bAckAgreements.end ())
1745  {
1746  WifiMacTrailer fcs;
1747  packet->RemoveTrailer (fcs);
1748  BufferedPacket bufferedPacket (packet, hdr);
1749 
1750  uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
1751  uint16_t mappedSeqControl = QosUtilsMapSeqControlToUniqueInteger (hdr.GetSequenceControl (), endSequence);
1752 
1753  BufferedPacketI i = (*it).second.second.begin ();
1754  for (; i != (*it).second.second.end ()
1755  && QosUtilsMapSeqControlToUniqueInteger ((*i).second.GetSequenceControl (), endSequence) < mappedSeqControl; i++)
1756  {
1757  ;
1758  }
1759  (*it).second.second.insert (i, bufferedPacket);
1760 
1761  //Update block ack cache
1762  BlockAckCachesI j = m_bAckCaches.find (std::make_pair (hdr.GetAddr2 (), hdr.GetQosTid ()));
1763  NS_ASSERT (j != m_bAckCaches.end ());
1764  (*j).second.UpdateWithMpdu (&hdr);
1765 
1766  return true;
1767  }
1768  return false;
1769 }
1770 
1771 void
1773  uint16_t startingSeq)
1774 {
1775  uint8_t tid = respHdr->GetTid ();
1776  BlockAckAgreement agreement (originator, tid);
1777  if (respHdr->IsImmediateBlockAck ())
1778  {
1779  agreement.SetImmediateBlockAck ();
1780  }
1781  else
1782  {
1783  agreement.SetDelayedBlockAck ();
1784  }
1785  agreement.SetAmsduSupport (respHdr->IsAmsduSupported ());
1786  agreement.SetBufferSize (respHdr->GetBufferSize () + 1);
1787  agreement.SetTimeout (respHdr->GetTimeout ());
1788  agreement.SetStartingSequence (startingSeq);
1789 
1790  std::list<BufferedPacket> buffer (0);
1791  AgreementKey key (originator, respHdr->GetTid ());
1792  AgreementValue value (agreement, buffer);
1793  m_bAckAgreements.insert (std::make_pair (key, value));
1794 
1795  BlockAckCache cache;
1796  cache.Init (startingSeq, respHdr->GetBufferSize () + 1);
1797  m_bAckCaches.insert (std::make_pair (key, cache));
1798 
1799  if (respHdr->GetTimeout () != 0)
1800  {
1801  AgreementsI it = m_bAckAgreements.find (std::make_pair (originator, respHdr->GetTid ()));
1802  Time timeout = MicroSeconds (1024 * agreement.GetTimeout ());
1803 
1804  AcIndex ac = QosUtilsMapTidToAc (agreement.GetTid ());
1805 
1806  it->second.first.m_inactivityEvent = Simulator::Schedule (timeout,
1808  m_edcaListeners[ac],
1809  originator, tid);
1810  }
1811 }
1812 
1813 void
1815 {
1816  AgreementsI it = m_bAckAgreements.find (std::make_pair (originator, tid));
1817  if (it != m_bAckAgreements.end ())
1818  {
1819  RxCompleteBufferedPacketsWithSmallerSequence (it->second.first.GetStartingSequence (), originator, tid);
1820  RxCompleteBufferedPacketsUntilFirstLost (originator, tid);
1821  m_bAckAgreements.erase (it);
1822 
1823  BlockAckCachesI i = m_bAckCaches.find (std::make_pair (originator, tid));
1824  NS_ASSERT (i != m_bAckCaches.end ());
1825  m_bAckCaches.erase (i);
1826  }
1827 }
1828 
1829 void
1831 {
1832  AgreementsI it = m_bAckAgreements.find (std::make_pair (originator, tid));
1833  if (it != m_bAckAgreements.end ())
1834  {
1835  uint16_t endSequence = ((*it).second.first.GetStartingSequence () + 2047) % 4096;
1836  uint16_t mappedStart = QosUtilsMapSeqControlToUniqueInteger (seq, endSequence);
1837  uint16_t guard = (*it).second.second.begin ()->second.GetSequenceControl () & 0xfff0;
1838  BufferedPacketI last = (*it).second.second.begin ();
1839 
1840  BufferedPacketI i = (*it).second.second.begin ();
1841  for (; i != (*it).second.second.end ()
1842  && QosUtilsMapSeqControlToUniqueInteger ((*i).second.GetSequenceNumber (), endSequence) < mappedStart;)
1843  {
1844  if (guard == (*i).second.GetSequenceControl ())
1845  {
1846  if (!(*i).second.IsMoreFragments ())
1847  {
1848  while (last != i)
1849  {
1850  m_rxCallback ((*last).first, &(*last).second);
1851  last++;
1852  }
1853  m_rxCallback ((*last).first, &(*last).second);
1854  last++;
1855  /* go to next packet */
1856  while (i != (*it).second.second.end () && ((guard >> 4) & 0x0fff) == (*i).second.GetSequenceNumber ())
1857  {
1858  i++;
1859  }
1860  if (i != (*it).second.second.end ())
1861  {
1862  guard = (*i).second.GetSequenceControl () & 0xfff0;
1863  last = i;
1864  }
1865  }
1866  else
1867  {
1868  guard++;
1869  }
1870  }
1871  else
1872  {
1873  /* go to next packet */
1874  while (i != (*it).second.second.end () && ((guard >> 4) & 0x0fff) == (*i).second.GetSequenceNumber ())
1875  {
1876  i++;
1877  }
1878  if (i != (*it).second.second.end ())
1879  {
1880  guard = (*i).second.GetSequenceControl () & 0xfff0;
1881  last = i;
1882  }
1883  }
1884  }
1885  (*it).second.second.erase ((*it).second.second.begin (), i);
1886  }
1887 }
1888 
1889 void
1891 {
1892  AgreementsI it = m_bAckAgreements.find (std::make_pair (originator, tid));
1893  if (it != m_bAckAgreements.end ())
1894  {
1895  uint16_t startingSeqCtrl = ((*it).second.first.GetStartingSequence () << 4) & 0xfff0;
1896  uint16_t guard = startingSeqCtrl;
1897 
1898  BufferedPacketI lastComplete = (*it).second.second.begin ();
1899  BufferedPacketI i = (*it).second.second.begin ();
1900  for (; i != (*it).second.second.end () && guard == (*i).second.GetSequenceControl (); i++)
1901  {
1902  if (!(*i).second.IsMoreFragments ())
1903  {
1904  while (lastComplete != i)
1905  {
1906  m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
1907  lastComplete++;
1908  }
1909  m_rxCallback ((*lastComplete).first, &(*lastComplete).second);
1910  lastComplete++;
1911  }
1912  guard = (*i).second.IsMoreFragments () ? (guard + 1) : ((guard + 16) & 0xfff0);
1913  }
1914  (*it).second.first.SetStartingSequence ((guard >> 4) & 0x0fff);
1915  /* All packets already forwarded to WifiMac must be removed from buffer:
1916  [begin (), lastComplete) */
1917  (*it).second.second.erase ((*it).second.second.begin (), lastComplete);
1918  }
1919 }
1920 
1921 void
1922 MacLow::SendBlockAckResponse (const CtrlBAckResponseHeader* blockAck, Mac48Address originator, bool immediate,
1923  Time duration, WifiMode blockAckReqTxMode)
1924 {
1925  Ptr<Packet> packet = Create<Packet> ();
1926  packet->AddHeader (*blockAck);
1927 
1928  WifiMacHeader hdr;
1930  hdr.SetAddr1 (originator);
1931  hdr.SetAddr2 (GetAddress ());
1932  hdr.SetDsNotFrom ();
1933  hdr.SetDsNotTo ();
1934  hdr.SetNoRetry ();
1935  hdr.SetNoMoreFragments ();
1936 
1937  WifiTxVector blockAckTxVector = GetBlockAckTxVector (originator, blockAckReqTxMode);
1938  WifiTxVector blockAckReqTxVector;
1939  blockAckReqTxVector.SetMode(blockAckReqTxMode);
1940  blockAckReqTxVector.SetNss(1);
1941  blockAckReqTxVector.SetStbc(false);
1942 
1943  m_currentPacket = packet;
1944  m_currentHdr = hdr;
1945  if (immediate)
1946  {
1948  duration -= GetSifs ();
1949  if (blockAck->IsBasic ())
1950  {
1951  duration -= GetBlockAckDuration (originator, blockAckReqTxVector, BASIC_BLOCK_ACK);
1952  }
1953  else if (blockAck->IsCompressed ())
1954  {
1955  duration -= GetBlockAckDuration (originator, blockAckReqTxVector, COMPRESSED_BLOCK_ACK);
1956  }
1957  else if (blockAck->IsMultiTid ())
1958  {
1959  NS_FATAL_ERROR ("Multi-tid block ack is not supported.");
1960  }
1961  }
1962  else
1963  {
1964  m_txParams.EnableAck ();
1965  duration += GetSifs ();
1966  duration += GetAckDuration (originator, blockAckReqTxVector);
1967  }
1969 
1970  if (!immediate)
1971  {
1972  StartDataTxTimers (blockAckTxVector);
1973  }
1974 
1975  NS_ASSERT (duration >= MicroSeconds (0));
1976  hdr.SetDuration (duration);
1977  //here should be present a control about immediate or delayed block ack
1978  //for now we assume immediate
1979  packet->AddHeader (hdr);
1980  WifiMacTrailer fcs;
1981  packet->AddTrailer (fcs);
1982  WifiPreamble preamble;
1983  if (blockAckTxVector.GetMode().GetModulationClass () == WIFI_MOD_CLASS_HT)
1984  preamble= WIFI_PREAMBLE_HT_MF;
1985  else
1986  preamble=WIFI_PREAMBLE_LONG;
1987  ForwardDown (packet, &hdr, blockAckTxVector,preamble);
1988  m_currentPacket = 0;
1989 }
1990 
1991 void
1993  Time duration, WifiMode blockAckReqTxMode)
1994 {
1995  NS_LOG_FUNCTION (this);
1996  CtrlBAckResponseHeader blockAck;
1997  uint8_t tid;
1998  bool immediate = false;
1999  if (!reqHdr.IsMultiTid ())
2000  {
2001  tid = reqHdr.GetTidInfo ();
2002  AgreementsI it = m_bAckAgreements.find (std::make_pair (originator, tid));
2003  if (it != m_bAckAgreements.end ())
2004  {
2005  blockAck.SetStartingSequence (reqHdr.GetStartingSequence ());
2006  blockAck.SetTidInfo (tid);
2007  immediate = (*it).second.first.IsImmediateBlockAck ();
2008  if (reqHdr.IsBasic ())
2009  {
2010  blockAck.SetType (BASIC_BLOCK_ACK);
2011  }
2012  else if (reqHdr.IsCompressed ())
2013  {
2014  blockAck.SetType (COMPRESSED_BLOCK_ACK);
2015  }
2016  BlockAckCachesI i = m_bAckCaches.find (std::make_pair (originator, tid));
2017  NS_ASSERT (i != m_bAckCaches.end ());
2018  (*i).second.FillBlockAckBitmap (&blockAck);
2019 
2020  /* All packets with smaller sequence than starting sequence control must be passed up to Wifimac
2021  * See 9.10.3 in IEEE8022.11e standard.
2022  */
2024  RxCompleteBufferedPacketsUntilFirstLost (originator, tid);
2025  }
2026  else
2027  {
2028  NS_LOG_DEBUG ("there's not a valid block ack agreement with " << originator);
2029  }
2030  }
2031  else
2032  {
2033  NS_FATAL_ERROR ("Multi-tid block ack is not supported.");
2034  }
2035 
2036  SendBlockAckResponse (&blockAck, originator, immediate, duration, blockAckReqTxMode);
2037 }
2038 
2039 void
2041 {
2042  if (agreement.GetTimeout () != 0)
2043  {
2044  NS_ASSERT (agreement.m_inactivityEvent.IsRunning ());
2045  agreement.m_inactivityEvent.Cancel ();
2046  Time timeout = MicroSeconds (1024 * agreement.GetTimeout ());
2047 
2048  AcIndex ac = QosUtilsMapTidToAc (agreement.GetTid ());
2049  //std::map<AcIndex, MacLowTransmissionListener*>::iterator it = m_edcaListeners.find (ac);
2050  //NS_ASSERT (it != m_edcaListeners.end ());
2051 
2052  agreement.m_inactivityEvent = Simulator::Schedule (timeout,
2054  m_edcaListeners[ac],
2055  agreement.GetPeer (),
2056  agreement.GetTid ());
2057  }
2058 }
2059 
2060 void
2062 {
2063  m_edcaListeners.insert (std::make_pair (ac, listener));
2064 }
2065 
2066 } // namespace ns3
uint32_t RemoveHeader(Header &header)
Definition: packet.cc:268
void Set(double snr)
Definition: snr-tag.cc:83
bool MustSendRts(void) const
Definition: mac-low.cc:183
Time GetPifs(void) const
Definition: mac-low.cc:533
uint32_t GetAckSize(void) const
Definition: mac-low.cc:901
virtual ~MacLowDcfListener()
Definition: mac-low.cc:64
void SetPifs(Time pifs)
Definition: mac-low.cc:473
Time m_ctsTimeout
Definition: mac-low.h:653
uint16_t GetBufferSize(void) const
Definition: mgt-headers.cc:943
uint8_t GetTid(void) const
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
EventId m_navCounterResetCtsMissed
Definition: mac-low.h:641
uint32_t GetSize(void) const
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:311
void ResetBlockAckInactivityTimerIfNeeded(BlockAckAgreement &agreement)
Definition: mac-low.cc:2040
EventId m_blockAckTimeoutEvent
Definition: mac-low.h:634
Time GetBlockAckDuration(Mac48Address to, WifiTxVector blockAckReqTxVector, enum BlockAckType type) const
Definition: mac-low.cc:952
Callback template class.
Definition: callback.h:920
virtual ~MacLowTransmissionListener()
Definition: mac-low.cc:49
uint16_t GetTimeout(void) const
Time GetAckDuration(WifiTxVector ackTxVector) const
Definition: mac-low.cc:942
enum ns3::MacLowTransmissionParameters::@87 m_waitAck
virtual void GotAck(double snr, WifiMode txMode)=0
bool IsBasic(void) const
void SetDuration(Time duration)
void SetPromisc(void)
Definition: mac-low.cc:488
EventId m_waitSifsEvent
Definition: mac-low.h:639
void SendDataAfterCts(Mac48Address source, Time duration, WifiMode txMode)
Definition: mac-low.cc:1639
void DoNavResetNow(Time duration)
Definition: mac-low.cc:1169
Mac48Address GetPeer(void) const
EventId m_fastAckTimeoutEvent
Definition: mac-low.h:631
Time m_pifs
Definition: mac-low.h:656
void AddPacketTag(const Tag &tag) const
Definition: packet.cc:841
bool DoNavStartNow(Time duration)
Definition: mac-low.cc:1179
void FastAckFailedTimeout(void)
Definition: mac-low.cc:1693
Mac48Address GetBssid(void) const
Definition: mac-low.cc:538
void SetSifs(Time sifs)
Definition: mac-low.cc:463
virtual void MissedAck(void)=0
std::pair< Mac48Address, uint8_t > AgreementKey
Definition: mac-low.h:673
enum WifiModulationClass GetModulationClass() const
Definition: wifi-mode.cc:93
WifiTxVector GetCtsToSelfTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Definition: mac-low.cc:1001
void SetNoMoreFragments(void)
bool IsImmediateBlockAck(void) const
Definition: mgt-headers.cc:931
void SetupPhyMacLowListener(Ptr< WifiPhy > phy)
Definition: mac-low.cc:312
#define NS_ASSERT(condition)
Definition: assert.h:64
void Init(uint16_t winStart, uint16_t winSize)
bool IsMultiTid(void) const
virtual void NotifyRxEndError(void)
Definition: mac-low.cc:267
virtual void BlockAckInactivityTimeout(Mac48Address originator, uint8_t tid)=0
uint32_t GetSize(void) const
Definition: packet.h:650
bool IsCompressed(void) const
bool HasDurationId(void) const
Definition: mac-low.cc:188
DcfListeners m_dcfListeners
Definition: mac-low.h:628
bool IsBlockAck(void) const
bool IsRunning(void) const
Definition: event-id.cc:59
void SetRxCallback(Callback< void, Ptr< Packet >, const WifiMacHeader * > callback)
Definition: mac-low.cc:544
Time GetCompressedBlockAckTimeout() const
Definition: mac-low.cc:508
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition: simulator.h:824
Mac48Address m_bssid
Definition: mac-low.h:649
bool IsCtl(void) const
ns3::Time timeout
BlockAckType
Definition: ctrl-headers.h:27
EventId m_sendCtsEvent
Definition: mac-low.h:636
MacLowRxCallback m_rxCallback
Definition: mac-low.h:625
Time GetCtsTimeout(void) const
Definition: mac-low.cc:513
void SetStartingSequence(uint16_t seq)
EventId m_superFastAckTimeoutEvent
Definition: mac-low.h:632
EventId m_sendAckEvent
Definition: mac-low.h:637
listen to events coming from ns3::MacLow.
Definition: mac-low.h:56
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition: wifi-mode.h:91
Time GetCtsDuration(WifiTxVector ctsTxVector) const
Definition: mac-low.cc:977
bool MustWaitFastAck(void) const
Definition: mac-low.cc:158
virtual void RegisterListener(WifiPhyListener *listener)=0
void SetTidInfo(uint8_t tid)
control how a packet is transmitted.The ns3::MacLow::StartTransmission method expects an instance of ...
Definition: mac-low.h:195
void WaitSifsAfterEndTx(void)
Definition: mac-low.cc:1679
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
std::vector< MacLowDcfListener * >::const_iterator DcfListenersCI
Definition: mac-low.h:626
bool IsCfpoll(void) const
void SetCtsToSelfSupported(bool enable)
Definition: mac-low.cc:448
void NormalAckTimeout(void)
Definition: mac-low.cc:1257
void SetBasicBlockAckTimeout(Time blockAckTimeout)
Definition: mac-low.cc:438
bool IsAmsduSupported(void) const
Definition: mgt-headers.cc:949
BlockAckCaches m_bAckCaches
Definition: mac-low.h:683
virtual bool IsStateIdle(void)=0
Time GetDuration(void) const
WifiPreamble
Definition: wifi-preamble.h:29
uint8_t GetQosTid(void) const
void DestroyBlockAckAgreement(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:1814
Time m_lastNavDuration
Definition: mac-low.h:660
virtual uint32_t GetSerializedSize(void) const
std::pair< Ptr< Packet >, WifiMacHeader > BufferedPacket
Definition: mac-low.h:670
void SendCtsToSelf(void)
Definition: mac-low.cc:1518
bool m_ctsToSelfSupported
Definition: mac-low.h:687
virtual void SetReceiveErrorCallback(RxErrorCallback callback)=0
void SetAddr1(Mac48Address address)
void CreateBlockAckAgreement(const MgtAddBaResponseHeader *respHdr, Mac48Address originator, uint16_t startingSeq)
Definition: mac-low.cc:1772
uint32_t GetBlockAckSize(enum BlockAckType type) const
Definition: mac-low.cc:908
receive notifications about phy events.
Definition: wifi-phy.h:44
void CtsTimeout(void)
Definition: mac-low.cc:1243
virtual void StartNext(void)=0
uint16_t GetSequenceControl(void) const
void EndTxNoAck(void)
Definition: mac-low.cc:1685
std::map< AgreementKey, BlockAckCache >::iterator BlockAckCachesI
Definition: mac-low.h:680
virtual void EndTxNoAck(void)=0
WifiTxVector GetAckTxVector(Mac48Address to, WifiMode dataTxMode) const
Definition: mac-low.cc:1027
void SetAckTimeout(Time ackTimeout)
Definition: mac-low.cc:433
virtual void GotCts(double snr, WifiMode txMode)=0
AcIndex QosUtilsMapTidToAc(uint8_t tid)
Definition: qos-utils.cc:27
void SendBlockAckResponse(const CtrlBAckResponseHeader *blockAck, Mac48Address originator, bool immediate, Time duration, WifiMode blockAckReqTxMode)
Definition: mac-low.cc:1922
Time GetRifs(void) const
Definition: mac-low.cc:523
virtual void NotifyRxStart(Time duration)
Definition: mac-low.cc:261
void NavCounterResetCtsMissed(Time rtsEndRxTime)
Definition: mac-low.cc:1160
Ptr< WifiRemoteStationManager > m_stationManager
Definition: mac-low.h:624
bool MustWaitMultiTidBlockAck(void) const
Definition: mac-low.cc:178
bool IsQosBlockAck(void) const
Headers for Block ack response.
Definition: ctrl-headers.h:102
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1238
Mac48Address GetAddress(void) const
Definition: mac-low.cc:493
uint32_t GetNextPacketSize(void) const
Definition: mac-low.cc:204
Agreements m_bAckAgreements
Definition: mac-low.h:682
bool HasNextPacket(void) const
Definition: mac-low.cc:199
WifiTxVector GetAckTxVectorForData(Mac48Address to, WifiMode dataTxMode) const
Definition: mac-low.cc:1043
bool IsMgt(void) const
void RegisterDcfListener(MacLowDcfListener *listener)
Definition: mac-low.cc:549
NS_LOG_COMPONENT_DEFINE("MacLow")
virtual uint32_t GetSerializedSize(void) const
void NotifySwitchingStartNow(Time duration)
Definition: mac-low.cc:627
Time m_slotTime
Definition: mac-low.h:655
bool m_promisc
Definition: mac-low.h:662
void SetNss(uint8_t nss)
void CancelAllEvents(void)
Definition: mac-low.cc:342
void StartTransmission(Ptr< const Packet > packet, const WifiMacHeader *hdr, MacLowTransmissionParameters parameters, MacLowTransmissionListener *listener)
Definition: mac-low.cc:556
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:43
std::list< BufferedPacket >::iterator BufferedPacketI
Definition: mac-low.h:671
void SetStartingSequence(uint16_t seq)
Ptr< Packet > Copy(void) const
Definition: packet.cc:122
void BlockAckTimeout(void)
Definition: mac-low.cc:1287
void NotifyCtsTimeoutStartNow(Time duration)
Definition: mac-low.cc:1212
uint16_t GetStartingSequence(void) const
void SendBlockAckAfterBlockAckRequest(const CtrlBAckRequestHeader reqHdr, Mac48Address originator, Time duration, WifiMode blockAckReqTxMode)
Definition: mac-low.cc:1992
void SuperFastAckTimeout(void)
Definition: mac-low.cc:1298
void SetBssid(Mac48Address ad)
Definition: mac-low.cc:483
listen for block ack events.
Definition: mac-low.h:170
uint32_t GetRtsSize(void) const
Definition: mac-low.cc:929
bool IsGroup(void) const
void SetAddr2(Mac48Address address)
Time CalculateTransmissionTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &parameters) const
Definition: mac-low.cc:1095
EventId m_normalAckTimeoutEvent
Definition: mac-low.h:630
void SetType(enum BlockAckType type)
void StartDataTxTimers(WifiTxVector dataTxVector)
Definition: mac-low.cc:1374
void AddTrailer(const Trailer &trailer)
Definition: packet.cc:284
bool IsBasic(void) const
void NotifyCtsTimeoutResetNow()
Definition: mac-low.cc:1220
bool MustWaitBasicBlockAck(void) const
Definition: mac-low.cc:168
bool MustWaitCompressedBlockAck(void) const
Definition: mac-low.cc:173
uint32_t RemoveTrailer(Trailer &trailer)
Definition: packet.cc:300
bool NeedCtsToSelf(void)
Definition: mac-low.cc:607
an EUI-48 address
Definition: mac48-address.h:41
virtual ~MacLowBlockAckEventListener()
Definition: mac-low.cc:71
virtual void Cancel(void)=0
Time m_ackTimeout
Definition: mac-low.h:650
listen to NAV eventsThis class is typically connected to an instance of ns3::Dcf and calls to its met...
Definition: mac-low.h:147
void FastAckTimeout(void)
Definition: mac-low.cc:1270
static Time Now(void)
Definition: simulator.cc:180
EventId m_ctsTimeoutEvent
Definition: mac-low.h:635
void RxCompleteBufferedPacketsWithSmallerSequence(uint16_t seq, Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:1830
void SetPhy(Ptr< WifiPhy > phy)
Definition: mac-low.cc:414
virtual bool IsStateTx(void)=0
Time m_basicBlockAckTimeout
Definition: mac-low.h:651
Time GetDurationId(void) const
Definition: mac-low.cc:193
uint16_t GetTimeout(void) const
Definition: mgt-headers.cc:937
uint8_t GetTid(void) const
Definition: mgt-headers.cc:925
virtual void MissedBlockAck(void)
Definition: mac-low.cc:58
uint8_t GetTidInfo(void) const
Time m_sifs
Definition: mac-low.h:654
const char * GetTypeString(void) const
void ReceiveError(Ptr< const Packet > packet, double rxSnr)
Definition: mac-low.cc:613
Time GetSlotTime(void) const
Definition: mac-low.cc:528
void SetMode(WifiMode mode)
Time m_lastNavStart
Definition: mac-low.h:659
void SetAmsduSupport(bool supported)
virtual void NotifyMaybeCcaBusyStart(Time duration)
Definition: mac-low.cc:273
WifiTxVector GetRtsTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Definition: mac-low.cc:1007
WifiTxVector GetDataTxVector(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Definition: mac-low.cc:1013
handle RTS/CTS/DATA/ACK transactions.
Definition: mac-low.h:380
virtual void MissedCts(void)=0
EventId m_sendDataEvent
Definition: mac-low.h:638
static Time CalculateTxDuration(uint32_t size, WifiTxVector txvector, enum WifiPreamble preamble)
Definition: wifi-phy.cc:439
MacLowTransmissionParameters m_txParams
Definition: mac-low.h:646
void SetRifs(Time rifs)
Definition: mac-low.cc:478
virtual void DoDispose(void)
Definition: mac-low.cc:320
void NotifyAckTimeoutResetNow()
Definition: mac-low.cc:1204
bool MustWaitSuperFastAck(void) const
Definition: mac-low.cc:163
Time CalculateOverallTxTime(Ptr< const Packet > packet, const WifiMacHeader *hdr, const MacLowTransmissionParameters &params) const
Definition: mac-low.cc:1050
QueueListeners m_edcaListeners
Definition: mac-low.h:686
WifiTxVector GetBlockAckTxVector(Mac48Address to, WifiMode dataTxMode) const
Definition: mac-low.cc:1032
bool IsData(void) const
Mac48Address m_self
Definition: mac-low.h:648
Maintains information for a block ack agreement.
bool IsQosData(void) const
EventId m_fastAckFailedTimeoutEvent
Definition: mac-low.h:633
uint32_t QosUtilsMapSeqControlToUniqueInteger(uint16_t seqControl, uint16_t endSequence)
Definition: qos-utils.cc:75
bool IsNavZero(void) const
Definition: mac-low.cc:1506
void NotifyAckTimeoutStartNow(Time duration)
Definition: mac-low.cc:1196
bool IsBlockAckReq(void) const
void SetSlotTime(Time slotTime)
Definition: mac-low.cc:468
Ptr< Packet > m_currentPacket
Definition: mac-low.h:644
Time GetSifs(void) const
Definition: mac-low.cc:518
bool RemovePacketTag(Tag &tag)
Definition: packet.cc:848
void SendCtsAfterRts(Mac48Address source, Time duration, WifiMode txMode, double rtsSnr)
Definition: mac-low.cc:1602
ns3::MacLow * m_macLow
Definition: mac-low.cc:281
#define NS_LOG_DEBUG(msg)
Definition: log.h:255
std::map< AgreementKey, AgreementValue >::iterator AgreementsI
Definition: mac-low.h:677
EventId m_endTxNoAckEvent
Definition: mac-low.h:640
virtual void NotifyTxStart(Time duration)
Definition: mac-low.cc:270
virtual void GotBlockAck(const CtrlBAckResponseHeader *blockAck, Mac48Address source)
Definition: mac-low.cc:53
void EnableOverrideDurationId(Time durationId)
Definition: mac-low.cc:93
virtual void SetReceiveOkCallback(RxOkCallback callback)=0
bool GetCtsToSelfSupported() const
Definition: mac-low.cc:453
void Cancel(void)
Definition: event-id.cc:47
void SetCtsTimeout(Time ctsTimeout)
Definition: mac-low.cc:458
void EnableNextData(uint32_t size)
Definition: mac-low.cc:83
Time GetAckTimeout(void) const
Definition: mac-low.cc:498
EventId m_waitRifsEvent
Definition: mac-low.h:642
void SetStbc(bool stbcsatuts)
void SendDataPacket(void)
Definition: mac-low.cc:1444
void SetTimeout(uint16_t timeout)
uint32_t GetCtsSize(void) const
Definition: mac-low.cc:987
WifiMacHeader m_currentHdr
Definition: mac-low.h:645
void SetType(enum WifiMacType type)
void SetAddress(Mac48Address ad)
Definition: mac-low.cc:428
bool IsCts(void) const
bool IsCompressed(void) const
Mac48Address GetAddr1(void) const
virtual void SendPacket(Ptr< const Packet > packet, WifiMode mode, enum WifiPreamble preamble, WifiTxVector txvector)=0
void ForwardDown(Ptr< const Packet > packet, const WifiMacHeader *hdr, WifiTxVector txVector, WifiPreamble preamble)
Definition: mac-low.cc:1229
void ReceiveOk(Ptr< Packet > packet, double rxSnr, WifiMode txMode, WifiPreamble preamble)
Definition: mac-low.cc:643
PhyMacLowListener(ns3::MacLow *macLow)
Definition: mac-low.cc:254
Time m_compressedBlockAckTimeout
Definition: mac-low.h:652
WifiMode GetMode(void) const
bool MustWaitAck(void) const
Definition: mac-low.cc:148
bool IsRts(void) const
Headers for Block ack request.
Definition: ctrl-headers.h:46
bool IsAck(void) const
void RegisterBlockAckListenerForAc(enum AcIndex ac, MacLowBlockAckEventListener *listener)
Definition: mac-low.cc:2061
virtual ~PhyMacLowListener()
Definition: mac-low.cc:258
bool IsExpired(void) const
Definition: event-id.cc:53
std::pair< BlockAckAgreement, std::list< BufferedPacket > > AgreementValue
Definition: mac-low.h:674
virtual void NotifySwitchingStart(Time duration)
Definition: mac-low.cc:276
virtual Time GetLastRxStartTime(void) const =0
WifiTxVector GetCtsTxVectorForRts(Mac48Address to, WifiMode rtsTxMode) const
Definition: mac-low.cc:1038
void SetBufferSize(uint16_t bufferSize)
Time GetBasicBlockAckTimeout() const
Definition: mac-low.cc:503
void NotifyNav(Ptr< const Packet > packet, const WifiMacHeader &hdr, WifiMode txMode, WifiPreamble preamble)
Definition: mac-low.cc:1118
bool IsMultiTid(void) const
Time m_rifs
Definition: mac-low.h:657
void SendAckAfterData(Mac48Address source, Time duration, WifiMode txMode, double rtsSnr)
Definition: mac-low.cc:1703
AcIndex
Definition: qos-utils.h:35
WifiTxVector GetCtsTxVector(Mac48Address to, WifiMode rtsTxMode) const
Definition: mac-low.cc:1022
bool StoreMpduIfNeeded(Ptr< Packet > packet, WifiMacHeader hdr)
Definition: mac-low.cc:1741
bool MustWaitNormalAck(void) const
Definition: mac-low.cc:153
virtual bool GetGreenfield(void) const =0
virtual ~MacLow()
Definition: mac-low.cc:306
Ptr< WifiPhy > m_phy
Definition: mac-low.h:623
void AddHeader(const Header &header)
Definition: packet.cc:253
Mac48Address GetAddr2(void) const
bool IsQosNoAck(void) const
void SetCompressedBlockAckTimeout(Time blockAckTimeout)
Definition: mac-low.cc:443
virtual void NotifyRxEndOk(void)
Definition: mac-low.cc:264
void SetWifiRemoteStationManager(Ptr< WifiRemoteStationManager > manager)
Definition: mac-low.cc:422
bool IsQosAck(void) const
class PhyMacLowListener * m_phyMacLowListener
Definition: mac-low.h:665
virtual uint32_t GetSerializedSize(void) const
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr) const
Definition: mac-low.cc:994
MacLowTransmissionListener * m_listener
Definition: mac-low.h:647
void SendRtsForPacket(void)
Definition: mac-low.cc:1317
void RxCompleteBufferedPacketsUntilFirstLost(Mac48Address originator, uint8_t tid)
Definition: mac-low.cc:1890