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_ALOHA_H 22 #define UAN_MAC_ALOHA_H 23 24 #include "uan-mac.h" 25 #include "ns3/mac8-address.h" 26 27 namespace ns3 28 { 29 30 31 class UanPhy; 32 class UanTxMode; 33 34 /** 35 * \ingroup uan 36 * 37 * ALOHA MAC Protocol, the simplest MAC protocol for wireless networks. 38 * 39 * Packets enqueued are immediately transmitted. This MAC attaches 40 * a UanHeaderCommon to outgoing packets for address information. 41 * (The type field is not used) 42 */ 43 class UanMacAloha : public UanMac 44 { 45 public: 46 /** Default constructor */ 47 UanMacAloha (); 48 /** Dummy destructor, see DoDispose. */ 49 virtual ~UanMacAloha (); 50 /** 51 * Register this type. 52 * \return The TypeId. 53 */ 54 static TypeId GetTypeId (void); 55 56 57 // Inherited methods 58 virtual bool Enqueue (Ptr<Packet> pkt, uint16_t protocolNumber, const Address &dest); 59 virtual void SetForwardUpCb (Callback<void, Ptr<Packet>, uint16_t, const Mac8Address&> cb); 60 virtual void AttachPhy (Ptr<UanPhy> phy); 61 virtual void Clear (void); 62 int64_t AssignStreams (int64_t stream); 63 64 private: 65 /** PHY layer attached to this MAC. */ 66 Ptr<UanPhy> m_phy; 67 /** Forwarding up callback. */ 68 Callback<void, Ptr<Packet>, uint16_t, const Mac8Address& > m_forUpCb; 69 /** Flag when we've been cleared. */ 70 bool m_cleared; 71 72 /** 73 * Receive packet from lower layer (passed to PHY as callback). 74 * 75 * \param pkt Packet being received. 76 * \param sinr SINR of received packet. 77 * \param txMode Mode of received packet. 78 */ 79 void RxPacketGood (Ptr<Packet> pkt, double sinr, UanTxMode txMode); 80 81 /** 82 * Packet received at lower layer in error. 83 * 84 * \param pkt Packet received in error. 85 * \param sinr SINR of received packet. 86 */ 87 void RxPacketError (Ptr<Packet> pkt, double sinr); 88 protected: 89 virtual void DoDispose (); 90 91 }; // class UanMacAloha 92 93 } // namespace ns3 94 95 #endif /* UAN_MAC_ALOHA_H */ 96