A Discrete-Event Network Simulator
API
uan-mac-rc.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 University of Washington
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: Leonard Tracy <lentracy@gmail.com>
19  */
20 
21 #include "uan-mac-rc.h"
22 #include "uan-header-rc.h"
23 #include "uan-tx-mode.h"
24 #include "uan-phy.h"
25 #include "uan-header-common.h"
26 #include "uan-phy-dual.h"
27 
28 #include "ns3/log.h"
29 #include "ns3/nstime.h"
30 #include "ns3/simulator.h"
31 #include "ns3/assert.h"
32 #include "ns3/double.h"
33 #include "ns3/uinteger.h"
34 
35 #include <list>
36 #include <utility>
37 
38 
39 
40 namespace ns3 {
41 
42 NS_LOG_COMPONENT_DEFINE ("UanMacRc");
43 
45 
47  : m_length (0),
48  m_frameNo (0),
49  m_retryNo (0),
50  m_transmitted (false)
51 {
52 
53 }
54 
55 Reservation::Reservation (std::list<std::pair <Ptr<Packet>, Mac8Address > > &list, uint8_t frameNo, uint32_t maxPkts)
56  : m_frameNo (frameNo),
57  m_retryNo (0),
58  m_transmitted (false)
59 {
60  uint32_t numPkts = (maxPkts) ? maxPkts : static_cast<uint32_t> (list.size ());
61  uint32_t length = 0;
62  UanHeaderRcData dh;
63  UanHeaderCommon ch;
64 
65  for (uint32_t i = 0; i < numPkts; i++)
66  {
67  length += list.front ().first->GetSize () +
68  ch.GetSerializedSize () +
69  dh.GetSerializedSize ();
70  m_pktList.push_back (list.front ());
71  list.pop_front ();
72  }
73  m_length = length;
74 }
75 
77 {
78  std::list<std::pair <Ptr<Packet>, Mac8Address > >::iterator it;
79  for (it = m_pktList.begin (); it != m_pktList.end (); it++)
80  {
81  it->first = Ptr<Packet> ((Packet *) 0);
82  }
83  m_pktList.clear ();
84  m_timestamp.clear ();
85 }
86 uint32_t
88 {
89  return static_cast<uint32_t> (m_pktList.size ());
90 }
91 
92 uint32_t
94 {
95  return m_length;
96 }
97 
98 const std::list<std::pair <Ptr<Packet>, Mac8Address > > &
100 {
101  return m_pktList;
102 }
103 
104 uint8_t
106 {
107  return m_frameNo;
108 }
109 
110 uint8_t
112 {
113  return m_retryNo;
114 }
115 
116 Time
118 {
119  return m_timestamp[n];
120 }
121 
122 bool
124 {
125  return m_transmitted;
126 }
127 
128 void
130 {
131  m_frameNo = fn;
132 }
133 
134 void
136 {
137  m_timestamp.push_back (t);
138 }
139 
140 void
142 {
143  m_retryNo++;
144 }
145 
146 void
148 {
149  NS_UNUSED (t);
150  m_transmitted = true;
151 }
152 
153 uint32_t UanMacRc::m_cntrlSends = 0;
154 
156  : UanMac (),
157  m_state (UNASSOCIATED),
158  m_rtsBlocked (false),
159  m_currentRate (10),
160  m_frameNo (0),
161  m_cleared (false)
162 {
163  m_ev = CreateObject<ExponentialRandomVariable> ();
164 
165  UanHeaderCommon ch;
166  UanHeaderRcCts ctsh;
168 
169  m_ctsSizeN = ctsh.GetSerializedSize ();
170  m_ctsSizeG = ch.GetSerializedSize () + ctsg.GetSerializedSize ();
171 }
172 
174 {
175 }
176 
177 void
179 {
180  if (m_cleared)
181  {
182  return;
183  }
184  m_cleared = true;
185  if (m_phy)
186  {
187  m_phy->Clear ();
188  m_phy = 0;
189  }
190  std::list<std::pair <Ptr<Packet>, Mac8Address > >::iterator it;
191  for (it = m_pktQueue.begin (); it != m_pktQueue.end (); it++)
192  {
193  it->first = 0;
194  }
195  m_pktQueue.clear ();
196  m_resList.clear ();
197  m_startAgain.Cancel ();
198  m_rtsEvent.Cancel ();
199 }
200 
201 void
203 {
204  Clear ();
206 }
207 
208 TypeId
210 {
211  static TypeId tid = TypeId ("ns3::UanMacRc")
212  .SetParent<UanMac> ()
213  .SetGroupName ("Uan")
214  .AddConstructor<UanMacRc> ()
215  .AddAttribute ("RetryRate",
216  "Number of retry attempts per second (of RTS/GWPING).",
217  DoubleValue (1 / 5.0),
219  MakeDoubleChecker<double> ())
220  .AddAttribute ("MaxFrames",
221  "Maximum number of frames to include in a single RTS.",
222  UintegerValue (1),
224  MakeUintegerChecker<uint32_t> ())
225  .AddAttribute ("QueueLimit",
226  "Maximum packets to queue at MAC.",
227  UintegerValue (10),
229  MakeUintegerChecker<uint32_t> ())
230  .AddAttribute ("SIFS",
231  "Spacing to give between frames (this should match gateway).",
232  TimeValue (Seconds (0.2)),
234  MakeTimeChecker ())
235  .AddAttribute ("NumberOfRates",
236  "Number of rate divisions supported by each PHY.",
237  UintegerValue (0),
239  MakeUintegerChecker<uint32_t> ())
240  .AddAttribute ("MinRetryRate",
241  "Smallest allowed RTS retry rate.",
242  DoubleValue (0.01),
244  MakeDoubleChecker<double> ())
245  .AddAttribute ("RetryStep",
246  "Retry rate increment.",
247  DoubleValue (0.01),
249  MakeDoubleChecker<double> ())
250  .AddAttribute ("MaxPropDelay",
251  "Maximum possible propagation delay to gateway.",
252  TimeValue (Seconds (2)),
254  MakeTimeChecker ())
255  .AddTraceSource ("Enqueue",
256  "A (data) packet arrived at MAC for transmission.",
258  "ns3::UanMacRc::QueueTracedCallback")
259  .AddTraceSource ("Dequeue",
260  "A (data) packet was passed down to PHY from MAC.",
262  "ns3::UanMacRc::QueueTracedCallback")
263  .AddTraceSource ("RX",
264  "A packet was destined for and received at this MAC layer.",
266  "ns3::UanMac::PacketModeTracedCallback")
267  ;
268  return tid;
269 }
270 
271 int64_t
272 UanMacRc::AssignStreams (int64_t stream)
273 {
274  NS_LOG_FUNCTION (this << stream);
275  m_ev->SetStream (stream);
276  return 1;
277 }
278 
279 bool
280 UanMacRc::Enqueue (Ptr<Packet> packet, uint16_t protocolNumber, const Address &dest)
281 {
282  if (protocolNumber > 0)
283  {
284  NS_LOG_WARN ("Warning: UanMacRc does not support multiple protocols. protocolNumber argument to Enqueue is being ignored");
285  }
286 
287 
288  if (m_pktQueue.size () >= m_queueLimit)
289  {
290  return false;
291  }
292 
293  m_pktQueue.push_back (std::make_pair (packet, Mac8Address::ConvertFrom (dest)));
294 
295  switch (m_state)
296  {
297  case UNASSOCIATED:
298  Associate ();
299  return true;
300  case IDLE:
301  if (!m_rtsEvent.IsRunning ())
302  {
303  SendRts ();
304  }
305  return true;
306  case GWPSENT:
307  case RTSSENT:
308  case DATATX:
309  return true;
310  }
311 
312  return true;
313 }
314 
315 void
317 {
318  m_forwardUpCb = cb;
319 }
320 
321 void
323 {
324  m_phy = phy;
325  m_phy->SetReceiveOkCallback (MakeCallback (&UanMacRc::ReceiveOkFromPhy, this));
326 }
327 
328 void
330 {
331  NS_UNUSED (sinr);
332  UanHeaderCommon ch;
333  pkt->RemoveHeader (ch);
334  if (ch.GetDest () == m_address || ch.GetDest () == Mac8Address::GetBroadcast ())
335  {
336  m_rxLogger (pkt, mode);
337  }
338 
339  switch (ch.GetType ())
340  {
341  case TYPE_DATA:
342 
343  if (ch.GetDest () == m_address)
344  {
345  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " UanMacRc Receiving DATA packet from PHY");
346  UanHeaderRcData dh;
347  pkt->RemoveHeader (dh);
348  m_forwardUpCb (pkt, ch.GetProtocolNumber (), ch.GetSrc ());
349  }
350  break;
351  case TYPE_RTS:
352  // Currently don't respond to RTS packets at non-gateway nodes
353  // (Code assumes single network neighberhood)
354  break;
355  case TYPE_CTS:
356  {
357  uint32_t ctsBytes = ch.GetSerializedSize () + pkt->GetSize ();
358  m_assocAddr = ch.GetSrc ();
360  pkt->RemoveHeader (ctsg);
361  m_currentRate = ctsg.GetRateNum ();
363 
364  UanHeaderRcRts rhtmp;
365 
366  Time winDelay = ctsg.GetWindowTime ();
367 
368  if (winDelay.GetSeconds () > 0)
369  {
370  m_rtsBlocked = false;
371  Simulator::Schedule (winDelay, &UanMacRc::BlockRtsing, this);
372  }
373  else
374  {
375  NS_FATAL_ERROR (Simulator::Now ().GetSeconds () << " Node " << m_address << " Received window period < 0");
376  }
377 
378  UanHeaderRcCts ctsh;
380  while (pkt->GetSize () > 0)
381  {
382  pkt->RemoveHeader (ctsh);
383  if (ctsh.GetAddress () == m_address)
384  {
385  if (m_state == GWPSENT)
386  {
387  m_assocAddr = ch.GetSrc ();
388  ScheduleData (ctsh, ctsg, ctsBytes);
389  }
390  else if (m_state == RTSSENT)
391  {
392  ScheduleData (ctsh, ctsg, ctsBytes);
393  }
394  else
395  {
396  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " received CTS while state != RTSSENT or GWPING");
397  }
398  }
399  }
400  }
401  break;
402  case TYPE_GWPING:
403  // Do not respond to GWPINGS at non-gateway nodes
404  break;
405  case TYPE_ACK:
406  m_rtsBlocked = true;
407  if (ch.GetDest () != m_address)
408  {
409  return;
410  }
411  ProcessAck (pkt);
412  break;
413  default:
414  NS_FATAL_ERROR ("Unknown packet type " << ch.GetType () << " received at node " << GetAddress ());
415  }
416 
417 }
418 
419 void
420 UanMacRc::ScheduleData (const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes)
421 {
423 
424 
425 
426  std::list<Reservation>::iterator it = m_resList.begin ();
427  for (; it != m_resList.end (); it++)
428  {
429  if (it->GetFrameNo () == ctsh.GetFrameNo ())
430  {
431  break;
432  }
433  }
434  if (it == m_resList.end ())
435  {
436  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " received CTS packet with no corresponding reservation!");
437  return;
438  }
439  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " received CTS packet. Scheduling data");
440  it->SetTransmitted ();
441 
442  double currentBps = m_phy->GetMode (m_currentRate).GetDataRateBps ();
443 
444  m_learnedProp = Simulator::Now () - ctsg.GetTxTimeStamp () - Seconds (ctsBytes * 8.0 / currentBps);
445 
446 
447  Time arrTime = ctsg.GetTxTimeStamp () + ctsh.GetDelayToTx ();
448  Time txTime = arrTime - m_learnedProp;
449 
450  Time startDelay = txTime - Simulator::Now ();
451 
452  Time frameDelay = Seconds (0);
453 
454  const std::list<std::pair <Ptr<Packet>, Mac8Address > > l = it->GetPktList ();
455  std::list<std::pair <Ptr<Packet>, Mac8Address > >::const_iterator pit;
456  pit = l.begin ();
457 
458 
459 
460  for (uint8_t i = 0; i < it->GetNoFrames (); i++, pit++)
461  {
462  Ptr<Packet> pkt = (*pit).first->Copy ();
463 
464  UanHeaderRcData dh;
465  dh.SetFrameNo (i);
466  dh.SetPropDelay (m_learnedProp);
467  pkt->AddHeader (dh);
468 
469  UanHeaderCommon ch;
470  ch.SetType (TYPE_DATA);
471  ch.SetDest (m_assocAddr);
472  ch.SetSrc (m_address);
473 
474  pkt->AddHeader (ch);
475  Time eventTime = startDelay + frameDelay;
476  if (eventTime.GetSeconds () < 0)
477  {
478  if (eventTime.GetSeconds () > -0.001)
479  {
480  eventTime = Seconds (0);
481  }
482  else
483  {
484  NS_FATAL_ERROR ("Scheduling error resulted in very negative data transmission time! eventTime = " << eventTime.GetSeconds ());
485  }
486  }
487  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " scheduling with delay " << eventTime.GetSeconds () << " propDelay " << m_learnedProp.GetSeconds () << " start delay " << startDelay.GetSeconds () << " arrival time " << arrTime.GetSeconds ());
488  Simulator::Schedule (eventTime, &UanMacRc::SendPacket, this, pkt, m_currentRate);
489  frameDelay = frameDelay + m_sifs + Seconds (pkt->GetSize () / currentBps);
490  }
491 
492  m_state = IDLE;
493  if (!m_pktQueue.empty ())
494  {
495 
496  if (m_rtsEvent.IsRunning ())
497  {
498  m_rtsEvent.Cancel ();
499  }
500 
501  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
502  double timeout = m_ev->GetValue ();
504  }
505 
506 }
507 
508 void
509 UanMacRc::SendPacket (Ptr<Packet> pkt, uint32_t rate)
510 {
511  UanHeaderCommon ch;
512  pkt->PeekHeader (ch);
513  std::string type;
514  switch (ch.GetType ())
515  {
516  case TYPE_DATA:
517  type = "DATA";
518  break;
519  case TYPE_RTS:
520  type = "RTS";
521  break;
522  case TYPE_CTS:
523  type = "CTS";
524  break;
525  case TYPE_ACK:
526  type = "ACK";
527  break;
528  case TYPE_GWPING:
529  type = "GWPING";
530  break;
531  default:
532  type = "UNKNOWN";
533  break;
534  }
535  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " transmitting " << pkt->GetSize () << " byte packet of type " << type << " with rate " << rate << "(" << m_phy->GetMode (rate).GetDataRateBps () << ") to " << ch.GetDest ());
536  m_dequeueLogger (pkt, rate);
537  m_phy->SendPacket (pkt, rate);
538 }
539 
540 void
542 {
543  UanHeaderRcAck ah;
544  ack->RemoveHeader (ah);
545 
546  std::list<Reservation>::iterator it = m_resList.begin ();
547  for (; it != m_resList.end (); it++)
548  {
549  if (it->GetFrameNo () == ah.GetFrameNo ())
550  {
551  break;
552  }
553  }
554  if (it == m_resList.end ())
555  {
556  NS_LOG_DEBUG ("In " << __func__ << " could not find reservation corresponding to received ACK");
557  return;
558  }
559  if (!it->IsTransmitted ())
560  {
561  return;
562  }
563  if (ah.GetNoNacks () > 0)
564  {
565  const std::list<std::pair <Ptr<Packet>, Mac8Address > > l = it->GetPktList ();
566  std::list<std::pair <Ptr<Packet>, Mac8Address > >::const_iterator pit;
567  pit = l.begin ();
568 
569  const std::set<uint8_t> &nacks = ah.GetNackedFrames ();
570  std::set<uint8_t>::iterator nit = nacks.begin ();
571  uint8_t pnum = 0;
572  for (; nit != nacks.end (); nit++)
573  {
574  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " Received NACK for " << (uint32_t) *nit);
575  while (pnum < *nit)
576  {
577  pit++;
578  pnum++;
579  }
580  UanHeaderRcData dh;
581  UanHeaderCommon ch;
582  m_pktQueue.push_front (*pit);
583  }
584  }
585  else
586  {
587  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Node " << m_address << " received ACK for all frames");
588  }
589  m_resList.erase (it);
590 }
591 
594 {
596 
597  rh.SetLength (static_cast<uint16_t> (res.GetLength ()));
598  rh.SetNoFrames (static_cast<uint8_t> (res.GetNoFrames ()));
599  rh.SetTimeStamp (res.GetTimestamp (res.GetRetryNo ()));
600  rh.SetFrameNo (res.GetFrameNo ());
601  rh.SetRetryNo (res.GetRetryNo ());
602  return rh;
603 }
604 
605 void
607 {
608  m_cntrlSends++;
609 
611  res.AddTimestamp (Simulator::Now ());
612  m_frameNo++;
613  m_resList.push_back (res);
614  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
615  bool phy1ok = IsPhy1Ok ();
616  if (phy1ok && !phyDual->IsPhy2Tx () & !m_rtsBlocked)
617  {
618  Ptr<Packet> pkt = Create<Packet> (0);
619  pkt->AddHeader (CreateRtsHeader (res));
620  pkt->AddHeader (UanHeaderCommon (m_address, Mac8Address::GetBroadcast (), static_cast<uint8_t>(TYPE_GWPING), 0));
621  NS_LOG_DEBUG (Simulator::Now ().GetSeconds () << " Sending first GWPING " << *pkt);
623  }
624  m_state = GWPSENT;
626  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
627  double timeout = m_ev->GetValue ();
629 }
630 
631 void
633 {
634  m_cntrlSends++;
635  if (m_state != GWPSENT)
636  {
637  return;
638  }
639  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
640  bool phy1ok = IsPhy1Ok ();
641  if (phy1ok && !phyDual->IsPhy2Tx () && !m_rtsBlocked)
642  {
643  Ptr<Packet> pkt = Create<Packet> ();
644 
645  Reservation res = m_resList.back ();
646  m_resList.pop_back ();
647  res.AddTimestamp (Simulator::Now ());
648  res.IncrementRetry ();
649 
650  pkt->AddHeader (CreateRtsHeader (res));
651  pkt->AddHeader (UanHeaderCommon (m_address, Mac8Address::GetBroadcast (), static_cast<uint8_t> (TYPE_GWPING), 0));
652 
654  m_resList.push_back (res);
655  }
657  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
658  double timeout = m_ev->GetValue ();
660 }
661 
662 
663 void
665 {
666  m_cntrlSends++;
667  if (m_state == RTSSENT)
668  {
669  return;
670  }
671 
672  NS_ASSERT (!m_pktQueue.empty ());
673 
675  res.AddTimestamp (Simulator::Now ());
676  m_frameNo++;
677  m_resList.push_back (res);
678  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
679  bool phy1ok = IsPhy1Ok ();
680  if (phy1ok && !phyDual->IsPhy2Tx () && !m_rtsBlocked )
681  {
682  Ptr<Packet> pkt = Create<Packet> (0);
683  pkt->AddHeader (CreateRtsHeader (res));
684  pkt->AddHeader (UanHeaderCommon (m_address, Mac8Address::GetBroadcast (), static_cast<uint8_t> (TYPE_RTS), 0));
686  }
687  m_state = RTSSENT;
689  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
690  double timeout = m_ev->GetValue ();
692 
693 }
694 
695 // We assume here that packet types are known at detection.
696 bool
698 {
699  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
700 
701  bool phy1ok = true;
702  if (phyDual->IsPhy1Rx ())
703  {
704  Ptr<Packet> pkt = phyDual->GetPhy1PacketRx ();
705  UanHeaderCommon ch;
706  pkt->PeekHeader (ch);
707  if (ch.GetType () == TYPE_CTS || ch.GetType () == TYPE_ACK)
708  {
709  phy1ok = false;
710  }
711  else if (ch.GetDest () == m_address)
712  {
713  phy1ok = false;
714  }
715  }
716  return phy1ok;
717 }
718 
719 void
721 {
722  m_cntrlSends++;
723 
724  if (m_state != RTSSENT)
725  {
726  return;
727  }
728  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
729 
730  bool phy1ok = IsPhy1Ok ();
731  if (phy1ok && !phyDual->IsPhy2Tx () && !m_rtsBlocked)
732  {
733 
734  if (m_resList.empty ())
735  {
736  NS_FATAL_ERROR (Simulator::Now ().GetSeconds () << " Node " << m_address << " tried to retry RTS with empty reservation list");
737  }
738  Ptr<Packet> pkt = Create<Packet> (0);
739 
740  Reservation res = m_resList.back ();
741  NS_ASSERT (!res.IsTransmitted ());
742  m_resList.pop_back ();
743  res.AddTimestamp (Simulator::Now ());
744  res.IncrementRetry ();
745  m_resList.push_back (res);
746  pkt->AddHeader (CreateRtsHeader (res));
747  pkt->AddHeader (UanHeaderCommon (m_address, Mac8Address::GetBroadcast (), static_cast<uint8_t> (TYPE_RTS), 0));
749 
750  }
751  m_state = RTSSENT;
753  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
754  double timeout = m_ev->GetValue ();
756 }
757 
758 void
760 {
761  m_rtsBlocked = true;
762 }
763 
764 } // namespace ns3
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void SetNoFrames(uint8_t no)
Set the number of data frames included in this reservation request.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
uint8_t GetFrameNo(void) const
Get the reservation frame number being ACKed.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
void SetPropDelay(Time propDelay)
Set the propagation delay as found in handshaking.
Cycle broadcast information.
Callback template class.
Definition: callback.h:1176
Mac8Address m_address
My addrese.s.
Definition: uan-mac-rc.h:215
void RtsTimeout(void)
Retry RTS.
Definition: uan-mac-rc.cc:720
void SetFrameNo(uint8_t frameNum)
Set the frame number of the reservation being transmitted.
EventId m_startAgain
(Unused).
Definition: uan-mac-rc.h:214
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SetSrc(Mac8Address src)
Set the source address.
bool IsPhy1Ok(void)
Check that PHY is ok: not CTS or ACK not to my address.
Definition: uan-mac-rc.cc:697
uint32_t m_maxFrames
Maximum number of frames to include in a single RTS.
Definition: uan-mac-rc.h:221
Header used for ACK packets by protocol UanMacRc.
void DoDispose()
Destructor implementation.
Definition: uan-mac-rc.cc:202
void AddTimestamp(Time t)
Set the time of the latest RTS sent.
Definition: uan-mac-rc.cc:135
Mac8Address GetAddress(void) const
Get the destination address, for scheduling info.
uint8_t m_frameNo
Frame number.
Definition: uan-mac-rc.h:138
#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:202
virtual ~UanMacRc()
Dummy destructor, DoDispose.
Definition: uan-mac-rc.cc:173
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:831
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
static Mac8Address GetBroadcast(void)
Get the broadcast address (255).
Definition: mac8-address.cc:87
Mac8Address GetSrc(void) const
Get the source address.
uint8_t m_frameNo
Current frame number.
Definition: uan-mac-rc.h:223
Time m_learnedProp
Propagation delay to gateway.
Definition: uan-mac-rc.h:225
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:65
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
UanHeaderRcRts CreateRtsHeader(const Reservation &res)
Create the RTS header from a Reservation.
Definition: uan-mac-rc.cc:593
ns3::Time timeout
void ProcessAck(Ptr< Packet > ack)
Process a received ACK.
Definition: uan-mac-rc.cc:541
uint8_t m_retryNo
Number of retries.
Definition: uan-mac-rc.h:142
std::list< std::pair< Ptr< Packet >, Mac8Address > > m_pktQueue
Pending packets.
Definition: uan-mac-rc.h:236
network packets
Definition: packet.h:231
uint8_t GetType(void) const
Get the header type value.
void ReceiveOkFromPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
PHY receive ok Callback.
Definition: uan-mac-rc.cc:329
Non-gateway node MAC for reservation channel MAC protocol.
Definition: uan-mac-rc.h:163
uint32_t m_length
Total length of queued packets.
Definition: uan-mac-rc.h:136
a polymophic address class
Definition: address.h:90
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
phy
Definition: third.py:86
uint32_t GetNoFrames() const
Get the number of frames in this Reservation.
Definition: uan-mac-rc.cc:87
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:446
void BlockRtsing(void)
Callback to block RST.
Definition: uan-mac-rc.cc:759
void SetTransmitted(bool t=true)
Set the reservation transmitted state.
Definition: uan-mac-rc.cc:147
double GetSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition: nstime.h:355
Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > m_forwardUpCb
The callback to forward a packet up to higher layer.
Definition: uan-mac-rc.h:241
Virtual base class for all UAN MAC protocols.
Definition: uan-mac.h:49
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
Definition: simulator.h:1381
Reservation()
Default constructor.
Definition: uan-mac-rc.cc:46
std::vector< Time > m_timestamp
Timestamps for each retry.
Definition: uan-mac-rc.h:140
uint8_t GetRetryNo() const
Get the retry number.
Definition: uan-mac-rc.cc:111
AttributeValue implementation for Time.
Definition: nstime.h:1069
TracedCallback< Ptr< const Packet >, uint32_t > m_dequeueLogger
A was passed down to the PHY from the MAC.
Definition: uan-mac-rc.h:248
const std::set< uint8_t > & GetNackedFrames(void) const
Get the set of NACK&#39;ed frames.
virtual uint32_t GetSerializedSize(void) const
virtual Address GetAddress(void)
Get the MAC Address.
Definition: uan-mac.cc:55
virtual void Clear(void)
Clears all pointer references.
Definition: uan-mac-rc.cc:178
Hold an unsigned integer type.
Definition: uinteger.h:44
double m_minRetryRate
Smallest allowed RTS retry rate.
Definition: uan-mac-rc.h:227
void SetAddress(Mac8Address addr)
Set the destination address, for scheduling info.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:41
std::list< std::pair< Ptr< Packet >, Mac8Address > > m_pktList
Queued packets for each address.
Definition: uan-mac-rc.h:134
double m_retryStep
Retry rate increment.
Definition: uan-mac-rc.h:228
bool IsTransmitted() const
Definition: uan-mac-rc.cc:123
A class used for addressing MAC8 MAC&#39;s.
Definition: mac8-address.h:42
Finished scheduling packet sends.
Definition: uan-mac-rc.h:206
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
A packet was destined for and received at this MAC layer.
Definition: uan-mac-rc.h:244
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition: callback.h:1489
Ptr< ExponentialRandomVariable > m_ev
Provides exponential random variables.
Definition: uan-mac-rc.h:313
Ptr< UanPhy > m_phy
PHY layer attached to this MAC.
Definition: uan-mac-rc.h:218
#define list
void SetLength(uint16_t length)
Set the number of data bytes in the reservation.
static uint32_t m_cntrlSends
Global count of calls to Associate, AssociateTimeout, SendRts, and RtsTimeout.
Definition: uan-mac-rc.h:310
void AssociateTimeout(void)
Periodically retry association.
Definition: uan-mac-rc.cc:632
void SetFrameNo(uint8_t fn)
Set the frame number.
Definition: uan-mac-rc.cc:129
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
bool m_cleared
Flag when we&#39;ve been cleared.
Definition: uan-mac-rc.h:233
UanMacRc()
Default constructor.
Definition: uan-mac-rc.cc:155
void SetTimeStamp(Time timeStamp)
Set RTS transmission time.
static TypeId GetTypeId(void)
Register this type.
Definition: uan-mac-rc.cc:209
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Common packet header fields.
virtual bool Enqueue(Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest)
Enqueue packet to be transmitted.
Definition: uan-mac-rc.cc:280
Associated with gateway.
Definition: uan-mac-rc.h:205
EventId m_rtsEvent
The RTS event.
Definition: uan-mac-rc.h:251
State m_state
MAC state.
Definition: uan-mac-rc.h:211
Time GetWindowTime(void) const
Get the window time (time duration following blocking time to allow RTS transmissions).
uint16_t GetRateNum(void) const
Get the data rate number.
double m_retryRate
Number of retry attempts per second (of RTS/GWPING.
Definition: uan-mac-rc.h:216
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:1070
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Definition: uan-mac-rc.cc:272
bool m_rtsBlocked
RTS blocked while processing ACK.
Definition: uan-mac-rc.h:212
TracedCallback< Ptr< const Packet >, uint32_t > m_enqueueLogger
A packet arrived at the MAC for transmission.
Definition: uan-mac-rc.h:246
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
uint16_t GetProtocolNumber(void) const
Get the packet type value.
std::list< Reservation > m_resList
List of scheduled reservations.
Definition: uan-mac-rc.h:238
Time m_sifs
Spacing between frames to account for timing error and processing delay.
Definition: uan-mac-rc.h:224
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:262
uint8_t GetNoNacks(void) const
Get the number of data frames being NACKed.
virtual void AttachPhy(Ptr< UanPhy > phy)
Attach PHY layer to this MAC.
Definition: uan-mac-rc.cc:322
void SendRts(void)
Send RTS packet.
Definition: uan-mac-rc.cc:664
void SetDest(Mac8Address dest)
Set the destination address.
void ScheduleData(const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes)
Schedule Packet sends.
Definition: uan-mac-rc.cc:420
uint32_t GetLength() const
Get the total length of the Reservation.
Definition: uan-mac-rc.cc:93
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
Send on packet on the PHY.
Definition: uan-mac-rc.cc:509
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
Stores reservation info for use in scheduling data channel by reservation channel MAC...
Definition: uan-mac-rc.h:52
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1007
uint8_t GetFrameNo() const
Get the frame number.
Definition: uan-mac-rc.cc:105
uint32_t m_numRates
Number of rates per Phy layer.
Definition: uan-mac-rc.h:219
virtual void SetForwardUpCb(Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > cb)
Set the callback to forward packets up to higher layers.
Definition: uan-mac-rc.cc:316
double GetValue(double mean, double bound)
Get the next random value, as a double from the exponential distribution with the specified mean and ...
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
virtual uint32_t GetSerializedSize(void) const
uint16_t GetRetryRate(void) const
Get the retry rate number.
void SetType(uint8_t type)
Set the header type.
uint32_t m_queueLimit
Maximum packets to queue at MAC.
Definition: uan-mac-rc.h:222
Two channel Phy.
Definition: uan-phy-dual.h:81
uint8_t GetFrameNo(void) const
Get the frame number of the RTS being cleared.
uint32_t m_currentRate
Rate number corresponding to data rate of current cycle.
Definition: uan-mac-rc.h:220
Time GetDelayToTx(void) const
Get the time delay from TX time of CTS packet until arrival of first data frame.
Mac8Address GetDest(void) const
Get the destination address.
uint32_t m_ctsSizeN
Size of UanHeaderRcCts.
Definition: uan-mac-rc.h:230
bool m_transmitted
Has this reservation been transmitted.
Definition: uan-mac-rc.h:144
This class can be used to hold variables of floating point type such as &#39;double&#39; or &#39;float&#39;...
Definition: double.h:41
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
virtual uint32_t GetSerializedSize(void) const
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
Mac8Address m_assocAddr
Next hop address.
Definition: uan-mac-rc.h:217
a unique identifier for an interface.
Definition: type-id.h:58
Time GetTxTimeStamp(void) const
Get the CTS transmit timestamp.
void Associate(void)
Associate with a gateway by sending the first GWPING.
Definition: uan-mac-rc.cc:606
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
Definition: mac8-address.cc:54
void SetRetryNo(uint8_t no)
Set the retry number of this RTS packet.
void IncrementRetry()
Increment the retry count.
Definition: uan-mac-rc.cc:141
RTS just sent.
Definition: uan-mac-rc.h:207
uint32_t m_ctsSizeG
Size of UanHeaderCommon and UanHeaderRcCtsGlobal.
Definition: uan-mac-rc.h:231
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
Time GetTimestamp(uint8_t n) const
Get the timestamp for the n&#39;th RTS.
Definition: uan-mac-rc.cc:117
~Reservation()
Destructor.
Definition: uan-mac-rc.cc:76
const std::list< std::pair< Ptr< Packet >, Mac8Address > > & GetPktList(void) const
Get the list of packets.
Definition: uan-mac-rc.cc:99
Extra data header information.
Definition: uan-header-rc.h:41
void SetFrameNo(uint8_t fno)
Set the frame number.
virtual uint32_t GetSerializedSize(void) const