diff --git a/src/lte/helper/lte-hex-grid-enb-topology-helper.cc b/src/lte/helper/lte-hex-grid-enb-topology-helper.cc new file mode 100644 index 000000000..6fdc354fe --- /dev/null +++ b/src/lte/helper/lte-hex-grid-enb-topology-helper.cc @@ -0,0 +1,171 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Nicola Baldo + */ + + +#include "lte-hex-grid-enb-topology-helper.h" +#include +#include +#include +#include +#include +#include + + +NS_LOG_COMPONENT_DEFINE ("LteHexGridEnbTopologyHelper"); + +namespace ns3 { + +NS_OBJECT_ENSURE_REGISTERED (LteHexGridEnbTopologyHelper); + +LteHexGridEnbTopologyHelper::LteHexGridEnbTopologyHelper () +{ + NS_LOG_FUNCTION (this); +} + +LteHexGridEnbTopologyHelper::~LteHexGridEnbTopologyHelper (void) +{ + NS_LOG_FUNCTION (this); +} + +TypeId LteHexGridEnbTopologyHelper::GetTypeId (void) +{ + static TypeId + tid = + TypeId ("ns3::LteHexGridEnbTopologyHelper") + .SetParent () + .AddConstructor () + .AddAttribute ("InterSiteDistance", + "The distance [m] between nearby sites", + DoubleValue (500), + MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_d), + MakeDoubleChecker ()) + .AddAttribute ("SectorOffset", + "The offset [m] in the position for the node of each sector with respect " + "to the center of the three-sector site", + DoubleValue (0.5), + MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_offset), + MakeDoubleChecker ()) + .AddAttribute ("SiteHeight", + "The height [m] of each site", + DoubleValue (30), + MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_siteHeight), + MakeDoubleChecker ()) + .AddAttribute ("MinX", "The x coordinate where the hex grid starts.", + DoubleValue (0.0), + MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_xMin), + MakeDoubleChecker ()) + .AddAttribute ("MinY", "The y coordinate where the hex grid starts.", + DoubleValue (0.0), + MakeDoubleAccessor (&LteHexGridEnbTopologyHelper::m_yMin), + MakeDoubleChecker ()) + .AddAttribute ("GridWidth", "The number of sites in even rows (odd rows will have one additional site).", + UintegerValue (1), + MakeUintegerAccessor (&LteHexGridEnbTopologyHelper::m_gridWidth), + MakeUintegerChecker ()) + ; + return tid; +} + +void +LteHexGridEnbTopologyHelper::DoDispose () +{ + NS_LOG_FUNCTION (this); + Object::DoDispose (); +} + + +void +LteHexGridEnbTopologyHelper::SetLteHelper (Ptr h) +{ + NS_LOG_FUNCTION (this << h); + m_lteHelper = h; +} + +NetDeviceContainer +LteHexGridEnbTopologyHelper::SetPositionAndInstallEnbDevice (NodeContainer c) +{ + NS_LOG_FUNCTION (this); + NetDeviceContainer enbDevs; + const double xydfactor = sqrt (0.75); + double yd = xydfactor*m_d; + for (uint32_t n = 0; n < c.GetN (); ++n) + { + uint32_t currentSite = n / 3; + uint32_t biRowIndex = (currentSite / (m_gridWidth + m_gridWidth + 1)); + uint32_t biRowRemainder = currentSite % (m_gridWidth + m_gridWidth + 1); + uint32_t rowIndex = biRowIndex*2; + uint32_t colIndex = biRowRemainder; + if (biRowRemainder >= m_gridWidth) + { + ++rowIndex; + colIndex -= m_gridWidth; + } + NS_LOG_LOGIC ("node " << n << " site " << currentSite + << " rowIndex " << rowIndex + << " colIndex " << colIndex + << " biRowIndex " << biRowIndex + << " biRowRemainder " << biRowRemainder); + double y = m_yMin + yd * rowIndex; + double x; + double antennaOrientation; + if ((rowIndex % 2) == 0) + { + x = m_xMin + m_d * colIndex; + } + else // row is odd + { + x = m_xMin -(0.5*m_d) + m_d * colIndex; + } + + switch (n%3) + { + case 0: + antennaOrientation = 0; + x += m_offset; + break; + + case 1: + antennaOrientation = 120; + x -= m_offset/2.0; + y += m_offset*xydfactor; + break; + + case 2: + antennaOrientation = -120; + x -= m_offset/2.0; + y -= m_offset*xydfactor; + break; + + default: + break; + } + Ptr node = c.Get (n); + Ptr mm = node->GetObject (); + Vector pos (x, y, m_siteHeight); + NS_LOG_LOGIC ("node " << n << " at " << pos << " antennaOrientation " << antennaOrientation); + mm->SetPosition (Vector (x, y, m_siteHeight)); + m_lteHelper->SetEnbAntennaModelAttribute ("Orientation", DoubleValue (antennaOrientation)); + enbDevs.Add (m_lteHelper->InstallEnbDevice (node)); + } + return enbDevs; +} + +} // namespace ns3 + diff --git a/src/lte/helper/lte-hex-grid-enb-topology-helper.h b/src/lte/helper/lte-hex-grid-enb-topology-helper.h new file mode 100644 index 000000000..e41b33a57 --- /dev/null +++ b/src/lte/helper/lte-hex-grid-enb-topology-helper.h @@ -0,0 +1,87 @@ +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * Author: Nicola Baldo + */ + +#ifndef LTE_HEX_GRID_ENB_TOPOLOGY_HELPER_H +#define LTE_HEX_GRID_ENB_TOPOLOGY_HELPER_H + +#include + +namespace ns3 { + + + +/** + * This helper class allows to easily create a topology with eNBs + * grouped in three-sector sites layed out on an hexagonal grid. The + * layout is done row-wise. + * + */ +class LteHexGridEnbTopologyHelper : public Object +{ +public: + LteHexGridEnbTopologyHelper (void); + virtual ~LteHexGridEnbTopologyHelper (void); + + static TypeId GetTypeId (void); + virtual void DoDispose (void); + + + /** + * Set the LteHelper to be used to actually create the EnbNetDevices + * + * \note if no EpcHelper is ever set, then LteHexGridEnbTopologyHelper will default + * to creating an LTE-only simulation with no EPC, using LteRlcSm as + * the RLC model, and without supporting any IP networking. In other + * words, it will be a radio-level simulation involving only LTE PHY + * and MAC and the FF Scheduler, with a saturation traffic model for + * the RLC. + * + * \param h a pointer to the EpcHelper to be used + */ + void SetLteHelper (Ptr h); + + /** + * Position the nodes on a hex grid and install the corresponding + * EnbNetDevices with antenna boresight configured properly + * + * \param c the node container where the devices are to be installed + * + * \return the NetDeviceContainer with the newly created devices + */ + NetDeviceContainer SetPositionAndInstallEnbDevice (NodeContainer c); + +private: + + Ptr m_lteHelper; + double m_offset; + double m_d; + double m_xMin; + double m_yMin; + uint32_t m_gridWidth; + uint32_t m_siteHeight; + +}; + + +} // namespace ns3 + + + +#endif // LTE_HEX_GRID_ENB_TOPOLOGY_HELPER_H diff --git a/src/lte/wscript b/src/lte/wscript index 6f6fa7970..72ffe7d16 100644 --- a/src/lte/wscript +++ b/src/lte/wscript @@ -39,6 +39,7 @@ def build(bld): 'helper/radio-bearer-stats-calculator.cc', 'helper/mac-stats-calculator.cc', 'helper/radio-environment-map-helper.cc', + 'helper/lte-hex-grid-enb-topology-helper.cc', 'model/rem-spectrum-phy.cc', 'model/ff-mac-csched-sap.cc', 'model/ff-mac-sched-sap.cc', @@ -132,6 +133,7 @@ def build(bld): 'helper/mac-stats-calculator.h', 'helper/radio-bearer-stats-calculator.h', 'helper/radio-environment-map-helper.h', + 'helper/lte-hex-grid-enb-topology-helper.h', 'model/rem-spectrum-phy.h', 'model/ff-mac-common.h', 'model/ff-mac-csched-sap.h',