--- a/src/lte/model/lte-chunk-processor.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/model/lte-chunk-processor.cc Mon Apr 27 13:27:02 2015 +0200
@@ -86,4 +86,18 @@
}
+
+void
+LteSpectrumValueCatcher::ReportValue (const SpectrumValue& value)
+{
+ m_value = value.Copy ();
+}
+
+Ptr<SpectrumValue>
+LteSpectrumValueCatcher::GetValue ()
+{
+ return m_value;
+}
+
+
} // namespace ns3
--- a/src/lte/model/lte-chunk-processor.h Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/model/lte-chunk-processor.h Mon Apr 27 13:27:02 2015 +0200
@@ -88,6 +88,34 @@
std::vector<LteChunkProcessorCallback> m_lteChunkProcessorCallbacks;
};
+
+/**
+ * A sink to be plugged to the callback of LteChunkProcessor allowing
+ * to save and later retrieve the latest reported value
+ *
+ */
+class LteSpectrumValueCatcher
+{
+public:
+
+ /**
+ * function to be plugged to LteChunkProcessor::AddCallback ()
+ *
+ * \param value
+ */
+ void ReportValue (const SpectrumValue& value);
+
+ /**
+ *
+ *
+ * \return the latest value reported by the LteChunkProcessor
+ */
+ Ptr<SpectrumValue> GetValue ();
+
+private:
+ Ptr<SpectrumValue> m_value;
+};
+
} // namespace ns3
--- a/src/lte/test/lte-test-downlink-power-control.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-downlink-power-control.cc Mon Apr 27 13:27:02 2015 +0200
@@ -41,9 +41,11 @@
#include <ns3/lte-ue-rrc.h>
#include "lte-ffr-simple.h"
-#include "lte-test-sinr-chunk-processor.h"
#include <ns3/lte-common.h>
+
+#include <ns3/lte-chunk-processor.h>
+
#include "lte-test-downlink-power-control.h"
#include <ns3/lte-rrc-sap.h>
@@ -441,17 +443,21 @@
Ptr<LtePhy> ue1Phy = ueDevs.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlDataPowerReceived = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlDataPowerReceived = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlDataPowerReceivedCatcher;
+ testDlDataPowerReceived->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlDataPowerReceivedCatcher));
ue1Phy->GetDownlinkSpectrumPhy ()->AddDataPowerChunkProcessor (testDlDataPowerReceived);
- Ptr<LteTestSinrChunkProcessor> testDlCtrlPowerReceived = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlCtrlPowerReceived = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlCtrlPowerReceivedCatcher;
+ testDlCtrlPowerReceived->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlCtrlPowerReceivedCatcher));
ue1Phy->GetDownlinkSpectrumPhy ()->AddRsPowerChunkProcessor (testDlCtrlPowerReceived);
Simulator::Stop (Seconds (0.400));
Simulator::Run ();
- double dataPower = 10.0 * std::log10 (testDlDataPowerReceived->GetSinr ()->operator[] (0));
- double ctrlPower = 10.0 * std::log10 (testDlCtrlPowerReceived->GetSinr ()->operator[] (0));
+ double dataPower = 10.0 * std::log10 (dlDataPowerReceivedCatcher.GetValue ()->operator[] (0));
+ double ctrlPower = 10.0 * std::log10 (dlCtrlPowerReceivedCatcher.GetValue ()->operator[] (0));
double powerDiff = (-1.0)*ctrlPower + dataPower;
NS_LOG_DEBUG ("DataPower: " << dataPower);
--- a/src/lte/test/lte-test-downlink-sinr.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-downlink-sinr.cc Mon Apr 27 13:27:02 2015 +0200
@@ -28,12 +28,12 @@
#include "ns3/boolean.h"
#include "ns3/lte-phy-tag.h"
#include "lte-test-ue-phy.h"
-#include "lte-test-sinr-chunk-processor.h"
#include "ns3/lte-spectrum-signal-parameters.h"
#include "lte-test-downlink-sinr.h"
#include <ns3/lte-control-messages.h>
#include "ns3/lte-helper.h"
+#include <ns3/lte-chunk-processor.h>
using namespace ns3;
@@ -112,7 +112,7 @@
: TestCase ("SINR calculation in downlink Data frame: " + name),
m_sv (sv),
m_sm (sv->GetSpectrumModel ()),
- m_sinr (sinr)
+ m_expectedSinr (sinr)
{
NS_LOG_INFO ("Creating LenaDownlinkSinrTestCase");
}
@@ -121,6 +121,7 @@
{
}
+
void
LteDownlinkDataSinrTestCase::DoRun (void)
{
@@ -135,7 +136,9 @@
dlPhy->SetCellId (cellId);
ulPhy->SetCellId (cellId);
- Ptr<LteTestSinrChunkProcessor> chunkProcessor = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> chunkProcessor = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher actualSinrCatcher;
+ chunkProcessor->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
dlPhy->AddDataSinrChunkProcessor (chunkProcessor);
/**
@@ -260,16 +263,10 @@
Simulator::Stop (Seconds (5.0));
Simulator::Run ();
- /**
- * Check that the values passed to LteChunkProcessor::EvaluateChunk () correspond
- * to known values which have been calculated offline (with octave) for the generated signals
- */
- Ptr<SpectrumValue> calculatedSinr = chunkProcessor->GetSinr ();
-
- NS_LOG_INFO ("Data Frame - Theoretical SINR: " << *m_sinr);
- NS_LOG_INFO ("Data Frame - Calculated SINR: " << *calculatedSinr);
+ NS_LOG_INFO ("Data Frame - Theoretical SINR: " << *m_expectedSinr);
+ NS_LOG_INFO ("Data Frame - Calculated SINR: " << *(actualSinrCatcher.GetValue ()));
- NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(*calculatedSinr, *m_sinr, 0.0000001, "Data Frame - Wrong SINR !");
+ NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(*(actualSinrCatcher.GetValue ()), *m_expectedSinr, 0.0000001, "Data Frame - Wrong SINR !");
dlPhy->Dispose ();
Simulator::Destroy ();
}
@@ -284,7 +281,7 @@
: TestCase ("SINR calculation in downlink Ctrl Frame: " + name),
m_sv (sv),
m_sm (sv->GetSpectrumModel ()),
-m_sinr (sinr)
+m_expectedSinr (sinr)
{
NS_LOG_INFO ("Creating LenaDownlinkCtrlSinrTestCase");
}
@@ -307,9 +304,11 @@
dlPhy->SetCellId (cellId);
ulPhy->SetCellId (cellId);
- Ptr<LteTestSinrChunkProcessor> chunkProcessor = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> chunkProcessor = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher actualSinrCatcher;
+ chunkProcessor->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
dlPhy->AddCtrlSinrChunkProcessor (chunkProcessor);
-
+
/**
* Generate several calls to LteSpectrumPhy::StartRx corresponding to several signals. One will be the signal of interest, i.e., the
* LteSpectrumSignalParametersDlCtrlFrame of the first signal will have the
@@ -432,16 +431,10 @@
Simulator::Stop (Seconds (5.0));
Simulator::Run ();
- /**
- * Check that the values passed to LteChunkProcessor::EvaluateChunk () correspond
- * to known values which have been calculated offline (with octave) for the generated signals
- */
- Ptr<SpectrumValue> calculatedSinr = chunkProcessor->GetSinr ();
+ NS_LOG_INFO ("Ctrl Frame - Theoretical SINR: " << *m_expectedSinr);
+ NS_LOG_INFO ("Ctrl Frame - Calculated SINR: " << *(actualSinrCatcher.GetValue ()));
- NS_LOG_INFO ("Ctrl Frame - Theoretical SINR: " << *m_sinr);
- NS_LOG_INFO ("Ctrl Frame - Calculated SINR: " << *calculatedSinr);
-
- NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(*calculatedSinr, *m_sinr, 0.0000001, "Data Frame - Wrong SINR !");
+ NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL(*(actualSinrCatcher.GetValue ()), *m_expectedSinr, 0.0000001, "Data Frame - Wrong SINR !");
dlPhy->Dispose ();
Simulator::Destroy ();
}
--- a/src/lte/test/lte-test-downlink-sinr.h Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-downlink-sinr.h Mon Apr 27 13:27:02 2015 +0200
@@ -50,7 +50,7 @@
Ptr<SpectrumValue> m_sv;
Ptr<const SpectrumModel> m_sm;
- Ptr<SpectrumValue> m_sinr;
+ Ptr<SpectrumValue> m_expectedSinr;
};
@@ -59,13 +59,13 @@
public:
LteDownlinkCtrlSinrTestCase (Ptr<SpectrumValue> sv, Ptr<SpectrumValue> sinr, std::string name);
virtual ~LteDownlinkCtrlSinrTestCase ();
-
- private:
- virtual void DoRun (void);
-
- Ptr<SpectrumValue> m_sv;
- Ptr<const SpectrumModel> m_sm;
- Ptr<SpectrumValue> m_sinr;
+
+private:
+ virtual void DoRun (void);
+
+ Ptr<SpectrumValue> m_sv;
+ Ptr<const SpectrumModel> m_sm;
+ Ptr<SpectrumValue> m_expectedSinr;
};
#endif /* LTE_TEST_DOWNLINK_SINR_H */
--- a/src/lte/test/lte-test-frequency-reuse.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-frequency-reuse.cc Mon Apr 27 13:27:02 2015 +0200
@@ -46,7 +46,6 @@
#include "lte-ffr-simple.h"
#include "lte-simple-spectrum-phy.h"
-#include "lte-test-sinr-chunk-processor.h"
#include <ns3/lte-common.h>
#include "lte-test-frequency-reuse.h"
--- a/src/lte/test/lte-test-interference-fr.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-interference-fr.cc Mon Apr 27 13:27:02 2015 +0200
@@ -39,7 +39,7 @@
#include "lte-test-interference-fr.h"
-#include "lte-test-sinr-chunk-processor.h"
+#include <ns3/lte-chunk-processor.h>
#include "lte-simple-spectrum-phy.h"
#include "ns3/spectrum-value.h"
@@ -50,6 +50,8 @@
NS_LOG_COMPONENT_DEFINE ("LteInterferenceFrTest");
+
+
/**
* TestSuite
*/
@@ -82,8 +84,8 @@
: TestCase ("Test: " + name),
m_d1 (d1),
m_d2 (d2),
- m_dlSinrDb (10 * std::log10 (dlSinr)),
- m_ulSinrDb (10 * std::log10 (ulSinr))
+ m_expectedDlSinrDb (10 * std::log10 (dlSinr)),
+ m_expectedUlSinrDb (10 * std::log10 (ulSinr))
{
NS_LOG_INFO ("Creating LteInterferenceFrTestCase");
}
@@ -174,21 +176,29 @@
// we plug in two instances, one for DL and one for UL
Ptr<LtePhy> ue1Phy = ueDevs1.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr1 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlSinr1 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlSinr1Catcher;
+ testDlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr1Catcher));
ue1Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr1);
Ptr<LtePhy> enb1phy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr1 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testUlSinr1 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher ulSinr1Catcher;
+ testUlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr1Catcher));
enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr1);
// same as above for eNB2 and UE2
Ptr<LtePhy> ue2Phy = ueDevs2.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr2 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlSinr2 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlSinr2Catcher;
+ testDlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr2Catcher));
ue2Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr2);
Ptr<LtePhy> enb2phy = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr2 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testUlSinr2 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher ulSinr2Catcher;
+ testUlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr2Catcher));
enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr2);
// need to allow for RRC connection establishment + SRS
@@ -198,33 +208,33 @@
for (uint32_t i = 0; i < 12; i++)
{
- double dlSinr1 = testDlSinr1->GetSinr ()->operator[] (i);
+ double dlSinr1 = dlSinr1Catcher.GetValue ()->operator[] (i);
double dlSinr1Db = 10.0 * std::log10 (dlSinr1);
- NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
+ NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_expectedDlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
- double dlSinr2 = testDlSinr2->GetSinr ()->operator[] (i);
+ double dlSinr2 = dlSinr2Catcher.GetValue ()->operator[] (i);
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2, 0, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
}
for (uint32_t i = 12; i < 24; i++)
{
- double dlSinr1 = testDlSinr1->GetSinr ()->operator[] (i);
+ double dlSinr1 = dlSinr1Catcher.GetValue ()->operator[] (i);
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1, 0, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
- double dlSinr2 = testDlSinr2->GetSinr ()->operator[] (i);
+ double dlSinr2 = dlSinr2Catcher.GetValue ()->operator[] (i);
double dlSinr2Db = 10.0 * std::log10 (dlSinr2);
- NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
+ NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_expectedDlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
}
//FR algorithms do not operate in uplink now, so we do not test it
-// double ulSinr1Db = 10.0 * std::log10 (testUlSinr1->GetSinr ()->operator[] (0));
+// double ulSinr1Db = 10.0 * std::log10 (testUlSinr1->GetValue ()->operator[] (0));
// NS_LOG_DEBUG("ulSinr1Db: "<< ulSinr1Db);
-// NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
+// NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
//
-// double ulSinr2Db = 10.0 * std::log10 (testUlSinr2->GetSinr ()->operator[] (0));
+// double ulSinr2Db = 10.0 * std::log10 (testUlSinr2->GetValue ()->operator[] (0));
// NS_LOG_DEBUG("ulSinr2Db: "<< ulSinr2Db);
-// NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
+// NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
Simulator::Destroy ();
}
@@ -344,21 +354,29 @@
// we plug in two instances, one for DL and one for UL
Ptr<LtePhy> ue1Phy = ueDevs1.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr1 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlSinr1 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlSinr1Catcher;
+ testDlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr1Catcher));
ue1Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr1);
Ptr<LtePhy> enb1phy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr1 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testUlSinr1 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher ulSinr1Catcher;
+ testUlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr1Catcher));
enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr1);
// same as above for eNB2 and UE2
Ptr<LtePhy> ue2Phy = ueDevs2.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr2 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlSinr2 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlSinr2Catcher;
+ testDlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr2Catcher));
ue2Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr2);
Ptr<LtePhy> enb2phy = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr2 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testUlSinr2 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher ulSinr2Catcher;
+ testUlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr2Catcher));
enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr2);
// need to allow for UE Measurement report
@@ -368,46 +386,46 @@
for (uint32_t i = 0; i < 12; i++)
{
- double dlSinr1 = testDlSinr1->GetSinr ()->operator[] (i);
+ double dlSinr1 = dlSinr1Catcher.GetValue ()->operator[] (i);
double dlSinr1Db = 10.0 * std::log10 (dlSinr1);
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_commonDlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
- double dlSinr2 = testDlSinr2->GetSinr ()->operator[] (i);
+ double dlSinr2 = dlSinr2Catcher.GetValue ()->operator[] (i);
double dlSinr2Db = 10.0 * std::log10 (dlSinr2);
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_commonDlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
}
for (uint32_t i = 12; i < 18; i++)
{
- double dlSinr1 = testDlSinr1->GetSinr ()->operator[] (i);
+ double dlSinr1 = dlSinr1Catcher.GetValue ()->operator[] (i);
double dlSinr1Db = 10.0 * std::log10 (dlSinr1);
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_edgeDlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
- double dlSinr2 = testDlSinr2->GetSinr ()->operator[] (i);
+ double dlSinr2 = dlSinr2Catcher.GetValue ()->operator[] (i);
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2, 0, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
}
for (uint32_t i = 18; i < 24; i++)
{
- double dlSinr1 = testDlSinr1->GetSinr ()->operator[] (i);
+ double dlSinr1 = dlSinr1Catcher.GetValue ()->operator[] (i);
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1, 0, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
- double dlSinr2 = testDlSinr2->GetSinr ()->operator[] (i);
+ double dlSinr2 = dlSinr2Catcher.GetValue ()->operator[] (i);
double dlSinr2Db = 10.0 * std::log10 (dlSinr2);
NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_edgeDlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
}
//FR algorithms do not operate in uplink now, so we do not test it
-// double ulSinr1Db = 10.0 * std::log10 (testUlSinr1->GetSinr ()->operator[] (0));
+// double ulSinr1Db = 10.0 * std::log10 (testUlSinr1->GetValue ()->operator[] (0));
// NS_LOG_DEBUG("ulSinr1Db: "<< ulSinr1Db);
-// NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
+// NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
//
-// double ulSinr2Db = 10.0 * std::log10 (testUlSinr2->GetSinr ()->operator[] (0));
+// double ulSinr2Db = 10.0 * std::log10 (testUlSinr2->GetValue ()->operator[] (0));
// NS_LOG_DEBUG("ulSinr2Db: "<< ulSinr2Db);
-// NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
+// NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
Simulator::Destroy ();
}
--- a/src/lte/test/lte-test-interference-fr.h Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-interference-fr.h Mon Apr 27 13:27:02 2015 +0200
@@ -49,8 +49,8 @@
double m_d1;
double m_d2;
- double m_dlSinrDb;
- double m_ulSinrDb;
+ double m_expectedDlSinrDb;
+ double m_expectedUlSinrDb;
};
class LteInterferenceStrictFrTestCase : public TestCase
--- a/src/lte/test/lte-test-interference.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-interference.cc Mon Apr 27 13:27:02 2015 +0200
@@ -35,9 +35,10 @@
#include "ns3/lte-ue-phy.h"
#include "ns3/lte-ue-net-device.h"
+#include <ns3/lte-chunk-processor.h>
+
#include "lte-test-interference.h"
-#include "lte-test-sinr-chunk-processor.h"
using namespace ns3;
@@ -98,8 +99,8 @@
: TestCase (name),
m_d1 (d1),
m_d2 (d2),
- m_dlSinrDb (10 * std::log10 (dlSinr)),
- m_ulSinrDb (10 * std::log10 (ulSinr)),
+ m_expectedDlSinrDb (10 * std::log10 (dlSinr)),
+ m_expectedUlSinrDb (10 * std::log10 (ulSinr)),
m_dlMcs (dlMcs),
m_ulMcs (ulMcs)
{
@@ -177,11 +178,15 @@
// we plug in two instances, one for DL and one for UL
Ptr<LtePhy> ue1Phy = ueDevs1.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr1 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlSinr1 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlSinr1Catcher;
+ testDlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr1Catcher));
ue1Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr1);
Ptr<LtePhy> enb1phy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr1 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testUlSinr1 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher ulSinr1Catcher;
+ testUlSinr1->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr1Catcher));
enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr1);
Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling",
@@ -194,11 +199,15 @@
// same as above for eNB2 and UE2
Ptr<LtePhy> ue2Phy = ueDevs2.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr2 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlSinr2 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlSinr2Catcher;
+ testDlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinr2Catcher));
ue2Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr2);
Ptr<LtePhy> enb2phy = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr2 = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testUlSinr2 = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher ulSinr2Catcher;
+ testUlSinr2->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinr2Catcher));
enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr2);
Config::Connect ("/NodeList/1/DeviceList/0/LteEnbMac/DlScheduling",
@@ -213,19 +222,19 @@
if (m_dlMcs > 0)
{
- double dlSinr1Db = 10.0 * std::log10 (testDlSinr1->GetSinr ()->operator[] (0));
- NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
+ double dlSinr1Db = 10.0 * std::log10 (dlSinr1Catcher.GetValue ()->operator[] (0));
+ NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr1Db, m_expectedDlSinrDb, 0.01, "Wrong SINR in DL! (eNB1 --> UE1)");
- double dlSinr2Db = 10.0 * std::log10 (testDlSinr2->GetSinr ()->operator[] (0));
- NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_dlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
+ double dlSinr2Db = 10.0 * std::log10 (dlSinr2Catcher.GetValue ()->operator[] (0));
+ NS_TEST_ASSERT_MSG_EQ_TOL (dlSinr2Db, m_expectedDlSinrDb, 0.01, "Wrong SINR in DL! (eNB2 --> UE2)");
}
if (m_ulMcs > 0)
{
- double ulSinr1Db = 10.0 * std::log10 (testUlSinr1->GetSinr ()->operator[] (0));
- NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
+ double ulSinr1Db = 10.0 * std::log10 (ulSinr1Catcher.GetValue ()->operator[] (0));
+ NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr1Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE1 --> eNB1)");
- double ulSinr2Db = 10.0 * std::log10 (testUlSinr2->GetSinr ()->operator[] (0));
- NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_ulSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
+ double ulSinr2Db = 10.0 * std::log10 (ulSinr2Catcher.GetValue ()->operator[] (0));
+ NS_TEST_ASSERT_MSG_EQ_TOL (ulSinr2Db, m_expectedUlSinrDb, 0.01, "Wrong SINR in UL! (UE2 --> eNB2)");
}
Simulator::Destroy ();
--- a/src/lte/test/lte-test-interference.h Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-interference.h Mon Apr 27 13:27:02 2015 +0200
@@ -56,8 +56,8 @@
double m_d1;
double m_d2;
- double m_dlSinrDb;
- double m_ulSinrDb;
+ double m_expectedDlSinrDb;
+ double m_expectedUlSinrDb;
uint16_t m_dlMcs;
uint16_t m_ulMcs;
};
--- a/src/lte/test/lte-test-link-adaptation.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-link-adaptation.cc Mon Apr 27 13:27:02 2015 +0200
@@ -31,9 +31,10 @@
#include "ns3/lte-ue-phy.h"
#include "ns3/lte-ue-net-device.h"
+#include <ns3/lte-chunk-processor.h>
+
#include "lte-test-link-adaptation.h"
-#include "lte-test-sinr-chunk-processor.h"
using namespace ns3;
@@ -206,7 +207,9 @@
// Use testing chunk processor in the PHY layer
// It will be used to test that the SNR is as intended
Ptr<LtePhy> uePhy = ueDevs.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testSinr = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testSinr = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher sinrCatcher;
+ testSinr->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &sinrCatcher));
uePhy->GetDownlinkSpectrumPhy ()->AddCtrlSinrChunkProcessor (testSinr);
Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling",
@@ -215,7 +218,7 @@
Simulator::Stop (Seconds (0.040));
Simulator::Run ();
- double calculatedSinrDb = 10.0 * std::log10 (testSinr->GetSinr ()->operator[] (0));
+ double calculatedSinrDb = 10.0 * std::log10 (sinrCatcher.GetValue ()->operator[] (0));
NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinrDb, m_snrDb, 0.0000001, "Wrong SINR !");
Simulator::Destroy ();
}
--- a/src/lte/test/lte-test-pathloss-model.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-pathloss-model.cc Mon Apr 27 13:27:02 2015 +0200
@@ -47,7 +47,6 @@
#include <ns3/lte-enb-phy.h>
#include <ns3/lte-ue-phy.h>
-#include "lte-test-sinr-chunk-processor.h"
#include "lte-test-ue-phy.h"
#include "lte-test-pathloss-model.h"
@@ -271,7 +270,9 @@
// Use testing chunk processor in the PHY layer
// It will be used to test that the SNR is as intended
//Ptr<LtePhy> uePhy = ueDevs.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testSinr = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testSinr = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher sinrCatcher;
+ testSinr->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &sinrCatcher));
uePhy->GetDownlinkSpectrumPhy ()->AddCtrlSinrChunkProcessor (testSinr);
// Config::Connect ("/NodeList/0/DeviceList/0/LteEnbMac/DlScheduling",
@@ -280,7 +281,7 @@
Simulator::Stop (Seconds (0.035));
Simulator::Run ();
- double calculatedSinrDb = 10.0 * std::log10 (testSinr->GetSinr ()->operator[] (0));
+ double calculatedSinrDb = 10.0 * std::log10 (sinrCatcher.GetValue ()->operator[] (0));
NS_LOG_INFO ("Distance " << m_distance << " Calculated SINR " << calculatedSinrDb << " ref " << m_snrDb);
Simulator::Destroy ();
NS_TEST_ASSERT_MSG_EQ_TOL (calculatedSinrDb, m_snrDb, 0.001, "Wrong SINR !");
--- a/src/lte/test/lte-test-sinr-chunk-processor.cc Fri Apr 24 16:53:51 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/* -*- 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> : Based on lte-sinr-chunk-processor code
- * Nicola Baldo <nbaldo>@cttc.es>
- */
-
-#include <ns3/log.h>
-#include <ns3/spectrum-value.h>
-#include "lte-test-sinr-chunk-processor.h"
-
-namespace ns3 {
-
-NS_LOG_COMPONENT_DEFINE ("LteTestSinrChunkProcessor");
-
-LteTestSinrChunkProcessor::LteTestSinrChunkProcessor ()
-{
- NS_LOG_FUNCTION (this);
-}
-
-LteTestSinrChunkProcessor::~LteTestSinrChunkProcessor ()
-{
- NS_LOG_FUNCTION (this);
-}
-
-void
-LteTestSinrChunkProcessor::AddCallback (LteChunkProcessorCallback c)
-{
- NS_LOG_FUNCTION (this);
-}
-
-void
-LteTestSinrChunkProcessor::Start ()
-{
- NS_LOG_FUNCTION (this);
- m_sumSinr = 0;
- m_totDuration = MicroSeconds (0);
-}
-
-void
-LteTestSinrChunkProcessor::EvaluateChunk (const SpectrumValue& sinr, Time duration)
-{
- NS_LOG_FUNCTION (this << sinr << duration);
- if (m_sumSinr == 0)
- {
- m_sumSinr = Create<SpectrumValue> (sinr.GetSpectrumModel ());
- }
- (*m_sumSinr) += sinr * duration.GetSeconds ();
- m_totDuration += duration;
- NS_LOG_LOGIC (this << " m_sumSinr = " << *m_sumSinr);
- NS_LOG_LOGIC (this << " m_totDuration = " << m_totDuration);
-}
-
-void
-LteTestSinrChunkProcessor::End ()
-{
- NS_LOG_FUNCTION (this);
- if (m_totDuration.GetSeconds () > 0)
- {
- NS_LOG_LOGIC (this << " m_sumSinr = " << *m_sumSinr);
- NS_LOG_LOGIC (this << " m_totDuration = " << m_totDuration);
- m_sinr = Create<SpectrumValue> ((*m_sumSinr) / m_totDuration.GetSeconds ());
- NS_LOG_LOGIC (this << " m_sumSinr / m_totDuration = " << *m_sinr);
- }
- else
- {
- NS_LOG_WARN ("m_numSinr == 0");
- }
-}
-
-Ptr<SpectrumValue>
-LteTestSinrChunkProcessor::GetSinr ()
-{
- NS_LOG_FUNCTION (this);
-
- NS_ASSERT (m_sinr);
- return m_sinr;
-}
-
-} // namespace ns3
--- a/src/lte/test/lte-test-sinr-chunk-processor.h Fri Apr 24 16:53:51 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-/* -*- 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> : Based on lte-sinr-chunk-processor code
- * Nicola Baldo <nbaldo@cttc.es>
- */
-
-#ifndef LTE_TEST_SINR_CHUNK_PROCESSOR_H
-#define LTE_TEST_SINR_CHUNK_PROCESSOR_H
-
-#include "ns3/lte-chunk-processor.h"
-
-namespace ns3 {
-
-/**
- * This custom LteTestSinrChunkProcessor averages the calculated SINR over time.
- * It is plugged on the receiving SpectrumPhy and therefore
- * receives the SINR SpectrumValue calculated by the LteInterference module.
- */
-class LteTestSinrChunkProcessor : public LteChunkProcessor
-{
-public:
- LteTestSinrChunkProcessor ();
- virtual ~LteTestSinrChunkProcessor ();
-
- virtual void AddCallback (LteChunkProcessorCallback c);
- virtual void Start ();
- virtual void EvaluateChunk (const SpectrumValue& sinr, Time duration);
- virtual void End ();
-
- Ptr<SpectrumValue> GetSinr ();
-
-private:
- Ptr<SpectrumValue> m_sumSinr;
- Ptr<SpectrumValue> m_sinr;
- Time m_totDuration;
-};
-
-
-} // namespace ns3
-
-#endif /* LTE_TEST_SINR_CHUNK_PROCESSOR_H */
--- a/src/lte/test/lte-test-ue-measurements.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-ue-measurements.cc Mon Apr 27 13:27:02 2015 +0200
@@ -51,7 +51,6 @@
#include <ns3/lte-ue-rrc.h>
#include "lte-test-ue-measurements.h"
-#include "lte-test-sinr-chunk-processor.h"
#include <ns3/lte-common.h>
using namespace ns3;
@@ -198,33 +197,12 @@
lteHelper->ActivateDataRadioBearer (ueDevs1, bearer);
lteHelper->ActivateDataRadioBearer (ueDevs2, bearer);
- // Use testing chunk processor in the PHY layer
- // It will be used to test that the SNR is as intended
- // we plug in two instances, one for DL and one for UL
-
- Ptr<LtePhy> ue1Phy = ueDevs1.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr1 = Create<LteTestSinrChunkProcessor> ();
- ue1Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr1);
-
- Ptr<LtePhy> enb1phy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr1 = Create<LteTestSinrChunkProcessor> ();
- enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr1);
Config::Connect ("/NodeList/2/DeviceList/0/LteUePhy/ReportUeMeasurements",
MakeBoundCallback (&ReportUeMeasurementsCallback, this));
Config::Connect ("/NodeList/0/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
MakeBoundCallback (&RecvMeasurementReportCallback, this));
- // same as above for eNB2 and UE2
-
- Ptr<LtePhy> ue2Phy = ueDevs2.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr2 = Create<LteTestSinrChunkProcessor> ();
- ue2Phy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr2);
-
- Ptr<LtePhy> enb2phy = enbDevs.Get (1)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr2 = Create<LteTestSinrChunkProcessor> ();
- enb1phy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr2);
-
Config::Connect ("/NodeList/3/DeviceList/0/LteUePhy/ReportUeMeasurements",
MakeBoundCallback (&ReportUeMeasurementsCallback, this));
Config::Connect ("/NodeList/1/DeviceList/0/LteEnbRrc/RecvMeasurementReport",
--- a/src/lte/test/lte-test-uplink-power-control.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-uplink-power-control.cc Mon Apr 27 13:27:02 2015 +0200
@@ -42,7 +42,6 @@
#include <ns3/lte-ue-rrc.h>
#include "lte-ffr-simple.h"
-#include "lte-test-sinr-chunk-processor.h"
#include <ns3/lte-common.h>
#include "lte-test-uplink-power-control.h"
--- a/src/lte/test/lte-test-uplink-sinr.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-uplink-sinr.cc Mon Apr 27 13:27:02 2015 +0200
@@ -28,12 +28,12 @@
#include "ns3/lte-phy-tag.h"
#include "lte-test-ue-phy.h"
-#include "lte-test-sinr-chunk-processor.h"
#include "ns3/lte-spectrum-signal-parameters.h"
#include "lte-test-uplink-sinr.h"
#include <ns3/lte-helper.h>
+#include <ns3/lte-chunk-processor.h>
using namespace ns3;
@@ -121,7 +121,7 @@
m_sv1 (sv1),
m_sv2 (sv2),
m_sm (sv1->GetSpectrumModel ()),
- m_sinr (sinr)
+ m_expectedSinr (sinr)
{
NS_LOG_INFO ("Creating LteUplinkDataSinrTestCase");
}
@@ -130,6 +130,7 @@
{
}
+
void
LteUplinkDataSinrTestCase::DoRun (void)
{
@@ -143,7 +144,9 @@
dlPhy->SetCellId (cellId);
ulPhy->SetCellId (cellId);
- Ptr<LteTestSinrChunkProcessor> chunkProcessor = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> chunkProcessor = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher actualSinrCatcher;
+ chunkProcessor->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &actualSinrCatcher));
ulPhy->AddDataSinrChunkProcessor (chunkProcessor);
/**
@@ -294,16 +297,12 @@
Simulator::Stop (Seconds (5.0));
Simulator::Run ();
- /**
- * Check that the values passed to LteChunkProcessor::EvaluateChunk () correspond
- * to known values which have been calculated offline (with octave) for the generated signals
- */
- Ptr<SpectrumValue> calculatedSinr = chunkProcessor->GetSinr ();
+ NS_LOG_INFO ("Data Frame - Theoretical SINR: " << *m_expectedSinr);
+ NS_LOG_INFO ("Data Frame - Calculated SINR: " << *(actualSinrCatcher.GetValue ()));
- NS_LOG_INFO ("Data Frame - Theoretical SINR: " << *m_sinr);
- NS_LOG_INFO ("Data Frame - Calculated SINR: " << *calculatedSinr);
-
- NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL (*calculatedSinr, *m_sinr, 0.0000001, "Data Frame - Wrong SINR !");
+ NS_TEST_EXPECT_MSG_NE (actualSinrCatcher.GetValue (), 0, "no actual SINR reported");
+
+ NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL (*(actualSinrCatcher.GetValue ()), *m_expectedSinr, 0.0000001, "Data Frame - Wrong SINR !");
ulPhy->Dispose ();
Simulator::Destroy ();
@@ -315,11 +314,11 @@
*/
LteUplinkSrsSinrTestCase::LteUplinkSrsSinrTestCase (Ptr<SpectrumValue> sv1, Ptr<SpectrumValue> sv2, Ptr<SpectrumValue> sinr, std::string name)
-: TestCase ("SINR calculation in uplink srs frame: " + name),
-m_sv1 (sv1),
-m_sv2 (sv2),
-m_sm (sv1->GetSpectrumModel ()),
-m_sinr (sinr)
+ : TestCase ("SINR calculation in uplink srs frame: " + name),
+ m_sv1 (sv1),
+ m_sv2 (sv2),
+ m_sm (sv1->GetSpectrumModel ()),
+ m_expectedSinr (sinr)
{
NS_LOG_INFO ("Creating LteUplinkSrsSinrTestCase");
}
@@ -329,6 +328,12 @@
}
void
+LteUplinkSrsSinrTestCase::ReportSinr (const SpectrumValue& sinr)
+{
+ m_actualSinr = sinr.Copy ();
+}
+
+void
LteUplinkSrsSinrTestCase::DoRun (void)
{
/**
@@ -344,9 +349,10 @@
dlPhy->SetCellId (cellId);
ulPhy->SetCellId (cellId);
- Ptr<LteTestSinrChunkProcessor> chunkProcessor = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> chunkProcessor = Create<LteChunkProcessor> ();
+ chunkProcessor->AddCallback (MakeCallback (&LteUplinkSrsSinrTestCase::ReportSinr, this));
ulPhy->AddCtrlSinrChunkProcessor (chunkProcessor);
-
+
/**
* Generate several calls to LteSpectrumPhy::StartRx corresponding to
* several signals.
@@ -464,16 +470,12 @@
Simulator::Stop (Seconds (5.0));
Simulator::Run ();
- /**
- * Check that the values passed to LteChunkProcessor::EvaluateChunk () correspond
- * to known values which have been calculated offline (with octave) for the generated signals
- */
- Ptr<SpectrumValue> calculatedSinr = chunkProcessor->GetSinr ();
+ NS_ASSERT_MSG (m_actualSinr != 0, "no actual SINR reported");
- NS_LOG_INFO ("SRS Frame - Theoretical SINR: " << *m_sinr);
- NS_LOG_INFO ("SRS Frame - Calculated SINR: " << *calculatedSinr);
-
- NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL (*calculatedSinr, *m_sinr, 0.0000001, "Data Frame - Wrong SINR !");
+ NS_LOG_INFO ("SRS Frame - Theoretical SINR: " << *m_expectedSinr);
+ NS_LOG_INFO ("SRS Frame - Calculated SINR: " << *m_actualSinr);
+
+ NS_TEST_ASSERT_MSG_SPECTRUM_VALUE_EQ_TOL (*m_actualSinr, *m_expectedSinr, 0.0000001, "Data Frame - Wrong SINR !");
ulPhy->Dispose ();
Simulator::Destroy ();
--- a/src/lte/test/lte-test-uplink-sinr.h Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/lte-test-uplink-sinr.h Mon Apr 27 13:27:02 2015 +0200
@@ -53,7 +53,7 @@
Ptr<SpectrumValue> m_sv1;
Ptr<SpectrumValue> m_sv2;
Ptr<const SpectrumModel> m_sm;
- Ptr<SpectrumValue> m_sinr;
+ Ptr<SpectrumValue> m_expectedSinr;
};
@@ -63,13 +63,22 @@
LteUplinkSrsSinrTestCase (Ptr<SpectrumValue> sv1, Ptr<SpectrumValue> sv2, Ptr<SpectrumValue> sinr, std::string name);
virtual ~LteUplinkSrsSinrTestCase ();
- private:
- virtual void DoRun (void);
-
- Ptr<SpectrumValue> m_sv1;
- Ptr<SpectrumValue> m_sv2;
- Ptr<const SpectrumModel> m_sm;
- Ptr<SpectrumValue> m_sinr;
+ /**
+ * Callback to be connected to an LteChunkProcessor to collect the reported SINR
+ *
+ * \param sinr
+ */
+ void ReportSinr (const SpectrumValue& sinr);
+
+private:
+ virtual void DoRun (void);
+
+ Ptr<SpectrumValue> m_sv1;
+ Ptr<SpectrumValue> m_sv2;
+ Ptr<const SpectrumModel> m_sm;
+
+ Ptr<SpectrumValue> m_expectedSinr;
+ Ptr<SpectrumValue> m_actualSinr;
};
--- a/src/lte/test/test-lte-antenna.cc Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/test/test-lte-antenna.cc Mon Apr 27 13:27:02 2015 +0200
@@ -37,7 +37,8 @@
#include "ns3/lte-global-pathloss-database.h"
-#include "lte-test-sinr-chunk-processor.h"
+#include <ns3/lte-chunk-processor.h>
+
using namespace ns3;
@@ -148,11 +149,15 @@
// Use testing chunk processor in the PHY layer
// It will be used to test that the SNR is as intended
Ptr<LtePhy> uePhy = ueDevs.Get (0)->GetObject<LteUeNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testDlSinr = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testDlSinr = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher dlSinrCatcher;
+ testDlSinr->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &dlSinrCatcher));
uePhy->GetDownlinkSpectrumPhy ()->AddDataSinrChunkProcessor (testDlSinr);
Ptr<LtePhy> enbphy = enbDevs.Get (0)->GetObject<LteEnbNetDevice> ()->GetPhy ()->GetObject<LtePhy> ();
- Ptr<LteTestSinrChunkProcessor> testUlSinr = Create<LteTestSinrChunkProcessor> ();
+ Ptr<LteChunkProcessor> testUlSinr = Create<LteChunkProcessor> ();
+ LteSpectrumValueCatcher ulSinrCatcher;
+ testUlSinr->AddCallback (MakeCallback (&LteSpectrumValueCatcher::ReportValue, &ulSinrCatcher));
enbphy->GetUplinkSpectrumPhy ()->AddDataSinrChunkProcessor (testUlSinr);
@@ -177,15 +182,15 @@
const double enbNoiseFigureDb = 5.0; // default eNB noise figure
double tolerance = (m_antennaGainDb != 0) ? std::abs (m_antennaGainDb) * 0.001 : 0.001;
- // first test with SINR from LteTestSinrChunkProcessor
+ // first test with SINR from LteChunkProcessor
// this can only be done for not-too-bad SINR otherwise the measurement won't be available
double expectedSinrDl = enbTxPowerDbm + m_antennaGainDb - noisePowerDbm + ueNoiseFigureDb;
if (expectedSinrDl > 0)
{
double calculatedSinrDbDl = -INFINITY;
- if (testDlSinr->GetSinr () != 0)
+ if (dlSinrCatcher.GetValue () != 0)
{
- calculatedSinrDbDl = 10.0 * std::log10 (testDlSinr->GetSinr ()->operator[] (0));
+ calculatedSinrDbDl = 10.0 * std::log10 (dlSinrCatcher.GetValue ()->operator[] (0));
}
// remember that propagation loss is 0dB
double calculatedAntennaGainDbDl = - (enbTxPowerDbm - calculatedSinrDbDl - noisePowerDbm - ueNoiseFigureDb);
@@ -195,9 +200,9 @@
if (expectedSinrUl > 0)
{
double calculatedSinrDbUl = -INFINITY;
- if (testUlSinr->GetSinr () != 0)
+ if (ulSinrCatcher.GetValue () != 0)
{
- calculatedSinrDbUl = 10.0 * std::log10 (testUlSinr->GetSinr ()->operator[] (0));
+ calculatedSinrDbUl = 10.0 * std::log10 (ulSinrCatcher.GetValue ()->operator[] (0));
}
double calculatedAntennaGainDbUl = - (ueTxPowerDbm - calculatedSinrDbUl - noisePowerDbm - enbNoiseFigureDb);
NS_TEST_ASSERT_MSG_EQ_TOL (calculatedAntennaGainDbUl, m_antennaGainDb, tolerance, "Wrong UL antenna gain!");
--- a/src/lte/wscript Fri Apr 24 16:53:51 2015 +0200
+++ b/src/lte/wscript Mon Apr 27 13:27:02 2015 +0200
@@ -129,7 +129,6 @@
'test/lte-test-uplink-sinr.cc',
'test/lte-test-link-adaptation.cc',
'test/lte-test-interference.cc',
- 'test/lte-test-sinr-chunk-processor.cc',
'test/lte-test-ue-phy.cc',
'test/lte-test-rr-ff-mac-scheduler.cc',
'test/lte-test-pf-ff-mac-scheduler.cc',