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