A Discrete-Event Network Simulator
API
uan-mac-rc-gw.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_GW_H
22 #define UAN_MAC_RC_GW_H
23 
24 #include "uan-mac.h"
25 #include "ns3/mac8-address.h"
26 
27 #include "ns3/nstime.h"
28 #include "ns3/traced-callback.h"
29 
30 
31 
32 
33 #include <set>
34 #include <map>
35 
36 namespace ns3 {
37 
38 class UanTxMode;
39 
57 class UanMacRcGw : public UanMac
58 {
59 public:
60  UanMacRcGw ();
61  virtual ~UanMacRcGw ();
62 
67  static TypeId GetTypeId (void);
68 
69  // Inherited methods
70  virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest);
71  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const Mac8Address&> cb);
72  virtual void AttachPhy (Ptr<UanPhy> phy);
73  virtual void Clear (void);
74  int64_t AssignStreams (int64_t stream);
75 
88  typedef void (* CycleCallback)
89  (Time now, Time delay, uint32_t numRts, uint32_t totalBytes,
90  double secs, uint32_t ctlRate, double actualX);
91 
92 
93 private:
95  enum State {
96  IDLE,
98  CTSING
99  };
101 
106  struct Request
107  {
108  uint8_t numFrames;
109  uint8_t frameNo;
110  uint8_t retryNo;
111  uint16_t length;
113  };
114 
119  struct AckData
120  {
121  uint8_t frameNo;
122  std::set<uint8_t> rxFrames;
123  uint8_t expFrames;
124  };
127 
131  uint32_t m_maxRes;
132  uint32_t m_numRates;
133  uint32_t m_rtsSize;
134  uint32_t m_ctsSizeN;
135  uint32_t m_ctsSizeG;
136  uint32_t m_ackSize;
138  uint32_t m_currentRateNum;
139  uint32_t m_numNodes;
140  uint32_t m_totalRate;
141  uint32_t m_rateStep;
142  uint32_t m_frameSize;
143 
144  double m_minRetryRate;
145  double m_retryStep;
146 
148  std::map<Mac8Address, Time> m_propDelay;
149 
151  std::map<Mac8Address, AckData> m_ackData;
152 
154  std::map<Mac8Address, Request> m_requests;
156  std::set<std::pair<Time, Mac8Address> > m_sortedRes;
157 
159  bool m_cleared;
160 
163 
177 
185  void ReceivePacket (Ptr<Packet> pkt, double sinr, UanTxMode mode);
186 
188  void StartCycle (void);
190  void EndCycle (void);
197  void SendPacket (Ptr<Packet> pkt, uint32_t rate);
199  void CycleStarted (void);
206  void ReceiveError (Ptr<Packet> pkt, double sinr);
207 
208  // Stuff for computing exp throughput
219  double ComputeAlpha (uint32_t totalFrames, uint32_t totalBytes, uint32_t n, uint32_t a, double deltaK);
225  std::vector<double> GetExpPdk (void);
235  double ComputeExpS (uint32_t a, uint32_t ld, std::vector<double> exppdk);
243  double ComputeExpS (uint32_t a, uint32_t ld);
251  uint32_t CompExpMinIndex (uint32_t n, uint32_t k);
260  double ComputePiK (uint32_t a, uint32_t n, uint32_t k);
270  double ComputeExpBOverA (uint32_t n, uint32_t a, uint32_t ldlh, std::vector<double> deltaK);
278  uint64_t NchooseK (uint32_t n, uint32_t k);
284  uint32_t FindOptA (void);
285 protected:
286  virtual void DoDispose ();
287 
288 }; // class UanMacRcGw
289 
290 } // namespace ns3
291 
292 #endif /* UAN_MAC_RC_GW_H */
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
ns3::UanMacRcGw::AttachPhy
virtual void AttachPhy(Ptr< UanPhy > phy)
Attach PHY layer to this MAC.
Definition: uan-mac-rc-gw.cc:189
ns3::UanMacRcGw::m_rxLogger
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
A packet was destined for and received at this MAC layer.
Definition: uan-mac-rc-gw.h:162
ns3::UanMacRcGw::m_minRetryRate
double m_minRetryRate
Smallest allowed RTS retry rate.
Definition: uan-mac-rc-gw.h:144
ns3::UanMacRcGw::Request
Reservation request.
Definition: uan-mac-rc-gw.h:107
ns3::Mac8Address
A class used for addressing MAC8 MAC's.
Definition: mac8-address.h:43
ns3::UanMacRcGw::AckData::rxFrames
std::set< uint8_t > rxFrames
Received frames.
Definition: uan-mac-rc-gw.h:122
ns3::UanMacRcGw::m_ctsSizeG
uint32_t m_ctsSizeG
Size of UanHeaderCommon and UanHeaderRcCtsGlobal.
Definition: uan-mac-rc-gw.h:135
ns3::Callback
Callback template class.
Definition: callback.h:1279
ns3::UanMacRcGw::m_sortedRes
std::set< std::pair< Time, Mac8Address > > m_sortedRes
Queued request times.
Definition: uan-mac-rc-gw.h:156
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::UanMacRcGw::State
State
Gateway state.
Definition: uan-mac-rc-gw.h:95
ns3::UanMacRcGw::AckData
Packet ACK data.
Definition: uan-mac-rc-gw.h:120
ns3::UanMacRcGw::Request::numFrames
uint8_t numFrames
Number of frames.
Definition: uan-mac-rc-gw.h:108
ns3::UanMacRcGw::m_rateStep
uint32_t m_rateStep
Increments available for rate assignment in bps.
Definition: uan-mac-rc-gw.h:141
ns3::UanMacRcGw::m_currentRateNum
uint32_t m_currentRateNum
Rate number corresponding to data rate of current cycle.
Definition: uan-mac-rc-gw.h:138
ns3::UanMacRcGw::CompExpMinIndex
uint32_t CompExpMinIndex(uint32_t n, uint32_t k)
Index to the k'th expected delay among n nodes.
Definition: uan-mac-rc-gw.cc:633
ns3::UanMacRcGw::ReceivePacket
void ReceivePacket(Ptr< Packet > pkt, double sinr, UanTxMode mode)
PHY receive ok callback.
Definition: uan-mac-rc-gw.cc:203
ns3::UanMacRcGw::IDLE
@ IDLE
Initial idle state.
Definition: uan-mac-rc-gw.h:96
ns3::UanMacRcGw::~UanMacRcGw
virtual ~UanMacRcGw()
Dummy destructor, see DoDispose.
Definition: uan-mac-rc-gw.cc:68
ns3::UanMacRcGw::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition: uan-mac-rc-gw.cc:97
ns3::UanMacRcGw::AssignStreams
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-gw.cc:719
ns3::UanMacRcGw::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: uan-mac-rc-gw.cc:103
ns3::UanMacRcGw::SetForwardUpCb
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-gw.cc:183
ns3::UanMacRcGw::m_cycleLogger
TracedCallback< Time, Time, uint32_t, uint32_t, double, uint32_t, double > m_cycleLogger
A packet was destined for and received at this MAC layer.
Definition: uan-mac-rc-gw.h:176
ns3::UanMacRcGw::NchooseK
uint64_t NchooseK(uint32_t n, uint32_t k)
Binomial coefficient.
Definition: uan-mac-rc-gw.cc:672
ns3::UanMacRcGw::CycleStarted
void CycleStarted(void)
Set state to INCYCLE.
Definition: uan-mac-rc-gw.cc:456
ns3::UanMacRcGw::SendPacket
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
Send packet on PHY.
Definition: uan-mac-rc-gw.cc:507
ns3::Ptr< Packet >
ns3::UanMacRcGw::m_ackSize
uint32_t m_ackSize
Size of UanHeaderCommon and UanHeaderRcAck.
Definition: uan-mac-rc-gw.h:136
ns3::UanMacRcGw::Request::frameNo
uint8_t frameNo
Current frame number.
Definition: uan-mac-rc-gw.h:109
ns3::UanMacRcGw::m_phy
Ptr< UanPhy > m_phy
PHY layer attached to this MAC.
Definition: uan-mac-rc-gw.h:128
bianchi11ax.k
int k
Definition: bianchi11ax.py:129
ns3::Address
a polymophic address class
Definition: address.h:91
uan-mac.h
ns3::UanMacRcGw
Gateway side of RC-MAC.
Definition: uan-mac-rc-gw.h:58
ns3::UanMacRcGw::INCYCLE
@ INCYCLE
Cycling through nodes.
Definition: uan-mac-rc-gw.h:97
ns3::UanMacRcGw::Request::rxTime
Time rxTime
Time request received.
Definition: uan-mac-rc-gw.h:112
ns3::UanMacRcGw::FindOptA
uint32_t FindOptA(void)
Compute the optimum maximum number of reservations to accept per cycle.
Definition: uan-mac-rc-gw.cc:695
ns3::UanMacRcGw::m_state
State m_state
Gateway processing state.
Definition: uan-mac-rc-gw.h:100
ns3::UanMacRcGw::CycleCallback
void(* CycleCallback)(Time now, Time delay, uint32_t numRts, uint32_t totalBytes, double secs, uint32_t ctlRate, double actualX)
TracedCallback signature for.
Definition: uan-mac-rc-gw.h:89
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::UanMacRcGw::m_cleared
bool m_cleared
Flag when we've been cleared.
Definition: uan-mac-rc-gw.h:159
ns3::UanMacRcGw::m_totalRate
uint32_t m_totalRate
Total available channel rate in bps (for a single channel, without splitting reservation channel).
Definition: uan-mac-rc-gw.h:140
ns3::UanMacRcGw::Enqueue
virtual bool Enqueue(Ptr< Packet > pkt, uint16_t protocolNumber, const Address &dest)
Enqueue packet to be transmitted.
Definition: uan-mac-rc-gw.cc:174
ns3::UanTxMode
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:42
ns3::UanMacRcGw::m_numRates
uint32_t m_numRates
Number of rates per Phy layer.
Definition: uan-mac-rc-gw.h:132
ns3::UanMacRcGw::GetExpPdk
std::vector< double > GetExpPdk(void)
Get the expected propagation delay to each node.
Definition: uan-mac-rc-gw.cc:570
ns3::UanMacRcGw::m_numNodes
uint32_t m_numNodes
Number of non-gateway nodes in this gateway's neighborhood.
Definition: uan-mac-rc-gw.h:139
ns3::UanMacRcGw::m_maxDelta
Time m_maxDelta
Maximum propagation delay between gateway and non-gateway nodes .
Definition: uan-mac-rc-gw.h:129
ns3::UanMacRcGw::m_rtsSize
uint32_t m_rtsSize
Size of UanHeaderCommon and UanHeaderRcRts.
Definition: uan-mac-rc-gw.h:133
ns3::UanMacRcGw::EndCycle
void EndCycle(void)
End cycle by scheduling pending ACKs.
Definition: uan-mac-rc-gw.cc:461
ns3::UanMacRcGw::m_requests
std::map< Mac8Address, Request > m_requests
Request for each node.
Definition: uan-mac-rc-gw.h:154
ns3::UanMacRcGw::m_frameSize
uint32_t m_frameSize
Size of data frames in bytes.
Definition: uan-mac-rc-gw.h:142
ns3::UanMacRcGw::ComputeExpBOverA
double ComputeExpBOverA(uint32_t n, uint32_t a, uint32_t ldlh, std::vector< double > deltaK)
Numeric function.
Definition: uan-mac-rc-gw.cc:653
ns3::UanMacRcGw::m_propDelay
std::map< Mac8Address, Time > m_propDelay
Propagation delay to each node.
Definition: uan-mac-rc-gw.h:148
ns3::UanMacRcGw::CTSING
@ CTSING
Sending CTS.
Definition: uan-mac-rc-gw.h:98
ns3::UanMacRcGw::Request::length
uint16_t length
Request header length.
Definition: uan-mac-rc-gw.h:111
ns3::UanMacRcGw::ComputeAlpha
double ComputeAlpha(uint32_t totalFrames, uint32_t totalBytes, uint32_t n, uint32_t a, double deltaK)
Compute alpha parameter.
Definition: uan-mac-rc-gw.cc:539
ns3::UanMac
Virtual base class for all UAN MAC protocols.
Definition: uan-mac.h:50
ns3::UanMacRcGw::UanMacRcGw
UanMacRcGw()
Constructor.
Definition: uan-mac-rc-gw.cc:48
ns3::UanMacRcGw::m_forwardUpCb
Callback< void, Ptr< Packet >, uint16_t, const Mac8Address & > m_forwardUpCb
Forwarding up callback.
Definition: uan-mac-rc-gw.h:126
ns3::UanMacRcGw::AckData::expFrames
uint8_t expFrames
Expected number of frames.
Definition: uan-mac-rc-gw.h:123
ns3::UanMacRcGw::StartCycle
void StartCycle(void)
Cycle through pending requests.
Definition: uan-mac-rc-gw.cc:288
ns3::UanMacRcGw::ComputeExpS
double ComputeExpS(uint32_t a, uint32_t ld, std::vector< double > exppdk)
Throughput for a reservations with framesize ld, given expected delays exppdk.
Definition: uan-mac-rc-gw.cc:598
ns3::UanMacRcGw::m_ctsSizeN
uint32_t m_ctsSizeN
Size of UanHeaderRcCts.
Definition: uan-mac-rc-gw.h:134
ns3::UanMacRcGw::ComputePiK
double ComputePiK(uint32_t a, uint32_t n, uint32_t k)
Numeric function.
Definition: uan-mac-rc-gw.cc:646
ns3::TracedCallback
Forward calls to a chain of Callback.
Definition: traced-callback.h:53
ns3::UanMacRcGw::AckData::frameNo
uint8_t frameNo
Frame number being ACK'ed.
Definition: uan-mac-rc-gw.h:121
ns3::UanMacRcGw::ReceiveError
void ReceiveError(Ptr< Packet > pkt, double sinr)
PHY receive error callback.
Definition: uan-mac-rc-gw.cc:197
ns3::UanMacRcGw::m_sifs
Time m_sifs
Spacing between frames to account for timing error and processing delay.
Definition: uan-mac-rc-gw.h:130
ns3::UanMacRcGw::m_ackData
std::map< Mac8Address, AckData > m_ackData
AckData for each node.
Definition: uan-mac-rc-gw.h:151
ns3::UanMacRcGw::m_currentRetryRate
uint16_t m_currentRetryRate
Retry rate number for current cycle.
Definition: uan-mac-rc-gw.h:137
ns3::UanMacRcGw::m_maxRes
uint32_t m_maxRes
Maximum number of reservations to accept per cycle.
Definition: uan-mac-rc-gw.h:131
sample-rng-plot.n
n
Definition: sample-rng-plot.py:37
third.phy
phy
Definition: third.py:93
ns3::UanMacRcGw::Clear
virtual void Clear(void)
Clears all pointer references.
Definition: uan-mac-rc-gw.cc:73
ns3::UanMacRcGw::m_retryStep
double m_retryStep
Retry rate increment.
Definition: uan-mac-rc-gw.h:145
ns3::UanMacRcGw::Request::retryNo
uint8_t retryNo
Retry number.
Definition: uan-mac-rc-gw.h:110