A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-global-pathloss-database.cc
Go to the documentation of this file.
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  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Nicola Baldo <nbaldo@cttc.es>
19  */
20 
21 
23 #include "ns3/lte-enb-net-device.h"
24 #include "ns3/lte-ue-net-device.h"
25 #include "ns3/lte-spectrum-phy.h"
26 
27 #include <limits>
28 
29 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("LteGlobalPathlossDatabase");
32 
33 
35 {
36 }
37 
38 void
40 {
41  NS_LOG_FUNCTION (this);
42  for (std::map<uint16_t, std::map<uint64_t, double> >::const_iterator cellIdIt = m_pathlossMap.begin ();
43  cellIdIt != m_pathlossMap.end ();
44  ++cellIdIt)
45  {
46  for (std::map<uint64_t, double>::const_iterator imsiIt = cellIdIt->second.begin ();
47  imsiIt != cellIdIt->second.end ();
48  ++imsiIt)
49  {
50  std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl;
51  }
52  }
53 }
54 
55 
56 double
57 LteGlobalPathlossDatabase::GetPathloss (uint16_t cellId, uint64_t imsi)
58 {
59  NS_LOG_FUNCTION (this);
60  std::map<uint16_t, std::map<uint64_t, double> >::iterator cellIt = m_pathlossMap.find (cellId);
61  if (cellIt == m_pathlossMap.end())
62  {
63  return std::numeric_limits<double>::infinity ();
64  }
65  std::map<uint64_t, double>::iterator ueIt = cellIt->second.find (imsi);
66  if (ueIt == cellIt->second.end())
67  {
68  return std::numeric_limits<double>::infinity ();
69  }
70  return ueIt->second;
71 }
72 
73 
74 void
76  Ptr<SpectrumPhy> txPhy,
77  Ptr<SpectrumPhy> rxPhy,
78  double lossDb)
79 {
80  NS_LOG_FUNCTION (this << lossDb);
81  uint16_t cellId = txPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
82  uint16_t imsi = rxPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
83  m_pathlossMap[cellId][imsi] = lossDb;
84 }
85 
86 
87 void
89  Ptr<SpectrumPhy> txPhy,
90  Ptr<SpectrumPhy> rxPhy,
91  double lossDb)
92 {
93  NS_LOG_FUNCTION (this << lossDb);
94  uint16_t imsi = txPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
95  uint16_t cellId = rxPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
96  m_pathlossMap[cellId][imsi] = lossDb;
97 }
98 
99 
100 
101 } // namespace ns3
void Print()
print the stored pathloss values to standard output
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
std::map< uint16_t, std::map< uint64_t, double > > m_pathlossMap
virtual Ptr< NetDevice > GetDevice()=0
get the associated NetDevice instance
double GetPathloss(uint16_t cellId, uint64_t imsi)
The eNodeB device implementation.
The LteUeNetDevice class implements the UE net device.