A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
uan-mac-cw.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_CW_H
22 #define UAN_MAC_CW_H
23 
24 #include "ns3/uan-mac.h"
25 #include "ns3/nstime.h"
26 #include "ns3/simulator.h"
27 #include "ns3/uan-phy.h"
28 #include "ns3/uan-tx-mode.h"
29 #include "ns3/uan-address.h"
30 #include "ns3/random-variable-stream.h"
31 
32 namespace ns3 {
33 
43 class UanMacCw : public UanMac,
44  public UanPhyListener
45 {
46 public:
47  UanMacCw ();
48  virtual ~UanMacCw ();
49  static TypeId GetTypeId (void);
50 
54  virtual void SetCw (uint32_t cw);
58  virtual void SetSlotTime (Time duration);
62  virtual uint32_t GetCw (void);
66  virtual Time GetSlotTime (void);
67 
68  // Inherited methods
69  virtual Address GetAddress ();
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 
77  // PHY listeners
79  virtual void NotifyRxStart (void);
81  virtual void NotifyRxEndOk (void);
83  virtual void NotifyRxEndError (void);
85  virtual void NotifyCcaStart (void);
87  virtual void NotifyCcaEnd (void);
89  virtual void NotifyTxStart (Time duration);
90 
99  int64_t AssignStreams (int64_t stream);
100 
101 private:
102  typedef enum {
104  } State;
105 
112 
113  // Mac parameters
114  uint32_t m_cw;
116 
117  // State variables
121  uint16_t m_pktTxProt;
125 
126  bool m_cleared;
127 
130 
131  void PhyRxPacketGood (Ptr<Packet> packet, double sinr, UanTxMode mode);
132  void PhyRxPacketError (Ptr<Packet> packet, double sinr);
133  void SaveTimer (void);
134  void StartTimer (void);
135  void SendPacket (void);
136  void EndTx (void);
137 protected:
138  virtual void DoDispose ();
139 };
140 
141 }
142 
143 #endif /* UAN_MAC_CW_H */
CW-MAC A MAC protocol similar in idea to the 802.11 DCF with constant backoff window.
Definition: uan-mac-cw.h:43
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
virtual Address GetAddress()
Definition: uan-mac-cw.cc:107
Callback template class.
Definition: callback.h:920
void SendPacket(void)
Definition: uan-mac-cw.cc:383
uint16_t m_pktTxProt
Definition: uan-mac-cw.h:121
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
static TypeId GetTypeId(void)
Definition: uan-mac-cw.cc:77
virtual void SetSlotTime(Time duration)
Definition: uan-mac-cw.cc:325
virtual void AttachPhy(Ptr< UanPhy > phy)
Definition: uan-mac-cw.cc:193
TracedCallback< Ptr< const Packet >, uint16_t > m_enqueueLogger
Definition: uan-mac-cw.h:110
virtual void Clear(void)
Definition: uan-mac-cw.cc:52
virtual Address GetBroadcast(void) const
Definition: uan-mac-cw.cc:202
Time m_savedDelayS
Definition: uan-mac-cw.h:119
virtual void NotifyRxEndError(void)
Function called by UanPhy object to notify of packet received in error.
Definition: uan-mac-cw.cc:233
a polymophic address class
Definition: address.h:86
virtual void SetAddress(UanAddress addr)
Definition: uan-mac-cw.cc:113
virtual bool Enqueue(Ptr< Packet > pkt, const Address &dest, uint16_t protocolNumber)
Definition: uan-mac-cw.cc:119
Virtual base class for all UAN MAC protocols.
Definition: uan-mac.h:47
TracedCallback< Ptr< const Packet >, UanTxMode > m_rxLogger
Definition: uan-mac-cw.h:109
virtual void SetCw(uint32_t cw)
Definition: uan-mac-cw.cc:320
virtual void NotifyRxStart(void)
Function called by UanPhy object to notify of packet reception.
Definition: uan-mac-cw.cc:209
void EndTx(void)
Definition: uan-mac-cw.cc:298
Abstraction of packet modulation information.
Definition: uan-tx-mode.h:36
Ptr< UniformRandomVariable > m_rv
Provides uniform random variables.
Definition: uan-mac-cw.h:129
Callback< void, Ptr< Packet >, const UanAddress & > m_forwardUpCb
Definition: uan-mac-cw.h:106
virtual void NotifyRxEndOk(void)
Function called by UanPhy object to notify of packet received successfully.
Definition: uan-mac-cw.cc:221
void SaveTimer(void)
Definition: uan-mac-cw.cc:356
virtual ~UanMacCw()
Definition: uan-mac-cw.cc:47
virtual void NotifyCcaStart(void)
Function called by UanPhy object to notify of channel sensed busy.
Definition: uan-mac-cw.cc:245
Interface for PHY event listener A class which implements this interface may register with Phy object...
Definition: uan-phy.h:128
virtual Time GetSlotTime(void)
Definition: uan-mac-cw.cc:335
virtual void NotifyTxStart(Time duration)
Function called by UanPhy object to notify of outgoing transmission start.
Definition: uan-mac-cw.cc:269
virtual void DoDispose()
Definition: uan-mac-cw.cc:70
EventId m_sendEvent
Definition: uan-mac-cw.h:122
EventId m_txEndEvent
Definition: uan-mac-cw.h:123
virtual uint32_t GetCw(void)
Definition: uan-mac-cw.cc:330
Ptr< UanPhy > m_phy
Definition: uan-mac-cw.h:108
an identifier for simulation events.
Definition: event-id.h:46
int64_t AssignStreams(int64_t stream)
Definition: uan-mac-cw.cc:290
virtual void SetForwardUpCb(Callback< void, Ptr< Packet >, const UanAddress & > cb)
Definition: uan-mac-cw.cc:187
void PhyRxPacketGood(Ptr< Packet > packet, double sinr, UanTxMode mode)
Definition: uan-mac-cw.cc:340
Ptr< Packet > m_pktTx
Definition: uan-mac-cw.h:120
UanAddress m_address
Definition: uan-mac-cw.h:107
void StartTimer(void)
Definition: uan-mac-cw.cc:367
TracedCallback< Ptr< const Packet >, uint16_t > m_dequeueLogger
Definition: uan-mac-cw.h:111
void PhyRxPacketError(Ptr< Packet > packet, double sinr)
Definition: uan-mac-cw.cc:351
a unique identifier for an interface.
Definition: type-id.h:49
uint32_t m_cw
Definition: uan-mac-cw.h:114
virtual void NotifyCcaEnd(void)
Function called by UanPhy object to notify of channel no longer sensed busy.
Definition: uan-mac-cw.cc:257