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 LORA_MAC_HELPER_H |
| 22 #define LORA_MAC_HELPER_H |
| 23 |
| 24 #include "ns3/net-device.h" |
| 25 #include "ns3/lora-channel.h" |
| 26 #include "ns3/lora-phy.h" |
| 27 #include "ns3/lora-mac.h" |
| 28 #include "ns3/lora-device-address-generator.h" |
| 29 #include "ns3/end-device-lora-mac.h" |
| 30 #include "ns3/gateway-lora-mac.h" |
| 31 #include "ns3/node-container.h" |
| 32 |
| 33 namespace ns3 { |
| 34 |
| 35 class LoraMacHelper |
| 36 { |
| 37 public: |
| 38 |
| 39 /** |
| 40 * Define the kind of device. Can be either GW (Gateway) or ED (End Device). |
| 41 */ |
| 42 enum DeviceType |
| 43 { |
| 44 GW, |
| 45 ED |
| 46 }; |
| 47 |
| 48 /** |
| 49 * Define the operational region. |
| 50 */ |
| 51 enum Regions |
| 52 { |
| 53 EU, |
| 54 US, |
| 55 China, |
| 56 EU433MHz, |
| 57 Australia, |
| 58 CN, |
| 59 AS923MHz, |
| 60 SouthKorea |
| 61 }; |
| 62 |
| 63 /** |
| 64 * Create a mac helper without any parameter set. The user must set |
| 65 * them all to be able to call Install later. |
| 66 */ |
| 67 LoraMacHelper (); |
| 68 |
| 69 /** |
| 70 * Set an attribute of the underlying MAC object. |
| 71 * |
| 72 * \param name the name of the attribute to set. |
| 73 * \param v the value of the attribute. |
| 74 */ |
| 75 void Set (std::string name, const AttributeValue &v); |
| 76 |
| 77 /** |
| 78 * Set the address generator to use for creation of these nodes. |
| 79 */ |
| 80 void SetAddressGenerator (Ptr<LoraDeviceAddressGenerator> addrGen); |
| 81 |
| 82 /** |
| 83 * Set the kind of MAC this helper will create. |
| 84 * |
| 85 * \param dt the device type (either gateway or end device). |
| 86 */ |
| 87 void SetDeviceType (enum DeviceType dt); |
| 88 |
| 89 /** |
| 90 * Set the region in which the device is to operate. |
| 91 */ |
| 92 void SetRegion (enum Regions region); |
| 93 |
| 94 /** |
| 95 * Create the LoRaMac instance and connect it to a device |
| 96 * |
| 97 * \param node the node on which we wish to create a wifi MAC. |
| 98 * \param device the device within which this MAC will be created. |
| 99 * \returns a newly-created LoraMac object. |
| 100 */ |
| 101 Ptr<LoraMac> Create (Ptr<Node> node, Ptr<NetDevice> device) const; |
| 102 |
| 103 /** |
| 104 * Set up the end device's data rates |
| 105 * This function assumes we are using the following convention: |
| 106 * SF7 -> DR5 |
| 107 * SF8 -> DR4 |
| 108 * SF9 -> DR3 |
| 109 * SF10 -> DR2 |
| 110 * SF11 -> DR1 |
| 111 * SF12 -> DR0 |
| 112 */ |
| 113 static void SetSpreadingFactorsUp (NodeContainer endDevices, |
| 114 NodeContainer gateways, |
| 115 Ptr<LoraChannel> channel); |
| 116 |
| 117 private: |
| 118 |
| 119 /** |
| 120 * Perform region-specific configurations for the 868 MHz EU band. |
| 121 */ |
| 122 void ConfigureForEuRegion (Ptr<EndDeviceLoraMac> edMac) const; |
| 123 |
| 124 /** |
| 125 * Perform region-specific configurations for the 868 MHz EU band. |
| 126 */ |
| 127 void ConfigureForEuRegion (Ptr<GatewayLoraMac> gwMac) const; |
| 128 |
| 129 /** |
| 130 * Apply configurations that are common both for the GatewayLoraMac and the |
| 131 * EndDeviceLoraMac classes. |
| 132 */ |
| 133 void ApplyCommonEuConfigurations (Ptr<LoraMac> loraMac) const; |
| 134 |
| 135 ObjectFactory m_mac; |
| 136 Ptr<LoraDeviceAddressGenerator> m_addrGen; //!< Pointer to the address generat
or to use |
| 137 enum DeviceType m_deviceType; //!< The kind of device to install |
| 138 enum Regions m_region; //!< The region in which the device will operate |
| 139 }; |
| 140 |
| 141 } //namespace ns3 |
| 142 |
| 143 #endif /* LORA_PHY_HELPER_H */ |
OLD | NEW |