mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 18:13:57 +02:00
Refactor leo propagation test case
This commit is contained in:
parent
0b239204b4
commit
fccc05f6c2
1 changed files with 61 additions and 90 deletions
|
@ -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<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (6.7e6, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (-7.0e6, 0, 0));
|
||||
|
||||
Ptr<LeoPropagationLossModel> model = CreateObject<LeoPropagationLossModel> ();
|
||||
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<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (6.7e6, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (-7.0e6, 0, 0));
|
||||
|
||||
Ptr<LeoPropagationLossModel> model = CreateObject<LeoPropagationLossModel> ();
|
||||
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<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (7e6, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (7.1e6, 0, 0));
|
||||
|
||||
Ptr<LeoPropagationLossModel> model = CreateObject<LeoPropagationLossModel> ();
|
||||
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<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (1000000.0, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (1000001.0, 0, 0));
|
||||
|
||||
Ptr<LeoPropagationLossModel> model = CreateObject<LeoPropagationLossModel> ();
|
||||
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<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (1000000.0, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (1000000.0, sin (M_PI / 9) * 1000000.0, 0));
|
||||
|
||||
Ptr<LeoPropagationLossModel> model = CreateObject<LeoPropagationLossModel> ();
|
||||
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<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (1000000.0, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (1000000.0, sin (M_PI / 9) * 1000000.0, 0));
|
||||
|
||||
Ptr<LeoPropagationLossModel> model = CreateObject<LeoPropagationLossModel> ();
|
||||
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<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (7e6, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (7.1e6, 0, 0));
|
||||
|
||||
Ptr<LeoPropagationLossModel> model = CreateObject<LeoPropagationLossModel> ();
|
||||
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<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (1000000.0, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (1000001.0, 0, 0));
|
||||
|
||||
Ptr<LeoPropagationLossModel> model = CreateObject<LeoPropagationLossModel> ();
|
||||
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue