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 ();
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);
335  {
336  m_rxLogger (pkt, mode);
337  }
338 
339  switch (ch.GetType ())
340  {
341  case TYPE_DATA:
342 
343  if (ch.GetDest () == Mac8Address::ConvertFrom (GetAddress ()))
344  {
345  NS_LOG_DEBUG (Now ().As (Time::S) << " Node " << Mac8Address::ConvertFrom (GetAddress ()) <<
346  " UanMacRc Receiving DATA packet from PHY");
347  UanHeaderRcData dh;
348  pkt->RemoveHeader (dh);
349  m_forwardUpCb (pkt, ch.GetProtocolNumber (), ch.GetSrc ());
350  }
351  break;
352  case TYPE_RTS:
353  // Currently don't respond to RTS packets at non-gateway nodes
354  // (Code assumes single network neighberhood)
355  break;
356  case TYPE_CTS:
357  {
358  uint32_t ctsBytes = ch.GetSerializedSize () + pkt->GetSize ();
359  m_assocAddr = ch.GetSrc ();
361  pkt->RemoveHeader (ctsg);
362  m_currentRate = ctsg.GetRateNum ();
364 
365  UanHeaderRcRts rhtmp;
366 
367  Time winDelay = ctsg.GetWindowTime ();
368 
369  if (winDelay > Time (0))
370  {
371  m_rtsBlocked = false;
372  Simulator::Schedule (winDelay, &UanMacRc::BlockRtsing, this);
373  }
374  else
375  {
376  NS_FATAL_ERROR (Now ().As (Time::S) << " Node " <<
377  Mac8Address::ConvertFrom (GetAddress ()) << " Received window period < 0");
378  }
379 
380  UanHeaderRcCts ctsh;
382  while (pkt->GetSize () > 0)
383  {
384  pkt->RemoveHeader (ctsh);
385  if (ctsh.GetAddress () == Mac8Address::ConvertFrom (GetAddress ()))
386  {
387  if (m_state == GWPSENT)
388  {
389  m_assocAddr = ch.GetSrc ();
390  ScheduleData (ctsh, ctsg, ctsBytes);
391  }
392  else if (m_state == RTSSENT)
393  {
394  ScheduleData (ctsh, ctsg, ctsBytes);
395  }
396  else
397  {
398  NS_LOG_DEBUG (Now ().As (Time::S) << " Node " <<
400  " received CTS while state != RTSSENT or GWPING");
401  }
402  }
403  }
404  }
405  break;
406  case TYPE_GWPING:
407  // Do not respond to GWPINGS at non-gateway nodes
408  break;
409  case TYPE_ACK:
410  m_rtsBlocked = true;
411  if (ch.GetDest () != Mac8Address::ConvertFrom (GetAddress ()))
412  {
413  return;
414  }
415  ProcessAck (pkt);
416  break;
417  default:
418  NS_FATAL_ERROR ("Unknown packet type " << ch.GetType () << " received at node " << GetAddress ());
419  }
420 
421 }
422 
423 void
424 UanMacRc::ScheduleData (const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes)
425 {
427 
428 
429 
430  std::list<Reservation>::iterator it = m_resList.begin ();
431  for (; it != m_resList.end (); it++)
432  {
433  if (it->GetFrameNo () == ctsh.GetFrameNo ())
434  {
435  break;
436  }
437  }
438  if (it == m_resList.end ())
439  {
440  NS_LOG_DEBUG (Now ().As (Time::S) << " Node " <<
442  " received CTS packet with no corresponding reservation!");
443  return;
444  }
445  NS_LOG_DEBUG (Now ().As (Time::S) <<
446  " Node " << Mac8Address::ConvertFrom (GetAddress ()) <<
447  " received CTS packet. Scheduling data");
448  it->SetTransmitted ();
449 
450  double currentBps = m_phy->GetMode (m_currentRate).GetDataRateBps ();
451 
452  m_learnedProp = Simulator::Now () - ctsg.GetTxTimeStamp () - Seconds (ctsBytes * 8.0 / currentBps);
453 
454 
455  Time arrTime = ctsg.GetTxTimeStamp () + ctsh.GetDelayToTx ();
456  Time txTime = arrTime - m_learnedProp;
457 
458  Time startDelay = txTime - Simulator::Now ();
459 
460  Time frameDelay = Seconds (0);
461 
462  const std::list<std::pair <Ptr<Packet>, Mac8Address > > l = it->GetPktList ();
463  std::list<std::pair <Ptr<Packet>, Mac8Address > >::const_iterator pit;
464  pit = l.begin ();
465 
466 
467 
468  for (uint8_t i = 0; i < it->GetNoFrames (); i++, pit++)
469  {
470  Ptr<Packet> pkt = (*pit).first->Copy ();
471 
472  UanHeaderRcData dh;
473  dh.SetFrameNo (i);
475  pkt->AddHeader (dh);
476 
477  UanHeaderCommon ch;
478  ch.SetType (TYPE_DATA);
479  ch.SetDest (m_assocAddr);
481 
482  pkt->AddHeader (ch);
483  Time eventTime = startDelay + frameDelay;
484  if (eventTime < Time (0))
485  {
486  NS_FATAL_ERROR ("Scheduling error resulted in very negative data transmission time! eventTime = " << eventTime.As (Time::S));
487  }
488  NS_LOG_DEBUG (Now ().As (Time::S) <<
489  " Node " << Mac8Address::ConvertFrom (GetAddress ()) <<
490  " scheduling with delay " << eventTime.As (Time::S) <<
491  " propDelay " << m_learnedProp.As (Time::S) <<
492  " start delay " << startDelay.As (Time::S) <<
493  " arrival time " << arrTime.As (Time::S));
494  Simulator::Schedule (eventTime, &UanMacRc::SendPacket, this, pkt, m_currentRate);
495  frameDelay = frameDelay + m_sifs + Seconds (pkt->GetSize () / currentBps);
496  }
497 
498  m_state = IDLE;
499  if (!m_pktQueue.empty ())
500  {
501 
502  if (m_rtsEvent.IsRunning ())
503  {
504  m_rtsEvent.Cancel ();
505  }
506 
507  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
508  double timeout = m_ev->GetValue ();
510  }
511 
512 }
513 
514 void
515 UanMacRc::SendPacket (Ptr<Packet> pkt, uint32_t rate)
516 {
517  UanHeaderCommon ch;
518  pkt->PeekHeader (ch);
519  std::string type;
520  switch (ch.GetType ())
521  {
522  case TYPE_DATA:
523  type = "DATA";
524  break;
525  case TYPE_RTS:
526  type = "RTS";
527  break;
528  case TYPE_CTS:
529  type = "CTS";
530  break;
531  case TYPE_ACK:
532  type = "ACK";
533  break;
534  case TYPE_GWPING:
535  type = "GWPING";
536  break;
537  default:
538  type = "UNKNOWN";
539  break;
540  }
541  NS_LOG_DEBUG (Now ().As (Time::S) <<
542  " Node " << Mac8Address::ConvertFrom (GetAddress ()) <<
543  " transmitting " << pkt->GetSize () <<
544  " byte packet of type " << type << " with rate " << rate <<
545  "(" << m_phy->GetMode (rate).GetDataRateBps () << ") to " << ch.GetDest ());
546  m_dequeueLogger (pkt, rate);
547  m_phy->SendPacket (pkt, rate);
548 }
549 
550 void
552 {
553  UanHeaderRcAck ah;
554  ack->RemoveHeader (ah);
555 
556  std::list<Reservation>::iterator it = m_resList.begin ();
557  for (; it != m_resList.end (); it++)
558  {
559  if (it->GetFrameNo () == ah.GetFrameNo ())
560  {
561  break;
562  }
563  }
564  if (it == m_resList.end ())
565  {
566  NS_LOG_DEBUG ("In " << __func__ << " could not find reservation corresponding to received ACK");
567  return;
568  }
569  if (!it->IsTransmitted ())
570  {
571  return;
572  }
573  if (ah.GetNoNacks () > 0)
574  {
575  const std::list<std::pair <Ptr<Packet>, Mac8Address > > l = it->GetPktList ();
576  std::list<std::pair <Ptr<Packet>, Mac8Address > >::const_iterator pit;
577  pit = l.begin ();
578 
579  const std::set<uint8_t> &nacks = ah.GetNackedFrames ();
580  std::set<uint8_t>::iterator nit = nacks.begin ();
581  uint8_t pnum = 0;
582  for (; nit != nacks.end (); nit++)
583  {
584  NS_LOG_DEBUG (Now ().As (Time::S) << " Node " <<
586  " Received NACK for " << (uint32_t) *nit);
587  while (pnum < *nit)
588  {
589  pit++;
590  pnum++;
591  }
592  UanHeaderRcData dh;
593  UanHeaderCommon ch;
594  m_pktQueue.push_front (*pit);
595  }
596  }
597  else
598  {
599  NS_LOG_DEBUG (Now ().As (Time::S) << " Node " <<
601  " received ACK for all frames");
602  }
603  m_resList.erase (it);
604 }
605 
608 {
610 
611  rh.SetLength (static_cast<uint16_t> (res.GetLength ()));
612  rh.SetNoFrames (static_cast<uint8_t> (res.GetNoFrames ()));
613  rh.SetTimeStamp (res.GetTimestamp (res.GetRetryNo ()));
614  rh.SetFrameNo (res.GetFrameNo ());
615  rh.SetRetryNo (res.GetRetryNo ());
616  return rh;
617 }
618 
619 void
621 {
622  m_cntrlSends++;
623 
625  res.AddTimestamp (Simulator::Now ());
626  m_frameNo++;
627  m_resList.push_back (res);
628  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
629  bool phy1ok = IsPhy1Ok ();
630  if (phy1ok && !phyDual->IsPhy2Tx () & !m_rtsBlocked)
631  {
632  Ptr<Packet> pkt = Create<Packet> (0);
633  pkt->AddHeader (CreateRtsHeader (res));
635  NS_LOG_DEBUG (Now ().As (Time::S) << " Sending first GWPING " << *pkt);
637  }
638  m_state = GWPSENT;
640  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
641  double timeout = m_ev->GetValue ();
643 }
644 
645 void
647 {
648  m_cntrlSends++;
649  if (m_state != GWPSENT)
650  {
651  return;
652  }
653  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
654  bool phy1ok = IsPhy1Ok ();
655  if (phy1ok && !phyDual->IsPhy2Tx () && !m_rtsBlocked)
656  {
657  Ptr<Packet> pkt = Create<Packet> ();
658 
659  Reservation res = m_resList.back ();
660  m_resList.pop_back ();
661  res.AddTimestamp (Simulator::Now ());
662  res.IncrementRetry ();
663 
664  pkt->AddHeader (CreateRtsHeader (res));
666 
668  m_resList.push_back (res);
669  }
671  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
672  double timeout = m_ev->GetValue ();
674 }
675 
676 
677 void
679 {
680  m_cntrlSends++;
681  if (m_state == RTSSENT)
682  {
683  return;
684  }
685 
686  NS_ASSERT (!m_pktQueue.empty ());
687 
689  res.AddTimestamp (Simulator::Now ());
690  m_frameNo++;
691  m_resList.push_back (res);
692  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
693  bool phy1ok = IsPhy1Ok ();
694  if (phy1ok && !phyDual->IsPhy2Tx () && !m_rtsBlocked )
695  {
696  Ptr<Packet> pkt = Create<Packet> (0);
697  pkt->AddHeader (CreateRtsHeader (res));
700  }
701  m_state = RTSSENT;
703  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
704  double timeout = m_ev->GetValue ();
706 
707 }
708 
709 // We assume here that packet types are known at detection.
710 bool
712 {
713  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
714 
715  bool phy1ok = true;
716  if (phyDual->IsPhy1Rx ())
717  {
718  Ptr<Packet> pkt = phyDual->GetPhy1PacketRx ();
719  UanHeaderCommon ch;
720  pkt->PeekHeader (ch);
721  if (ch.GetType () == TYPE_CTS || ch.GetType () == TYPE_ACK)
722  {
723  phy1ok = false;
724  }
725  else if (ch.GetDest () == Mac8Address::ConvertFrom (GetAddress ()))
726  {
727  phy1ok = false;
728  }
729  }
730  return phy1ok;
731 }
732 
733 void
735 {
736  m_cntrlSends++;
737 
738  if (m_state != RTSSENT)
739  {
740  return;
741  }
742  Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual> ();
743 
744  bool phy1ok = IsPhy1Ok ();
745  if (phy1ok && !phyDual->IsPhy2Tx () && !m_rtsBlocked)
746  {
747 
748  if (m_resList.empty ())
749  {
750  NS_FATAL_ERROR (Now ().As (Time::S) << " Node " <<
752  " tried to retry RTS with empty reservation list");
753  }
754  Ptr<Packet> pkt = Create<Packet> (0);
755 
756  Reservation res = m_resList.back ();
757  NS_ASSERT (!res.IsTransmitted ());
758  m_resList.pop_back ();
759  res.AddTimestamp (Simulator::Now ());
760  res.IncrementRetry ();
761  m_resList.push_back (res);
762  pkt->AddHeader (CreateRtsHeader (res));
765 
766  }
767  m_state = RTSSENT;
769  m_ev->SetAttribute ("Mean", DoubleValue (1 / m_retryRate));
770  double timeout = m_ev->GetValue ();
772 }
773 
774 void
776 {
777  m_rtsBlocked = true;
778 }
779 
780 } // namespace ns3
ns3::UanMacRc::RTSSENT
@ RTSSENT
RTS just sent.
Definition: uan-mac-rc.h:207
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::UanMacRc::TYPE_DATA
@ TYPE_DATA
Data.
Definition: uan-mac-rc.h:168
ns3::UanMacRc::TYPE_RTS
@ TYPE_RTS
RTS.
Definition: uan-mac-rc.h:170
ns3::UanMacRc::Enqueue
virtual bool Enqueue(Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest)
Enqueue packet to be transmitted.
Definition: uan-mac-rc.cc:280
ns3::UanMacRc::m_ctsSizeN
uint32_t m_ctsSizeN
Size of UanHeaderRcCts.
Definition: uan-mac-rc.h:229
ns3::Mac8Address
A class used for addressing MAC8 MAC's.
Definition: mac8-address.h:43
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
NS_ASSERT
#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
ns3::Reservation::SetFrameNo
void SetFrameNo(uint8_t fn)
Set the frame number.
Definition: uan-mac-rc.cc:129
ns3::MakeTimeChecker
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
ns3::Packet::PeekHeader
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:290
ns3::UanMacRc::ProcessAck
void ProcessAck(Ptr< Packet > ack)
Process a received ACK.
Definition: uan-mac-rc.cc:551
ns3::UanMacRc::SetForwardUpCb
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
ns3::UanMacRc::m_startAgain
EventId m_startAgain
(Unused).
Definition: uan-mac-rc.h:214
ns3::UanMacRc::ReceiveOkFromPhy
void ReceiveOkFromPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
PHY receive ok Callback.
Definition: uan-mac-rc.cc:329
ns3::UanHeaderCommon::SetDest
void SetDest(Mac8Address dest)
Set the destination address.
Definition: uan-header-common.cc:67
ns3::Packet::GetSize
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
ns3::Packet::AddHeader
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::UanMacRc::m_ev
Ptr< ExponentialRandomVariable > m_ev
Provides exponential random variables.
Definition: uan-mac-rc.h:312
ns3::UanMacRc::ScheduleData
void ScheduleData(const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes)
Schedule Packet sends.
Definition: uan-mac-rc.cc:424
ns3::UanHeaderRcRts::SetTimeStamp
void SetTimeStamp(Time timeStamp)
Set RTS transmission time.
Definition: uan-header-rc.cc:188
ns3::Mac8Address::ConvertFrom
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
Definition: mac8-address.cc:54
ns3::Simulator::Now
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Reservation::SetTransmitted
void SetTransmitted(bool t=true)
Set the reservation transmitted state.
Definition: uan-mac-rc.cc:147
ns3::UanMacRc::SendRts
void SendRts(void)
Send RTS packet.
Definition: uan-mac-rc.cc:678
ns3::UanMacRc::m_assocAddr
Mac8Address m_assocAddr
Next hop address.
Definition: uan-mac-rc.h:216
ns3::Reservation::m_frameNo
uint8_t m_frameNo
Frame number.
Definition: uan-mac-rc.h:138
ns3::UanMacRc::m_sifs
Time m_sifs
Spacing between frames to account for timing error and processing delay.
Definition: uan-mac-rc.h:223
ns3::Reservation::m_retryNo
uint8_t m_retryNo
Number of retries.
Definition: uan-mac-rc.h:142
ns3::Reservation::GetRetryNo
uint8_t GetRetryNo() const
Get the retry number.
Definition: uan-mac-rc.cc:111
ns3::Reservation::~Reservation
~Reservation()
Destructor.
Definition: uan-mac-rc.cc:76
ns3::UanHeaderRcCts::SetAddress
void SetAddress(Mac8Address addr)
Set the destination address, for scheduling info.
Definition: uan-header-rc.cc:471
ns3::UanMacRc::m_ctsSizeG
uint32_t m_ctsSizeG
Size of UanHeaderCommon and UanHeaderRcCtsGlobal.
Definition: uan-mac-rc.h:230
NS_LOG_WARN
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
Definition: log.h:265
ns3::UanHeaderRcCtsGlobal::GetRateNum
uint16_t GetRateNum(void) const
Get the data rate number.
Definition: uan-header-rc.cc:357
ns3::UanHeaderRcRts::SetLength
void SetLength(uint16_t length)
Set the number of data bytes in the reservation.
Definition: uan-header-rc.cc:183
ns3::UanPhyDual
Two channel Phy.
Definition: uan-phy-dual.h:82
ns3::ObjectBase::SetAttribute
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:185
ns3::UanHeaderCommon::GetDest
Mac8Address GetDest(void) const
Get the destination address.
Definition: uan-header-common.cc:99
ns3::Time::As
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:429
ns3::UanMacRc::m_frameNo
uint8_t m_frameNo
Current frame number.
Definition: uan-mac-rc.h:222
ns3::UanMacRc::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: uan-mac-rc.cc:209
ns3::UanMacRc::m_currentRate
uint32_t m_currentRate
Rate number corresponding to data rate of current cycle.
Definition: uan-mac-rc.h:219
ns3::Reservation::GetPktList
const std::list< std::pair< Ptr< Packet >, Mac8Address > > & GetPktList(void) const
Get the list of packets.
Definition: uan-mac-rc.cc:99
ns3::Simulator::Schedule
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
ns3::UanHeaderCommon::GetProtocolNumber
uint16_t GetProtocolNumber(void) const
Get the packet type value.
Definition: uan-header-common.cc:115
ns3::Reservation::GetNoFrames
uint32_t GetNoFrames() const
Get the number of frames in this Reservation.
Definition: uan-mac-rc.cc:87
ns3::UanMacRc::~UanMacRc
virtual ~UanMacRc()
Dummy destructor, DoDispose.
Definition: uan-mac-rc.cc:173
ns3::UanHeaderCommon
Common packet header fields.
Definition: uan-header-common.h:65
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::DoubleValue
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:41
ns3::UanMacRc::m_phy
Ptr< UanPhy > m_phy
PHY layer attached to this MAC.
Definition: uan-mac-rc.h:217
ns3::MakeTraceSourceAccessor
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Definition: trace-source-accessor.h:202
ns3::UanHeaderRcRts::SetFrameNo
void SetFrameNo(uint8_t fno)
Set the frame number.
Definition: uan-header-rc.cc:171
uan-header-rc.h
ns3::Reservation::GetLength
uint32_t GetLength() const
Get the total length of the Reservation.
Definition: uan-mac-rc.cc:93
ns3::Packet
network packets
Definition: packet.h:232
ns3::UanHeaderCommon::GetSrc
Mac8Address GetSrc(void) const
Get the source address.
Definition: uan-header-common.cc:104
ns3::Reservation::AddTimestamp
void AddTimestamp(Time t)
Set the time of the latest RTS sent.
Definition: uan-mac-rc.cc:135
ns3::Ptr< Packet >
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
ns3::UanMacRc::m_resList
std::list< Reservation > m_resList
List of scheduled reservations.
Definition: uan-mac-rc.h:237
ns3::UanMacRc::m_rxLogger
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
A packet was destined for and received at this MAC layer.
Definition: uan-mac-rc.h:243
ns3::UanMacRc::IDLE
@ IDLE
Finished scheduling packet sends.
Definition: uan-mac-rc.h:206
ns3::UanMacRc::m_learnedProp
Time m_learnedProp
Propagation delay to gateway.
Definition: uan-mac-rc.h:224
ns3::EventId::IsRunning
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:71
ns3::UanHeaderRcRts::SetRetryNo
void SetRetryNo(uint8_t no)
Set the retry number of this RTS packet.
Definition: uan-header-rc.cc:194
ns3::Now
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:287
uan-phy.h
ns3::UanMacRc::UanMacRc
UanMacRc()
Default constructor.
Definition: uan-mac-rc.cc:155
uan-tx-mode.h
ns3::Address
a polymophic address class
Definition: address.h:91
ns3::UanMacRc::m_queueLimit
uint32_t m_queueLimit
Maximum packets to queue at MAC.
Definition: uan-mac-rc.h:221
ns3::UanHeaderRcAck::GetFrameNo
uint8_t GetFrameNo(void) const
Get the reservation frame number being ACKed.
Definition: uan-header-rc.cc:595
ns3::UanHeaderRcData::SetPropDelay
void SetPropDelay(Time propDelay)
Set the propagation delay as found in handshaking.
Definition: uan-header-rc.cc:72
ns3::UanMac::GetAddress
virtual Address GetAddress(void)
Get the MAC Address.
Definition: uan-mac.cc:55
ns3::Reservation::IncrementRetry
void IncrementRetry()
Increment the retry count.
Definition: uan-mac-rc.cc:141
ns3::UanMacRc::TYPE_CTS
@ TYPE_CTS
CTS.
Definition: uan-mac-rc.h:171
ns3::Packet::RemoveHeader
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
ns3::EventId::Cancel
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
NS_UNUSED
#define NS_UNUSED(x)
Mark a local variable as unused.
Definition: unused.h:36
ns3::UanMacRc::m_cleared
bool m_cleared
Flag when we've been cleared.
Definition: uan-mac-rc.h:232
ns3::Reservation::GetFrameNo
uint8_t GetFrameNo() const
Get the frame number.
Definition: uan-mac-rc.cc:105
uan-mac-rc.h
ns3::UanMacRc::IsPhy1Ok
bool IsPhy1Ok(void)
Check that PHY is ok: not CTS or ACK not to my address.
Definition: uan-mac-rc.cc:711
ns3::UanHeaderCommon::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition: uan-header-common.cc:129
ns3::UanMacRc::RtsTimeout
void RtsTimeout(void)
Retry RTS.
Definition: uan-mac-rc.cc:734
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::UanTxMode
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:42
ns3::UanHeaderRcCtsGlobal::GetWindowTime
Time GetWindowTime(void) const
Get the window time (time duration following blocking time to allow RTS transmissions).
Definition: uan-header-rc.cc:339
list
#define list
Definition: openflow-interface.h:47
ns3::UanHeaderRcData::SetFrameNo
void SetFrameNo(uint8_t frameNum)
Set the frame number of the reservation being transmitted.
Definition: uan-header-rc.cc:66
ns3::UanHeaderRcCtsGlobal::GetTxTimeStamp
Time GetTxTimeStamp(void) const
Get the CTS transmit timestamp.
Definition: uan-header-rc.cc:345
ns3::UanHeaderRcCts::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition: uan-header-rc.cc:506
ns3::UanHeaderCommon::SetSrc
void SetSrc(Mac8Address src)
Set the source address.
Definition: uan-header-common.cc:72
ns3::UanHeaderRcData
Extra data header information.
Definition: uan-header-rc.h:42
ns3::UanHeaderRcCts::GetFrameNo
uint8_t GetFrameNo(void) const
Get the frame number of the RTS being cleared.
Definition: uan-header-rc.cc:476
ns3::UanHeaderRcAck
Header used for ACK packets by protocol UanMacRc.
Definition: uan-header-rc.h:459
ns3::Reservation
Stores reservation info for use in scheduling data channel by reservation channel MAC.
Definition: uan-mac-rc.h:53
ns3::UanMacRc::CreateRtsHeader
UanHeaderRcRts CreateRtsHeader(const Reservation &res)
Create the RTS header from a Reservation.
Definition: uan-mac-rc.cc:607
ns3::UanMacRc::AssociateTimeout
void AssociateTimeout(void)
Periodically retry association.
Definition: uan-mac-rc.cc:646
ns3::UanHeaderRcCtsGlobal
Cycle broadcast information.
Definition: uan-header-rc.h:239
ns3::UanMacRc::m_enqueueLogger
TracedCallback< Ptr< const Packet >, uint32_t > m_enqueueLogger
A packet arrived at the MAC for transmission.
Definition: uan-mac-rc.h:245
ns3::UanMacRc::m_minRetryRate
double m_minRetryRate
Smallest allowed RTS retry rate.
Definition: uan-mac-rc.h:226
ns3::MakeCallback
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:1642
ns3::Reservation::GetTimestamp
Time GetTimestamp(uint8_t n) const
Get the timestamp for the n'th RTS.
Definition: uan-mac-rc.cc:117
ns3::MakeDoubleAccessor
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
ns3::Reservation::m_pktList
std::list< std::pair< Ptr< Packet >, Mac8Address > > m_pktList
Queued packets for each address.
Definition: uan-mac-rc.h:134
ns3::UanMacRc::m_rtsEvent
EventId m_rtsEvent
The RTS event.
Definition: uan-mac-rc.h:250
ns3::UanMacRc::Associate
void Associate(void)
Associate with a gateway by sending the first GWPING.
Definition: uan-mac-rc.cc:620
ns3::UanMacRc
Non-gateway node MAC for reservation channel MAC protocol.
Definition: uan-mac-rc.h:164
ns3::UanMacRc::DoDispose
void DoDispose()
Destructor implementation.
Definition: uan-mac-rc.cc:202
ns3::UanMacRc::m_numRates
uint32_t m_numRates
Number of rates per Phy layer.
Definition: uan-mac-rc.h:218
timeout
ns3::Time timeout
Definition: openflow-switch.cc:52
ns3::UanHeaderRcAck::GetNoNacks
uint8_t GetNoNacks(void) const
Get the number of data frames being NACKed.
Definition: uan-header-rc.cc:601
ns3::UanHeaderRcData::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition: uan-header-rc.cc:90
NS_LOG_DEBUG
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
ns3::UanHeaderCommon::SetType
void SetType(uint8_t type)
Set the header type.
Definition: uan-header-common.cc:78
ns3::UanHeaderRcCtsGlobal::GetSerializedSize
virtual uint32_t GetSerializedSize(void) const
Definition: uan-header-rc.cc:362
ns3::UanMacRc::UNASSOCIATED
@ UNASSOCIATED
Initial state.
Definition: uan-mac-rc.h:204
ns3::UanMac
Virtual base class for all UAN MAC protocols.
Definition: uan-mac.h:50
uan-phy-dual.h
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::UanMacRc::m_retryStep
double m_retryStep
Retry rate increment.
Definition: uan-mac-rc.h:227
ns3::UanMacRc::GWPSENT
@ GWPSENT
Associated with gateway.
Definition: uan-mac-rc.h:205
ns3::Packet::Copy
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Definition: packet.cc:121
ns3::Reservation::m_length
uint32_t m_length
Total length of queued packets.
Definition: uan-mac-rc.h:136
ns3::UanHeaderRcCts::GetAddress
Mac8Address GetAddress(void) const
Get the destination address, for scheduling info.
Definition: uan-header-rc.cc:500
ns3::Time::S
@ S
second
Definition: nstime.h:115
ns3::Reservation::IsTransmitted
bool IsTransmitted() const
Definition: uan-mac-rc.cc:123
ns3::UanMacRc::m_forwardUpCb
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:240
ns3::UanMacRc::Clear
virtual void Clear(void)
Clears all pointer references.
Definition: uan-mac-rc.cc:178
ns3::UanMacRc::m_dequeueLogger
TracedCallback< Ptr< const Packet >, uint32_t > m_dequeueLogger
A was passed down to the PHY from the MAC.
Definition: uan-mac-rc.h:247
ns3::UanMacRc::SendPacket
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
Send on packet on the PHY.
Definition: uan-mac-rc.cc:515
ns3::UanMacRc::DATATX
@ DATATX
(Unused).
Definition: uan-mac-rc.h:208
uan-header-common.h
ns3::UanMacRc::AttachPhy
virtual void AttachPhy(Ptr< UanPhy > phy)
Attach PHY layer to this MAC.
Definition: uan-mac-rc.cc:322
ns3::UanHeaderCommon::GetType
uint8_t GetType(void) const
Get the header type value.
Definition: uan-header-common.cc:109
ns3::Reservation::Reservation
Reservation()
Default constructor.
Definition: uan-mac-rc.cc:46
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition: log-macros-enabled.h:244
ns3::Mac8Address::GetBroadcast
static Mac8Address GetBroadcast(void)
Get the broadcast address (255).
Definition: mac8-address.cc:87
ns3::UanMacRc::m_state
State m_state
MAC state.
Definition: uan-mac-rc.h:211
ns3::UanMacRc::BlockRtsing
void BlockRtsing(void)
Callback to block RST.
Definition: uan-mac-rc.cc:775
ns3::UanMacRc::m_cntrlSends
static uint32_t m_cntrlSends
Global count of calls to Associate, AssociateTimeout, SendRts, and RtsTimeout.
Definition: uan-mac-rc.h:309
ns3::UanHeaderRcRts
RTS header.
Definition: uan-header-rc.h:118
ns3::RandomVariableStream::SetStream
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
Definition: random-variable-stream.cc:100
ns3::UintegerValue
Hold an unsigned integer type.
Definition: uinteger.h:44
ns3::UanMacRc::TYPE_ACK
@ TYPE_ACK
ACK.
Definition: uan-mac-rc.h:172
ns3::UanHeaderRcAck::GetNackedFrames
const std::set< uint8_t > & GetNackedFrames(void) const
Get the set of NACK'ed frames.
Definition: uan-header-rc.cc:589
ns3::UanMacRc::m_pktQueue
std::list< std::pair< Ptr< Packet >, Mac8Address > > m_pktQueue
Pending packets.
Definition: uan-mac-rc.h:235
ns3::UanMacRc::m_rtsBlocked
bool m_rtsBlocked
RTS blocked while processing ACK.
Definition: uan-mac-rc.h:212
ns3::UanHeaderRcCtsGlobal::GetRetryRate
uint16_t GetRetryRate(void) const
Get the retry rate number.
Definition: uan-header-rc.cc:351
ns3::MakeUintegerAccessor
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
ns3::UanHeaderRcCts
CTS header.
Definition: uan-header-rc.h:343
ns3::UanMacRc::m_retryRate
double m_retryRate
Number of retry attempts per second (of RTS/GWPING.
Definition: uan-mac-rc.h:215
ns3::UanHeaderRcCts::GetDelayToTx
Time GetDelayToTx(void) const
Get the time delay from TX time of CTS packet until arrival of first data frame.
Definition: uan-header-rc.cc:488
ns3::ExponentialRandomVariable::GetValue
double GetValue(double mean, double bound)
Get the next random value, as a double from the exponential distribution with the specified mean and ...
Definition: random-variable-stream.cc:407
ns3::Reservation::m_timestamp
std::vector< Time > m_timestamp
Timestamps for each retry.
Definition: uan-mac-rc.h:140
ns3::Reservation::m_transmitted
bool m_transmitted
Has this reservation been transmitted.
Definition: uan-mac-rc.h:144
ns3::Object::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
ns3::UanMacRc::m_maxFrames
uint32_t m_maxFrames
Maximum number of frames to include in a single RTS.
Definition: uan-mac-rc.h:220
ns3::UanMacRc::AssignStreams
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
sample-rng-plot.n
n
Definition: sample-rng-plot.py:37
third.phy
phy
Definition: third.py:93
ns3::MakeTimeAccessor
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:1354
ns3::UanMacRc::TYPE_GWPING
@ TYPE_GWPING
Gateway ping.
Definition: uan-mac-rc.h:169
ns3::UanHeaderRcRts::SetNoFrames
void SetNoFrames(uint8_t no)
Set the number of data frames included in this reservation request.
Definition: uan-header-rc.cc:177