fixed node id logging in LTE
authorNicola Baldo <nbaldo@cttc.es>
Thu, 23 Apr 2015 13:33:58 +0200
changeset 11338 7f7f613e3be9
parent 11337 bd2696da948b
child 11339 6c5838ae1366
fixed node id logging in LTE
src/lte/model/lte-enb-phy.cc
src/lte/model/lte-ue-phy.cc
--- a/src/lte/model/lte-enb-phy.cc	Sun Apr 19 21:39:32 2015 +0200
+++ b/src/lte/model/lte-enb-phy.cc	Thu Apr 23 13:33:58 2015 +0200
@@ -152,7 +152,6 @@
   m_harqPhyModule = Create <LteHarqPhy> ();
   m_downlinkSpectrumPhy->SetHarqPhyModule (m_harqPhyModule);
   m_uplinkSpectrumPhy->SetHarqPhyModule (m_harqPhyModule);
-  Simulator::ScheduleNow (&LteEnbPhy::StartFrame, this);
 }
 
 TypeId
@@ -250,6 +249,25 @@
 LteEnbPhy::DoInitialize ()
 {
   NS_LOG_FUNCTION (this);
+  bool haveNodeId = false;
+  uint32_t nodeId;
+  if (m_netDevice != 0)
+    {
+      Ptr<Node> node = m_netDevice->GetNode ();
+      if (node != 0)
+        {
+          nodeId = node->GetId ();
+          haveNodeId = true;
+        }
+    }
+  if (haveNodeId)
+    {
+      Simulator::ScheduleWithContext (nodeId, Seconds (0), &LteEnbPhy::StartFrame, this);
+    }
+  else
+    {
+      Simulator::ScheduleNow (&LteEnbPhy::StartFrame, this);
+    }
   Ptr<SpectrumValue> noisePsd = LteSpectrumValueHelper::CreateNoisePowerSpectralDensity (m_ulEarfcn, m_ulBandwidth, m_noiseFigure);
   m_uplinkSpectrumPhy->SetNoisePowerSpectralDensity (noisePsd);
   LtePhy::DoInitialize ();
--- a/src/lte/model/lte-ue-phy.cc	Sun Apr 19 21:39:32 2015 +0200
+++ b/src/lte/model/lte-ue-phy.cc	Thu Apr 23 13:33:58 2015 +0200
@@ -22,6 +22,7 @@
 
 #include <ns3/object-factory.h>
 #include <ns3/log.h>
+#include <ns3/node.h>
 #include <cfloat>
 #include <cmath>
 #include <ns3/simulator.h>
@@ -162,7 +163,6 @@
 
   NS_ASSERT_MSG (Simulator::Now ().GetNanoSeconds () == 0,
                  "Cannot create UE devices after simulation started");
-  Simulator::ScheduleNow (&LteUePhy::SubframeIndication, this, 1, 1);
   Simulator::Schedule (m_ueMeasurementsFilterPeriod, &LteUePhy::ReportUeMeasurements, this);
 
   DoReset ();
@@ -302,6 +302,25 @@
 LteUePhy::DoInitialize ()
 {
   NS_LOG_FUNCTION (this);
+  bool haveNodeId = false;
+  uint32_t nodeId;
+  if (m_netDevice != 0)
+    {
+      Ptr<Node> node = m_netDevice->GetNode ();
+      if (node != 0)
+        {
+          nodeId = node->GetId ();
+          haveNodeId = true;
+        }
+    }
+  if (haveNodeId)
+    {
+      Simulator::ScheduleWithContext (nodeId, Seconds (0), &LteUePhy::SubframeIndication, this, 1, 1);
+    }
+  else
+    {
+      Simulator::ScheduleNow (&LteUePhy::SubframeIndication, this, 1, 1);
+    }  
   LtePhy::DoInitialize ();
 }