A Discrete-Event Network Simulator
API
uan-mac-rc.h
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#ifndef UAN_MAC_RC_H
22#define UAN_MAC_RC_H
23
24#include "uan-mac.h"
25#include "ns3/mac8-address.h"
26
27#include "ns3/nstime.h"
28#include "ns3/trace-source-accessor.h"
29#include "ns3/traced-callback.h"
30#include "ns3/event-id.h"
31#include "ns3/random-variable-stream.h"
32
33#include <list>
34#include <utility>
35#include <vector>
36
37
38namespace ns3 {
39
40class Address;
41class UanTxMode;
42class UanHeaderRcRts;
43class UanHeaderRcCts;
44class UanHeaderRcCtsGlobal;
45class UanPhy;
46
47
53{
54public:
56 Reservation ();
66 Reservation (std::list<std::pair <Ptr<Packet>, Mac8Address > > &list, uint8_t frameNo, uint32_t maxPkts = 0);
68 ~Reservation ();
74 uint32_t GetNoFrames () const;
82 uint32_t GetLength () const;
88 const std::list<std::pair <Ptr<Packet>, Mac8Address > > &GetPktList (void) const;
94 uint8_t GetFrameNo () const;
100 uint8_t GetRetryNo () const;
107 Time GetTimestamp (uint8_t n) const;
108
110 bool IsTransmitted () const;
116 void SetFrameNo (uint8_t fn);
122 void AddTimestamp (Time t);
124 void IncrementRetry ();
130 void SetTransmitted (bool t = true);
131
132private:
134 std::list<std::pair <Ptr<Packet>, Mac8Address > > m_pktList;
138 uint8_t m_frameNo;
140 std::vector<Time> m_timestamp;
142 uint8_t m_retryNo;
145
146}; // class Reservation
147
148
163class UanMacRc : public UanMac
164{
165public:
167 enum {
172 TYPE_ACK
173 };
175 UanMacRc ();
177 virtual ~UanMacRc ();
178
183 static TypeId GetTypeId (void);
184
185 // Inherited methods
186 virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest);
187 virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const Mac8Address&> cb);
188 virtual void AttachPhy (Ptr<UanPhy> phy);
189 virtual void Clear (void);
190 int64_t AssignStreams (int64_t stream);
191
198 typedef void (* QueueTracedCallback)
199 (Ptr<const Packet> packet, uint32_t proto);
200
201private:
203 enum State {
208 DATATX
209 };
210
213
215 double m_retryRate;
222 uint8_t m_frameNo;
225
227 double m_retryStep;
228
231
233
235 std::list<std::pair <Ptr<Packet>, Mac8Address > > m_pktQueue;
237 std::list<Reservation> m_resList;
238
241
248
258 void ReceiveOkFromPhy (Ptr<Packet> pkt, double sinr, UanTxMode mode);
260 void Associate (void);
262 void AssociateTimeout (void);
264 void SendRts (void);
266 void RtsTimeout (void);
281 void ScheduleData (const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes);
287 void ProcessAck (Ptr<Packet> ack);
294 void SendPacket (Ptr<Packet> pkt, uint32_t rate);
301 bool IsPhy1Ok (void);
303 void BlockRtsing (void);
304
310
313
314protected:
315 void DoDispose ();
316
317}; // class UanMacRc
318
319} // namespace ns3
320
321#endif /* UAN_MAC_RC_H */
a polymophic address class
Definition: address.h:91
Callback template class.
Definition: callback.h:1279
An identifier for simulation events.
Definition: event-id.h:54
A class used for addressing MAC8 MAC's.
Definition: mac8-address.h:43
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
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Cycle broadcast information.
Virtual base class for all UAN MAC protocols.
Definition: uan-mac.h:50
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
State
MAC state.
Definition: uan-mac-rc.h:203
@ 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(* QueueTracedCallback)(Ptr< const Packet > packet, uint32_t proto)
TracedCallback signature for dequeue of a packet.
Definition: uan-mac-rc.h:199
void AssociateTimeout(void)
Periodically retry association.
Definition: uan-mac-rc.cc:644
void RtsTimeout(void)
Retry RTS.
Definition: uan-mac-rc.cc:732
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:42
Every class exported by the ns3 library is enclosed in the ns3 namespace.
phy
Definition: third.py:84
#define list