A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "uan-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 
38 namespace ns3 {
39 
40 class Address;
41 class UanTxMode;
42 class UanHeaderRcRts;
43 class UanHeaderRcCts;
44 class UanHeaderRcCtsGlobal;
45 class UanPhy;
46 
47 
53 {
54 public:
58  Reservation ();
65  Reservation (std::list<std::pair <Ptr<Packet>, UanAddress > > &list, uint8_t frameNo, uint32_t maxPkts = 0);
66  ~Reservation ();
70  uint32_t GetNoFrames () const;
74  uint32_t GetLength () const;
78  const std::list<std::pair <Ptr<Packet>, UanAddress > > &GetPktList (void) const;
82  uint8_t GetFrameNo () const;
86  uint8_t GetRetryNo () const;
91  Time GetTimestamp (uint8_t n) const;
95  bool IsTransmitted () const;
99  void SetFrameNo (uint8_t fn);
103  void AddTimestamp (Time t);
107  void IncrementRetry ();
112  void SetTransmitted (bool t = true);
113 private:
114  std::list<std::pair <Ptr<Packet>, UanAddress > > m_pktList;
115  uint32_t m_length;
116  uint8_t m_frameNo;
117  std::vector<Time> m_timestamp;
118  uint8_t m_retryNo;
120 
121 };
122 
123 
137 class UanMacRc : public UanMac
138 {
139 public:
140  enum {
142  };
143  UanMacRc ();
144  virtual ~UanMacRc ();
145 
146  static TypeId GetTypeId (void);
147 
148  // Inherited virtual functions
149  virtual Address GetAddress (void);
150  virtual void SetAddress (UanAddress addr);
151  virtual bool Enqueue (Ptr<Packet> pkt, const Address &dest, uint16_t protocolNumber);
152  virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, const UanAddress&> cb);
153  virtual void AttachPhy (Ptr<UanPhy> phy);
154  virtual Address GetBroadcast (void) const;
155  virtual void Clear (void);
156 
165  int64_t AssignStreams (int64_t stream);
166 
167 private:
168  enum State {
170  };
171 
174 
177  double m_retryRate;
180  uint32_t m_numRates;
181  uint32_t m_currentRate;
182  uint32_t m_maxFrames;
183  uint32_t m_queueLimit;
184  uint8_t m_frameNo;
187 
188  uint16_t m_numRetryRates;
190  double m_retryStep;
191 
192  uint32_t m_ctsSizeN;
193  uint32_t m_ctsSizeG;
194 
195  bool m_cleared;
196 
197  std::list<std::pair <Ptr<Packet>, UanAddress > > m_pktQueue;
198  std::list<Reservation> m_resList;
199 
201 
205 
207  void ReceiveOkFromPhy (Ptr<Packet>, double sinr, UanTxMode mode);
208 
209  void Associate (void);
210  void AssociateTimeout (void);
211  void SendRts (void);
212  void RtsTimeout (void);
214  void ScheduleData (const UanHeaderRcCts &ctsh, const UanHeaderRcCtsGlobal &ctsg, uint32_t ctsBytes);
215  void ProcessAck (Ptr<Packet> ack);
216  void SendPacket (Ptr<Packet> pkt, uint32_t rate);
217  bool IsPhy1Ok (void);
218  void BlockRtsing (void);
219 
220  static uint32_t m_cntrlSends;
221 
224 
225 protected:
226  void DoDispose ();
227 };
228 
229 }
230 
231 #endif /* UAN_MAC_RC_H */