diff --git a/test/leo-propagation-test-suite.cc b/test/leo-propagation-test-suite.cc index 7dd9a0d..f0b7dcd 100644 --- a/test/leo-propagation-test-suite.cc +++ b/test/leo-propagation-test-suite.cc @@ -11,117 +11,88 @@ using namespace ns3; class LeoPropagationRxNoLosTestCase : public TestCase { public: - LeoPropagationRxNoLosTestCase () - : TestCase ("Test RxNoLos for without LOS") - {} - virtual ~LeoPropagationRxNoLosTestCase () - {} - + LeoPropagationRxNoLosTestCase () : TestCase ("no reception without line-of-sight") {} + virtual ~LeoPropagationRxNoLosTestCase () {} private: - virtual void DoRun (void); + virtual void DoRun (void) + { + Ptr a = CreateObject (); + a->SetPosition (Vector3D (6.7e6, 0, 0)); + Ptr b = CreateObject (); + b->SetPosition (Vector3D (-7.0e6, 0, 0)); + + Ptr model = CreateObject (); + model->SetAttribute ("ElevationAngle", DoubleValue (10.0)); + + NS_TEST_ASSERT_MSG_LT (model->CalcRxPower (1.0, a, b), -500.0, "received transmission on destination without line-of-sight"); + } }; -void -LeoPropagationRxNoLosTestCase::DoRun () -{ - Ptr a = CreateObject (); - a->SetPosition (Vector3D (6.7e6, 0, 0)); - Ptr b = CreateObject (); - b->SetPosition (Vector3D (-7.0e6, 0, 0)); - - Ptr model = CreateObject (); - model->SetAttribute ("MaxDistance", DoubleValue (6000)); // km - model->SetAttribute ("ElevationAngle", DoubleValue (10.0)); - - NS_TEST_ASSERT_MSG_LT (model->CalcRxPower (1.0, a, b), -500.0, "0 Rx power without LOS"); -} - class LeoPropagationRxLosTestCase : public TestCase { public: - LeoPropagationRxLosTestCase () - : TestCase ("Test Rx with LOS") - {} - virtual ~LeoPropagationRxLosTestCase () - {} - + LeoPropagationRxLosTestCase () : TestCase ("reception of neighboring nodes") {} + virtual ~LeoPropagationRxLosTestCase () {} private: - virtual void DoRun (void); + virtual void DoRun (void) + { + Ptr a = CreateObject (); + a->SetPosition (Vector3D (7e6, 0, 0)); + Ptr b = CreateObject (); + b->SetPosition (Vector3D (7.1e6, 0, 0)); + + Ptr model = CreateObject (); + model->SetAttribute ("ElevationAngle", DoubleValue (10.0)); + model->SetAttribute ("AtmosphericLoss", DoubleValue (0.0)); + model->SetAttribute ("FreeSpacePathLoss", DoubleValue (0.0)); + model->SetAttribute ("LinkMargin", DoubleValue (0.0)); + + NS_TEST_ASSERT_MSG_EQ (model->CalcRxPower (1.0, a, b), 1.0, "Tx not same as Rx power"); + } }; -void -LeoPropagationRxLosTestCase::DoRun () -{ - Ptr a = CreateObject (); - a->SetPosition (Vector3D (1000000.0, 0, 0)); - Ptr b = CreateObject (); - b->SetPosition (Vector3D (1000001.0, 0, 0)); - - Ptr model = CreateObject (); - model->SetAttribute ("ElevationAngle", DoubleValue (10.0)); - model->SetAttribute ("AtmosphericLoss", DoubleValue (0.0)); - model->SetAttribute ("FreeSpacePathLoss", DoubleValue (0.0)); - model->SetAttribute ("LinkMargin", DoubleValue (0.0)); - - NS_TEST_ASSERT_MSG_EQ (model->CalcRxPower (1.0, a, b), 1.0, "Tx same as Rx power without losses and LOS"); -} - class LeoPropagationBadAngleTestCase : public TestCase { public: - LeoPropagationBadAngleTestCase () - : TestCase ("Test Rx with too large elevation angle") - {} - virtual ~LeoPropagationBadAngleTestCase () - {} - + LeoPropagationBadAngleTestCase () : TestCase ("no reception outside of beam") {} + virtual ~LeoPropagationBadAngleTestCase () {} private: - virtual void DoRun (void); + void DoRun () + { + Ptr a = CreateObject (); + a->SetPosition (Vector3D (1000000.0, 0, 0)); + Ptr b = CreateObject (); + b->SetPosition (Vector3D (1000000.0, sin (M_PI / 9) * 1000000.0, 0)); + + Ptr model = CreateObject (); + model->SetAttribute ("ElevationAngle", DoubleValue (90)); + + NS_TEST_ASSERT_MSG_LT (model->CalcRxPower (1.0, a, b), -500.0, "reception outside of beam"); + } }; -void -LeoPropagationBadAngleTestCase::DoRun () -{ - Ptr a = CreateObject (); - a->SetPosition (Vector3D (1000000.0, 0, 0)); - Ptr b = CreateObject (); - b->SetPosition (Vector3D (1000000.0, sin (M_PI / 9) * 1000000.0, 0)); - - Ptr model = CreateObject (); - model->SetAttribute ("ElevationAngle", DoubleValue (90)); - - NS_TEST_ASSERT_MSG_LT (model->CalcRxPower (1.0, a, b), -500.0, "Tx must be 0 if elevation is too large"); -} - class LeoPropagationLossTestCase : public TestCase { public: - LeoPropagationLossTestCase () - : TestCase ("Test Rx with some losses") - {} - virtual ~LeoPropagationLossTestCase () - {} - + LeoPropagationLossTestCase () : TestCase ("path losses are applied") {} + virtual ~LeoPropagationLossTestCase () {} private: - virtual void DoRun (void); + void DoRun () + { + Ptr a = CreateObject (); + a->SetPosition (Vector3D (7e6, 0, 0)); + Ptr b = CreateObject (); + b->SetPosition (Vector3D (7.1e6, 0, 0)); + + Ptr model = CreateObject (); + model->SetAttribute ("AtmosphericLoss", DoubleValue (0.1)); + model->SetAttribute ("FreeSpacePathLoss", DoubleValue (0.1)); + model->SetAttribute ("LinkMargin", DoubleValue (0.3)); + + NS_TEST_ASSERT_MSG_EQ (model->CalcRxPower (1.0, a, b), 0.5, "Rx power is incorrect"); + } }; -void -LeoPropagationLossTestCase::DoRun () -{ - Ptr a = CreateObject (); - a->SetPosition (Vector3D (1000000.0, 0, 0)); - Ptr b = CreateObject (); - b->SetPosition (Vector3D (1000001.0, 0, 0)); - - Ptr model = CreateObject (); - model->SetAttribute ("AtmosphericLoss", DoubleValue (0.1)); - model->SetAttribute ("FreeSpacePathLoss", DoubleValue (0.1)); - model->SetAttribute ("LinkMargin", DoubleValue (0.3)); - - NS_TEST_ASSERT_MSG_EQ (model->CalcRxPower (1.0, a, b), 0.5, "Tx must be smaller with some losses"); -} - class LeoPropagationTestSuite : public TestSuite { public: