A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "uan-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 
60 class UanMacRcGw : public UanMac
61 {
62 public:
63  UanMacRcGw ();
64  virtual ~UanMacRcGw ();
65 
66  static TypeId GetTypeId (void);
67 
68  // Inherited virtual functions
69  virtual Address GetAddress (void);
70  virtual void SetAddress (UanAddress addr);
71  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
72  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
73  virtual void AttachPhy (Ptr<UanPhy> phy);
74  virtual Address GetBroadcast (void) const;
75  virtual void Clear (void);
76 
85  int64_t AssignStreams (int64_t stream);
86 
87 private:
88  enum State {
90  };
92 
93  struct Request
94  {
95  uint8_t numFrames;
96  uint8_t frameNo;
97  uint8_t retryNo;
98  uint16_t length;
100  };
101 
102  struct AckData
103  {
104  uint8_t frameNo;
105  std::set<uint8_t> rxFrames;
106  uint8_t expFrames;
107  };
113  uint32_t m_maxRes;
114  uint32_t m_numRates;
115  uint32_t m_rtsSize;
116  uint32_t m_ctsSizeN;
117  uint32_t m_ctsSizeG;
118  uint32_t m_ackSize;
121  uint32_t m_numNodes;
122  uint32_t m_totalRate;
123  uint32_t m_rateStep;
124  uint32_t m_frameSize;
125 
127  double m_retryStep;
128 
129  std::map<UanAddress, Time> m_propDelay;
130 
131  std::map<UanAddress, AckData> m_ackData;
132 
133 
134  std::map<UanAddress, Request> m_requests;
135  std::set<std::pair<Time, UanAddress> > m_sortedRes;
136 
137  bool m_cleared;
138 
140 
141  // Start time, min p-delay, reservations, frames, bytes, window size, ctl rate, retry rate
143 
144  void ReceivePacket (Ptr<Packet> pkt, double sinr, UanTxMode mode);
145  void StartCycle (void);
146  void EndCycle (void);
147  void SendPacket (Ptr<Packet> pkt, uint32_t rate);
148  void CycleStarted (void);
149  void ReceiveError (Ptr<Packet> pkt, double sinr);
150 
151  // Stuff for computing exp throughput
152  double ComputeAlpha (uint32_t totalFrames, uint32_t totalBytes, uint32_t n, uint32_t a, double deltaK);
153  std::vector<double> GetExpPdk (void);
154  double ComputeExpS (uint32_t a, uint32_t ld, std::vector<double> exppdk);
155  double ComputeExpS (uint32_t a, uint32_t ld);
156  uint32_t CompExpMinIndex (uint32_t n, uint32_t k);
157  double ComputePiK (uint32_t a, uint32_t n, uint32_t k);
158  double ComputeExpBOverA (uint32_t n, uint32_t a, uint32_t ldlh, std::vector<double> deltaK);
159  uint64_t NchooseK (uint32_t n, uint32_t k);
160  uint32_t FindOptA (void);
161 protected:
162  virtual void DoDispose ();
163 
164 };
165 
171 bool operator < (UanAddress &a, UanAddress &b);
172 
173 }
174 
175 #endif /* UAN_MAC_RC_GW_H */
std::set< std::pair< Time, UanAddress > > m_sortedRes
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
virtual void AttachPhy(Ptr< UanPhy > phy)
uint32_t CompExpMinIndex(uint32_t n, uint32_t k)
Callback template class.
Definition: callback.h:920
TracedCallback< Time, Time, uint32_t, uint32_t, double, uint32_t, double > m_cycleLogger
uint32_t m_ctsSizeG
int64_t AssignStreams(int64_t stream)
Gateway side of RC-MAC.
Definition: uan-mac-rc-gw.h:60
uint32_t m_numRates
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
std::map< UanAddress, Time > m_propDelay
uint16_t m_currentRetryRate
bool operator<(const Room &a, const Room &b)
virtual void Clear(void)
virtual Address GetBroadcast(void) const
Callback< void, Ptr< Packet >, const UanAddress & > m_forwardUpCb
virtual ~UanMacRcGw()
a polymophic address class
Definition: address.h:86
std::vector< double > GetExpPdk(void)
void ReceiveError(Ptr< Packet > pkt, double sinr)
double ComputeExpS(uint32_t a, uint32_t ld, std::vector< double > exppdk)
void SendPacket(Ptr< Packet > pkt, uint32_t rate)
Virtual base class for all UAN MAC protocols.
Definition: uan-mac.h:47
virtual Address GetAddress(void)
uint64_t NchooseK(uint32_t n, uint32_t k)
uint32_t m_numNodes
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:36
void ReceivePacket(Ptr< Packet > pkt, double sinr, UanTxMode mode)
virtual void DoDispose()
uint32_t m_rateStep
virtual void SetAddress(UanAddress addr)
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
uint32_t m_currentRateNum
uint32_t FindOptA(void)
uint32_t m_ctsSizeN
static TypeId GetTypeId(void)
std::map< UanAddress, Request > m_requests
Ptr< UanPhy > m_phy
uint32_t m_frameSize
uint32_t m_totalRate
void StartCycle(void)
void CycleStarted(void)
double ComputePiK(uint32_t a, uint32_t n, uint32_t k)
uint32_t m_rtsSize
void EndCycle(void)
std::map< UanAddress, AckData > m_ackData
UanAddress m_address
virtual bool Enqueue(Ptr< Packet > pkt, const Address &dest, uint16_t protocolNumber)
double ComputeAlpha(uint32_t totalFrames, uint32_t totalBytes, uint32_t n, uint32_t a, double deltaK)
std::set< uint8_t > rxFrames
a unique identifier for an interface.
Definition: type-id.h:49
uint32_t m_ackSize
double ComputeExpBOverA(uint32_t n, uint32_t a, uint32_t ldlh, std::vector< double > deltaK)
virtual void SetForwardUpCb(Callback< void, Ptr< Packet >, const UanAddress & > cb)