added support to generate Radio Environment Maps
authorNicola Baldo <nbaldo@cttc.es>
Mon, 16 Jan 2012 19:54:48 +0100
changeset 8560 729a6248d9d3
parent 8559 4850866f297b
child 8561 89164d840d69
added support to generate Radio Environment Maps
src/lte/doc/source/lte-user.rst
src/lte/examples/lena-rem.cc
src/lte/examples/wscript
src/lte/helper/radio-environment-map-helper.cc
src/lte/helper/radio-environment-map-helper.h
src/lte/model/rem-spectrum-phy.cc
src/lte/model/rem-spectrum-phy.h
src/lte/wscript
--- a/src/lte/doc/source/lte-user.rst	Mon Jan 16 19:26:57 2012 +0100
+++ b/src/lte/doc/source/lte-user.rst	Mon Jan 16 19:54:48 2012 +0100
@@ -469,6 +469,54 @@
 with different antenna orientations to be installed on each node.
 
 
+Radio Environment Maps
+----------------------
+
+By using the class RadioEnvironmentMapHelper it is possible to output
+to a file a Radio Environment Map (REM), i.e., a uniform 2D grid of values
+that represent the Signal-to-noise ratio in the downlink with respect
+to the eNB that has the strongest signal at each point. 
+
+To do this, you just need to add the following code to your simulation
+program towards the end, right before the call to Simulator::Run ()::
+
+  Ptr<RadioEnvironmentMapHelper> remHelper = CreateObject<RadioEnvironmentMapHelper> ();
+  remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0"));
+  remHelper->SetAttribute ("OutputFile", StringValue ("rem.out"));
+  remHelper->SetAttribute ("XMin", DoubleValue (-400.0));
+  remHelper->SetAttribute ("XMax", DoubleValue (400.0));
+  remHelper->SetAttribute ("XRes", UintegerValue (100));
+  remHelper->SetAttribute ("YMin", DoubleValue (-300.0));
+  remHelper->SetAttribute ("YMax", DoubleValue (300.0));
+  remHelper->SetAttribute ("YRes", UintegerValue (75));
+  remHelper->SetAttribute ("Z", DoubleValue (0.0));
+  remHelper->Install ();
+
+By configuring the attributes of the RadioEnvironmentMapHelper object
+as shown above, you can tune the parameters of the REM to be
+generated. Note that each RadioEnvironmentMapHelper instance can
+generate only one REM; if you want to generate more REMs, you need to
+create one separate instance for each REM. 
+
+The REM is stored in an ASCII file in the following format:
+
+ * column 1 is the x coordinate
+ * column 2 is the y coordinate
+ * column 3 is the z coordinate
+ * column 4 is the SINR in linear units
+
+A minimal gnuplot script that allows you to plot the REM is given
+below::
+
+   set view map;
+   set xlabel "X"
+   set ylabel "Y"
+   set cblabel "SINR (dB)"
+   plot "rem.out" using ($1):($2):(10*log10($4)) with image
+  
+
+
+
 Evolved Packet Core (EPC)
 -------------------------
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/examples/lena-rem.cc	Mon Jan 16 19:54:48 2012 +0100
@@ -0,0 +1,121 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011 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: Manuel Requena <manuel.requena@cttc.es>
+ *         Nicola Baldo <nbaldo@cttc.es>
+ */
+
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/mobility-module.h"
+#include "ns3/lte-module.h"
+#include "ns3/config-store.h"
+#include "ns3/spectrum-module.h"
+//#include "ns3/gtk-config-store.h"
+
+using namespace ns3;
+
+int main (int argc, char *argv[])
+{	
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+	
+  // to save a template default attribute file run it like this:
+  // ./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Save --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lena-first-sim
+  //
+  // to load a previously created default attribute file
+  // ./waf --command-template="%s --ns3::ConfigStore::Filename=input-defaults.txt --ns3::ConfigStore::Mode=Load --ns3::ConfigStore::FileFormat=RawText" --run src/lte/examples/lena-first-sim
+
+  ConfigStore inputConfig;
+  inputConfig.ConfigureDefaults ();
+
+  // Parse again so you can override default values from the command line
+  cmd.Parse (argc, argv);
+
+  Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
+
+  // Uncomment to enable logging
+  //lteHelper->EnableLogComponents ();
+
+  // Create Nodes: eNodeB and UE
+  NodeContainer enbNodes;
+  NodeContainer ueNodes;
+  enbNodes.Create (1);
+  ueNodes.Create (1);
+
+  // Install Mobility Model
+  MobilityHelper mobility;
+  mobility.SetMobilityModel ("ns3::BuildingsMobilityModel");
+  mobility.Install (enbNodes);
+  mobility.SetMobilityModel ("ns3::BuildingsMobilityModel");
+  mobility.Install (ueNodes);
+
+  // Create Devices and install them in the Nodes (eNB and UE)
+  NetDeviceContainer enbDevs;
+  NetDeviceContainer ueDevs;
+  // Default scheduler is PF, uncomment to use RR
+  //lteHelper->SetSchedulerType ("ns3::RrFfMacScheduler");
+
+  enbDevs = lteHelper->InstallEnbDevice (enbNodes);
+  ueDevs = lteHelper->InstallUeDevice (ueNodes);
+
+  // Attach a UE to a eNB
+  lteHelper->Attach (ueDevs, enbDevs.Get (0));
+
+  // Activate an EPS bearer
+  enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
+  EpsBearer bearer (q);
+  lteHelper->ActivateEpsBearer (ueDevs, bearer, EpcTft::Default ());
+
+
+  // Configure Radio Environment Map (REM) output
+  // for LTE-only simulations always use /ChannelList/0 which is the downlink channel
+  Ptr<RadioEnvironmentMapHelper> remHelper = CreateObject<RadioEnvironmentMapHelper> ();
+  remHelper->SetAttribute ("ChannelPath", StringValue ("/ChannelList/0"));
+  remHelper->SetAttribute ("OutputFile", StringValue ("rem.out"));
+  remHelper->SetAttribute ("XMin", DoubleValue (-400.0));
+  remHelper->SetAttribute ("XMax", DoubleValue (400.0));
+  remHelper->SetAttribute ("XRes", UintegerValue (100));
+  remHelper->SetAttribute ("YMin", DoubleValue (-300.0));
+  remHelper->SetAttribute ("YMax", DoubleValue (300.0));
+  remHelper->SetAttribute ("YRes", UintegerValue (75));
+  remHelper->SetAttribute ("Z", DoubleValue (0.0));
+  remHelper->Install ();
+
+  // here's a minimal gnuplot script that will plot the above:
+  // 
+  // set view map;
+  // set term x11;
+  // set xlabel "X"
+  // set ylabel "Y"
+  // set cblabel "SINR (dB)"
+  // plot "rem.out" using ($1):($2):(10*log10($4)) with image
+  
+    
+
+
+  Simulator::Stop (Seconds (0.020));
+
+  Simulator::Run ();
+
+  //GtkConfigStore config;
+  //config.ConfigureAttributes ();
+
+  Simulator::Destroy ();
+  return 0;
+}
--- a/src/lte/examples/wscript	Mon Jan 16 19:26:57 2012 +0100
+++ b/src/lte/examples/wscript	Mon Jan 16 19:54:48 2012 +0100
@@ -28,4 +28,6 @@
     obj = bld.create_ns3_program('lena-simple-epc',
                                  ['lte'])
     obj.source = 'lena-simple-epc.cc'
-
+    obj = bld.create_ns3_program('lena-rem',
+                                 ['lte'])
+    obj.source = 'lena-rem.cc'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/helper/radio-environment-map-helper.cc	Mon Jan 16 19:54:48 2012 +0100
@@ -0,0 +1,203 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2012 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 "radio-environment-map-helper.h"
+
+#include <ns3/abort.h>
+#include <ns3/log.h>
+#include <ns3/double.h>
+#include <ns3/uinteger.h>
+#include <ns3/string.h>
+#include <ns3/spectrum-channel.h>
+#include <ns3/config.h>
+#include <ns3/rem-spectrum-phy.h>
+#include <ns3/buildings-mobility-model.h>
+#include <ns3/simulator.h>
+#include <ns3/node.h>
+
+#include <fstream>
+
+
+NS_LOG_COMPONENT_DEFINE ("RadioEnvironmentMapHelper");
+
+namespace ns3 {
+
+
+
+NS_OBJECT_ENSURE_REGISTERED (RadioEnvironmentMapHelper);
+
+RadioEnvironmentMapHelper::RadioEnvironmentMapHelper ()
+{
+}
+
+
+RadioEnvironmentMapHelper::~RadioEnvironmentMapHelper ()
+{
+}
+
+
+
+void
+RadioEnvironmentMapHelper::DoDispose ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+TypeId
+RadioEnvironmentMapHelper::GetTypeId (void)
+{
+  NS_LOG_FUNCTION ("RadioEnvironmentMapHelper::GetTypeId");
+  static TypeId tid = TypeId ("ns3::RadioEnvironmentMapHelper")
+    .SetParent<Object> ()
+    .AddConstructor<RadioEnvironmentMapHelper> ()
+    .AddAttribute ("ChannelPath", "The path to the channel for which the Radio Environment Map is to be generated",
+                   StringValue ("/ChannelList/0"),
+                   MakeStringAccessor (&RadioEnvironmentMapHelper::m_channelPath),
+                   MakeStringChecker ())
+    .AddAttribute ("OutputFile", "the filename to which the Radio Environment Map is saved",
+                   StringValue ("rem.out"),
+                   MakeStringAccessor (&RadioEnvironmentMapHelper::m_outputFile),
+                   MakeStringChecker ())
+    .AddAttribute ("XMin", "The min x coordinate of the map.",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_xMin),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("YMin", "The min y coordinate of the map.",
+                   DoubleValue (0.0),
+                   MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_yMin),
+                   MakeDoubleChecker<double> ())
+   .AddAttribute ("XMax", "The max x coordinate of the map.",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_xMax),
+                   MakeDoubleChecker<double> ())
+    .AddAttribute ("YMax", "The max y coordinate of the map.",
+                   DoubleValue (1.0),
+                   MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_yMax),
+                   MakeDoubleChecker<double> ())
+   .AddAttribute ("XRes", "The resolution (number of points) of the map along the x axis.",
+                   UintegerValue (100),
+                   MakeUintegerAccessor (&RadioEnvironmentMapHelper::m_xRes),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("YRes", "The resolution (number of points) of the map along the y axis.",
+                   UintegerValue (100),
+                   MakeUintegerAccessor (&RadioEnvironmentMapHelper::m_yRes),
+                   MakeUintegerChecker<uint32_t> ())
+    .AddAttribute ("Z", "The value of the z coordinate for which the map is to be generated",
+		   DoubleValue (0.0),
+                   MakeDoubleAccessor (&RadioEnvironmentMapHelper::m_z),
+                   MakeDoubleChecker<double> ())
+
+  ;
+  return tid;
+}
+
+
+
+
+void 
+RadioEnvironmentMapHelper::Install ()
+{
+  NS_LOG_FUNCTION (this);
+  if (!m_rem.empty ())
+    {
+      NS_FATAL_ERROR ("only one REM supported per instance of RadioEnvironmentMapHelper");
+    }
+  Config::MatchContainer match = Config::LookupMatches (m_channelPath);
+  if (match.GetN () != 1)
+    {
+      NS_FATAL_ERROR ("Lookup " << m_channelPath << " should have exactly one match");
+    }
+  m_channel = match.Get (0)->GetObject<SpectrumChannel> ();
+  NS_ABORT_MSG_IF (m_channel == 0, "object at " << m_channelPath << "is not of type SpectrumChannel");
+
+  double xStep = (m_xMax - m_xMin)/m_xRes;
+  double yStep = (m_yMax - m_yMin)/m_yRes;
+  
+  for (double x = m_xMin; x <= m_xMax ; x += xStep)
+    {
+      m_rem.push_back (std::list<RemPoint> ());
+      for (double y = m_yMin; y <= m_yMax ; y += yStep)
+        {
+          RemPoint p;
+          p.phy = CreateObject<RemSpectrumPhy> ();
+          p.bmm = CreateObject<BuildingsMobilityModel> ();
+          p.phy->SetMobility (p.bmm);
+          p.bmm->SetPosition (Vector (x, y, m_z));
+          m_rem.back ().push_back (p);
+        }      
+    }
+  Simulator::Schedule (Seconds (0.0055), &RadioEnvironmentMapHelper::Connect, this);
+  Simulator::Schedule (Seconds (0.0065), &RadioEnvironmentMapHelper::PrintAndDisconnect, this);  
+
+}
+
+void 
+RadioEnvironmentMapHelper::Connect ()
+{
+  NS_LOG_FUNCTION (this);
+  for (std::list<std::list<RemPoint> >::iterator it1 = m_rem.begin ();
+       it1 != m_rem.end ();
+       ++it1)
+    {
+      for (std::list<RemPoint>::iterator it2 = it1->begin ();
+           it2 != it1->end ();
+           ++it2)
+        {
+          NS_LOG_LOGIC ("adding phy " << it2->phy);
+          m_channel->AddRx (it2->phy);
+        }
+    }
+}
+
+void 
+RadioEnvironmentMapHelper::PrintAndDisconnect ()
+{
+  NS_LOG_FUNCTION (this);
+  std::ofstream outFile;
+  outFile.open (m_outputFile.c_str ());
+  if (!outFile.is_open ())
+    {
+      NS_FATAL_ERROR ("Can't open file " << (m_outputFile));
+      return;
+    }
+  
+  for (std::list<std::list<RemPoint> >::iterator it1 = m_rem.begin ();
+       it1 != m_rem.end ();
+       ++it1)
+    {
+      for (std::list<RemPoint>::iterator it2 = it1->begin ();
+           it2 != it1->end ();
+           ++it2)
+        {
+          Vector pos = it2->bmm->GetPosition ();
+          outFile << pos.x << "\t" 
+                  << pos.y << "\t" 
+                  << pos.z << "\t" 
+                  << it2->phy->GetSinr ()
+                  << std::endl;
+          m_channel->RemoveRx (it2->phy);
+        }
+    }
+  outFile.close ();
+}
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/helper/radio-environment-map-helper.h	Mon Jan 16 19:54:48 2012 +0100
@@ -0,0 +1,91 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 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 RADIO_ENVIRONMENT_MAP_HELPER_H
+#define RADIO_ENVIRONMENT_MAP_HELPER_H
+
+
+#include <ns3/object.h>
+
+
+
+namespace ns3 {
+
+class RemSpectrumPhy;
+class Node;
+class NetDevice;
+class SpectrumChannel;
+class BuildingsMobilityModel;
+
+/** 
+ * Generates a 2D map of the SINR from the strongest transmitter. 
+ * 
+ */
+class RadioEnvironmentMapHelper : public Object
+{
+public:  
+
+  RadioEnvironmentMapHelper ();
+
+  virtual ~RadioEnvironmentMapHelper ();
+  
+  // inherited from Object
+  virtual void DoDispose (void);
+  static TypeId GetTypeId (void);
+
+  void Install ();
+
+private:
+
+  void Connect ();
+  void PrintAndDisconnect ();
+
+
+  struct RemPoint 
+  {
+    Ptr<RemSpectrumPhy> phy;
+    Ptr<Node> node;
+    Ptr<NetDevice> dev;
+    Ptr<BuildingsMobilityModel> bmm;
+  };
+
+  std::list<std::list<RemPoint> > m_rem;
+
+  double m_xMin;
+  double m_xMax;
+  uint32_t m_xRes;
+
+  double m_yMin;
+  double m_yMax;
+  uint32_t m_yRes;
+  
+  double m_z;
+
+  std::string m_channelPath;
+  std::string m_outputFile;
+  
+  Ptr<SpectrumChannel> m_channel;
+};
+
+
+}
+
+#endif /* RADIO_ENVIRONMENT_MAP_HELPER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/rem-spectrum-phy.cc	Mon Jan 16 19:54:48 2012 +0100
@@ -0,0 +1,159 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2009 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 <ns3/object-factory.h>
+#include <ns3/log.h>
+#include <ns3/double.h>
+#include <ns3/simulator.h>
+#include <ns3/trace-source-accessor.h>
+#include <ns3/antenna-model.h>
+
+#include "rem-spectrum-phy.h"
+
+NS_LOG_COMPONENT_DEFINE ("RemSpectrumPhy");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (RemSpectrumPhy);
+
+RemSpectrumPhy::RemSpectrumPhy ()
+  : m_mobility (0),
+    m_netDevice (0),
+    m_channel (0),
+    m_referenceSignalPower (0),
+    m_sumPower (0)
+{
+  NS_LOG_FUNCTION (this);
+}
+
+
+
+RemSpectrumPhy::~RemSpectrumPhy ()
+{
+  NS_LOG_FUNCTION (this);
+}
+
+void
+RemSpectrumPhy::DoDispose ()
+{
+  NS_LOG_FUNCTION (this);
+  m_mobility = 0;
+  m_netDevice = 0;
+  m_channel = 0;
+  SpectrumPhy::DoDispose ();
+}
+
+TypeId
+RemSpectrumPhy::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::RemSpectrumPhy")
+    .SetParent<SpectrumPhy> ()
+    .AddConstructor<RemSpectrumPhy> ()
+    .AddAttribute ("NoisePower",
+                   "the power of the measuring instrument noise, in Watts. Default to a kT of -174 dBm with a noise figure of 9 dB and a bandwidth of 25 LTE Resource Blocks",
+                   DoubleValue (1.4230e-10),
+                   MakeDoubleAccessor (&RemSpectrumPhy::m_noisePower),
+                   MakeDoubleChecker<double> ())
+    ;
+  return tid;
+}
+
+
+
+Ptr<NetDevice>
+RemSpectrumPhy::GetDevice ()
+{
+  return m_netDevice;
+}
+
+
+Ptr<MobilityModel>
+RemSpectrumPhy::GetMobility ()
+{
+  return m_mobility;
+}
+
+
+Ptr<const SpectrumModel>
+RemSpectrumPhy::GetRxSpectrumModel () const
+{
+  return m_spectrumModel;
+}
+
+void
+RemSpectrumPhy::SetDevice (Ptr<NetDevice> d)
+{
+  NS_LOG_FUNCTION (this << d);
+  m_netDevice = d;
+}
+
+
+void
+RemSpectrumPhy::SetMobility (Ptr<MobilityModel> m)
+{
+  NS_LOG_FUNCTION (this << m);
+  m_mobility = m;
+}
+
+
+void
+RemSpectrumPhy::SetChannel (Ptr<SpectrumChannel> c)
+{
+  NS_LOG_FUNCTION (this << c);
+  m_channel = c;
+}
+
+void
+RemSpectrumPhy::SetRxSpectrumModel (Ptr<SpectrumModel> m)
+{
+  NS_LOG_FUNCTION (this << m);
+  m_spectrumModel = m;
+}
+
+Ptr<AntennaModel>
+RemSpectrumPhy::GetRxAntenna ()
+{
+  return 0;
+}
+
+
+void
+RemSpectrumPhy::StartRx (Ptr<SpectrumSignalParameters> params)
+{
+  NS_LOG_FUNCTION ( this << params);
+  double power = Integral (*(params->psd));
+  NS_ASSERT_MSG (params->duration.GetMilliSeconds () == 1, 
+                 "RemSpectrumPhy works only for LTE signals with duration of 1 ms");
+  m_sumPower += power;
+  if (power > m_referenceSignalPower)
+    {
+      m_referenceSignalPower = power;
+    }
+}
+
+double
+RemSpectrumPhy::GetSinr ()
+{
+  return m_referenceSignalPower / (m_sumPower + m_noisePower);
+}
+
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/lte/model/rem-spectrum-phy.h	Mon Jan 16 19:54:48 2012 +0100
@@ -0,0 +1,105 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2012 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 REM_SPECTRUM_PHY_H
+#define REM_SPECTRUM_PHY_H
+
+
+#include <ns3/spectrum-value.h>
+#include <ns3/mobility-model.h>
+#include <ns3/packet.h>
+#include <ns3/nstime.h>
+#include <ns3/net-device.h>
+#include <ns3/spectrum-phy.h>
+#include <ns3/spectrum-channel.h>
+#include <string>
+#include <fstream>
+
+namespace ns3 {
+
+
+/**
+ *
+ * This minimal SpectrumPhy implemetation calculates the SINR with
+ * respect to the strongest signal for a given point. The original
+ * purpose of this class is to be used to generate a
+ * Radio Environment Map (REM) by locating several instances in a grid
+ * fashion, and connecting them to the channel only for a very short
+ * amount of time. 
+ *
+ * The assumption on which this class works is that the system
+ * being considered is an infrastructured radio access network using
+ * FDD, hence all signals will be transmitted simultaneously. 
+ */
+class RemSpectrumPhy : public SpectrumPhy
+{
+
+public:
+  RemSpectrumPhy ();
+  virtual ~RemSpectrumPhy ();
+
+  static TypeId GetTypeId (void);
+
+// inherited from SpectrumPhy
+  void SetChannel (Ptr<SpectrumChannel> c);
+  void SetMobility (Ptr<MobilityModel> m);
+  void SetDevice (Ptr<NetDevice> d);
+  Ptr<MobilityModel> GetMobility ();
+  Ptr<NetDevice> GetDevice ();
+  Ptr<const SpectrumModel> GetRxSpectrumModel () const;
+  Ptr<AntennaModel> GetRxAntenna ();
+  void StartRx (Ptr<SpectrumSignalParameters> params);
+
+  void SetRxSpectrumModel (Ptr<SpectrumModel>); 
+  
+  /** 
+   * 
+   * 
+   * \return the Signal to Noise Ratio calculated 
+   */
+  double GetSinr ();
+
+protected:
+  void DoDispose ();
+
+private:
+  Ptr<MobilityModel> m_mobility;
+  Ptr<NetDevice> m_netDevice;
+  Ptr<SpectrumChannel> m_channel;
+  Ptr<SpectrumModel> m_spectrumModel;
+
+  double m_referenceSignalPower;
+  double m_sumPower;
+  double m_noisePower;  
+
+};
+
+
+
+
+
+
+}
+
+
+
+
+
+#endif /* REM_SPECTRUM_PHY_H */
--- a/src/lte/wscript	Mon Jan 16 19:26:57 2012 +0100
+++ b/src/lte/wscript	Mon Jan 16 19:54:48 2012 +0100
@@ -38,6 +38,8 @@
         'helper/epc-helper.cc',
         'helper/radio-bearer-stats-calculator.cc',
         'helper/mac-stats-calculator.cc',
+        'helper/radio-environment-map-helper.cc',
+        'model/rem-spectrum-phy.cc',
         'model/ff-mac-csched-sap.cc',
         'model/ff-mac-sched-sap.cc',
         'model/lte-mac-sap.cc',
@@ -125,6 +127,8 @@
         'helper/epc-helper.h',
         'helper/mac-stats-calculator.h',
         'helper/radio-bearer-stats-calculator.h',
+        'helper/radio-environment-map-helper.h',    
+        'model/rem-spectrum-phy.h',    
         'model/ff-mac-common.h',
         'model/ff-mac-csched-sap.h',
         'model/ff-mac-sched-sap.h',