A Discrete-Event Network Simulator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
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  */
21 #ifndef UAN_MAC_RC_GW_H
22 #define UAN_MAC_RC_GW_H
24 #include "uan-mac.h"
25 #include "uan-address.h"
27 #include "ns3/nstime.h"
28 #include "ns3/traced-callback.h"
33 #include <set>
34 #include <map>
36 namespace ns3 {
38 class UanTxMode;
57 class UanMacRcGw : public UanMac
58 {
59 public:
60  UanMacRcGw ();
61  virtual ~UanMacRcGw ();
67  static TypeId GetTypeId (void);
69  // Inherited methods
70  virtual Address GetAddress (void);
71  virtual void SetAddress (UanAddress addr);
72  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
73  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
74  virtual void AttachPhy (Ptr<UanPhy> phy);
75  virtual Address GetBroadcast (void) const;
76  virtual void Clear (void);
77  int64_t AssignStreams (int64_t stream);
79 private:
81  enum State {
82  IDLE,
85  };
92  struct Request
93  {
94  uint8_t numFrames;
95  uint8_t frameNo;
96  uint8_t retryNo;
97  uint16_t length;
99  };
105  struct AckData
106  {
107  uint8_t frameNo;
108  std::set<uint8_t> rxFrames;
109  uint8_t expFrames;
110  };
118  uint32_t m_maxRes;
119  uint32_t m_numRates;
120  uint32_t m_rtsSize;
121  uint32_t m_ctsSizeN;
122  uint32_t m_ctsSizeG;
123  uint32_t m_ackSize;
125  uint32_t m_currentRateNum;
126  uint32_t m_numNodes;
127  uint32_t m_totalRate;
128  uint32_t m_rateStep;
129  uint32_t m_frameSize;
131  double m_minRetryRate;
132  double m_retryStep;
135  std::map<UanAddress, Time> m_propDelay;
138  std::map<UanAddress, AckData> m_ackData;
141  std::map<UanAddress, Request> m_requests;
143  std::set<std::pair<Time, UanAddress> > m_sortedRes;
146  bool m_cleared;
172  void ReceivePacket (Ptr<Packet> pkt, double sinr, UanTxMode mode);
175  void StartCycle (void);
177  void EndCycle (void);
184  void SendPacket (Ptr<Packet> pkt, uint32_t rate);
186  void CycleStarted (void);
193  void ReceiveError (Ptr<Packet> pkt, double sinr);
195  // Stuff for computing exp throughput
206  double ComputeAlpha (uint32_t totalFrames, uint32_t totalBytes, uint32_t n, uint32_t a, double deltaK);
212  std::vector<double> GetExpPdk (void);
222  double ComputeExpS (uint32_t a, uint32_t ld, std::vector<double> exppdk);
230  double ComputeExpS (uint32_t a, uint32_t ld);
238  uint32_t CompExpMinIndex (uint32_t n, uint32_t k);
247  double ComputePiK (uint32_t a, uint32_t n, uint32_t k);
257  double ComputeExpBOverA (uint32_t n, uint32_t a, uint32_t ldlh, std::vector<double> deltaK);
265  uint64_t NchooseK (uint32_t n, uint32_t k);
271  uint32_t FindOptA (void);
272 protected:
273  virtual void DoDispose ();
275 }; // class UanMacRcGw
277 } // namespace ns3
279 #endif /* UAN_MAC_RC_GW_H */
std::set< std::pair< Time, UanAddress > > m_sortedRes
Queued request times.
double m_retryStep
Retry rate increment.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
virtual void AttachPhy(Ptr< UanPhy > phy)
Attach PHY layer to this MAC.
Time rxTime
Time request received.
Definition: uan-mac-rc-gw.h:98
uint32_t CompExpMinIndex(uint32_t n, uint32_t k)
Index to the k'th expected delay among n nodes.
Callback template class.
Definition: callback.h:924
TracedCallback< Time, Time, uint32_t, uint32_t, double, uint32_t, double > m_cycleLogger
A packet was destined for and received at this MAC layer.
uint32_t m_ctsSizeG
Size of UanHeaderCommon and UanHeaderRcCtsGlobal.
bool m_cleared
Flag when we've been cleared.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Gateway side of RC-MAC.
Definition: uan-mac-rc-gw.h:57
uint32_t m_numRates
Number of rates per Phy layer.
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
Time m_sifs
Spacing between frames to account for timing error and processing delay.
std::map< UanAddress, Time > m_propDelay
Propagation delay to each node.
uint16_t m_currentRetryRate
Retry rate number for current cycle.
double m_minRetryRate
Smallest allowed RTS retry rate.
virtual void Clear(void)
Clears all pointer references.
virtual Address GetBroadcast(void) const
Get the broadcast address.
State m_state
Gateway processing state.
Definition: uan-mac-rc-gw.h:86
Callback< void, Ptr< Packet >, const UanAddress & > m_forwardUpCb
Forwarding up callback.
virtual ~UanMacRcGw()
Dummy destructor, see DoDispose.
a polymophic address class
Definition: address.h:86
uint8_t numFrames
Number of frames.
Definition: uan-mac-rc-gw.h:94
Gateway state.
Definition: uan-mac-rc-gw.h:81
std::vector< double > GetExpPdk(void)
Get the expected propagation delay to each node.
void ReceiveError(Ptr< Packet > pkt, double sinr)
PHY receive error callback.
Time m_maxDelta
Maximum propagation delay between gateway and non-gateway nodes .
double ComputeExpS(uint32_t a, uint32_t ld, std::vector< double > exppdk)
Throughput for a reservations with framesize ld, given expected delays exppdk.
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
Send packet on PHY.
Virtual base class for all UAN MAC protocols.
Definition: uan-mac.h:47
virtual Address GetAddress(void)
Get the MAC Address.
uint64_t NchooseK(uint32_t n, uint32_t k)
Binomial coefficient.
A class used for addressing UAN MAC's.
Definition: uan-address.h:40
uint32_t m_numNodes
Number of non-gateway nodes in this gateway's neighborhood.
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:41
void ReceivePacket(Ptr< Packet > pkt, double sinr, UanTxMode mode)
PHY recieve ok callback.
uint8_t frameNo
Current frame number.
Definition: uan-mac-rc-gw.h:95
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
uint32_t m_rateStep
Increments available for rate assignment in bps.
virtual void SetAddress(UanAddress addr)
Set the address.
uint16_t length
Request header length.
Definition: uan-mac-rc-gw.h:97
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
A packet was destined for and received at this MAC layer.
uint32_t m_currentRateNum
Rate number corresponding to data rate of current cycle.
uint32_t FindOptA(void)
Compute the optimum maximum number of reservations to accept per cycle.
uint8_t expFrames
Expected number of frames.
uint32_t m_ctsSizeN
Size of UanHeaderRcCts.
static TypeId GetTypeId(void)
Register this type.
Reservation request.
Definition: uan-mac-rc-gw.h:92
Cycling through nodes.
Definition: uan-mac-rc-gw.h:83
uint8_t frameNo
Frame number being ACK'ed.
std::map< UanAddress, Request > m_requests
Request for each node.
Ptr< UanPhy > m_phy
PHY layer attached to this MAC.
uint32_t m_frameSize
Size of data frames in bytes.
uint32_t m_totalRate
Total available channel rate in bps (for a single channel, without splitting reservation channel)...
void StartCycle(void)
Cycle through pending requests.
uint32_t m_maxRes
Maximum number of reservations to accept per cycle.
void CycleStarted(void)
Set state to INCYCLE.
double ComputePiK(uint32_t a, uint32_t n, uint32_t k)
Numeric function.
uint32_t m_rtsSize
Size of UanHeaderCommon and UanHeaderRcRts.
void EndCycle(void)
End cycle by scheduling pending ACKs.
std::map< UanAddress, AckData > m_ackData
AckData for each node.
UanAddress m_address
The MAC address.
uint8_t retryNo
Retry number.
Definition: uan-mac-rc-gw.h:96
Initial idle state.
Definition: uan-mac-rc-gw.h:82
virtual bool Enqueue(Ptr< Packet > pkt, const Address &dest, uint16_t protocolNumber)
Enqueue packet to be transmitted.
double ComputeAlpha(uint32_t totalFrames, uint32_t totalBytes, uint32_t n, uint32_t a, double deltaK)
Compute alpha parameter.
std::set< uint8_t > rxFrames
Received frames.
Packet ACK data.
a unique identifier for an interface.
Definition: type-id.h:49
uint32_t m_ackSize
Size of UanHeaderCommon and UanHeaderRcAck.
double ComputeExpBOverA(uint32_t n, uint32_t a, uint32_t ldlh, std::vector< double > deltaK)
Numeric function.
virtual void SetForwardUpCb(Callback< void, Ptr< Packet >, const UanAddress & > cb)
Set the callback to forward packets up to higher layers.