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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Leonard Tracy <lentracy@gmail.com>
7 */
8
9#include "uan-mac-rc.h"
10
11#include "uan-header-common.h"
12#include "uan-header-rc.h"
13#include "uan-phy-dual.h"
14#include "uan-phy.h"
15#include "uan-tx-mode.h"
16
17#include "ns3/assert.h"
18#include "ns3/double.h"
19#include "ns3/log.h"
20#include "ns3/nstime.h"
21#include "ns3/simulator.h"
22#include "ns3/uinteger.h"
23
24#include <list>
25#include <utility>
26
27namespace ns3
28{
29
30NS_LOG_COMPONENT_DEFINE("UanMacRc");
31
33
35 : m_length(0),
36 m_frameNo(0),
37 m_retryNo(0),
38 m_transmitted(false)
39{
40}
41
43 uint8_t frameNo,
44 uint32_t maxPkts)
45 : m_frameNo(frameNo),
46 m_retryNo(0),
47 m_transmitted(false)
48{
49 uint32_t numPkts = (maxPkts) ? maxPkts : static_cast<uint32_t>(list.size());
50 uint32_t length = 0;
53
54 for (uint32_t i = 0; i < numPkts; i++)
55 {
56 length += list.front().first->GetSize() + ch.GetSerializedSize() + dh.GetSerializedSize();
57 m_pktList.push_back(list.front());
58 list.pop_front();
59 }
60 m_length = length;
61}
62
64{
65 for (auto it = m_pktList.begin(); it != m_pktList.end(); it++)
66 {
67 it->first = Ptr<Packet>((Packet*)nullptr);
68 }
69 m_pktList.clear();
70 m_timestamp.clear();
71}
72
75{
76 return static_cast<uint32_t>(m_pktList.size());
77}
78
81{
82 return m_length;
83}
84
85const std::list<std::pair<Ptr<Packet>, Mac8Address>>&
87{
88 return m_pktList;
89}
90
91uint8_t
93{
94 return m_frameNo;
95}
96
97uint8_t
99{
100 return m_retryNo;
101}
102
103Time
105{
106 return m_timestamp[n];
107}
108
109bool
111{
112 return m_transmitted;
113}
114
115void
117{
118 m_frameNo = fn;
119}
120
121void
123{
124 m_timestamp.push_back(t);
125}
126
127void
132
133void
135{
136 m_transmitted = true;
137}
138
140
142 : UanMac(),
143 m_state(UNASSOCIATED),
144 m_rtsBlocked(false),
145 m_currentRate(10),
146 m_frameNo(0),
147 m_cleared(false)
148{
150
152 UanHeaderRcCts ctsh;
154
157}
158
162
163void
165{
166 if (m_cleared)
167 {
168 return;
169 }
170 m_cleared = true;
171 if (m_phy)
172 {
173 m_phy->Clear();
174 m_phy = nullptr;
175 }
176 for (auto it = m_pktQueue.begin(); it != m_pktQueue.end(); it++)
177 {
178 it->first = nullptr;
179 }
180 m_pktQueue.clear();
181 m_resList.clear();
184}
185
186void
192
193TypeId
195{
196 static TypeId tid =
197 TypeId("ns3::UanMacRc")
198 .SetParent<UanMac>()
199 .SetGroupName("Uan")
200 .AddConstructor<UanMacRc>()
201 .AddAttribute("RetryRate",
202 "Number of retry attempts per second (of RTS/GWPING).",
203 DoubleValue(1 / 5.0),
206 .AddAttribute("MaxFrames",
207 "Maximum number of frames to include in a single RTS.",
208 UintegerValue(1),
211 .AddAttribute("QueueLimit",
212 "Maximum packets to queue at MAC.",
213 UintegerValue(10),
216 .AddAttribute("SIFS",
217 "Spacing to give between frames (this should match gateway).",
218 TimeValue(Seconds(0.2)),
221 .AddAttribute("NumberOfRates",
222 "Number of rate divisions supported by each PHY.",
223 UintegerValue(0),
226 .AddAttribute("MinRetryRate",
227 "Smallest allowed RTS retry rate.",
228 DoubleValue(0.01),
231 .AddAttribute("RetryStep",
232 "Retry rate increment.",
233 DoubleValue(0.01),
236 .AddAttribute("MaxPropDelay",
237 "Maximum possible propagation delay to gateway.",
238 TimeValue(Seconds(2)),
241 .AddTraceSource("Enqueue",
242 "A (data) packet arrived at MAC for transmission.",
244 "ns3::UanMacRc::QueueTracedCallback")
245 .AddTraceSource("Dequeue",
246 "A (data) packet was passed down to PHY from MAC.",
248 "ns3::UanMacRc::QueueTracedCallback")
249 .AddTraceSource("RX",
250 "A packet was destined for and received at this MAC layer.",
252 "ns3::UanMac::PacketModeTracedCallback");
253 return tid;
254}
255
256int64_t
258{
259 NS_LOG_FUNCTION(this << stream);
260 m_ev->SetStream(stream);
261 return 1;
262}
263
264bool
265UanMacRc::Enqueue(Ptr<Packet> packet, uint16_t protocolNumber, const Address& dest)
266{
267 if (protocolNumber > 0)
268 {
269 NS_LOG_WARN("Warning: UanMacRc does not support multiple protocols. protocolNumber "
270 "argument to Enqueue is being ignored");
271 }
272
273 if (m_pktQueue.size() >= m_queueLimit)
274 {
275 return false;
276 }
277
278 m_pktQueue.emplace_back(packet, Mac8Address::ConvertFrom(dest));
279
280 switch (m_state)
281 {
282 case UNASSOCIATED:
283 Associate();
284 return true;
285 case IDLE:
286 if (!m_rtsEvent.IsPending())
287 {
288 SendRts();
289 }
290 return true;
291 case GWPSENT:
292 case RTSSENT:
293 case DATATX:
294 return true;
295 }
296
297 return true;
298}
299
300void
302{
303 m_forwardUpCb = cb;
304}
305
306void
308{
309 m_phy = phy;
310 m_phy->SetReceiveOkCallback(MakeCallback(&UanMacRc::ReceiveOkFromPhy, this));
311}
312
313void
315{
317 pkt->RemoveHeader(ch);
320 {
321 m_rxLogger(pkt, mode);
322 }
323
324 switch (ch.GetType())
325 {
326 case TYPE_DATA:
327
329 {
331 << " UanMacRc Receiving DATA packet from PHY");
333 pkt->RemoveHeader(dh);
334 m_forwardUpCb(pkt, ch.GetProtocolNumber(), ch.GetSrc());
335 }
336 break;
337 case TYPE_RTS:
338 // Currently don't respond to RTS packets at non-gateway nodes
339 // (Code assumes single network neighborhood)
340 break;
341 case TYPE_CTS: {
342 uint32_t ctsBytes = ch.GetSerializedSize() + pkt->GetSize();
343 m_assocAddr = ch.GetSrc();
345 pkt->RemoveHeader(ctsg);
346 m_currentRate = ctsg.GetRateNum();
348
349 UanHeaderRcRts rhtmp;
350
351 Time winDelay = ctsg.GetWindowTime();
352
353 if (winDelay > Time(0))
354 {
355 m_rtsBlocked = false;
357 }
358 else
359 {
361 << " Received window period < 0");
362 }
363
364 UanHeaderRcCts ctsh;
366 while (pkt->GetSize() > 0)
367 {
368 pkt->RemoveHeader(ctsh);
370 {
371 if (m_state == GWPSENT)
372 {
373 m_assocAddr = ch.GetSrc();
374 ScheduleData(ctsh, ctsg, ctsBytes);
375 }
376 else if (m_state == RTSSENT)
377 {
378 ScheduleData(ctsh, ctsg, ctsBytes);
379 }
380 else
381 {
383 << " Node " << Mac8Address::ConvertFrom(GetAddress())
384 << " received CTS while state != RTSSENT or GWPING");
385 }
386 }
387 }
388 }
389 break;
390 case TYPE_GWPING:
391 // Do not respond to GWPINGS at non-gateway nodes
392 break;
393 case TYPE_ACK:
394 m_rtsBlocked = true;
396 {
397 return;
398 }
399 ProcessAck(pkt);
400 break;
401 default:
402 NS_FATAL_ERROR("Unknown packet type " << ch.GetType() << " received at node "
403 << GetAddress());
404 }
405}
406
407void
409 const UanHeaderRcCtsGlobal& ctsg,
410 uint32_t ctsBytes)
411{
413
414 auto it = m_resList.begin();
415 for (; it != m_resList.end(); it++)
416 {
417 if (it->GetFrameNo() == ctsh.GetFrameNo())
418 {
419 break;
420 }
421 }
422 if (it == m_resList.end())
423 {
425 << " Node " << Mac8Address::ConvertFrom(GetAddress())
426 << " received CTS packet with no corresponding reservation!");
427 return;
428 }
430 << " received CTS packet. Scheduling data");
431 it->SetTransmitted();
432
433 double currentBps = m_phy->GetMode(m_currentRate).GetDataRateBps();
434
435 m_learnedProp = Simulator::Now() - ctsg.GetTxTimeStamp() - Seconds(ctsBytes * 8.0 / currentBps);
436
437 Time arrTime = ctsg.GetTxTimeStamp() + ctsh.GetDelayToTx();
438 Time txTime = arrTime - m_learnedProp;
439
440 Time startDelay = txTime - Simulator::Now();
441
442 Time frameDelay = Seconds(0);
443
444 const std::list<std::pair<Ptr<Packet>, Mac8Address>> l = it->GetPktList();
445 auto pit = l.begin();
446
447 for (uint8_t i = 0; i < it->GetNoFrames(); i++, pit++)
448 {
449 Ptr<Packet> pkt = (*pit).first->Copy();
450
452 dh.SetFrameNo(i);
454 pkt->AddHeader(dh);
455
457 ch.SetType(TYPE_DATA);
460
461 pkt->AddHeader(ch);
462 Time eventTime = startDelay + frameDelay;
463 if (eventTime < Time(0))
464 {
466 "Scheduling error resulted in very negative data transmission time! eventTime = "
467 << eventTime.As(Time::S));
468 }
470 << " Node " << Mac8Address::ConvertFrom(GetAddress())
471 << " scheduling with delay " << eventTime.As(Time::S) << " propDelay "
472 << m_learnedProp.As(Time::S) << " start delay " << startDelay.As(Time::S)
473 << " arrival time " << arrTime.As(Time::S));
475 frameDelay = frameDelay + m_sifs + Seconds(pkt->GetSize() / currentBps);
476 }
477
478 m_state = IDLE;
479 if (!m_pktQueue.empty())
480 {
481 if (m_rtsEvent.IsPending())
482 {
484 }
485
486 m_ev->SetAttribute("Mean", DoubleValue(1 / m_retryRate));
487 double timeout = m_ev->GetValue();
489 }
490}
491
492void
494{
496 pkt->PeekHeader(ch);
497 std::string type;
498 switch (ch.GetType())
499 {
500 case TYPE_DATA:
501 type = "DATA";
502 break;
503 case TYPE_RTS:
504 type = "RTS";
505 break;
506 case TYPE_CTS:
507 type = "CTS";
508 break;
509 case TYPE_ACK:
510 type = "ACK";
511 break;
512 case TYPE_GWPING:
513 type = "GWPING";
514 break;
515 default:
516 type = "UNKNOWN";
517 break;
518 }
520 << " Node " << Mac8Address::ConvertFrom(GetAddress()) << " transmitting "
521 << pkt->GetSize() << " byte packet of type " << type << " with rate " << rate
522 << "(" << m_phy->GetMode(rate).GetDataRateBps() << ") to " << ch.GetDest());
523 m_dequeueLogger(pkt, rate);
524 m_phy->SendPacket(pkt, rate);
525}
526
527void
529{
531 ack->RemoveHeader(ah);
532
533 auto it = m_resList.begin();
534 for (; it != m_resList.end(); it++)
535 {
536 if (it->GetFrameNo() == ah.GetFrameNo())
537 {
538 break;
539 }
540 }
541 if (it == m_resList.end())
542 {
543 NS_LOG_DEBUG("In " << __func__
544 << " could not find reservation corresponding to received ACK");
545 return;
546 }
547 if (!it->IsTransmitted())
548 {
549 return;
550 }
551 if (ah.GetNoNacks() > 0)
552 {
553 const std::list<std::pair<Ptr<Packet>, Mac8Address>> l = it->GetPktList();
554 auto pit = l.begin();
555
556 const std::set<uint8_t>& nacks = ah.GetNackedFrames();
557 auto nit = nacks.begin();
558 uint8_t pnum = 0;
559 for (; nit != nacks.end(); nit++)
560 {
562 << " Received NACK for " << (uint32_t)*nit);
563 while (pnum < *nit)
564 {
565 pit++;
566 pnum++;
567 }
570 m_pktQueue.push_front(*pit);
571 }
572 }
573 else
574 {
576 << " received ACK for all frames");
577 }
578 m_resList.erase(it);
579}
580
583{
585
586 rh.SetLength(static_cast<uint16_t>(res.GetLength()));
587 rh.SetNoFrames(static_cast<uint8_t>(res.GetNoFrames()));
588 rh.SetTimeStamp(res.GetTimestamp(res.GetRetryNo()));
589 rh.SetFrameNo(res.GetFrameNo());
590 rh.SetRetryNo(res.GetRetryNo());
591 return rh;
592}
593
594void
596{
597 m_cntrlSends++;
598
600 res.AddTimestamp(Simulator::Now());
601 m_frameNo++;
602 m_resList.push_back(res);
603 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
604 bool phy1ok = IsPhy1Ok();
605 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
606 {
608 pkt->AddHeader(CreateRtsHeader(res));
611 static_cast<uint8_t>(TYPE_GWPING),
612 0));
613 NS_LOG_DEBUG(Now().As(Time::S) << " Sending first GWPING " << *pkt);
615 }
618 m_ev->SetAttribute("Mean", DoubleValue(1 / m_retryRate));
619 double timeout = m_ev->GetValue();
621}
622
623void
625{
626 m_cntrlSends++;
627 if (m_state != GWPSENT)
628 {
629 return;
630 }
631 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
632 bool phy1ok = IsPhy1Ok();
633 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
634 {
636
637 Reservation res = m_resList.back();
638 m_resList.pop_back();
639 res.AddTimestamp(Simulator::Now());
640 res.IncrementRetry();
641
642 pkt->AddHeader(CreateRtsHeader(res));
645 static_cast<uint8_t>(TYPE_GWPING),
646 0));
647
649 m_resList.push_back(res);
650 }
652 m_ev->SetAttribute("Mean", DoubleValue(1 / m_retryRate));
653 double timeout = m_ev->GetValue();
655}
656
657void
659{
660 m_cntrlSends++;
661 if (m_state == RTSSENT)
662 {
663 return;
664 }
665
666 NS_ASSERT(!m_pktQueue.empty());
667
669 res.AddTimestamp(Simulator::Now());
670 m_frameNo++;
671 m_resList.push_back(res);
672 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
673 bool phy1ok = IsPhy1Ok();
674 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
675 {
677 pkt->AddHeader(CreateRtsHeader(res));
680 static_cast<uint8_t>(TYPE_RTS),
681 0));
683 }
686 m_ev->SetAttribute("Mean", DoubleValue(1 / m_retryRate));
687 double timeout = m_ev->GetValue();
689}
690
691// We assume here that packet types are known at detection.
692bool
694{
695 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
696
697 bool phy1ok = true;
698 if (phyDual->IsPhy1Rx())
699 {
700 Ptr<Packet> pkt = phyDual->GetPhy1PacketRx();
702 pkt->PeekHeader(ch);
703 if (ch.GetType() == TYPE_CTS || ch.GetType() == TYPE_ACK ||
705 {
706 phy1ok = false;
707 }
708 }
709 return phy1ok;
710}
711
712void
714{
715 m_cntrlSends++;
716
717 if (m_state != RTSSENT)
718 {
719 return;
720 }
721 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
722
723 bool phy1ok = IsPhy1Ok();
724 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
725 {
726 if (m_resList.empty())
727 {
729 << " tried to retry RTS with empty reservation list");
730 }
732
733 Reservation res = m_resList.back();
734 NS_ASSERT(!res.IsTransmitted());
735 m_resList.pop_back();
736 res.AddTimestamp(Simulator::Now());
737 res.IncrementRetry();
738 m_resList.push_back(res);
739 pkt->AddHeader(CreateRtsHeader(res));
742 static_cast<uint8_t>(TYPE_RTS),
743 0));
745 }
748 m_ev->SetAttribute("Mean", DoubleValue(1 / m_retryRate));
749 double timeout = m_ev->GetValue();
751}
752
753void
755{
756 m_rtsBlocked = true;
757}
758
759} // namespace ns3
a polymophic address class
Definition address.h:90
Callback template class.
Definition callback.h:422
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Definition double.h:31
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition event-id.cc:44
bool IsPending() const
This method is syntactic sugar for !IsExpired().
Definition event-id.cc:65
A class used for addressing MAC8 MAC's.
static Mac8Address GetBroadcast()
Get the broadcast address (255).
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
network packets
Definition packet.h:228
Smart pointer class similar to boost::intrusive_ptr.
Stores reservation info for use in scheduling data channel by reservation channel MAC.
Definition uan-mac-rc.h:40
uint32_t GetNoFrames() const
Get the number of frames in this Reservation.
Definition uan-mac-rc.cc:74
uint32_t GetLength() const
Get the total length of the Reservation.
Definition uan-mac-rc.cc:80
~Reservation()
Destructor.
Definition uan-mac-rc.cc:63
std::list< std::pair< Ptr< Packet >, Mac8Address > > m_pktList
Queued packets for each address.
Definition uan-mac-rc.h:123
bool m_transmitted
Has this reservation been transmitted.
Definition uan-mac-rc.h:133
const std::list< std::pair< Ptr< Packet >, Mac8Address > > & GetPktList() const
Get the list of packets.
Definition uan-mac-rc.cc:86
Reservation()
Default constructor.
Definition uan-mac-rc.cc:34
Time GetTimestamp(uint8_t n) const
Get the timestamp for the n'th RTS.
uint8_t GetFrameNo() const
Get the frame number.
Definition uan-mac-rc.cc:92
void IncrementRetry()
Increment the retry count.
uint8_t m_frameNo
Frame number.
Definition uan-mac-rc.h:127
void SetFrameNo(uint8_t fn)
Set the frame number.
bool IsTransmitted() const
uint8_t m_retryNo
Number of retries.
Definition uan-mac-rc.h:131
uint8_t GetRetryNo() const
Get the retry number.
Definition uan-mac-rc.cc:98
uint32_t m_length
Total length of queued packets.
Definition uan-mac-rc.h:125
void SetTransmitted(bool t=true)
Set the reservation transmitted state.
void AddTimestamp(Time t)
Set the time of the latest RTS sent.
std::vector< Time > m_timestamp
Timestamps for each retry.
Definition uan-mac-rc.h:129
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:404
@ S
second
Definition nstime.h:105
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
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.
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:35
virtual Address GetAddress()
Get the MAC Address.
Definition uan-mac.cc:41
Non-gateway node MAC for reservation channel MAC protocol.
Definition uan-mac-rc.h:152
void Clear() override
Clears all pointer references.
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
Send on packet on the PHY.
void ReceiveOkFromPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
PHY receive ok Callback.
void ScheduleData(const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes)
Schedule Packet sends.
double m_retryRate
Number of retry attempts per second (of RTS/GWPING.
Definition uan-mac-rc.h:205
void SetForwardUpCb(Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > cb) override
Set the callback to forward packets up to higher layers.
UanHeaderRcRts CreateRtsHeader(const Reservation &res)
Create the RTS header from a Reservation.
EventId m_startAgain
(Unused).
Definition uan-mac-rc.h:204
void BlockRtsing()
Callback to block RST.
TracedCallback< Ptr< const Packet >, uint32_t > m_dequeueLogger
A was passed down to the PHY from the MAC.
Definition uan-mac-rc.h:237
uint32_t m_queueLimit
Maximum packets to queue at MAC.
Definition uan-mac-rc.h:211
void AttachPhy(Ptr< UanPhy > phy) override
Attach PHY layer to this MAC.
void RtsTimeout()
Retry RTS.
EventId m_rtsEvent
The RTS event.
Definition uan-mac-rc.h:240
uint8_t m_frameNo
Current frame number.
Definition uan-mac-rc.h:212
Ptr< ExponentialRandomVariable > m_ev
Provides exponential random variables.
Definition uan-mac-rc.h:304
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< UanPhy > m_phy
PHY layer attached to this MAC.
Definition uan-mac-rc.h:207
void DoDispose() override
Destructor implementation.
double m_minRetryRate
Smallest allowed RTS retry rate.
Definition uan-mac-rc.h:216
std::list< std::pair< Ptr< Packet >, Mac8Address > > m_pktQueue
Pending packets.
Definition uan-mac-rc.h:225
double m_retryStep
Retry rate increment.
Definition uan-mac-rc.h:217
uint32_t m_ctsSizeN
Size of UanHeaderRcCts.
Definition uan-mac-rc.h:219
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:230
UanMacRc()
Default constructor.
void AssociateTimeout()
Periodically retry association.
~UanMacRc() override
Dummy destructor, DoDispose.
void Associate()
Associate with a gateway by sending the first GWPING.
static uint32_t m_cntrlSends
Global count of calls to Associate, AssociateTimeout, SendRts, and RtsTimeout.
Definition uan-mac-rc.h:301
bool IsPhy1Ok()
Check that PHY is ok: not CTS or ACK not to my address.
void SendRts()
Send RTS packet.
uint32_t m_ctsSizeG
Size of UanHeaderCommon and UanHeaderRcCtsGlobal.
Definition uan-mac-rc.h:220
Time m_learnedProp
Propagation delay to gateway.
Definition uan-mac-rc.h:214
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
A packet was destined for and received at this MAC layer.
Definition uan-mac-rc.h:233
State m_state
MAC state.
Definition uan-mac-rc.h:201
uint32_t m_currentRate
Rate number corresponding to data rate of current cycle.
Definition uan-mac-rc.h:209
void ProcessAck(Ptr< Packet > ack)
Process a received ACK.
bool Enqueue(Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest) override
Enqueue packet to be transmitted.
bool m_rtsBlocked
RTS blocked while processing ACK.
Definition uan-mac-rc.h:202
@ TYPE_DATA
Data.
Definition uan-mac-rc.h:157
@ TYPE_GWPING
Gateway ping.
Definition uan-mac-rc.h:158
std::list< Reservation > m_resList
List of scheduled reservations.
Definition uan-mac-rc.h:227
TracedCallback< Ptr< const Packet >, uint32_t > m_enqueueLogger
A packet arrived at the MAC for transmission.
Definition uan-mac-rc.h:235
Time m_sifs
Spacing between frames to account for timing error and processing delay.
Definition uan-mac-rc.h:213
Mac8Address m_assocAddr
Next hop address.
Definition uan-mac-rc.h:206
bool m_cleared
Flag when we've been cleared.
Definition uan-mac-rc.h:222
uint32_t m_maxFrames
Maximum number of frames to include in a single RTS.
Definition uan-mac-rc.h:210
@ DATATX
(Unused).
Definition uan-mac-rc.h:198
@ IDLE
Finished scheduling packet sends.
Definition uan-mac-rc.h:196
@ RTSSENT
RTS just sent.
Definition uan-mac-rc.h:197
@ GWPSENT
Associated with gateway.
Definition uan-mac-rc.h:195
@ UNASSOCIATED
Initial state.
Definition uan-mac-rc.h:194
uint32_t m_numRates
Number of rates per Phy layer.
Definition uan-mac-rc.h:208
static TypeId GetTypeId()
Register this type.
Two channel Phy.
Abstraction of packet modulation information.
Definition uan-tx-mode.h:32
Hold an unsigned integer type.
Definition uinteger.h:34
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition log.h:257
#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:250
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition simulator.cc:294
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
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 > MakeUintegerChecker()
Definition uinteger.h:85
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition nstime.h:1396
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:684
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Definition uinteger.h:35
Ptr< const AttributeChecker > MakeDoubleChecker()
Definition double.h:82
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Definition double.h:32
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Definition nstime.h:1416
ns3::Time timeout