OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2011 The Boeing Company |
| 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: |
| 19 * Tom Henderson <thomas.r.henderson@boeing.com> |
| 20 * Tommaso Pecorella <tommaso.pecorella@unifi.it> |
| 21 * Margherita Filippetti <morag87@gmail.com> |
| 22 */ |
| 23 #ifndef LR_WPAN_TSCH_NET_DEVICE_H |
| 24 #define LR_WPAN_TSCH_NET_DEVICE_H |
| 25 |
| 26 #include <ns3/net-device.h> |
| 27 #include <ns3/traced-callback.h> |
| 28 #include <ns3/lr-wpan-tsch-mac.h> |
| 29 |
| 30 namespace ns3 { |
| 31 |
| 32 class LrWpanPhy; |
| 33 //class LrWpanCsmaCa; |
| 34 class SpectrumChannel; |
| 35 class Node; |
| 36 |
| 37 /** |
| 38 * \ingroup lr-wpan |
| 39 * |
| 40 * \brief Network layer to device interface. |
| 41 * |
| 42 * The ns3::NetDevice includes IP-specific API such as GetMulticast(), Send() |
| 43 * and SendTo() methods, which do not map well the the 802.15.4 MAC MCPS |
| 44 * DataRequest primitive. So, the basic design is to provide, as |
| 45 * much as makes sense, the class ns3::NetDevice API, but rely on the user |
| 46 * accessing the LrWpanMac pointer to make 802.15.4-specific API calls. |
| 47 * As such, this is really just an encapsulating class. |
| 48 */ |
| 49 class LrWpanTschNetDevice : public NetDevice |
| 50 { |
| 51 public: |
| 52 /** |
| 53 * Get the type ID. |
| 54 * |
| 55 * \return the object TypeId |
| 56 */ |
| 57 static TypeId GetTypeId (void); |
| 58 |
| 59 LrWpanTschNetDevice (void); |
| 60 virtual ~LrWpanTschNetDevice (void); |
| 61 |
| 62 /** |
| 63 * Set the MAC to be used by this NetDevice. |
| 64 * |
| 65 * \param mac the MAC to be used |
| 66 */ |
| 67 void SetMac (Ptr<LrWpanTschMac> mac); |
| 68 |
| 69 /** |
| 70 * Set the PHY to be used by the MAC and this NetDevice. |
| 71 * |
| 72 * \param phy the PHY to be used |
| 73 */ |
| 74 void SetPhy (Ptr<LrWpanPhy> phy); |
| 75 |
| 76 /** |
| 77 * Set the CSMA/CA implementation to be used by the MAC and this NetDevice. |
| 78 * |
| 79 * \param csmaca the CSMA/CA implementation to be used |
| 80 */ |
| 81 //void SetCsmaCa (Ptr<LrWpanCsmaCa> csmaca); |
| 82 |
| 83 /** |
| 84 * Set the channel to which the NetDevice, and therefore the PHY, should be |
| 85 * attached to. |
| 86 * |
| 87 * \param channel the channel to be used |
| 88 */ |
| 89 void SetChannel (Ptr<SpectrumChannel> channel); |
| 90 |
| 91 /** |
| 92 * Get the MAC used by this NetDevice. |
| 93 * |
| 94 * \return the MAC object |
| 95 */ |
| 96 Ptr<LrWpanTschMac> GetMac (void) const; |
| 97 |
| 98 /** |
| 99 * Get the PHY used by this NetDevice. |
| 100 * |
| 101 * \return the PHY object |
| 102 */ |
| 103 Ptr<LrWpanPhy> GetPhy (void) const; |
| 104 |
| 105 /** |
| 106 * Get the CSMA/CA implementation used by this NetDevice. |
| 107 * |
| 108 * \return the CSMA/CA implementation object |
| 109 */ |
| 110 //Ptr<LrWpanCsmaCa> GetCsmaCa (void) const; |
| 111 |
| 112 // From class NetDevice |
| 113 virtual void SetIfIndex (const uint32_t index); |
| 114 virtual uint32_t GetIfIndex (void) const; |
| 115 virtual Ptr<Channel> GetChannel (void) const; |
| 116 /** |
| 117 * This method indirects to LrWpanMac::SetShortAddress () |
| 118 */ |
| 119 virtual void SetAddress (Address address); |
| 120 /** |
| 121 * This method indirects to LrWpanMac::SetShortAddress () |
| 122 */ |
| 123 virtual Address GetAddress (void) const; |
| 124 virtual bool SetMtu (const uint16_t mtu); |
| 125 virtual uint16_t GetMtu (void) const; |
| 126 virtual bool IsLinkUp (void) const; |
| 127 virtual void AddLinkChangeCallback (Callback<void> callback); |
| 128 virtual bool IsBroadcast (void) const; |
| 129 virtual Address GetBroadcast (void) const; |
| 130 virtual bool IsMulticast (void) const; |
| 131 virtual Address GetMulticast (Ipv4Address multicastGroup) const; |
| 132 virtual Address GetMulticast (Ipv6Address addr) const; |
| 133 virtual bool IsBridge (void) const; |
| 134 virtual bool IsPointToPoint (void) const; |
| 135 virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolN
umber); |
| 136 virtual bool Send (Ptr<Packet> packet, const Address& dest, bool use_ack, uint
16_t protocolNumber); |
| 137 virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Addres
s& dest, uint16_t protocolNumber); |
| 138 virtual Ptr<Node> GetNode (void) const; |
| 139 virtual void SetNode (Ptr<Node> node); |
| 140 virtual bool NeedsArp (void) const; |
| 141 |
| 142 virtual void SetReceiveCallback (ReceiveCallback cb); |
| 143 virtual void SetPromiscReceiveCallback (PromiscReceiveCallback cb); |
| 144 virtual bool SupportsSendFrom (void) const; |
| 145 |
| 146 /** |
| 147 * The callback used by the MAC to hand over incoming packets to the |
| 148 * NetDevice. This callback will in turn use the ReceiveCallback set by |
| 149 * SetReceiveCallback() to notify upper layers. |
| 150 * |
| 151 * \param params 802.15.4 specific parameters, including source and destinatio
n addresses |
| 152 * \param pkt the packet do be delivered |
| 153 */ |
| 154 void McpsDataIndication (McpsDataIndicationParams params, Ptr<Packet> pkt); |
| 155 |
| 156 /** |
| 157 * Assign a fixed random variable stream number to the random variables |
| 158 * used by this model. Return the number of streams that have been assigned. |
| 159 * |
| 160 * \param stream first stream index to use |
| 161 * \return the number of stream indices assigned by this model |
| 162 */ |
| 163 int64_t AssignStreams (int64_t stream); |
| 164 |
| 165 /********************TSCH*************************/ |
| 166 /** |
| 167 * Show the setted slotframe status |
| 168 * \param TSCH MAC slotframe status |
| 169 */ |
| 170 void SlotframeConfirm (MlmeSetSlotframeConfirmParams params); |
| 171 |
| 172 /** |
| 173 * Show the setted link status |
| 174 * \param TSCH MAC link status |
| 175 */ |
| 176 void LinkConfirm (MlmeSetLinkConfirmParams params); |
| 177 |
| 178 /** |
| 179 * Show the setted TSCH mode status |
| 180 * \param TSCH mode status |
| 181 */ |
| 182 void ModeConfirm (MlmeTschModeConfirmParams params); |
| 183 |
| 184 private: |
| 185 // Inherited from NetDevice/Object |
| 186 virtual void DoDispose (void); |
| 187 virtual void DoInitialize (void); |
| 188 |
| 189 /** |
| 190 * Mark NetDevice link as up. |
| 191 */ |
| 192 void LinkUp (void); |
| 193 |
| 194 /** |
| 195 * Mark NetDevice link as down. |
| 196 */ |
| 197 void LinkDown (void); |
| 198 |
| 199 /** |
| 200 * Attribute accessor method for the "Channel" attribute. |
| 201 * |
| 202 * \return the channel to which this NetDevice is attached |
| 203 */ |
| 204 Ptr<SpectrumChannel> DoGetChannel (void) const; |
| 205 |
| 206 /** |
| 207 * Configure PHY, MAC and CSMA/CA. |
| 208 */ |
| 209 void CompleteConfig (void); |
| 210 |
| 211 /** |
| 212 * The MAC for this NetDevice. |
| 213 */ |
| 214 Ptr<LrWpanTschMac> m_mac; |
| 215 |
| 216 /** |
| 217 * The PHY for this NetDevice. |
| 218 */ |
| 219 Ptr<LrWpanPhy> m_phy; |
| 220 |
| 221 /** |
| 222 * The CSMA/CA implementation for this NetDevice. |
| 223 */ |
| 224 //Ptr<LrWpanCsmaCa> m_csmaca; |
| 225 |
| 226 /** |
| 227 * The node associated with this NetDevice. |
| 228 */ |
| 229 Ptr<Node> m_node; |
| 230 |
| 231 /** |
| 232 * True if MAC, PHY and CSMA/CA where successfully configured and the |
| 233 * NetDevice is ready for being used. |
| 234 */ |
| 235 bool m_configComplete; |
| 236 |
| 237 /** |
| 238 * Configure the NetDevice to request MAC layer acknowledgements when sending |
| 239 * packets using the Send() API. |
| 240 */ |
| 241 bool m_useAcks; |
| 242 |
| 243 /** |
| 244 * Is the link/device currently up and running? |
| 245 */ |
| 246 bool m_linkUp; |
| 247 |
| 248 /** |
| 249 * The interface index of this NetDevice. |
| 250 */ |
| 251 uint32_t m_ifIndex; |
| 252 |
| 253 /** |
| 254 * Trace source for link up/down changes. |
| 255 */ |
| 256 TracedCallback<> m_linkChanges; |
| 257 |
| 258 /** |
| 259 * Upper layer callback used for notification of new data packet arrivals. |
| 260 */ |
| 261 ReceiveCallback m_receiveCallback; |
| 262 }; |
| 263 |
| 264 } // namespace ns3 |
| 265 |
| 266 #endif /* LR_WPAN_NET_DEVICE_H */ |
OLD | NEW |