Lena Helper updated for managing fading module and lena-fading.cc example works
This commit is contained in:
@@ -147,16 +147,16 @@ BuildingsPropagationLossModel::GetTypeId (void)
|
||||
MakeEnumAccessor (&BuildingsPropagationLossModel::SetEnvironment,
|
||||
&BuildingsPropagationLossModel::GetEnvironment),
|
||||
MakeEnumChecker (BuildingsPropagationLossModel::Urban, "Urban",
|
||||
BuildingsPropagationLossModel::SubUrban, "SubUrban",
|
||||
BuildingsPropagationLossModel::OpenAreas, "OpenAreas"))
|
||||
BuildingsPropagationLossModel::SubUrban, "SubUrban",
|
||||
BuildingsPropagationLossModel::OpenAreas, "OpenAreas"))
|
||||
|
||||
.AddAttribute ("CitySize",
|
||||
"Dimension of the city",
|
||||
EnumValue (BuildingsPropagationLossModel::Large),
|
||||
MakeEnumAccessor (&BuildingsPropagationLossModel::SetCitySize),
|
||||
MakeEnumChecker (BuildingsPropagationLossModel::Small, "Small",
|
||||
BuildingsPropagationLossModel::Medium, "Medium",
|
||||
BuildingsPropagationLossModel::Large, "Large"));
|
||||
BuildingsPropagationLossModel::Medium, "Medium",
|
||||
BuildingsPropagationLossModel::Large, "Large"));
|
||||
|
||||
|
||||
return tid;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* 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>
|
||||
* Author: Marco Miozzo <marco.miozzo@cttc.es>
|
||||
*/
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include "ns3/mobility-module.h"
|
||||
#include "ns3/lte-module.h"
|
||||
#include "ns3/config-store.h"
|
||||
#include <ns3/string.h>
|
||||
//#include "ns3/gtk-config-store.h"
|
||||
using namespace ns3;
|
||||
|
||||
@@ -42,22 +43,27 @@ int main (int argc, char *argv[])
|
||||
//inputConfig.ConfigureDefaults ();
|
||||
|
||||
// parse again so you can override default values from the command line
|
||||
cmd.Parse (argc, argv);
|
||||
//cmd.Parse (argc, argv);
|
||||
|
||||
Ptr<LenaHelper> lena = CreateObject<LenaHelper> ();
|
||||
|
||||
//lena->EnableLogComponents ();
|
||||
|
||||
// LogComponentEnable ("LtePhy", LOG_LEVEL_ALL);
|
||||
// LogComponentEnable ("LteEnbPhy", LOG_LEVEL_ALL);
|
||||
// LogComponentEnable ("LteUePhy", LOG_LEVEL_ALL);
|
||||
// LogComponentEnable ("PfFfMacScheduler", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("LenaHelper", LOG_LEVEL_ALL);
|
||||
// LogComponentEnable ("BuildingsPropagationLossModel", LOG_LEVEL_ALL);
|
||||
LogComponentEnable ("TraceFadingLossModel", LOG_LEVEL_ALL);
|
||||
|
||||
lena->SetAttribute ("FadingModel", StringValue ("ns3::TraceFadingLossModel"));
|
||||
lena->SetFadingModelAttribute ("TraceFilename", StringValue ("src/lte/model/FadingTraces/fading_trace_EPA_3kmph.fad"));
|
||||
// these parameters have to setted only in case of the trace format
|
||||
// differs from the standard one, that is
|
||||
// - 10 seconds length trace
|
||||
// - 10,000 samples
|
||||
// - 0.5 seconds for window size
|
||||
// - 100 RB
|
||||
lena->SetFadingModelAttribute ("TraceLength", TimeValue (Seconds (10.0)));
|
||||
lena->SetFadingModelAttribute ("SamplesNum", UintegerValue (10000));
|
||||
lena->SetFadingModelAttribute ("WindowSize", TimeValue (Seconds (0.5)));
|
||||
lena->SetFadingModelAttribute ("RbNum", UintegerValue (100));
|
||||
|
||||
// Create Nodes: eNodeB and UE
|
||||
NodeContainer enbNodes;
|
||||
|
||||
@@ -94,7 +94,7 @@ LenaHelper::DoStart (void)
|
||||
}
|
||||
if (m_fadingModelFactory.GetTypeId ().GetName ().compare ( "ns3::TraceFadingLossModel") == 0)
|
||||
{
|
||||
m_fadingModule = CreateObject<TraceFadingLossModel> ();
|
||||
m_fadingModule = m_fadingModelFactory.Create<TraceFadingLossModel> ();
|
||||
m_downlinkChannel->AddSpectrumPropagationLossModel (m_fadingModule);
|
||||
m_uplinkChannel->AddSpectrumPropagationLossModel (m_fadingModule);
|
||||
}
|
||||
@@ -190,7 +190,6 @@ LenaHelper::SetFadingModel (std::string type)
|
||||
void
|
||||
LenaHelper::SetFadingModelAttribute (std::string n, const AttributeValue &v)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << n);
|
||||
m_fadingModelFactory.Set (n, v);
|
||||
}
|
||||
|
||||
@@ -376,10 +375,13 @@ LenaHelper::Attach (Ptr<NetDevice> ueDevice, Ptr<NetDevice> enbDevice)
|
||||
|
||||
if (m_fadingModelFactory.GetTypeId ().GetName ().compare ( "ns3::TraceFadingLossModel") == 0)
|
||||
{
|
||||
Ptr<MobilityModel> mm_enb = enbDevice->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> mm_ue = ueDevice->GetObject<MobilityModel> ();
|
||||
m_fadingModule->CreateFadingChannelRealization (mm_enb, mm_ue); //downlink
|
||||
m_fadingModule->CreateFadingChannelRealization (mm_ue, mm_enb); //uplink
|
||||
Ptr<MobilityModel> mm_enb_dl = enbPhy->GetDownlinkSpectrumPhy ()->GetMobility ()->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> mm_ue_ul = uePhy->GetUplinkSpectrumPhy ()->GetMobility ()->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> mm_enb_ul = enbPhy->GetUplinkSpectrumPhy ()->GetMobility ()->GetObject<MobilityModel> ();
|
||||
Ptr<MobilityModel> mm_ue_dl = uePhy->GetDownlinkSpectrumPhy ()->GetMobility ()->GetObject<MobilityModel> ();
|
||||
|
||||
m_fadingModule->CreateFadingChannelRealization (mm_enb_dl, mm_ue_dl); //downlink eNB -> UE
|
||||
m_fadingModule->CreateFadingChannelRealization (mm_ue_ul, mm_enb_ul); //uplink UE -> eNB
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -216,14 +216,13 @@ private:
|
||||
Ptr<PropagationLossModel> m_uplinkPropagationLossModel;
|
||||
|
||||
ObjectFactory m_schedulerFactory;
|
||||
ObjectFactory m_propagationModelFactory;
|
||||
|
||||
ObjectFactory m_dlPropagationModelFactory;
|
||||
ObjectFactory m_ulPropagationModelFactory;
|
||||
|
||||
ObjectFactory m_fadingModelFactory;
|
||||
|
||||
Ptr<TraceFadingLossModel> m_fadingModule;
|
||||
Ptr<TraceFadingLossModel> m_fadingModule;
|
||||
|
||||
Ptr<MacStatsCalculator> m_macStats;
|
||||
Ptr<RlcStatsCalculator> m_rlcStats;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Giuseppe Piro <g.piro@poliba.it>
|
||||
* Author: Marco Miozzo <mmiozzo@cttc.es>
|
||||
* Marco Miozzo <mmiozzo@cttc.es>
|
||||
*/
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <ns3/log.h>
|
||||
#include <ns3/string.h>
|
||||
#include <ns3/double.h>
|
||||
#include "ns3/uinteger.h"
|
||||
#include <fstream>
|
||||
#include <ns3/simulator.h>
|
||||
|
||||
@@ -38,10 +39,6 @@ NS_OBJECT_ENSURE_REGISTERED (TraceFadingLossModel);
|
||||
|
||||
|
||||
TraceFadingLossModel::TraceFadingLossModel ()
|
||||
: m_traceLength (10.0),
|
||||
m_samplesNum (10000),
|
||||
m_windowSize (0.5),
|
||||
m_rbNum (100)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
SetNext (NULL);
|
||||
@@ -61,29 +58,47 @@ TraceFadingLossModel::GetTypeId (void)
|
||||
.SetParent<SpectrumPropagationLossModel> ()
|
||||
.AddConstructor<TraceFadingLossModel> ()
|
||||
.AddAttribute ("TraceFilename",
|
||||
"Name of file to load a trace from. By default, uses /JakesTraces/fading_trace_EPA_3kmph.fad",
|
||||
"Name of file to load a trace from.",
|
||||
StringValue (""),
|
||||
MakeStringAccessor (&TraceFadingLossModel::m_traceFile),
|
||||
MakeStringAccessor (&TraceFadingLossModel::SetTraceFileName),
|
||||
MakeStringChecker ())
|
||||
.AddAttribute ("TraceLength",
|
||||
"The total length of the fading trace (default value 10 s.)",
|
||||
TimeValue (Seconds (10.0)),
|
||||
MakeTimeAccessor (&TraceFadingLossModel::m_traceLength),
|
||||
MakeTimeAccessor (&TraceFadingLossModel::SetTraceLength),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("SamplesNum",
|
||||
"The number of samples the trace is made of (default 10000)",
|
||||
DoubleValue (10000),
|
||||
MakeDoubleAccessor (&TraceFadingLossModel::m_samplesNum),
|
||||
MakeDoubleChecker<double> ())
|
||||
UintegerValue (10000),
|
||||
MakeUintegerAccessor (&TraceFadingLossModel::m_samplesNum),
|
||||
MakeUintegerChecker<uint32_t> ())
|
||||
.AddAttribute ("WindowSize",
|
||||
"The size of the window for the fading trace (default value 0.5 s.)",
|
||||
TimeValue (Seconds (0.5)),
|
||||
MakeTimeAccessor (&TraceFadingLossModel::m_windowSize),
|
||||
MakeTimeChecker ())
|
||||
.AddAttribute ("RbNum",
|
||||
"The number of RB the trace is made of (default 100)",
|
||||
UintegerValue (100),
|
||||
MakeUintegerAccessor (&TraceFadingLossModel::m_rbNum),
|
||||
MakeUintegerChecker<uint8_t> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
||||
void
|
||||
TraceFadingLossModel::SetTraceFileName (std::string fileName)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << "Set Fading Trace " << fileName);
|
||||
|
||||
m_traceFile = fileName;
|
||||
}
|
||||
|
||||
void
|
||||
TraceFadingLossModel::SetTraceLength (Time t)
|
||||
{
|
||||
m_traceLength = t;
|
||||
}
|
||||
|
||||
void
|
||||
TraceFadingLossModel::LoadTrace ()
|
||||
@@ -98,8 +113,8 @@ TraceFadingLossModel::LoadTrace ()
|
||||
NS_ASSERT_MSG(ifTraceFile.good (), " Fading trace file not found");
|
||||
}
|
||||
|
||||
NS_LOG_INFO (this << " length " << m_traceLength.GetSeconds ());
|
||||
NS_LOG_INFO (this << " RB " << m_rbNum << " samples " << m_samplesNum);
|
||||
// NS_LOG_INFO (this << " length " << m_traceLength.GetSeconds ());
|
||||
// NS_LOG_INFO (this << " RB " << (uint32_t)m_rbNum << " samples " << m_samplesNum);
|
||||
for (uint32_t i = 0; i < m_rbNum; i++)
|
||||
{
|
||||
FadingTraceSample rbTimeFadingTrace;
|
||||
@@ -111,7 +126,6 @@ TraceFadingLossModel::LoadTrace ()
|
||||
}
|
||||
m_fadingTrace.push_back (rbTimeFadingTrace);
|
||||
}
|
||||
ifTraceFile.close ();
|
||||
m_timeGranularity = m_traceLength.GetMilliSeconds () / m_samplesNum;
|
||||
}
|
||||
|
||||
@@ -199,7 +213,7 @@ TraceFadingLossModel::CreateFadingChannelRealization (Ptr<const MobilityModel> e
|
||||
UniformVariable* startV = new UniformVariable (1, (m_traceLength.GetSeconds () - m_windowSize.GetSeconds ()) * 1000.0);
|
||||
ChannelRealizationId_t mobilityPair = std::make_pair (enbMobility,ueMobility);
|
||||
m_startVariableMap.insert (std::pair<ChannelRealizationId_t,UniformVariable* > (mobilityPair, startV));
|
||||
m_windowOffsetsMap.insert (std::pair<ChannelRealizationId_t,int> (mobilityPair, startV->GetValue ()));
|
||||
m_windowOffsetsMap.insert (std::pair<ChannelRealizationId_t,int> (mobilityPair, startV->GetValue ()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Giuseppe Piro <g.piro@poliba.it>
|
||||
* Author: Marco Miozzo <mmiozzo@cttc.es>
|
||||
* Marco Miozzo <mmiozzo@cttc.es>
|
||||
*/
|
||||
|
||||
|
||||
@@ -85,6 +85,9 @@ private:
|
||||
*/
|
||||
double GetValue (int subChannel, double speed);
|
||||
|
||||
void SetTraceFileName (std::string fileName);
|
||||
void SetTraceLength (Time t);
|
||||
|
||||
void LoadTrace ();
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user