diff --git a/src/mobility/model/building.cc b/src/mobility/model/building.cc index daa71c060..db5f4b12f 100644 --- a/src/mobility/model/building.cc +++ b/src/mobility/model/building.cc @@ -33,7 +33,9 @@ Building::Building (double _xMin, double _xMax, uint8_t _nFloors, uint8_t _nRoomX, uint8_t _nRoomY) : m_floor (_nFloors), m_roomX (_nRoomX), - m_roomY (_nRoomY) + m_roomY (_nRoomY), + m_buildingType (Residential), + m_externalWalls (ConcreteWithWindows) { m_buldingBounds = Box (_xMin, _xMax, _yMin, _yMax, _zMin, _zMax); @@ -43,9 +45,23 @@ Building::Building (double _xMin, double _xMax, Building::Building () : m_floor (0), m_roomX (0), - m_roomY (0) + m_roomY (0), + m_buildingType (Residential), + m_externalWalls (ConcreteWithWindows) { m_buldingBounds = Box (); } +Building::BuildingType_t +Building::GetBuildingType () +{ + return (m_buildingType); +} + +Building::ExtWallsType_t +Building::GetExtWallsType () +{ + return (m_externalWalls); +} + } // namespace ns3 diff --git a/src/mobility/model/building.h b/src/mobility/model/building.h index 122186327..adaa14499 100644 --- a/src/mobility/model/building.h +++ b/src/mobility/model/building.h @@ -40,6 +40,10 @@ public: { Residential, Office, Commercial }; + enum ExtWallsType_t + { + Wood, ConcreteWithWindows, ConcreteWithoutWindows + }; /** * \param _xMin x coordinates of left boundary. * \param _xMax x coordinates of right boundary. @@ -64,6 +68,16 @@ public: */ Building (); + /** + * Return the type of building (i.e., Residential, Office, Commercial) + */ + BuildingType_t GetBuildingType (); + + /** + * Return the type of external walls (i.e., Wood, ConcreteWithWindows, ConcreteWithoutWindows) + */ + ExtWallsType_t GetExtWallsType (); + private: Box m_buldingBounds; @@ -72,6 +86,8 @@ private: uint8_t m_roomY; uint8_t m_buildingId; + BuildingType_t m_buildingType; + ExtWallsType_t m_externalWalls; }; diff --git a/src/propagation/model/buildings-propagation-loss-model.cc b/src/propagation/model/buildings-propagation-loss-model.cc index 247661390..ca44ddb28 100644 --- a/src/propagation/model/buildings-propagation-loss-model.cc +++ b/src/propagation/model/buildings-propagation-loss-model.cc @@ -113,7 +113,7 @@ BuildingsPropagationLossModel::GetEnvironment (void) const double -BuildingsPropagationLossModel::OkumuraHata (Ptr a, Ptr b) const +BuildingsPropagationLossModel::OkumuraHata (Ptr a, Ptr b) const { // Hp: a is the rooftop antenna (from GetLoss logic) double loss = 0.0; @@ -182,26 +182,80 @@ BuildingsPropagationLossModel::OkumuraHata (Ptr a, Ptr a, Ptr b) const +BuildingsPropagationLossModel::ItuR1411 (Ptr a, Ptr b) const { + double dist = a->GetDistanceFrom (b); + double lossLow = 0.0; + double lossUp = 0.0; + double pi = 3.141592653589793; + double Lbp = 20*log10(m_lambda*m_lambda/(8*pi*a->GetPosition ().z*b->GetPosition ().z)); + double Rbp = (4 * a->GetPosition ().z * b->GetPosition ().z) / m_lambda; - return (0.0); + if (dist <= Rbp) + { + lossLow = Lbp + 20*log10(dist/Rbp); + lossUp = Lbp + 20 + 25*log10(dist/Rbp); + } + else + { + lossLow = Lbp + 40*log10(dist/Rbp); + lossUp = Lbp + 20 + 40*log10(dist/Rbp); + } + + double loss = (lossUp + lossLow) / 2; // CHECK!!! + + return (loss); } double -BuildingsPropagationLossModel::ItuR1238 (Ptr a, Ptr b) const +BuildingsPropagationLossModel::ItuR1238 (Ptr a, Ptr b) const { - - return (0.0); + double N = 0.0; + Ptr aBuilding = a->GetBuilding (); + if (aBuilding->GetBuildingType () == Building::Residential) + { + N = 28; + } + else if (aBuilding->GetBuildingType () == Building::Office) + { + N = 30; + } + else if (aBuilding->GetBuildingType () == Building::Commercial) + { + N = 22; + + } + else + { + NS_LOG_ERROR (this << " Unkwnon Wall Type"); + } + + double loss = 20*log10(m_frequency) + N*log10(a->GetDistanceFrom (b)) - 28.0; + + return (loss); } double -BuildingsPropagationLossModel::BEWPL (Ptr a) const +BuildingsPropagationLossModel::BEWPL (Ptr a) const { - - return (0.0); + double loss = 0.0; + Ptr aBuilding = a->GetBuilding (); + if (aBuilding->GetExtWallsType () == Building::Wood) + { + loss = 4; + } + else if (aBuilding->GetExtWallsType () == Building::ConcreteWithWindows) + { + loss = 7; + } + else if (aBuilding->GetExtWallsType () == Building::ConcreteWithoutWindows) + { + loss = 10; // 10 ~ 20 dB + } + + return (loss); } diff --git a/src/propagation/model/buildings-propagation-loss-model.h b/src/propagation/model/buildings-propagation-loss-model.h index 78e14fff9..7199d8172 100644 --- a/src/propagation/model/buildings-propagation-loss-model.h +++ b/src/propagation/model/buildings-propagation-loss-model.h @@ -24,6 +24,8 @@ #include "ns3/nstime.h" #include "ns3/propagation-loss-model.h" +#include +#include namespace ns3 { @@ -82,10 +84,10 @@ public: private: virtual double DoCalcRxPower (double txPowerDbm, Ptr a, Ptr b) const; - double OkumuraHata (Ptr a, Ptr b) const; - double ItuR1411 (Ptr a, Ptr b) const; - double ItuR1238 (Ptr a, Ptr b) const; - double BEWPL (Ptr a) const; + double OkumuraHata (Ptr a, Ptr b) const; + double ItuR1411 (Ptr a, Ptr b) const; + double ItuR1238 (Ptr a, Ptr b) const; + double BEWPL (Ptr a) const; double C; // OH loss coefficient for the environment double N; // ITU-R P.1238: power loss coefficient