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 
34 
36 {
37 }
38 
39 void
41 {
42  NS_LOG_FUNCTION (this);
43  for (std::map<uint16_t, std::map<uint64_t, double> >::const_iterator cellIdIt = m_pathlossMap.begin ();
44  cellIdIt != m_pathlossMap.end ();
45  ++cellIdIt)
46  {
47  for (std::map<uint64_t, double>::const_iterator imsiIt = cellIdIt->second.begin ();
48  imsiIt != cellIdIt->second.end ();
49  ++imsiIt)
50  {
51  std::cout << "CellId: " << cellIdIt->first << " IMSI: " << imsiIt->first << " pathloss: " << imsiIt->second << " dB" << std::endl;
52  }
53  }
54 }
55 
56 
57 double
58 LteGlobalPathlossDatabase::GetPathloss (uint16_t cellId, uint64_t imsi)
59 {
60  NS_LOG_FUNCTION (this);
61  std::map<uint16_t, std::map<uint64_t, double> >::iterator cellIt = m_pathlossMap.find (cellId);
62  if (cellIt == m_pathlossMap.end())
63  {
64  return std::numeric_limits<double>::infinity ();
65  }
66  std::map<uint64_t, double>::iterator ueIt = cellIt->second.find (imsi);
67  if (ueIt == cellIt->second.end())
68  {
69  return std::numeric_limits<double>::infinity ();
70  }
71  return ueIt->second;
72 }
73 
74 
75 void
77  Ptr<SpectrumPhy> txPhy,
78  Ptr<SpectrumPhy> rxPhy,
79  double lossDb)
80 {
81  NS_LOG_FUNCTION (this << lossDb);
82  uint16_t cellId = txPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
83  uint16_t imsi = rxPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
84  m_pathlossMap[cellId][imsi] = lossDb;
85 }
86 
87 
88 void
90  Ptr<SpectrumPhy> txPhy,
91  Ptr<SpectrumPhy> rxPhy,
92  double lossDb)
93 {
94  NS_LOG_FUNCTION (this << lossDb);
95  uint16_t imsi = txPhy->GetDevice ()->GetObject<LteUeNetDevice> ()->GetImsi ();
96  uint16_t cellId = rxPhy->GetDevice ()->GetObject<LteEnbNetDevice> ()->GetCellId ();
97  m_pathlossMap[cellId][imsi] = lossDb;
98 }
99 
100 
101 
102 } // namespace ns3
void Print()
print the stored pathloss values to standard output
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
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.