A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
uan-mac-rc.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 University of Washington
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Leonard Tracy <lentracy@gmail.com>
18 */
19
20#include "uan-mac-rc.h"
21
22#include "uan-header-common.h"
23#include "uan-header-rc.h"
24#include "uan-phy-dual.h"
25#include "uan-phy.h"
26#include "uan-tx-mode.h"
27
28#include "ns3/assert.h"
29#include "ns3/double.h"
30#include "ns3/log.h"
31#include "ns3/nstime.h"
32#include "ns3/simulator.h"
33#include "ns3/uinteger.h"
34
35#include <list>
36#include <utility>
37
38namespace ns3
39{
40
41NS_LOG_COMPONENT_DEFINE("UanMacRc");
42
44
46 : m_length(0),
47 m_frameNo(0),
48 m_retryNo(0),
49 m_transmitted(false)
50{
51}
52
54 uint8_t frameNo,
55 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() + ch.GetSerializedSize() + dh.GetSerializedSize();
68 m_pktList.push_back(list.front());
69 list.pop_front();
70 }
71 m_length = length;
72}
73
75{
76 for (auto it = m_pktList.begin(); it != m_pktList.end(); it++)
77 {
78 it->first = Ptr<Packet>((Packet*)nullptr);
79 }
80 m_pktList.clear();
81 m_timestamp.clear();
82}
83
86{
87 return static_cast<uint32_t>(m_pktList.size());
88}
89
92{
93 return m_length;
94}
95
96const std::list<std::pair<Ptr<Packet>, Mac8Address>>&
98{
99 return m_pktList;
100}
101
102uint8_t
104{
105 return m_frameNo;
106}
107
108uint8_t
110{
111 return m_retryNo;
112}
113
114Time
116{
117 return m_timestamp[n];
118}
119
120bool
122{
123 return m_transmitted;
124}
125
126void
128{
129 m_frameNo = fn;
130}
131
132void
134{
135 m_timestamp.push_back(t);
136}
137
138void
140{
141 m_retryNo++;
142}
143
144void
146{
147 m_transmitted = true;
148}
149
151
153 : UanMac(),
154 m_state(UNASSOCIATED),
155 m_rtsBlocked(false),
156 m_currentRate(10),
157 m_frameNo(0),
158 m_cleared(false)
159{
160 m_ev = CreateObject<ExponentialRandomVariable>();
161
163 UanHeaderRcCts ctsh;
165
168}
169
171{
172}
173
174void
176{
177 if (m_cleared)
178 {
179 return;
180 }
181 m_cleared = true;
182 if (m_phy)
183 {
184 m_phy->Clear();
185 m_phy = nullptr;
186 }
187 for (auto it = m_pktQueue.begin(); it != m_pktQueue.end(); it++)
188 {
189 it->first = nullptr;
190 }
191 m_pktQueue.clear();
192 m_resList.clear();
195}
196
197void
199{
200 Clear();
202}
203
204TypeId
206{
207 static TypeId tid =
208 TypeId("ns3::UanMacRc")
209 .SetParent<UanMac>()
210 .SetGroupName("Uan")
211 .AddConstructor<UanMacRc>()
212 .AddAttribute("RetryRate",
213 "Number of retry attempts per second (of RTS/GWPING).",
214 DoubleValue(1 / 5.0),
216 MakeDoubleChecker<double>())
217 .AddAttribute("MaxFrames",
218 "Maximum number of frames to include in a single RTS.",
219 UintegerValue(1),
221 MakeUintegerChecker<uint32_t>())
222 .AddAttribute("QueueLimit",
223 "Maximum packets to queue at MAC.",
224 UintegerValue(10),
226 MakeUintegerChecker<uint32_t>())
227 .AddAttribute("SIFS",
228 "Spacing to give between frames (this should match gateway).",
229 TimeValue(Seconds(0.2)),
232 .AddAttribute("NumberOfRates",
233 "Number of rate divisions supported by each PHY.",
234 UintegerValue(0),
236 MakeUintegerChecker<uint32_t>())
237 .AddAttribute("MinRetryRate",
238 "Smallest allowed RTS retry rate.",
239 DoubleValue(0.01),
241 MakeDoubleChecker<double>())
242 .AddAttribute("RetryStep",
243 "Retry rate increment.",
244 DoubleValue(0.01),
246 MakeDoubleChecker<double>())
247 .AddAttribute("MaxPropDelay",
248 "Maximum possible propagation delay to gateway.",
249 TimeValue(Seconds(2)),
252 .AddTraceSource("Enqueue",
253 "A (data) packet arrived at MAC for transmission.",
255 "ns3::UanMacRc::QueueTracedCallback")
256 .AddTraceSource("Dequeue",
257 "A (data) packet was passed down to PHY from MAC.",
259 "ns3::UanMacRc::QueueTracedCallback")
260 .AddTraceSource("RX",
261 "A packet was destined for and received at this MAC layer.",
263 "ns3::UanMac::PacketModeTracedCallback");
264 return tid;
265}
266
267int64_t
269{
270 NS_LOG_FUNCTION(this << stream);
271 m_ev->SetStream(stream);
272 return 1;
273}
274
275bool
276UanMacRc::Enqueue(Ptr<Packet> packet, uint16_t protocolNumber, const Address& dest)
277{
278 if (protocolNumber > 0)
279 {
280 NS_LOG_WARN("Warning: UanMacRc does not support multiple protocols. protocolNumber "
281 "argument to Enqueue is being ignored");
282 }
283
284 if (m_pktQueue.size() >= m_queueLimit)
285 {
286 return false;
287 }
288
289 m_pktQueue.emplace_back(packet, Mac8Address::ConvertFrom(dest));
290
291 switch (m_state)
292 {
293 case UNASSOCIATED:
294 Associate();
295 return true;
296 case IDLE:
297 if (!m_rtsEvent.IsRunning())
298 {
299 SendRts();
300 }
301 return true;
302 case GWPSENT:
303 case RTSSENT:
304 case DATATX:
305 return true;
306 }
307
308 return true;
309}
310
311void
313{
314 m_forwardUpCb = cb;
315}
316
317void
319{
320 m_phy = phy;
321 m_phy->SetReceiveOkCallback(MakeCallback(&UanMacRc::ReceiveOkFromPhy, this));
322}
323
324void
326{
328 pkt->RemoveHeader(ch);
331 {
332 m_rxLogger(pkt, mode);
333 }
334
335 switch (ch.GetType())
336 {
337 case TYPE_DATA:
338
340 {
342 << " UanMacRc Receiving DATA packet from PHY");
344 pkt->RemoveHeader(dh);
345 m_forwardUpCb(pkt, ch.GetProtocolNumber(), ch.GetSrc());
346 }
347 break;
348 case TYPE_RTS:
349 // Currently don't respond to RTS packets at non-gateway nodes
350 // (Code assumes single network neighborhood)
351 break;
352 case TYPE_CTS: {
353 uint32_t ctsBytes = ch.GetSerializedSize() + pkt->GetSize();
354 m_assocAddr = ch.GetSrc();
356 pkt->RemoveHeader(ctsg);
357 m_currentRate = ctsg.GetRateNum();
359
360 UanHeaderRcRts rhtmp;
361
362 Time winDelay = ctsg.GetWindowTime();
363
364 if (winDelay > Time(0))
365 {
366 m_rtsBlocked = false;
368 }
369 else
370 {
372 << " Received window period < 0");
373 }
374
375 UanHeaderRcCts ctsh;
377 while (pkt->GetSize() > 0)
378 {
379 pkt->RemoveHeader(ctsh);
381 {
382 if (m_state == GWPSENT)
383 {
384 m_assocAddr = ch.GetSrc();
385 ScheduleData(ctsh, ctsg, ctsBytes);
386 }
387 else if (m_state == RTSSENT)
388 {
389 ScheduleData(ctsh, ctsg, ctsBytes);
390 }
391 else
392 {
394 << " Node " << Mac8Address::ConvertFrom(GetAddress())
395 << " received CTS while state != RTSSENT or GWPING");
396 }
397 }
398 }
399 }
400 break;
401 case TYPE_GWPING:
402 // Do not respond to GWPINGS at non-gateway nodes
403 break;
404 case TYPE_ACK:
405 m_rtsBlocked = true;
407 {
408 return;
409 }
410 ProcessAck(pkt);
411 break;
412 default:
413 NS_FATAL_ERROR("Unknown packet type " << ch.GetType() << " received at node "
414 << GetAddress());
415 }
416}
417
418void
420 const UanHeaderRcCtsGlobal& ctsg,
421 uint32_t ctsBytes)
422{
424
425 auto it = m_resList.begin();
426 for (; it != m_resList.end(); it++)
427 {
428 if (it->GetFrameNo() == ctsh.GetFrameNo())
429 {
430 break;
431 }
432 }
433 if (it == m_resList.end())
434 {
436 << " Node " << Mac8Address::ConvertFrom(GetAddress())
437 << " received CTS packet with no corresponding reservation!");
438 return;
439 }
441 << " received CTS packet. Scheduling data");
442 it->SetTransmitted();
443
444 double currentBps = m_phy->GetMode(m_currentRate).GetDataRateBps();
445
446 m_learnedProp = Simulator::Now() - ctsg.GetTxTimeStamp() - Seconds(ctsBytes * 8.0 / currentBps);
447
448 Time arrTime = ctsg.GetTxTimeStamp() + ctsh.GetDelayToTx();
449 Time txTime = arrTime - m_learnedProp;
450
451 Time startDelay = txTime - Simulator::Now();
452
453 Time frameDelay = Seconds(0);
454
455 const std::list<std::pair<Ptr<Packet>, Mac8Address>> l = it->GetPktList();
456 auto pit = l.begin();
457
458 for (uint8_t i = 0; i < it->GetNoFrames(); i++, pit++)
459 {
460 Ptr<Packet> pkt = (*pit).first->Copy();
461
463 dh.SetFrameNo(i);
465 pkt->AddHeader(dh);
466
468 ch.SetType(TYPE_DATA);
471
472 pkt->AddHeader(ch);
473 Time eventTime = startDelay + frameDelay;
474 if (eventTime < Time(0))
475 {
477 "Scheduling error resulted in very negative data transmission time! eventTime = "
478 << eventTime.As(Time::S));
479 }
481 << " Node " << Mac8Address::ConvertFrom(GetAddress())
482 << " scheduling with delay " << eventTime.As(Time::S) << " propDelay "
483 << m_learnedProp.As(Time::S) << " start delay " << startDelay.As(Time::S)
484 << " arrival time " << arrTime.As(Time::S));
486 frameDelay = frameDelay + m_sifs + Seconds(pkt->GetSize() / currentBps);
487 }
488
489 m_state = IDLE;
490 if (!m_pktQueue.empty())
491 {
492 if (m_rtsEvent.IsRunning())
493 {
495 }
496
498 double timeout = m_ev->GetValue();
500 }
501}
502
503void
505{
507 pkt->PeekHeader(ch);
508 std::string type;
509 switch (ch.GetType())
510 {
511 case TYPE_DATA:
512 type = "DATA";
513 break;
514 case TYPE_RTS:
515 type = "RTS";
516 break;
517 case TYPE_CTS:
518 type = "CTS";
519 break;
520 case TYPE_ACK:
521 type = "ACK";
522 break;
523 case TYPE_GWPING:
524 type = "GWPING";
525 break;
526 default:
527 type = "UNKNOWN";
528 break;
529 }
531 << " Node " << Mac8Address::ConvertFrom(GetAddress()) << " transmitting "
532 << pkt->GetSize() << " byte packet of type " << type << " with rate " << rate
533 << "(" << m_phy->GetMode(rate).GetDataRateBps() << ") to " << ch.GetDest());
534 m_dequeueLogger(pkt, rate);
535 m_phy->SendPacket(pkt, rate);
536}
537
538void
540{
542 ack->RemoveHeader(ah);
543
544 auto it = m_resList.begin();
545 for (; it != m_resList.end(); it++)
546 {
547 if (it->GetFrameNo() == ah.GetFrameNo())
548 {
549 break;
550 }
551 }
552 if (it == m_resList.end())
553 {
554 NS_LOG_DEBUG("In " << __func__
555 << " could not find reservation corresponding to received ACK");
556 return;
557 }
558 if (!it->IsTransmitted())
559 {
560 return;
561 }
562 if (ah.GetNoNacks() > 0)
563 {
564 const std::list<std::pair<Ptr<Packet>, Mac8Address>> l = it->GetPktList();
565 auto pit = l.begin();
566
567 const std::set<uint8_t>& nacks = ah.GetNackedFrames();
568 auto nit = nacks.begin();
569 uint8_t pnum = 0;
570 for (; nit != nacks.end(); nit++)
571 {
573 << " Received NACK for " << (uint32_t)*nit);
574 while (pnum < *nit)
575 {
576 pit++;
577 pnum++;
578 }
581 m_pktQueue.push_front(*pit);
582 }
583 }
584 else
585 {
587 << " 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
605void
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));
622 static_cast<uint8_t>(TYPE_GWPING),
623 0));
624 NS_LOG_DEBUG(Now().As(Time::S) << " Sending first GWPING " << *pkt);
626 }
630 double timeout = m_ev->GetValue();
632}
633
634void
636{
637 m_cntrlSends++;
638 if (m_state != GWPSENT)
639 {
640 return;
641 }
642 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
643 bool phy1ok = IsPhy1Ok();
644 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
645 {
646 Ptr<Packet> pkt = Create<Packet>();
647
648 Reservation res = m_resList.back();
649 m_resList.pop_back();
650 res.AddTimestamp(Simulator::Now());
651 res.IncrementRetry();
652
653 pkt->AddHeader(CreateRtsHeader(res));
656 static_cast<uint8_t>(TYPE_GWPING),
657 0));
658
660 m_resList.push_back(res);
661 }
664 double timeout = m_ev->GetValue();
666}
667
668void
670{
671 m_cntrlSends++;
672 if (m_state == RTSSENT)
673 {
674 return;
675 }
676
677 NS_ASSERT(!m_pktQueue.empty());
678
680 res.AddTimestamp(Simulator::Now());
681 m_frameNo++;
682 m_resList.push_back(res);
683 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
684 bool phy1ok = IsPhy1Ok();
685 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
686 {
687 Ptr<Packet> pkt = Create<Packet>(0);
688 pkt->AddHeader(CreateRtsHeader(res));
691 static_cast<uint8_t>(TYPE_RTS),
692 0));
694 }
698 double timeout = m_ev->GetValue();
700}
701
702// We assume here that packet types are known at detection.
703bool
705{
706 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
707
708 bool phy1ok = true;
709 if (phyDual->IsPhy1Rx())
710 {
711 Ptr<Packet> pkt = phyDual->GetPhy1PacketRx();
713 pkt->PeekHeader(ch);
714 if (ch.GetType() == TYPE_CTS || ch.GetType() == TYPE_ACK)
715 {
716 phy1ok = false;
717 }
718 else if (ch.GetDest() == Mac8Address::ConvertFrom(GetAddress()))
719 {
720 phy1ok = false;
721 }
722 }
723 return phy1ok;
724}
725
726void
728{
729 m_cntrlSends++;
730
731 if (m_state != RTSSENT)
732 {
733 return;
734 }
735 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
736
737 bool phy1ok = IsPhy1Ok();
738 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
739 {
740 if (m_resList.empty())
741 {
743 << " tried to retry RTS with empty reservation list");
744 }
745 Ptr<Packet> pkt = Create<Packet>(0);
746
747 Reservation res = m_resList.back();
748 NS_ASSERT(!res.IsTransmitted());
749 m_resList.pop_back();
750 res.AddTimestamp(Simulator::Now());
751 res.IncrementRetry();
752 m_resList.push_back(res);
753 pkt->AddHeader(CreateRtsHeader(res));
756 static_cast<uint8_t>(TYPE_RTS),
757 0));
759 }
763 double timeout = m_ev->GetValue();
765}
766
767void
769{
770 m_rtsBlocked = true;
771}
772
773} // namespace ns3
a polymophic address class
Definition: address.h:101
Callback template class.
Definition: callback.h:438
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition: double.h:42
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:55
bool IsRunning() const
This method is syntactic sugar for !IsExpired().
Definition: event-id.cc:76
double GetValue(double mean, double bound)
Get the next random value drawn from the distribution.
A class used for addressing MAC8 MAC's.
Definition: mac8-address.h:44
static Mac8Address GetBroadcast()
Get the broadcast address (255).
Definition: mac8-address.cc:88
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
Definition: mac8-address.cc:56
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:211
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:444
network packets
Definition: packet.h:239
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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:51
uint32_t GetNoFrames() const
Get the number of frames in this Reservation.
Definition: uan-mac-rc.cc:85
uint32_t GetLength() const
Get the total length of the Reservation.
Definition: uan-mac-rc.cc:91
~Reservation()
Destructor.
Definition: uan-mac-rc.cc:74
std::list< std::pair< Ptr< Packet >, Mac8Address > > m_pktList
Queued packets for each address.
Definition: uan-mac-rc.h:134
bool m_transmitted
Has this reservation been transmitted.
Definition: uan-mac-rc.h:144
const std::list< std::pair< Ptr< Packet >, Mac8Address > > & GetPktList() const
Get the list of packets.
Definition: uan-mac-rc.cc:97
Reservation()
Default constructor.
Definition: uan-mac-rc.cc:45
Time GetTimestamp(uint8_t n) const
Get the timestamp for the n'th RTS.
Definition: uan-mac-rc.cc:115
uint8_t GetFrameNo() const
Get the frame number.
Definition: uan-mac-rc.cc:103
void IncrementRetry()
Increment the retry count.
Definition: uan-mac-rc.cc:139
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:127
bool IsTransmitted() const
Definition: uan-mac-rc.cc:121
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:109
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:145
void AddTimestamp(Time t)
Set the time of the latest RTS sent.
Definition: uan-mac-rc.cc:133
std::vector< Time > m_timestamp
Timestamps for each retry.
Definition: uan-mac-rc.h:140
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:208
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:415
@ S
second
Definition: nstime.h:116
AttributeValue implementation for Time.
Definition: nstime.h:1413
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
Common packet header fields.
void SetSrc(Mac8Address src)
Set the source address.
uint32_t GetSerializedSize() const override
uint8_t GetType() const
Get the header type value.
Mac8Address GetDest() const
Get the destination address.
Mac8Address GetSrc() const
Get the source address.
void SetDest(Mac8Address dest)
Set the destination address.
void SetType(uint8_t type)
Set the header type.
uint16_t GetProtocolNumber() const
Get the packet type value.
Header used for ACK packets by protocol UanMacRc.
const std::set< uint8_t > & GetNackedFrames() const
Get the set of NACK'ed frames.
uint8_t GetFrameNo() const
Get the reservation frame number being ACKed.
uint8_t GetNoNacks() const
Get the number of data frames being NACKed.
Cycle broadcast information.
uint16_t GetRetryRate() const
Get the retry rate number.
Time GetTxTimeStamp() const
Get the CTS transmit timestamp.
Time GetWindowTime() const
Get the window time (time duration following blocking time to allow RTS transmissions).
uint16_t GetRateNum() const
Get the data rate number.
uint32_t GetSerializedSize() const override
Time GetDelayToTx() const
Get the time delay from TX time of CTS packet until arrival of first data frame.
uint8_t GetFrameNo() const
Get the frame number of the RTS being cleared.
uint32_t GetSerializedSize() const override
Mac8Address GetAddress() const
Get the destination address, for scheduling info.
void SetAddress(Mac8Address addr)
Set the destination address, for scheduling info.
Extra data header information.
Definition: uan-header-rc.h:41
void SetFrameNo(uint8_t frameNum)
Set the frame number of the reservation being transmitted.
uint32_t GetSerializedSize() const override
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:46
virtual Address GetAddress()
Get the MAC Address.
Definition: uan-mac.cc:52
Non-gateway node MAC for reservation channel MAC protocol.
Definition: uan-mac-rc.h:163
void Clear() override
Clears all pointer references.
Definition: uan-mac-rc.cc:175
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
Send on packet on the PHY.
Definition: uan-mac-rc.cc:504
void ReceiveOkFromPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
PHY receive ok Callback.
Definition: uan-mac-rc.cc:325
void ScheduleData(const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes)
Schedule Packet sends.
Definition: uan-mac-rc.cc:419
double m_retryRate
Number of retry attempts per second (of RTS/GWPING.
Definition: uan-mac-rc.h:216
void SetForwardUpCb(Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > cb) override
Set the callback to forward packets up to higher layers.
Definition: uan-mac-rc.cc:312
UanHeaderRcRts CreateRtsHeader(const Reservation &res)
Create the RTS header from a Reservation.
Definition: uan-mac-rc.cc:593
EventId m_startAgain
(Unused).
Definition: uan-mac-rc.h:215
void BlockRtsing()
Callback to block RST.
Definition: uan-mac-rc.cc:768
TracedCallback< Ptr< const Packet >, uint32_t > m_dequeueLogger
A was passed down to the PHY from the MAC.
Definition: uan-mac-rc.h:248
uint32_t m_queueLimit
Maximum packets to queue at MAC.
Definition: uan-mac-rc.h:222
void AttachPhy(Ptr< UanPhy > phy) override
Attach PHY layer to this MAC.
Definition: uan-mac-rc.cc:318
void RtsTimeout()
Retry RTS.
Definition: uan-mac-rc.cc:727
EventId m_rtsEvent
The RTS event.
Definition: uan-mac-rc.h:251
uint8_t m_frameNo
Current frame number.
Definition: uan-mac-rc.h:223
Ptr< ExponentialRandomVariable > m_ev
Provides exponential random variables.
Definition: uan-mac-rc.h:315
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Definition: uan-mac-rc.cc:268
Ptr< UanPhy > m_phy
PHY layer attached to this MAC.
Definition: uan-mac-rc.h:218
void DoDispose() override
Destructor implementation.
Definition: uan-mac-rc.cc:198
double m_minRetryRate
Smallest allowed RTS retry rate.
Definition: uan-mac-rc.h:227
std::list< std::pair< Ptr< Packet >, Mac8Address > > m_pktQueue
Pending packets.
Definition: uan-mac-rc.h:236
double m_retryStep
Retry rate increment.
Definition: uan-mac-rc.h:228
uint32_t m_ctsSizeN
Size of UanHeaderRcCts.
Definition: uan-mac-rc.h:230
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
UanMacRc()
Default constructor.
Definition: uan-mac-rc.cc:152
void AssociateTimeout()
Periodically retry association.
Definition: uan-mac-rc.cc:635
~UanMacRc() override
Dummy destructor, DoDispose.
Definition: uan-mac-rc.cc:170
void Associate()
Associate with a gateway by sending the first GWPING.
Definition: uan-mac-rc.cc:606
static uint32_t m_cntrlSends
Global count of calls to Associate, AssociateTimeout, SendRts, and RtsTimeout.
Definition: uan-mac-rc.h:312
bool IsPhy1Ok()
Check that PHY is ok: not CTS or ACK not to my address.
Definition: uan-mac-rc.cc:704
void SendRts()
Send RTS packet.
Definition: uan-mac-rc.cc:669
uint32_t m_ctsSizeG
Size of UanHeaderCommon and UanHeaderRcCtsGlobal.
Definition: uan-mac-rc.h:231
Time m_learnedProp
Propagation delay to gateway.
Definition: uan-mac-rc.h:225
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
A packet was destined for and received at this MAC layer.
Definition: uan-mac-rc.h:244
State m_state
MAC state.
Definition: uan-mac-rc.h:212
uint32_t m_currentRate
Rate number corresponding to data rate of current cycle.
Definition: uan-mac-rc.h:220
void ProcessAck(Ptr< Packet > ack)
Process a received ACK.
Definition: uan-mac-rc.cc:539
bool Enqueue(Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest) override
Enqueue packet to be transmitted.
Definition: uan-mac-rc.cc:276
bool m_rtsBlocked
RTS blocked while processing ACK.
Definition: uan-mac-rc.h:213
@ 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
std::list< Reservation > m_resList
List of scheduled reservations.
Definition: uan-mac-rc.h:238
TracedCallback< Ptr< const Packet >, uint32_t > m_enqueueLogger
A packet arrived at the MAC for transmission.
Definition: uan-mac-rc.h:246
Time m_sifs
Spacing between frames to account for timing error and processing delay.
Definition: uan-mac-rc.h:224
Mac8Address m_assocAddr
Next hop address.
Definition: uan-mac-rc.h:217
bool m_cleared
Flag when we've been cleared.
Definition: uan-mac-rc.h:233
uint32_t m_maxFrames
Maximum number of frames to include in a single RTS.
Definition: uan-mac-rc.h:221
@ DATATX
(Unused).
Definition: uan-mac-rc.h:209
@ IDLE
Finished scheduling packet sends.
Definition: uan-mac-rc.h:207
@ RTSSENT
RTS just sent.
Definition: uan-mac-rc.h:208
@ GWPSENT
Associated with gateway.
Definition: uan-mac-rc.h:206
@ UNASSOCIATED
Initial state.
Definition: uan-mac-rc.h:205
uint32_t m_numRates
Number of rates per Phy layer.
Definition: uan-mac-rc.h:219
static TypeId GetTypeId()
Register this type.
Definition: uan-mac-rc.cc:205
Two channel Phy.
Definition: uan-phy-dual.h:79
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:43
Hold an unsigned integer type.
Definition: uinteger.h:45
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:66
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition: double.h:43
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition: nstime.h:1434
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1414
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition: uinteger.h:46
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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:261
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition: simulator.cc:305
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
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.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:704
#define list
ns3::Time timeout