Add Building class, BuildingMobilityModel and BuildingPropagationModel

This commit is contained in:
Marco Miozzo committed 2011-06-22 13:31:45 +02:00
1 parent eeee762ea2
commit 2ff788a753
8 files changed
+761

No files matched your search

+51
View File
@@ -0,0 +1,51 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#include <ns3/building.h>
// #include <ns3/box.h>
namespace ns3 {
Building::Building (double _xMin, double _xMax,
double _yMin, double _yMax,
double _zMin, double _zMax,
uint8_t _nFloors, uint8_t _nRoomX, uint8_t _nRoomY) :
m_floor (_nFloors),
m_roomX (_nRoomX),
m_roomY (_nRoomY)
{
m_buldingBounds = Box (_xMin, _xMax, _yMin, _yMax, _zMin, _zMax);
}
Building::Building ()
: m_floor (0),
m_roomX (0),
m_roomY (0)
{
m_buldingBounds = Box ();
}
} // namespace ns3
+86
View File
@@ -0,0 +1,86 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#ifndef BUILDING_H
#define BUILDING_H
#include <ns3/attribute.h>
#include <ns3/attribute-helper.h>
#include <ns3/vector.h>
#include <ns3/box.h>
#include <ns3/simple-ref-count.h>
namespace ns3 {
/**
* \ingroup mobility
* \brief a 3d building block
*/
class Building : public SimpleRefCount<Building>
{
public:
enum BuildingType_t
{
Residential, Office, Commercial
};
/**
* \param _xMin x coordinates of left boundary.
* \param _xMax x coordinates of right boundary.
* \param _yMin y coordinates of bottom boundary.
* \param _yMax y coordinates of top boundary.
* \param _zMin z coordinates of down boundary.
* \param _zMax z coordinates of up boundary.
* \param _nFloors number of floors
* \param _nRoomX number of rooms in the x axis
* \param _nRoomY number of rooms in the y axis
*
* Create a building.
*/
Building (double _xMin, double _xMax,
double _yMin, double _yMax,
double _zMin, double _zMax,
uint8_t _nFloors, uint8_t _nRoomX, uint8_t _nRoomY);
/**
* Create a zero-sized building located at coordinates (0.0,0.0,0.0)
* and with no floors and 1 room.
*/
Building ();
private:
Box m_buldingBounds;
uint8_t m_floor;
uint8_t m_roomX;
uint8_t m_roomY;
uint8_t m_buildingId;
};
//std::ostream &operator << (std::ostream &os, const Box &box);
//std::istream &operator >> (std::istream &is, Box &box);
ATTRIBUTE_HELPER_HEADER (Building);
} // namespace ns3
#endif /* BUILDING_H */
@@ -0,0 +1,117 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#include <ns3/simulator.h>
#include <ns3/position-allocator.h>
#include <ns3/buildings-mobility-model.h>
#include "ns3/pointer.h"
namespace ns3 {
NS_OBJECT_ENSURE_REGISTERED (BuildingsMobilityModel);
TypeId
BuildingsMobilityModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::BuildingsMobilityModel")
.SetParent<MobilityModel> ()
.SetGroupName ("Mobility")
.AddConstructor<BuildingsMobilityModel> ()
.AddAttribute ("Bounds",
"Bounds of the area to cruise.",
BoxValue (Box (-100.0, 100.0, -100.0, 100.0, 0.0, 100.0)),
MakeBoxAccessor (&BuildingsMobilityModel::m_bounds),
MakeBoxChecker ());
return tid;
}
BuildingsMobilityModel::BuildingsMobilityModel ()
{
m_indoor = false;
}
void
BuildingsMobilityModel::DoDispose (void)
{
// chain up
m_surroudingBuildings.clear ();
MobilityModel::DoDispose ();
}
Vector
BuildingsMobilityModel::DoGetPosition (void) const
{
m_helper.Update ();
return m_helper.GetCurrentPosition ();
}
void
BuildingsMobilityModel::DoSetPosition (const Vector &position)
{
m_helper.SetPosition (position);
}
Vector
BuildingsMobilityModel::DoGetVelocity (void) const
{
return m_helper.GetVelocity ();
}
bool
BuildingsMobilityModel::IsIndoor (void)
{
return (m_indoor);
}
bool
BuildingsMobilityModel::IsOutdoor (void)
{
return (!m_indoor);
}
void
BuildingsMobilityModel::SetIndoor (Ptr<Building> building)
{
m_indoor = true;
m_myBuilding = building;
}
void
BuildingsMobilityModel::SetOutdoor (void)
{
m_indoor = false;
}
void
BuildingsMobilityModel::SetSurroudingBuilding(Ptr<Building> building)
{
m_surroudingBuildings.push_back (building);
}
Ptr<Building>
BuildingsMobilityModel::GetBuilding ()
{
return (m_myBuilding);
}
} // namespace
@@ -0,0 +1,88 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#ifndef BUILDINGS_MOBILITY_MODEL_H
#define BUILDINGS_MOBILITY_MODEL_H
#include <ns3/mobility-model.h>
#include <ns3/ptr.h>
#include <ns3/object.h>
#include <ns3/box.h>
#include <map>
#include <ns3/constant-velocity-helper.h>
#include <ns3/building.h>
//#include "ns3/random-variable.h"
//#include "ns3/nstime.h"
//#include "ns3/event-id.h"
namespace ns3 {
/**
* \ingroup mobility
* \brief Buildings mobility model
*
* This model implements the managment of scenarios where users might be
* either indoor (e.g., houses, offices, etc.) and outdoor.
*
*/
class BuildingsMobilityModel : public MobilityModel
{
public:
static TypeId GetTypeId (void);
BuildingsMobilityModel ();
bool IsIndoor (void);
bool IsOutdoor (void);
void SetIndoor (Ptr<Building> building);
void SetOutdoor (void);
void SetSurroudingBuilding(Ptr<Building> building);
Ptr<Building> GetBuilding ();
private:
virtual void DoDispose (void);
virtual Vector DoGetPosition (void) const;
virtual void DoSetPosition (const Vector &position);
virtual Vector DoGetVelocity (void) const;
ConstantVelocityHelper m_helper;
Box m_bounds; // bounds of the simulation field (if needed)
std::list < Ptr<Building> > m_surroudingBuildings; // buildings blocks
Ptr<Building> m_myBuilding;
bool m_indoor;
};
} // namespace ns3
#endif // BUILDINGS_MOBILITY_MODEL_H
+4
View File
@@ -19,6 +19,8 @@ def build(bld):
'model/steady-state-random-waypoint-mobility-model.cc',
'model/waypoint.cc',
'model/waypoint-mobility-model.cc',
'model/building.cc',
'model/buildings-mobility-model.cc',
'helper/mobility-helper.cc',
'helper/ns2-mobility-helper.cc',
]
@@ -48,6 +50,8 @@ def build(bld):
'model/random-waypoint-mobility-model.h',
'model/steady-state-random-waypoint-mobility-model.h',
'model/waypoint.h',
'model/building.h',
'model/buildings-mobility-model.h',
'model/waypoint-mobility-model.h',
'helper/mobility-helper.h',
'helper/ns2-mobility-helper.h',
@@ -0,0 +1,309 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#include "ns3/propagation-loss-model.h"
#include "ns3/log.h"
#include "ns3/mobility-model.h"
#include "ns3/double.h"
#include "ns3/pointer.h"
#include <math.h>
#include "buildings-propagation-loss-model.h"
#include "ns3/buildings-mobility-model.h"
namespace ns3 {
NS_LOG_COMPONENT_DEFINE ("BuildingsPropagationLossModel");
NS_OBJECT_ENSURE_REGISTERED (BuildingsPropagationLossModel);
TypeId
BuildingsPropagationLossModel::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::BuildingsPropagationLossModel")
.SetParent<PropagationLossModel> ()
.AddConstructor<BuildingsPropagationLossModel> ()
.AddAttribute ("Lambda",
"The wavelength (default is 2.3 GHz at 300 000 km/s).",
DoubleValue (300000000.0 / 2.3e9),
MakeDoubleAccessor (&BuildingsPropagationLossModel::m_lambda),
MakeDoubleChecker<double> ())
.AddAttribute ("Frequency",
"The Frequency (default is 2.3 GHz).",
DoubleValue (2.3e9),
MakeDoubleAccessor (&BuildingsPropagationLossModel::m_frequency),
MakeDoubleChecker<double> ())
.AddAttribute ("MinDistance",
"The distance under which the propagation model refuses to give results (m) ",
DoubleValue (0.5),
MakeDoubleAccessor (&BuildingsPropagationLossModel::SetMinDistance, &BuildingsPropagationLossModel::GetMinDistance),
MakeDoubleChecker<double> ());
return tid;
}
BuildingsPropagationLossModel::BuildingsPropagationLossModel () :
C (0),
m_environment (Urban),
m_citySize (Large)
{
}
void
BuildingsPropagationLossModel::SetLambda (double frequency, double speed)
{
m_lambda = speed / frequency;
m_frequency = frequency;
}
void
BuildingsPropagationLossModel::SetLambda (double lambda)
{
m_lambda = lambda;
m_frequency = 300000000 / lambda;
}
double
BuildingsPropagationLossModel::GetLambda (void) const
{
return m_lambda;
}
void
BuildingsPropagationLossModel::SetMinDistance (double minDistance)
{
m_minDistance = minDistance;
}
double
BuildingsPropagationLossModel::GetMinDistance (void) const
{
return m_minDistance;
}
void
BuildingsPropagationLossModel::SetEnvironment (Environment env)
{
m_environment = env;
}
BuildingsPropagationLossModel::Environment
BuildingsPropagationLossModel::GetEnvironment (void) const
{
return m_environment;
}
double
BuildingsPropagationLossModel::OkumuraHata (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
{
// Hp: a is the rooftop antenna (from GetLoss logic)
double loss = 0.0;
if (m_frequency<=1500)
{
// standard Okumura Hata (from wikipedia)
double log_f = log10 (m_frequency);
double log_aHeight = 13.82 * log10 (a->GetPosition ().z);
double log_bHeight = 0.0;
if (m_citySize == Large)
{
if (m_frequency<200)
{
log_bHeight = 8.29 * pow (log10 (1.54 * b->GetPosition ().z), 2) - 1.1;
}
else
{
log_bHeight = 3.2 * pow (log10 (11.75 * b->GetPosition ().z), 2) - 4.97;
}
}
else
{
log_bHeight = 0.8 + (1.1*log10(m_frequency) - 0.7)*b->GetPosition ().z - 1.56*log10(m_frequency);
}
loss = 69.55 + (26.16 * log_f) - log_aHeight + (((44.9 - (6.55 * log_f) ))*log10 (a->GetDistanceFrom (b))) - log_bHeight;
if (m_environment == SubUrban)
{
loss += 2 * (pow(log10 (m_frequency / 28), 2)) - 5.4;
}
else if (m_environment == OpenAreas)
{
loss += -4.70*pow(log10(m_frequency),2) + 18.33*log10(m_frequency) - 40.94;
}
}
else if (m_frequency <= 2170) // max 3GPP freq EUTRA band #1
{
// COST 231 Okumura model
double log_f = log10 (m_frequency);
double log_aHeight = 13.83 * log10 (a->GetPosition ().z);
double log_bHeight = 0.0;
if (m_citySize == Large)
{
log_bHeight = 3.2 * pow ((log10(11.75 * b->GetPosition ().z)),2);
}
else
{
log_bHeight = 1.1*log10(m_frequency) - 0.7*b->GetPosition ().z - (1.56*log10(m_frequency) - 0.8);
}
loss = 46.3 + (33.9 * log_f) - log_aHeight + (((44.9 - (6.55 * log_f) ))*log10 (a->GetDistanceFrom (b))) - log_bHeight;
}
else if (m_frequency <= 2690) // max 3GPP freq EUTRA band #1
{
// Empirical model from
// "Path Loss Models for Suburban Scenario at 2.3GHz, 2.6GHz and 3.5GHz"
// Sun Kun, Wang Ping, Li Yingze
// Antennas, Propagation and EM Theory, 2008. ISAPE 2008. 8th International Symposium on
loss = 36 + 26*log10(a->GetDistanceFrom (b));
}
return (loss);
}
double
BuildingsPropagationLossModel::ItuR1411 (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
{
return (0.0);
}
double
BuildingsPropagationLossModel::ItuR1238 (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
{
return (0.0);
}
double
BuildingsPropagationLossModel::BEWPL (Ptr<MobilityModel> a) const
{
return (0.0);
}
double
BuildingsPropagationLossModel::GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
{
double distance = a->GetDistanceFrom (b);
if (distance <= m_minDistance)
{
return 0.0;
}
// get the BuildingsMobilityModel pointers
Ptr<BuildingsMobilityModel> a1 = DynamicCast<BuildingsMobilityModel> (a);
Ptr<BuildingsMobilityModel> b1 = DynamicCast<BuildingsMobilityModel> (b);
double loss = 0.0;
if (a1->IsOutdoor ())
{
if (b1->IsIndoor ())
{
if (distance > 1000)
{
if (a1->GetPosition ().z > m_rooftopThreshold)
{
// Over the rooftop tranmission -> Okumura Hata
loss = OkumuraHata (a1, b1);
}
else
{
// TODO put a limit in distance (i.e., < 2000 for small cells)
// short range outdoor communication within street canyon
loss = ItuR1411 (a1, b1);
}
}
else
{
// short range outdoor communication within street canyon
loss = ItuR1411 (a1, b1);
}
}
else
{
// b indoor
if (distance > 1000)
{
loss = OkumuraHata (a1, b1) + BEWPL(b1);
}
else
{
loss = ItuR1411 (a1, b1) + BEWPL(b1);
}
} // end b1->isIndoor ()
}
else
{
// a is indoor
if (b1->IsIndoor ())
{
if (a1->GetBuilding () == b1->GetBuilding ())
{
// nodes are in same building -> indoor communication ITU-R P.1238
loss = ItuR1238 (a1, b1);
}
else
{
loss = ItuR1411 (a1, b1) + BEWPL(a1) + BEWPL(b1);
}
}
else
{
// b is outdoor
if (distance > 1000)
{
if (b1->GetPosition ().z > m_rooftopThreshold)
{
loss = OkumuraHata (a1, b1) + BEWPL(a1);
}
else
{
loss = ItuR1411 (a1, b1) + BEWPL(a1);
}
}
else
{
loss = ItuR1411 (a1, b1) + BEWPL(a1);
}
} // end b1->IsIndoor ()
} // end a1->IsOutdoor ()
return (loss);
}
double
BuildingsPropagationLossModel::DoCalcRxPower (double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const
{
return txPowerDbm + GetLoss (a, b);
}
} // namespace ns3
@@ -0,0 +1,104 @@
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2011 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: Marco Miozzo <marco.miozzo@cttc.es>
*
*/
#ifndef BUILDINGS_PROPAGATION_LOSS_MODEL_H_
#define BUILDINGS_PROPAGATION_LOSS_MODEL_H_
#include "ns3/nstime.h"
#include "ns3/propagation-loss-model.h"
namespace ns3 {
/**
* \ingroup propagation
*
* \brief The Building-Propagation-Model is a compound of different models able to evaluate the pathloss from 200 to 2600 MHz, in different environments and with buildings (i.e., indoor and outdoor communications).
*
* This model includes Hata model, COST231, ITU-R P.1411 (short range
* communications), ITU-R P.1238 (indoor communications).
* Building-Propagation-Model properly combines the models above in order
* to be able to evaluate the pathloss under different scenarios, in detail:
* - Environments: urban, suburban, open-areas;
* - frequency: from 200 uo to 2600 MHz
* - short range communications vs long range communications
* - Node position respect to buildings: indoor, outdoor and hybrid (indoor <-> outdoor)
* - Building penetretation loss
* - floors, etc...
*
* Frequency: 200 MHz to 2000 MHz
* Link Distance:up to 20 km
* Short/long distance commutation: 1 Km
* \warning This model works with BuildingsMobilityModel
*
*/
class BuildingsPropagationLossModel : public PropagationLossModel
{
public:
static TypeId GetTypeId (void);
BuildingsPropagationLossModel ();
enum Environment
{
Urban, SubUrban, OpenAreas
};
enum CitySize
{
Small, Medium, Large
};
/**
* \param a the mobility model of the source
* \param b the mobility model of the destination
* \returns the propagation loss (in dBm)
*/
double GetLoss (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
void SetEnvironment (Environment env);
void SetLambda (double lambda);
void SetMinDistance (double minDistance);
Environment GetEnvironment (void) const;
double GetMinDistance (void) const;
double GetLambda (void) const;
void SetLambda (double frequency, double speed);
private:
virtual double DoCalcRxPower (double txPowerDbm, Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
double OkumuraHata (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
double ItuR1411 (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
double ItuR1238 (Ptr<MobilityModel> a, Ptr<MobilityModel> b) const;
double BEWPL (Ptr<MobilityModel> a) const;
double C; // OH loss coefficient for the environment
double N; // ITU-R P.1238: power loss coefficient
double m_lambda;
Environment m_environment;
CitySize m_citySize;
double m_minDistance; // in meter
double m_frequency; // frequency in MHz
double m_rooftopThreshold; // in meter (used to discriminate OH and short range canyoning)
};
}
#endif /* COST231PROPAGATIONMODEL_H_ */
+2
View File
@@ -8,6 +8,7 @@ def build(bld):
'model/propagation-loss-model.cc',
'model/jakes-propagation-loss-model.cc',
'model/cost231-propagation-loss-model.cc',
'model/buildings-propagation-loss-model.cc',
]
module_test = bld.create_ns3_module_test_library('propagation')
@@ -22,6 +23,7 @@ def build(bld):
'model/propagation-loss-model.h',
'model/jakes-propagation-loss-model.h',
'model/cost231-propagation-loss-model.h',
'model/buildings-propagation-loss-model.h',
]
if (bld.env['ENABLE_EXAMPLES']):