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