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_H
22 #define UAN_MAC_H
23 
24 #include "ns3/address.h"
25 #include "ns3/object.h"
26 #include "ns3/packet.h"
27 
28 #include "ns3/address.h"
29 #include "ns3/nstime.h"
30 #include "ns3/ptr.h"
31 #include "ns3/mac8-address.h"
32 
33 namespace ns3 {
34 
35 class UanPhy;
36 class UanChannel;
37 class UanNetDevice;
38 class UanTransducer;
39 class UanTxMode;
40 class Mac8Address;
41 
42 
43 
44 /**
45  * \ingroup uan
46  *
47  * Virtual base class for all UAN MAC protocols.
48  */
49 class UanMac : public Object
50 {
51 public:
52   /** Default constructor */
53   UanMac ();
54   /**
55    * Register this type.
56    * \return The TypeId.
57    */
58    static TypeId GetTypeId (void);
59 
60   /**
61    * Get the MAC Address.
62    *
63    * \return MAC Address.
64    */
65   virtual Address GetAddress (void);
66 
67   /**
68    * Set the address.
69    *
70    * \param addr Mac8Address for this MAC.
71    */
72   virtual void SetAddress (Mac8Address addr);
73 
74   /**
75    * Enqueue packet to be transmitted.
76    *
77    * \param pkt Packet to be transmitted.
78    * \param dest Destination address.
79    * \param protocolNumber The type of the packet.
80    * \return True if packet was successfully enqueued.
81    */
82   virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest) = 0;
83   /**
84    * Set the callback to forward packets up to higher layers.
85    *
86    * \param cb The callback.
87    * \pname{packet} The packet.
88    * \pname{address} The source address.
89    */
90   virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const Mac8Address&> cb) = 0;
91 
92   /**
93    * Attach PHY layer to this MAC.
94    *
95    * Some MACs may be designed to work with multiple PHY
96    * layers.  Others may only work with one.
97    *
98    * \param phy Phy layer to attach to this MAC.
99    */
100   virtual void AttachPhy (Ptr<UanPhy> phy) = 0;
101 
102   /**
103    * Get the broadcast address.
104    *
105    * \return The broadcast address.
106    */
107   virtual Address GetBroadcast (void) const;
108 
109   /** Clears all pointer references. */
110   virtual void Clear (void) = 0;
111 
112  /**
113   * Assign a fixed random variable stream number to the random variables
114   * used by this model.  Return the number of streams (possibly zero) that
115   * have been assigned.
116   *
117   * \param stream First stream index to use.
118   * \return The number of stream indices assigned by this model.
119   */
120   virtual int64_t AssignStreams (int64_t stream) = 0;
121 
122   /**
123    *  TracedCallback signature for packet reception/enqueue/dequeue events.
124    *
125    * \param [in] packet The Packet.
126    * \param [in] mode The UanTxMode.
127    */
128   typedef void (* PacketModeTracedCallback)
129     (Ptr<const Packet> packet, UanTxMode mode);
130 
131   /**
132    * Get the Tx mode index (Modulation type).
133    * \return the Tx mode index
134    */
135   uint32_t GetTxModeIndex ();
136 
137   /**
138    * Set the Tx mode index (Modulation type).
139    * \param txModeIndex the Tx mode index
140    */
141   void SetTxModeIndex (uint32_t txModeIndex);
142 
143 private:
144   /** Modulation type */
145   uint32_t m_txModeIndex;
146   /** The MAC address. */
147   Mac8Address m_address;
148 
149 };  // class UanMac
150 
151 } // namespace ns3
152 
153 #endif /* UAN_MAC_H */
154