1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 2 /* 3 * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) 4 * Copyright (c) 2013 Budiarto Herman 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation; 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * 19 * Original work authors (from lte-enb-rrc.cc): 20 * - Nicola Baldo <nbaldo@cttc.es> 21 * - Marco Miozzo <mmiozzo@cttc.es> 22 * - Manuel Requena <manuel.requena@cttc.es> 23 * 24 * Converted to ANR interface by: 25 * - Budiarto Herman <budiarto.herman@magister.fi> 26 */ 27 28 #ifndef LTE_ANR_H 29 #define LTE_ANR_H 30 31 #include <ns3/object.h> 32 #include <ns3/lte-rrc-sap.h> 33 #include <ns3/lte-anr-sap.h> 34 #include <map> 35 36 namespace ns3 { 37 38 39 class LteAnrSapProvider; 40 class LteAnrSapUser; 41 class LteNeighbourRelation; 42 43 /** 44 * \brief Automatic Neighbour Relation function. 45 * 46 * ANR is a conceptually a list of neighbouring cells called the Neighbour 47 * Relation Table (NRT). ANR has the capability of automatically inserting new 48 * entries into NRT based on measurement reports obtained from the eNodeB RRC 49 * instance. Besides this, ANR also supports manual insertion and accepts 50 * queries for the NRT content. 51 * 52 * The LteHelper class automatically installs one ANR instance for each eNodeB 53 * RRC instance. When installed, ANR will assist the eNodeB RRC's handover 54 * function, e.g., by preventing an X2-based handover execution if there is no 55 * X2 interface to the target neighbour cell. If this is not desired, it can be 56 * disabled by the following code sample: 57 * 58 * Config::SetDefault ("ns3::LteHelper::AnrEnabled", BooleanValue (false)); 59 * Ptr<LteHelper> lteHelper = CreateObject<LteHelper> (); 60 * 61 * The communication between an ANR instance and the eNodeB RRC instance is done 62 * through the *ANR SAP* interface. The ANR instance corresponds to the 63 * "provider" part of this interface, while the eNodeB RRC instance takes the 64 * role of the "user" part. The following code skeleton establishes the 65 * connection between both instances: 66 * 67 * Ptr<LteEnbRrc> u = ...; 68 * Ptr<LteAnr> p = ...; 69 * u->SetLteAnrSapProvider (p->GetLteAnrSapProvider ()); 70 * p->SetLteAnrSapUser (u->GetLteAnrSapUser ()); 71 * 72 * However, user rarely needs to use the above code, since it has already been 73 * taken care by LteHelper::InstallEnbDevice. 74 * 75 * The current ANR model is inspired from Section 22.3.2a and 22.3.3 of 3GPP 76 * TS 36.300. 77 * 78 * \sa SetLteAnrSapProvider, SetLteAnrSapUser 79 */ 80 class LteAnr : public Object 81 { 82 public: 83 /** 84 * \brief Creates an ANR instance. 85 * \param servingCellId the cell ID of the eNodeB instance whom this ANR 86 * instance is to be associated with 87 */ 88 LteAnr (uint16_t servingCellId); 89 virtual ~LteAnr (); 90 91 /** 92 * \brief Get the type ID. 93 * \return the object TypeId 94 */ 95 static TypeId GetTypeId (); 96 97 /** 98 * \brief Provide an advance information about a related neighbouring cell 99 * and add it as a new Neighbour Relation entry. 100 * \param cellId the cell ID of the new neighbour 101 * 102 * This function simulates the Neighbour Relation addition operation by 103 * network operations and maintenance, as depicted in Section 22.3.2a of 104 * 3GPP TS 36.300. 105 * 106 * An entry added by this function will have the NoRemove flag set to TRUE and 107 * the NoHo flag set to TRUE. Hence, the cell may not act as the target cell 108 * of a handover, unless a measurement report of the cell is received, which 109 * will update the NoHo flag to FALSE. 110 */ 111 void AddNeighbourRelation (uint16_t cellId); 112 113 /** 114 * \brief Remove an existing Neighbour Relation entry. 115 * \param cellId the cell ID to be removed from the NRT 116 * 117 * This function simulates the Neighbour Relation removal operation by 118 * network operations and maintenance, as depicted in Section 22.3.2a of 119 * 3GPP TS 36.300. 120 */ 121 void RemoveNeighbourRelation (uint16_t cellId); 122 123 /** 124 * \brief Set the "user" part of the ANR SAP interface that this ANR instance 125 * will interact with. 126 * \param s a reference to the "user" part of the interface, typically a 127 * member of an LteEnbRrc instance 128 */ 129 virtual void SetLteAnrSapUser (LteAnrSapUser* s); 130 131 /** 132 * \brief Export the "provider" part of the ANR SAP interface. 133 * \return the reference to the "provider" part of the interface, typically to 134 * be kept by an LteEnbRrc instance 135 */ 136 virtual LteAnrSapProvider* GetLteAnrSapProvider (); 137 138 /// let the forwarder class access the protected and private members 139 friend class MemberLteAnrSapProvider<LteAnr>; 140 141 protected: 142 // inherited from Object 143 virtual void DoInitialize (); 144 virtual void DoDispose (); 145 146 private: 147 148 // ANR SAP PROVIDER IMPLEMENTATION 149 150 /** 151 * \brief Implementation of LteAnrSapProvider::ReportUeMeas. 152 * \param measResults a single report of one measurement identity 153 */ 154 void DoReportUeMeas (LteRrcSap::MeasResults measResults); 155 156 /** 157 * \brief Implementation of LteAnrSapProvider::AddNeighbourRelation. 158 * \param cellId the Physical Cell ID of the new neighbouring cell 159 */ 160 void DoAddNeighbourRelation (uint16_t cellId); 161 162 /** 163 * \brief Implementation of LteAnrSapProvider::GetNoRemove. 164 * \param cellId the Physical Cell ID of the neighbouring cell of interest 165 * \return if true, the Neighbour Relation shall *not* be removed from the NRT 166 */ 167 bool DoGetNoRemove (uint16_t cellId) const; 168 169 /** 170 * \brief Implementation of LteAnrSapProvider::GetNoHo. 171 * \param cellId the Physical Cell ID of the neighbouring cell of interest 172 * \return if true, the Neighbour Relation shall *not* be used by the eNodeB 173 * for handover reasons 174 */ 175 bool DoGetNoHo (uint16_t cellId) const; 176 177 /** 178 * \brief Implementation of LteAnrSapProvider::GetNoX2. 179 * \param cellId the Physical Cell ID of the neighbouring cell of interest 180 * \return if true, the Neighbour Relation shall *not* use an X2 interface in 181 * order to initiate procedures towards the eNodeB parenting the 182 * target cell 183 */ 184 bool DoGetNoX2 (uint16_t cellId) const; 185 186 // ANR SAP 187 188 /** 189 * \brief Reference to the "provider" part of the ANR SAP interface, which is 190 * automatically created when this class instantiates. 191 */ 192 LteAnrSapProvider* m_anrSapProvider; 193 194 /** 195 * \brief Reference to the "user" part of the ANR SAP interface, which is 196 * provided by the eNodeB RRC instance. 197 */ 198 LteAnrSapUser* m_anrSapUser; 199 200 // ATTRIBUTE 201 202 /// The attribute Threshold. 203 uint8_t m_threshold; 204 205 /** 206 * \brief Neighbour Relation between two eNodeBs (serving eNodeB and neighbour 207 * eNodeB). 208 */ 209 struct NeighbourRelation_t 210 { 211 bool noRemove; ///< no remove 212 bool noHo; ///< no HO 213 bool noX2; ///< no X2 214 bool detectedAsNeighbour; ///< detected as neighbor 215 }; 216 217 /// cellId 218 typedef std::map<uint16_t, NeighbourRelation_t> NeighbourRelationTable_t; 219 220 /// neighbor relation table 221 NeighbourRelationTable_t m_neighbourRelationTable; 222 223 /** 224 * \internal methods 225 * \param cellId 226 * \returns the neighbor relation 227 */ 228 const NeighbourRelation_t* Find (uint16_t cellId) const; 229 230 /// The expected measurement identity 231 uint8_t m_measId; 232 233 /// Serving cell ID 234 uint16_t m_servingCellId; 235 236 }; // end of class LteAnr 237 238 239 } // end of namespace ns3 240 241 242 #endif /* LTE_ANR_H */ 243