A Discrete-Event Network Simulator
API
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 std::list<std::pair<Ptr<Packet>, Mac8Address>>::iterator it;
77 for (it = m_pktList.begin(); it != m_pktList.end(); it++)
78 {
79 it->first = Ptr<Packet>((Packet*)nullptr);
80 }
81 m_pktList.clear();
82 m_timestamp.clear();
83}
84
87{
88 return static_cast<uint32_t>(m_pktList.size());
89}
90
93{
94 return m_length;
95}
96
97const std::list<std::pair<Ptr<Packet>, Mac8Address>>&
99{
100 return m_pktList;
101}
102
103uint8_t
105{
106 return m_frameNo;
107}
108
109uint8_t
111{
112 return m_retryNo;
113}
114
115Time
117{
118 return m_timestamp[n];
119}
120
121bool
123{
124 return m_transmitted;
125}
126
127void
129{
130 m_frameNo = fn;
131}
132
133void
135{
136 m_timestamp.push_back(t);
137}
138
139void
141{
142 m_retryNo++;
143}
144
145void
147{
148 m_transmitted = true;
149}
150
152
154 : UanMac(),
155 m_state(UNASSOCIATED),
156 m_rtsBlocked(false),
157 m_currentRate(10),
158 m_frameNo(0),
159 m_cleared(false)
160{
161 m_ev = CreateObject<ExponentialRandomVariable>();
162
164 UanHeaderRcCts ctsh;
166
169}
170
172{
173}
174
175void
177{
178 if (m_cleared)
179 {
180 return;
181 }
182 m_cleared = true;
183 if (m_phy)
184 {
185 m_phy->Clear();
186 m_phy = nullptr;
187 }
188 std::list<std::pair<Ptr<Packet>, Mac8Address>>::iterator it;
189 for (it = m_pktQueue.begin(); it != m_pktQueue.end(); it++)
190 {
191 it->first = nullptr;
192 }
193 m_pktQueue.clear();
194 m_resList.clear();
197}
198
199void
201{
202 Clear();
204}
205
206TypeId
208{
209 static TypeId tid =
210 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 return tid;
267}
268
269int64_t
271{
272 NS_LOG_FUNCTION(this << stream);
273 m_ev->SetStream(stream);
274 return 1;
275}
276
277bool
278UanMacRc::Enqueue(Ptr<Packet> packet, uint16_t protocolNumber, const Address& dest)
279{
280 if (protocolNumber > 0)
281 {
282 NS_LOG_WARN("Warning: UanMacRc does not support multiple protocols. protocolNumber "
283 "argument to Enqueue is being ignored");
284 }
285
286 if (m_pktQueue.size() >= m_queueLimit)
287 {
288 return false;
289 }
290
291 m_pktQueue.emplace_back(packet, Mac8Address::ConvertFrom(dest));
292
293 switch (m_state)
294 {
295 case UNASSOCIATED:
296 Associate();
297 return true;
298 case IDLE:
299 if (!m_rtsEvent.IsRunning())
300 {
301 SendRts();
302 }
303 return true;
304 case GWPSENT:
305 case RTSSENT:
306 case DATATX:
307 return true;
308 }
309
310 return true;
311}
312
313void
315{
316 m_forwardUpCb = cb;
317}
318
319void
321{
322 m_phy = phy;
323 m_phy->SetReceiveOkCallback(MakeCallback(&UanMacRc::ReceiveOkFromPhy, this));
324}
325
326void
328{
330 pkt->RemoveHeader(ch);
333 {
334 m_rxLogger(pkt, mode);
335 }
336
337 switch (ch.GetType())
338 {
339 case TYPE_DATA:
340
342 {
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 neighborhood)
353 break;
354 case TYPE_CTS: {
355 uint32_t ctsBytes = ch.GetSerializedSize() + pkt->GetSize();
356 m_assocAddr = ch.GetSrc();
358 pkt->RemoveHeader(ctsg);
359 m_currentRate = ctsg.GetRateNum();
361
362 UanHeaderRcRts rhtmp;
363
364 Time winDelay = ctsg.GetWindowTime();
365
366 if (winDelay > Time(0))
367 {
368 m_rtsBlocked = false;
370 }
371 else
372 {
374 << " Received window period < 0");
375 }
376
377 UanHeaderRcCts ctsh;
379 while (pkt->GetSize() > 0)
380 {
381 pkt->RemoveHeader(ctsh);
383 {
384 if (m_state == GWPSENT)
385 {
386 m_assocAddr = ch.GetSrc();
387 ScheduleData(ctsh, ctsg, ctsBytes);
388 }
389 else if (m_state == RTSSENT)
390 {
391 ScheduleData(ctsh, ctsg, ctsBytes);
392 }
393 else
394 {
396 << " Node " << Mac8Address::ConvertFrom(GetAddress())
397 << " received CTS while state != RTSSENT or GWPING");
398 }
399 }
400 }
401 }
402 break;
403 case TYPE_GWPING:
404 // Do not respond to GWPINGS at non-gateway nodes
405 break;
406 case TYPE_ACK:
407 m_rtsBlocked = true;
409 {
410 return;
411 }
412 ProcessAck(pkt);
413 break;
414 default:
415 NS_FATAL_ERROR("Unknown packet type " << ch.GetType() << " received at node "
416 << GetAddress());
417 }
418}
419
420void
422 const UanHeaderRcCtsGlobal& ctsg,
423 uint32_t ctsBytes)
424{
426
427 std::list<Reservation>::iterator it = m_resList.begin();
428 for (; it != m_resList.end(); it++)
429 {
430 if (it->GetFrameNo() == ctsh.GetFrameNo())
431 {
432 break;
433 }
434 }
435 if (it == m_resList.end())
436 {
438 << " Node " << Mac8Address::ConvertFrom(GetAddress())
439 << " received CTS packet with no corresponding reservation!");
440 return;
441 }
443 << " received CTS packet. Scheduling data");
444 it->SetTransmitted();
445
446 double currentBps = m_phy->GetMode(m_currentRate).GetDataRateBps();
447
448 m_learnedProp = Simulator::Now() - ctsg.GetTxTimeStamp() - Seconds(ctsBytes * 8.0 / currentBps);
449
450 Time arrTime = ctsg.GetTxTimeStamp() + ctsh.GetDelayToTx();
451 Time txTime = arrTime - m_learnedProp;
452
453 Time startDelay = txTime - Simulator::Now();
454
455 Time frameDelay = Seconds(0);
456
457 const std::list<std::pair<Ptr<Packet>, Mac8Address>> l = it->GetPktList();
458 std::list<std::pair<Ptr<Packet>, Mac8Address>>::const_iterator pit;
459 pit = l.begin();
460
461 for (uint8_t i = 0; i < it->GetNoFrames(); i++, pit++)
462 {
463 Ptr<Packet> pkt = (*pit).first->Copy();
464
466 dh.SetFrameNo(i);
468 pkt->AddHeader(dh);
469
471 ch.SetType(TYPE_DATA);
474
475 pkt->AddHeader(ch);
476 Time eventTime = startDelay + frameDelay;
477 if (eventTime < Time(0))
478 {
480 "Scheduling error resulted in very negative data transmission time! eventTime = "
481 << eventTime.As(Time::S));
482 }
484 << " Node " << Mac8Address::ConvertFrom(GetAddress())
485 << " scheduling with delay " << eventTime.As(Time::S) << " propDelay "
486 << m_learnedProp.As(Time::S) << " start delay " << startDelay.As(Time::S)
487 << " arrival time " << arrTime.As(Time::S));
489 frameDelay = frameDelay + m_sifs + Seconds(pkt->GetSize() / currentBps);
490 }
491
492 m_state = IDLE;
493 if (!m_pktQueue.empty())
494 {
495 if (m_rtsEvent.IsRunning())
496 {
498 }
499
501 double timeout = m_ev->GetValue();
503 }
504}
505
506void
508{
510 pkt->PeekHeader(ch);
511 std::string type;
512 switch (ch.GetType())
513 {
514 case TYPE_DATA:
515 type = "DATA";
516 break;
517 case TYPE_RTS:
518 type = "RTS";
519 break;
520 case TYPE_CTS:
521 type = "CTS";
522 break;
523 case TYPE_ACK:
524 type = "ACK";
525 break;
526 case TYPE_GWPING:
527 type = "GWPING";
528 break;
529 default:
530 type = "UNKNOWN";
531 break;
532 }
534 << " Node " << Mac8Address::ConvertFrom(GetAddress()) << " transmitting "
535 << pkt->GetSize() << " byte packet of type " << type << " with rate " << rate
536 << "(" << m_phy->GetMode(rate).GetDataRateBps() << ") to " << ch.GetDest());
537 m_dequeueLogger(pkt, rate);
538 m_phy->SendPacket(pkt, rate);
539}
540
541void
543{
545 ack->RemoveHeader(ah);
546
547 std::list<Reservation>::iterator it = m_resList.begin();
548 for (; it != m_resList.end(); it++)
549 {
550 if (it->GetFrameNo() == ah.GetFrameNo())
551 {
552 break;
553 }
554 }
555 if (it == m_resList.end())
556 {
557 NS_LOG_DEBUG("In " << __func__
558 << " could not find reservation corresponding to received ACK");
559 return;
560 }
561 if (!it->IsTransmitted())
562 {
563 return;
564 }
565 if (ah.GetNoNacks() > 0)
566 {
567 const std::list<std::pair<Ptr<Packet>, Mac8Address>> l = it->GetPktList();
568 std::list<std::pair<Ptr<Packet>, Mac8Address>>::const_iterator pit;
569 pit = l.begin();
570
571 const std::set<uint8_t>& nacks = ah.GetNackedFrames();
572 std::set<uint8_t>::iterator nit = nacks.begin();
573 uint8_t pnum = 0;
574 for (; nit != nacks.end(); nit++)
575 {
577 << " Received NACK for " << (uint32_t)*nit);
578 while (pnum < *nit)
579 {
580 pit++;
581 pnum++;
582 }
585 m_pktQueue.push_front(*pit);
586 }
587 }
588 else
589 {
591 << " received ACK for all frames");
592 }
593 m_resList.erase(it);
594}
595
598{
600
601 rh.SetLength(static_cast<uint16_t>(res.GetLength()));
602 rh.SetNoFrames(static_cast<uint8_t>(res.GetNoFrames()));
603 rh.SetTimeStamp(res.GetTimestamp(res.GetRetryNo()));
604 rh.SetFrameNo(res.GetFrameNo());
605 rh.SetRetryNo(res.GetRetryNo());
606 return rh;
607}
608
609void
611{
612 m_cntrlSends++;
613
616 m_frameNo++;
617 m_resList.push_back(res);
618 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
619 bool phy1ok = IsPhy1Ok();
620 if (phy1ok && !phyDual->IsPhy2Tx() & !m_rtsBlocked)
621 {
622 Ptr<Packet> pkt = Create<Packet>(0);
623 pkt->AddHeader(CreateRtsHeader(res));
626 static_cast<uint8_t>(TYPE_GWPING),
627 0));
628 NS_LOG_DEBUG(Now().As(Time::S) << " Sending first GWPING " << *pkt);
630 }
634 double timeout = m_ev->GetValue();
636}
637
638void
640{
641 m_cntrlSends++;
642 if (m_state != GWPSENT)
643 {
644 return;
645 }
646 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
647 bool phy1ok = IsPhy1Ok();
648 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
649 {
650 Ptr<Packet> pkt = Create<Packet>();
651
652 Reservation res = m_resList.back();
653 m_resList.pop_back();
655 res.IncrementRetry();
656
657 pkt->AddHeader(CreateRtsHeader(res));
660 static_cast<uint8_t>(TYPE_GWPING),
661 0));
662
664 m_resList.push_back(res);
665 }
668 double timeout = m_ev->GetValue();
670}
671
672void
674{
675 m_cntrlSends++;
676 if (m_state == RTSSENT)
677 {
678 return;
679 }
680
681 NS_ASSERT(!m_pktQueue.empty());
682
685 m_frameNo++;
686 m_resList.push_back(res);
687 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
688 bool phy1ok = IsPhy1Ok();
689 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
690 {
691 Ptr<Packet> pkt = Create<Packet>(0);
692 pkt->AddHeader(CreateRtsHeader(res));
695 static_cast<uint8_t>(TYPE_RTS),
696 0));
698 }
702 double timeout = m_ev->GetValue();
704}
705
706// We assume here that packet types are known at detection.
707bool
709{
710 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
711
712 bool phy1ok = true;
713 if (phyDual->IsPhy1Rx())
714 {
715 Ptr<Packet> pkt = phyDual->GetPhy1PacketRx();
717 pkt->PeekHeader(ch);
718 if (ch.GetType() == TYPE_CTS || ch.GetType() == TYPE_ACK)
719 {
720 phy1ok = false;
721 }
722 else if (ch.GetDest() == Mac8Address::ConvertFrom(GetAddress()))
723 {
724 phy1ok = false;
725 }
726 }
727 return phy1ok;
728}
729
730void
732{
733 m_cntrlSends++;
734
735 if (m_state != RTSSENT)
736 {
737 return;
738 }
739 Ptr<UanPhyDual> phyDual = m_phy->GetObject<UanPhyDual>();
740
741 bool phy1ok = IsPhy1Ok();
742 if (phy1ok && !phyDual->IsPhy2Tx() && !m_rtsBlocked)
743 {
744 if (m_resList.empty())
745 {
747 << " tried to retry RTS with empty reservation list");
748 }
749 Ptr<Packet> pkt = Create<Packet>(0);
750
751 Reservation res = m_resList.back();
752 NS_ASSERT(!res.IsTransmitted());
753 m_resList.pop_back();
755 res.IncrementRetry();
756 m_resList.push_back(res);
757 pkt->AddHeader(CreateRtsHeader(res));
760 static_cast<uint8_t>(TYPE_RTS),
761 0));
763 }
767 double timeout = m_ev->GetValue();
769}
770
771void
773{
774 m_rtsBlocked = true;
775}
776
777} // namespace ns3
a polymophic address class
Definition: address.h:100
Callback template class.
Definition: callback.h:443
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, as a double from the exponential distribution with the specified mean and ...
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:93
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
Definition: mac8-address.cc:61
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
Definition: object-base.cc:200
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:353
network packets
Definition: packet.h:241
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:294
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:268
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:863
Ptr< Packet > Copy() const
performs a COW copy of the packet.
Definition: packet.cc:131
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Definition: packet.cc:305
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:86
uint32_t GetLength() const
Get the total length of the Reservation.
Definition: uan-mac-rc.cc:92
~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:98
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:116
uint8_t GetFrameNo() const
Get the frame number.
Definition: uan-mac-rc.cc:104
void IncrementRetry()
Increment the retry count.
Definition: uan-mac-rc.cc:140
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:128
bool IsTransmitted() const
Definition: uan-mac-rc.cc:122
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:110
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:146
void AddTimestamp(Time t)
Set the time of the latest RTS sent.
Definition: uan-mac-rc.cc:134
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:568
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
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:417
@ S
second
Definition: nstime.h:116
AttributeValue implementation for Time.
Definition: nstime.h:1423
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
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:176
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
Send on packet on the PHY.
Definition: uan-mac-rc.cc:507
void ReceiveOkFromPhy(Ptr< Packet > pkt, double sinr, UanTxMode mode)
PHY receive ok Callback.
Definition: uan-mac-rc.cc:327
void ScheduleData(const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes)
Schedule Packet sends.
Definition: uan-mac-rc.cc:421
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:314
UanHeaderRcRts CreateRtsHeader(const Reservation &res)
Create the RTS header from a Reservation.
Definition: uan-mac-rc.cc:597
EventId m_startAgain
(Unused).
Definition: uan-mac-rc.h:215
void BlockRtsing()
Callback to block RST.
Definition: uan-mac-rc.cc:772
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:320
void RtsTimeout()
Retry RTS.
Definition: uan-mac-rc.cc:731
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:270
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:200
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
@ 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
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:153
void AssociateTimeout()
Periodically retry association.
Definition: uan-mac-rc.cc:639
~UanMacRc() override
Dummy destructor, DoDispose.
Definition: uan-mac-rc.cc:171
void Associate()
Associate with a gateway by sending the first GWPING.
Definition: uan-mac-rc.cc:610
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:708
void SendRts()
Send RTS packet.
Definition: uan-mac-rc.cc:673
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:542
bool Enqueue(Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest) override
Enqueue packet to be transmitted.
Definition: uan-mac-rc.cc:278
bool m_rtsBlocked
RTS blocked while processing ACK.
Definition: uan-mac-rc.h:213
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:207
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 AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1424
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:160
#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:296
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1336
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:848
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:691
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:535
phy
Definition: third.py:82
#define list
ns3::Time timeout