A Discrete-Event Network Simulator
API
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 
34 {
35 }
36 
37 void
39 {
40  NS_LOG_FUNCTION (this);
41  for (std::map<uint16_t, std::map<uint64_t, double> >::const_iterator cellIdIt = m_pathlossMap.begin ();
42  cellIdIt != m_pathlossMap.end ();
43  ++cellIdIt)
44  {
45  for (std::map<uint64_t, double>::const_iterator imsiIt = cellIdIt->second.begin ();
46  imsiIt != cellIdIt->second.end ();
47  ++imsiIt)
48  {
49  std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl;
50  }
51  }
52 }
53 
54 
55 double
56 LteGlobalPathlossDatabase::GetPathloss (uint16_t cellId, uint64_t imsi)
57 {
58  NS_LOG_FUNCTION (this);
59  std::map<uint16_t, std::map<uint64_t, double> >::iterator cellIt = m_pathlossMap.find (cellId);
60  if (cellIt == m_pathlossMap.end())
61  {
62  return std::numeric_limits<double>::infinity ();
63  }
64  std::map<uint64_t, double>::iterator ueIt = cellIt->second.find (imsi);
65  if (ueIt == cellIt->second.end())
66  {
67  return std::numeric_limits<double>::infinity ();
68  }
69  return ueIt->second;
70 }
71 
72 
73 void
77  double lossDb)
78 {
79  NS_LOG_FUNCTION (this << lossDb);
80  uint16_t cellId = txPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
81  uint16_t imsi = rxPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
82  m_pathlossMap[cellId][imsi] = lossDb;
83 }
84 
85 
86 void
90  double lossDb)
91 {
92  NS_LOG_FUNCTION (this << lossDb);
93  uint16_t imsi = txPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
94  uint16_t cellId = rxPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
95  m_pathlossMap[cellId][imsi] = lossDb;
96 }
97 
98 
99 
100 } // namespace ns3
void Print()
print the stored pathloss values to standard output
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#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:204
std::map< uint16_t, std::map< uint64_t, double > > m_pathlossMap
List of the last pathloss value for each UE by CellId.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
double GetPathloss(uint16_t cellId, uint64_t imsi)
The eNodeB device implementation.
The LteUeNetDevice class implements the UE net device.