OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2017 University of Padova |
| 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: Davide Magrin <magrinda@dei.unipd.it> |
| 19 */ |
| 20 |
| 21 #ifndef GATEWAY_LORA_PHY_H |
| 22 #define GATEWAY_LORA_PHY_H |
| 23 |
| 24 #include "ns3/object.h" |
| 25 #include "ns3/net-device.h" |
| 26 #include "ns3/nstime.h" |
| 27 #include "ns3/mobility-model.h" |
| 28 #include "ns3/node.h" |
| 29 #include "ns3/lora-phy.h" |
| 30 #include "ns3/traced-value.h" |
| 31 #include <list> |
| 32 |
| 33 namespace ns3 { |
| 34 |
| 35 class LoraChannel; |
| 36 |
| 37 /** |
| 38 * Class modeling a Lora SX1301 chip. |
| 39 * |
| 40 * This class models the behaviour of the chip employed in Lora gateways. These |
| 41 * chips are characterized by the presence of 8 receive paths, or parallel |
| 42 * receivers, which can be employed to listen to different channels |
| 43 * simultaneously. This characteristic of the chip is modeled using the |
| 44 * ReceivePath class, which describes a single parallel receiver. GatewayLoraPhy |
| 45 * essentially holds and manages a collection of these objects. |
| 46 */ |
| 47 class GatewayLoraPhy : public LoraPhy |
| 48 { |
| 49 public: |
| 50 |
| 51 static TypeId GetTypeId (void); |
| 52 |
| 53 GatewayLoraPhy(); |
| 54 virtual ~GatewayLoraPhy(); |
| 55 |
| 56 virtual void StartReceive (Ptr<Packet> packet, double rxPowerDbm, uint8_t sf, |
| 57 Time duration, double frequencyMHz); |
| 58 |
| 59 virtual void EndReceive (Ptr<Packet> packet, |
| 60 Ptr<LoraInterferenceHelper::Event> event); |
| 61 |
| 62 virtual void Send (Ptr<Packet> packet, LoraTxParameters txParams, |
| 63 double frequencyMHz, double txPowerDbm); |
| 64 |
| 65 virtual void TxFinished (Ptr<Packet> packet); |
| 66 |
| 67 bool IsTransmitting (void); |
| 68 |
| 69 virtual bool IsOnFrequency (double frequencyMHz); |
| 70 |
| 71 /** |
| 72 * Add a reception path, locked on a specific frequency. |
| 73 * |
| 74 * \param frequencyMHz The frequency on which to set this ReceptionPath. |
| 75 */ |
| 76 void AddReceptionPath (double frequencyMHz); |
| 77 |
| 78 /** |
| 79 * Reset the list of reception paths. |
| 80 * |
| 81 * This method deletes all currently available ReceptionPath objects. |
| 82 */ |
| 83 void ResetReceptionPaths (void); |
| 84 |
| 85 /** |
| 86 * A vector containing the sensitivities required to correctly decode |
| 87 * different spreading factors. |
| 88 */ |
| 89 static const double sensitivity[6]; |
| 90 |
| 91 private: |
| 92 |
| 93 /** |
| 94 * This class represents a configurable reception path. |
| 95 * |
| 96 * ReceptionPaths are configured to listen on a certain frequency. Differently |
| 97 * from EndDeviceLoraPhys, these do not need to be configured to listen for a |
| 98 * certain SF. ReceptionPaths be either locked on an event or free. |
| 99 */ |
| 100 class ReceptionPath : public SimpleRefCount<GatewayLoraPhy::ReceptionPath> |
| 101 { |
| 102 |
| 103 public: |
| 104 |
| 105 /** |
| 106 * Constructor. |
| 107 * |
| 108 * \param frequencyMHz The frequency this path is set to listen on. |
| 109 */ |
| 110 ReceptionPath (double frequencyMHz); |
| 111 |
| 112 ~ReceptionPath(); |
| 113 |
| 114 /** |
| 115 * Getter for the operating frequency. |
| 116 * |
| 117 * \return The frequency this ReceivePath is configured to listen on. |
| 118 */ |
| 119 double GetFrequency (void); |
| 120 |
| 121 /** |
| 122 * Setter for the frequency. |
| 123 * |
| 124 * \param frequencyMHz The frequency [MHz] this ReceptionPath will listen on
. |
| 125 */ |
| 126 void SetFrequency (double frequencyMHz); |
| 127 |
| 128 /** |
| 129 * Query whether this reception path is available to lock on a signal. |
| 130 * |
| 131 * \return True if its current state is free, false if it's currently locked
. |
| 132 */ |
| 133 bool IsAvailable (void); |
| 134 |
| 135 /** |
| 136 * Set this reception path as available. |
| 137 * |
| 138 * This function sets the m_available variable as true, and deletes the |
| 139 * LoraInterferenceHelper Event this ReceivePath was previously locked on. |
| 140 */ |
| 141 void Free (void); |
| 142 |
| 143 /** |
| 144 * Set this reception path as not available and lock it on the |
| 145 * provided event. |
| 146 * |
| 147 * \param event The LoraInterferenceHelper Event to lock on. |
| 148 */ |
| 149 void LockOnEvent (Ptr<LoraInterferenceHelper::Event> event); |
| 150 |
| 151 /** |
| 152 * Set the event this reception path is currently on. |
| 153 * |
| 154 * \param event the event to lock this ReceptionPath on. |
| 155 */ |
| 156 void SetEvent (Ptr<LoraInterferenceHelper::Event> event); |
| 157 |
| 158 /** |
| 159 * Get the event this reception path is currently on. |
| 160 * |
| 161 * \returns 0 if no event is currently being received, a pointer to |
| 162 * the event otherwise. |
| 163 */ |
| 164 Ptr<LoraInterferenceHelper::Event> GetEvent (void); |
| 165 |
| 166 private: |
| 167 |
| 168 /** |
| 169 * The frequency this path is currently listening on, in MHz. |
| 170 */ |
| 171 double m_frequencyMHz; |
| 172 |
| 173 /** |
| 174 * Whether this reception path is available to lock on a signal or not. |
| 175 */ |
| 176 bool m_available; |
| 177 |
| 178 /** |
| 179 * The event this reception path is currently locked on. |
| 180 */ |
| 181 Ptr< LoraInterferenceHelper::Event > m_event; |
| 182 }; |
| 183 |
| 184 /** |
| 185 * A list containing the various parallel receivers that are managed by this |
| 186 * Gateway. |
| 187 */ |
| 188 std::list<Ptr<ReceptionPath> > m_receptionPaths; |
| 189 |
| 190 /** |
| 191 * The number of occupied reception paths. |
| 192 */ |
| 193 TracedValue<int> m_occupiedReceptionPaths; |
| 194 |
| 195 /** |
| 196 * Trace source that is fired when a packet cannot be received because all |
| 197 * available ReceivePath instances are busy. |
| 198 * |
| 199 * \see class CallBackTraceSource |
| 200 */ |
| 201 TracedCallback<Ptr<const Packet>, uint32_t> m_noMoreDemodulators; |
| 202 |
| 203 bool m_isTransmitting; //!< Flag indicating whether a transmission is going on |
| 204 }; |
| 205 |
| 206 } /* namespace ns3 */ |
| 207 |
| 208 #endif /* GATEWAY_LORA_PHY_H */ |
OLD | NEW |