mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 01:53:58 +02:00
Extend waypoints tests and limit reception by angle and distance
This commit is contained in:
parent
83c5bc3b2e
commit
3fb0969930
6 changed files with 181 additions and 16 deletions
|
@ -1,7 +1,10 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/mobility-model.h"
|
||||
#include "ns3/double.h"
|
||||
|
||||
#include "leo-propagation-loss-model.h"
|
||||
|
||||
|
@ -18,6 +21,16 @@ LeoPropagationLossModel::GetTypeId (void)
|
|||
.SetParent<PropagationLossModel> ()
|
||||
.SetGroupName ("Leo")
|
||||
.AddConstructor<LeoPropagationLossModel> ()
|
||||
.AddAttribute ("MaxDistance",
|
||||
"Cut-off distance for signal propagation",
|
||||
DoubleValue (1000000.0),
|
||||
MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance),
|
||||
MakeDoubleChecker<double> ())
|
||||
.AddAttribute ("MaxAngle",
|
||||
"Cut-off angle for signal propagation",
|
||||
DoubleValue (20.0),
|
||||
MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffAngle),
|
||||
MakeDoubleChecker<double> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
@ -31,17 +44,24 @@ LeoPropagationLossModel::~LeoPropagationLossModel ()
|
|||
}
|
||||
|
||||
double
|
||||
LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
LeoPropagationLossModel::GetAngle (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
|
||||
{
|
||||
//Vector aPos = a->GetPosition ();
|
||||
//Vector bPos = b->GetPosition ();
|
||||
Vector3D pa = a->GetPosition ();
|
||||
Vector3D pb = b->GetPosition ();
|
||||
|
||||
// TODO perform line-earth intersection (ray tracing)
|
||||
// TODO check angle between satellite and ground-station
|
||||
// primitivec cut-of at 1000 km
|
||||
if (a->GetDistanceFrom (b) > 1000000.0)
|
||||
double prod = abs ((pa.x * pb.x) + (pa.y * pb.y) + (pa.z * pb.z));
|
||||
double norm = pb.GetLength () * pa.GetLength ();
|
||||
|
||||
return acos (prod / norm);
|
||||
}
|
||||
|
||||
double
|
||||
LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
{
|
||||
// TODO create attributes for max distance and angle
|
||||
if (a->GetDistanceFrom (b) > m_cutoffDistance && GetAngle (a, b) > m_cutoffAngle)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,21 @@ public:
|
|||
static TypeId GetTypeId (void);
|
||||
LeoPropagationLossModel ();
|
||||
virtual ~LeoPropagationLossModel ();
|
||||
|
||||
static double GetAngle (Ptr<MobilityModel> a, Ptr<MobilityModel> b);
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Cutoff distance for signal
|
||||
*/
|
||||
double m_cutoffDistance;
|
||||
|
||||
/**
|
||||
* Cutoff angle for signal
|
||||
*/
|
||||
double m_cutoffAngle;
|
||||
|
||||
/**
|
||||
* Returns the Rx Power taking into account only the particular
|
||||
* PropagationLossModel.
|
||||
|
|
|
@ -41,10 +41,10 @@ IslIcmpTestCase::DoRun (void)
|
|||
std::vector<std::string> satWps =
|
||||
{
|
||||
// TODO use different waypoints
|
||||
"contrib/leo/data/test/waypoints.txt",
|
||||
"contrib/leo/data/test/waypoints.txt",
|
||||
"contrib/leo/data/test/waypoints.txt",
|
||||
"contrib/leo/data/test/waypoints.txt",
|
||||
"contrib/leo/data/starlink/45391.waypoints",
|
||||
"contrib/leo/data/starlink/45392.waypoints",
|
||||
"contrib/leo/data/starlink/45393.waypoints",
|
||||
"contrib/leo/data/starlink/45394.waypoints",
|
||||
};
|
||||
|
||||
LeoSatNodeHelper satHelper;
|
||||
|
@ -76,7 +76,7 @@ IslIcmpTestCase::DoRun (void)
|
|||
ApplicationContainer clientApps;
|
||||
for (uint32_t i = 0; i < satellites.GetN (); i ++)
|
||||
{
|
||||
UdpEchoClientHelper echoClient (islIp.GetAddress ((i+1) % satellites.GetN (), 0), 9);
|
||||
UdpEchoClientHelper echoClient (islIp.GetAddress ((i+3) % satellites.GetN (), 0), 9);
|
||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (10));
|
||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.0)));
|
||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
|
||||
#include "ns3/leo-module.h"
|
||||
#include "ns3/test.h"
|
||||
#include "ns3/log.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
NS_LOG_COMPONENT_DEFINE ("LeoMobilityTestSuite");
|
||||
|
||||
class LeoMobilityWaypointTestCase : public TestCase
|
||||
{
|
||||
public:
|
||||
|
@ -25,7 +28,7 @@ LeoMobilityWaypointTestCase::DoRun (void)
|
|||
{
|
||||
Ptr<LeoWaypointInputFileStreamContainer> container = CreateObject<LeoWaypointInputFileStreamContainer> ();
|
||||
container->SetAttribute("File", StringValue ("contrib/leo/data/waypoints.txt"));
|
||||
container->SetAttribute("LastTime", TimeValue (Time (1)));
|
||||
container->SetAttribute("LastTime", TimeValue (Time (0)));
|
||||
|
||||
Ptr<WaypointMobilityModel> mobility = CreateObject<WaypointMobilityModel> ();
|
||||
Waypoint wp;
|
||||
|
@ -33,8 +36,9 @@ LeoMobilityWaypointTestCase::DoRun (void)
|
|||
{
|
||||
mobility->AddWaypoint (wp);
|
||||
}
|
||||
NS_LOG_INFO ("Model has " << mobility->WaypointsLeft () << " waypoints left");
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ ((mobility->WaypointsLeft () > 0), true, "Reading waypoints from empty");
|
||||
NS_TEST_ASSERT_MSG_EQ ((mobility->WaypointsLeft () > 2), true, "Reading waypoints from empty");
|
||||
}
|
||||
|
||||
class LeoMobilityTestSuite : public TestSuite
|
||||
|
|
126
test/leo-propagation-test-suite.cc
Normal file
126
test/leo-propagation-test-suite.cc
Normal file
|
@ -0,0 +1,126 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
|
||||
#include "ns3/core-module.h"
|
||||
#include "ns3/test.h"
|
||||
|
||||
#include "ns3/leo-module.h"
|
||||
|
||||
using namespace ns3;
|
||||
|
||||
class LeoPropagationAngleTestCase1 : public TestCase
|
||||
{
|
||||
public:
|
||||
LeoPropagationAngleTestCase1 ();
|
||||
virtual ~LeoPropagationAngleTestCase1 ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
LeoPropagationAngleTestCase1::LeoPropagationAngleTestCase1 ()
|
||||
: TestCase ("Test angle computation 90 deg")
|
||||
{
|
||||
}
|
||||
|
||||
LeoPropagationAngleTestCase1::~LeoPropagationAngleTestCase1 ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LeoPropagationAngleTestCase1::DoRun (void)
|
||||
{
|
||||
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (10, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (0, 10, 0));
|
||||
|
||||
double angle = LeoPropagationLossModel::GetAngle (a, b);
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ ((1.570 < angle && angle < 1.571), true, "Angle should be 90 deg.");
|
||||
}
|
||||
|
||||
class LeoPropagationAngleTestCase2 : public TestCase
|
||||
{
|
||||
public:
|
||||
LeoPropagationAngleTestCase2 ();
|
||||
virtual ~LeoPropagationAngleTestCase2 ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
LeoPropagationAngleTestCase2::LeoPropagationAngleTestCase2 ()
|
||||
: TestCase ("Test angle computation 0 deg")
|
||||
{
|
||||
}
|
||||
|
||||
LeoPropagationAngleTestCase2::~LeoPropagationAngleTestCase2 ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LeoPropagationAngleTestCase2::DoRun (void)
|
||||
{
|
||||
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (10, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (10, 0, 0));
|
||||
|
||||
double angle = LeoPropagationLossModel::GetAngle (a, b);
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ ((-0.1 < angle && angle < 0.1), true, "Angle should be 0 deg.");
|
||||
}
|
||||
|
||||
class LeoPropagationAngleTestCase3 : public TestCase
|
||||
{
|
||||
public:
|
||||
LeoPropagationAngleTestCase3 ();
|
||||
virtual ~LeoPropagationAngleTestCase3 ();
|
||||
|
||||
private:
|
||||
virtual void DoRun (void);
|
||||
};
|
||||
|
||||
LeoPropagationAngleTestCase3::LeoPropagationAngleTestCase3 ()
|
||||
: TestCase ("Test angle computation 0 vector")
|
||||
{
|
||||
}
|
||||
|
||||
LeoPropagationAngleTestCase3::~LeoPropagationAngleTestCase3 ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
LeoPropagationAngleTestCase3::DoRun (void)
|
||||
{
|
||||
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||
a->SetPosition (Vector3D (0, 0, 0));
|
||||
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||
b->SetPosition (Vector3D (0, 0, 0));
|
||||
|
||||
double angle = LeoPropagationLossModel::GetAngle (a, b);
|
||||
|
||||
NS_TEST_ASSERT_MSG_EQ (isnan(angle), true, "Angle should be NaN");
|
||||
}
|
||||
|
||||
// The TestSuite class names the TestSuite, identifies what type of TestSuite,
|
||||
// and enables the TestCases to be run. Typically, only the constructor for
|
||||
// this class must be defined
|
||||
//
|
||||
class LeoPropagationTestSuite : public TestSuite
|
||||
{
|
||||
public:
|
||||
LeoPropagationTestSuite ();
|
||||
};
|
||||
|
||||
LeoPropagationTestSuite::LeoPropagationTestSuite ()
|
||||
: TestSuite ("leo-propagation", UNIT)
|
||||
{
|
||||
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
|
||||
AddTestCase (new LeoPropagationAngleTestCase1, TestCase::QUICK);
|
||||
AddTestCase (new LeoPropagationAngleTestCase2, TestCase::QUICK);
|
||||
AddTestCase (new LeoPropagationAngleTestCase3, TestCase::QUICK);
|
||||
}
|
||||
|
||||
// Do not forget to allocate an instance of this TestSuite
|
||||
static LeoPropagationTestSuite leoTestSuite;
|
1
wscript
1
wscript
|
@ -29,6 +29,7 @@ def build(bld):
|
|||
module_test = bld.create_ns3_module_test_library('leo')
|
||||
module_test.source = [
|
||||
'test/leo-test-suite.cc',
|
||||
'test/leo-propagation-test-suite.cc',
|
||||
'test/isl-test-suite.cc',
|
||||
'test/isl-mock-channel-test-suite.cc',
|
||||
'test/leo-mock-channel-test-suite.cc',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue