moved LteGlobalPathlossDatabase from example program to separate helper
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "ns3/lte-module.h"
|
||||
#include "ns3/config-store.h"
|
||||
#include "ns3/radio-bearer-stats-calculator.h"
|
||||
#include "ns3/lte-global-pathloss-database.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
@@ -35,97 +36,9 @@
|
||||
using namespace ns3;
|
||||
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("InterCellInterference");
|
||||
NS_LOG_COMPONENT_DEFINE ("LenaPathlossTraces");
|
||||
|
||||
|
||||
/**
|
||||
* Store the last pathloss value for each TX-RX pair. This is an
|
||||
* example of how the PathlossTrace (provided by some SpectrumChannel
|
||||
* implementations) work.
|
||||
*
|
||||
*/
|
||||
class GlobalPathlossDatabase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* update the pathloss value
|
||||
*
|
||||
* \param context
|
||||
* \param txPhy the transmitting PHY
|
||||
* \param rxPhy the receiving PHY
|
||||
* \param lossDb the loss in dB
|
||||
*/
|
||||
virtual void UpdatePathloss (std::string context, Ptr<SpectrumPhy> txPhy, Ptr<SpectrumPhy> rxPhy, double lossDb) = 0;
|
||||
|
||||
/**
|
||||
* print the stored pathloss values to standard output
|
||||
*
|
||||
*/
|
||||
void Print ();
|
||||
|
||||
protected:
|
||||
|
||||
// CELL ID IMSI PATHLOSS
|
||||
std::map<uint16_t, std::map<uint64_t, double> > m_pathlossMap;
|
||||
};
|
||||
|
||||
void
|
||||
GlobalPathlossDatabase::Print ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
for (std::map<uint16_t, std::map<uint64_t, double> >::const_iterator cellIdIt = m_pathlossMap.begin ();
|
||||
cellIdIt != m_pathlossMap.end ();
|
||||
++cellIdIt)
|
||||
{
|
||||
for (std::map<uint64_t, double>::const_iterator imsiIt = cellIdIt->second.begin ();
|
||||
imsiIt != cellIdIt->second.end ();
|
||||
++imsiIt)
|
||||
{
|
||||
std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DownlinkGlobalPathlossDatabase : public GlobalPathlossDatabase
|
||||
{
|
||||
public:
|
||||
// inherited from GlobalPathlossDatabase
|
||||
virtual void UpdatePathloss (std::string context, Ptr<SpectrumPhy> txPhy, Ptr<SpectrumPhy> rxPhy, double lossDb);
|
||||
};
|
||||
|
||||
void
|
||||
DownlinkGlobalPathlossDatabase::UpdatePathloss (std::string context,
|
||||
Ptr<SpectrumPhy> txPhy,
|
||||
Ptr<SpectrumPhy> rxPhy,
|
||||
double lossDb)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << lossDb);
|
||||
uint16_t cellId = txPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
|
||||
uint16_t imsi = rxPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
|
||||
m_pathlossMap[cellId][imsi] = lossDb;
|
||||
}
|
||||
|
||||
|
||||
class UplinkGlobalPathlossDatabase : public GlobalPathlossDatabase
|
||||
{
|
||||
public:
|
||||
// inherited from GlobalPathlossDatabase
|
||||
virtual void UpdatePathloss (std::string context, Ptr<SpectrumPhy> txPhy, Ptr<SpectrumPhy> rxPhy, double lossDb);
|
||||
};
|
||||
|
||||
void
|
||||
UplinkGlobalPathlossDatabase::UpdatePathloss (std::string context,
|
||||
Ptr<SpectrumPhy> txPhy,
|
||||
Ptr<SpectrumPhy> rxPhy,
|
||||
double lossDb)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << lossDb);
|
||||
uint16_t imsi = txPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
|
||||
uint16_t cellId = rxPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
|
||||
m_pathlossMap[cellId][imsi] = lossDb;
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
@@ -242,15 +155,15 @@ int main (int argc, char *argv[])
|
||||
|
||||
|
||||
|
||||
// keep track of all path loss values in a global object
|
||||
DownlinkGlobalPathlossDatabase dlPathlossDb;
|
||||
UplinkGlobalPathlossDatabase ulPathlossDb;
|
||||
// keep track of all path loss values in two centralized objects
|
||||
DownlinkLteGlobalPathlossDatabase dlPathlossDb;
|
||||
UplinkLteGlobalPathlossDatabase ulPathlossDb;
|
||||
// we rely on the fact that LteHelper creates the DL channel object first, then the UL channel object,
|
||||
// hence the former will have index 0 and the latter 1
|
||||
Config::Connect ("/ChannelList/0/PathLoss",
|
||||
MakeCallback (&DownlinkGlobalPathlossDatabase::UpdatePathloss, &dlPathlossDb));
|
||||
MakeCallback (&DownlinkLteGlobalPathlossDatabase::UpdatePathloss, &dlPathlossDb));
|
||||
Config::Connect ("/ChannelList/1/PathLoss",
|
||||
MakeCallback (&UplinkGlobalPathlossDatabase::UpdatePathloss, &ulPathlossDb));
|
||||
MakeCallback (&UplinkLteGlobalPathlossDatabase::UpdatePathloss, &ulPathlossDb));
|
||||
|
||||
Simulator::Run ();
|
||||
|
||||
|
||||
98
src/lte/helper/lte-global-pathloss-database.cc
Normal file
98
src/lte/helper/lte-global-pathloss-database.cc
Normal file
@@ -0,0 +1,98 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2011,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 <nbaldo@cttc.es>
|
||||
*/
|
||||
|
||||
|
||||
#include "lte-global-pathloss-database.h"
|
||||
#include "ns3/lte-enb-net-device.h"
|
||||
#include "ns3/lte-ue-net-device.h"
|
||||
#include "ns3/lte-spectrum-phy.h"
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("LteGlobalPathlossDatabase");
|
||||
|
||||
|
||||
|
||||
void
|
||||
LteGlobalPathlossDatabase::Print ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
for (std::map<uint16_t, std::map<uint64_t, double> >::const_iterator cellIdIt = m_pathlossMap.begin ();
|
||||
cellIdIt != m_pathlossMap.end ();
|
||||
++cellIdIt)
|
||||
{
|
||||
for (std::map<uint64_t, double>::const_iterator imsiIt = cellIdIt->second.begin ();
|
||||
imsiIt != cellIdIt->second.end ();
|
||||
++imsiIt)
|
||||
{
|
||||
std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double
|
||||
LteGlobalPathlossDatabase::GetPathloss (uint16_t cellId, uint64_t imsi)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
std::map<uint16_t, std::map<uint64_t, double> >::iterator cellIt = m_pathlossMap.find (cellId);
|
||||
if (cellIt == m_pathlossMap.end())
|
||||
{
|
||||
return std::numeric_limits<double>::infinity ();
|
||||
}
|
||||
std::map<uint64_t, double>::iterator ueIt = cellIt->second.find (imsi);
|
||||
if (ueIt == cellIt->second.end())
|
||||
{
|
||||
return std::numeric_limits<double>::infinity ();
|
||||
}
|
||||
return ueIt->second;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DownlinkLteGlobalPathlossDatabase::UpdatePathloss (std::string context,
|
||||
Ptr<SpectrumPhy> txPhy,
|
||||
Ptr<SpectrumPhy> rxPhy,
|
||||
double lossDb)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << lossDb);
|
||||
uint16_t cellId = txPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
|
||||
uint16_t imsi = rxPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
|
||||
m_pathlossMap[cellId][imsi] = lossDb;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UplinkLteGlobalPathlossDatabase::UpdatePathloss (std::string context,
|
||||
Ptr<SpectrumPhy> txPhy,
|
||||
Ptr<SpectrumPhy> rxPhy,
|
||||
double lossDb)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << lossDb);
|
||||
uint16_t imsi = txPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
|
||||
uint16_t cellId = rxPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
|
||||
m_pathlossMap[cellId][imsi] = lossDb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
98
src/lte/helper/lte-global-pathloss-database.h
Normal file
98
src/lte/helper/lte-global-pathloss-database.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2011,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 <nbaldo@cttc.es>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef LTE_GLOBAL_PATHLOSS_DATABASE_H
|
||||
#define LTE_GLOBAL_PATHLOSS_DATABASE_H
|
||||
|
||||
#include <ns3/log.h>
|
||||
#include <ns3/ptr.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class SpectrumPhy;
|
||||
|
||||
/**
|
||||
* Store the last pathloss value for each TX-RX pair. This is an
|
||||
* example of how the PathlossTrace (provided by some SpectrumChannel
|
||||
* implementations) work.
|
||||
*
|
||||
*/
|
||||
class LteGlobalPathlossDatabase
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* update the pathloss value
|
||||
*
|
||||
* \param context
|
||||
* \param txPhy the transmitting PHY
|
||||
* \param rxPhy the receiving PHY
|
||||
* \param lossDb the loss in dB
|
||||
*/
|
||||
virtual void UpdatePathloss (std::string context, Ptr<SpectrumPhy> txPhy, Ptr<SpectrumPhy> rxPhy, double lossDb) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* \param cellId the id of the eNB
|
||||
* \param imsi the id of the UE
|
||||
*
|
||||
* \return the pathloss value bewteen the UE and the eNB
|
||||
*/
|
||||
double GetPathloss (uint16_t cellId, uint64_t imsi);
|
||||
|
||||
/**
|
||||
* print the stored pathloss values to standard output
|
||||
*
|
||||
*/
|
||||
void Print ();
|
||||
|
||||
protected:
|
||||
|
||||
// CELL ID IMSI PATHLOSS
|
||||
std::map<uint16_t, std::map<uint64_t, double> > m_pathlossMap;
|
||||
};
|
||||
|
||||
|
||||
class DownlinkLteGlobalPathlossDatabase : public LteGlobalPathlossDatabase
|
||||
{
|
||||
public:
|
||||
// inherited from LteGlobalPathlossDatabase
|
||||
virtual void UpdatePathloss (std::string context, Ptr<SpectrumPhy> txPhy, Ptr<SpectrumPhy> rxPhy, double lossDb);
|
||||
};
|
||||
|
||||
|
||||
class UplinkLteGlobalPathlossDatabase : public LteGlobalPathlossDatabase
|
||||
{
|
||||
public:
|
||||
// inherited from LteGlobalPathlossDatabase
|
||||
virtual void UpdatePathloss (std::string context, Ptr<SpectrumPhy> txPhy, Ptr<SpectrumPhy> rxPhy, double lossDb);
|
||||
};
|
||||
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // LTE_GLOBAL_PATHLOSS_DATABASE_H
|
||||
@@ -47,6 +47,7 @@ def build(bld):
|
||||
'helper/phy-rx-stats-calculator.cc',
|
||||
'helper/radio-environment-map-helper.cc',
|
||||
'helper/lte-hex-grid-enb-topology-helper.cc',
|
||||
'helper/lte-global-pathloss-database.cc',
|
||||
'model/rem-spectrum-phy.cc',
|
||||
'model/ff-mac-common.cc',
|
||||
'model/ff-mac-csched-sap.cc',
|
||||
@@ -170,6 +171,7 @@ def build(bld):
|
||||
'helper/radio-bearer-stats-connector.h',
|
||||
'helper/radio-environment-map-helper.h',
|
||||
'helper/lte-hex-grid-enb-topology-helper.h',
|
||||
'helper/lte-global-pathloss-database.h',
|
||||
'model/rem-spectrum-phy.h',
|
||||
'model/ff-mac-common.h',
|
||||
'model/ff-mac-csched-sap.h',
|
||||
|
||||
Reference in New Issue
Block a user