mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 01:53:58 +02:00
Add LOS computation for ISL links
This commit is contained in:
parent
f6786c3a66
commit
c1496e29f9
4 changed files with 132 additions and 7 deletions
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "ns3/log.h"
|
#include "ns3/log.h"
|
||||||
#include "ns3/mobility-model.h"
|
#include "ns3/mobility-model.h"
|
||||||
|
#include "math.h"
|
||||||
|
|
||||||
#include "isl-propagation-loss-model.h"
|
#include "isl-propagation-loss-model.h"
|
||||||
|
|
||||||
|
@ -52,6 +53,31 @@ IslPropagationLossModel::~IslPropagationLossModel ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const double
|
||||||
|
IslPropagationLossModel::EARTH_RAD = 6.3781E6;
|
||||||
|
|
||||||
|
bool
|
||||||
|
IslPropagationLossModel::GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
|
||||||
|
{
|
||||||
|
// origin of LOS
|
||||||
|
Vector3D o = a->GetPosition ();
|
||||||
|
double ol = o.GetLength ();
|
||||||
|
|
||||||
|
// second point of LOS
|
||||||
|
Vector3D bp = b->GetPosition ();
|
||||||
|
double bl = bp.GetLength ();
|
||||||
|
|
||||||
|
// unit vector
|
||||||
|
Vector3D u = Vector3D ((o.x-bp.x)/bl, (o.y-bp.y)/bl, (o.z-bp.z)/bl);
|
||||||
|
|
||||||
|
// center point of sphere is 0
|
||||||
|
double uo = (u.x*o.x) + (u.y*o.y) + (u.z*o.z);
|
||||||
|
double delta = (uo*uo) - (ol*ol - (EARTH_RAD*EARTH_RAD));
|
||||||
|
|
||||||
|
return delta < 0;
|
||||||
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||||
Ptr<MobilityModel> a,
|
Ptr<MobilityModel> a,
|
||||||
|
@ -62,7 +88,7 @@ IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||||
// curvature + distance)
|
// curvature + distance)
|
||||||
|
|
||||||
// primitivec cut-of at 1000 km
|
// primitivec cut-of at 1000 km
|
||||||
if (a->GetDistanceFrom (b) > 1000000.0)
|
if (!GetLos (a, b))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,9 +33,22 @@ namespace ns3 {
|
||||||
class IslPropagationLossModel : public PropagationLossModel
|
class IslPropagationLossModel : public PropagationLossModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
static const double EARTH_RAD;
|
||||||
|
|
||||||
static TypeId GetTypeId (void);
|
static TypeId GetTypeId (void);
|
||||||
IslPropagationLossModel ();
|
IslPropagationLossModel ();
|
||||||
virtual ~IslPropagationLossModel ();
|
virtual ~IslPropagationLossModel ();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* true if there is at least one intersection of ISL line-of-sight with earth
|
||||||
|
* (LOS is blocked by earth)
|
||||||
|
*
|
||||||
|
* Assumes earth is sperical.
|
||||||
|
*
|
||||||
|
* \param a first node
|
||||||
|
* \param b second node
|
||||||
|
*/
|
||||||
|
static bool GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b);
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Returns the Rx Power taking into account only the particular
|
* Returns the Rx Power taking into account only the particular
|
||||||
|
|
85
test/isl-propagation-test-suite.cc
Normal file
85
test/isl-propagation-test-suite.cc
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
/* -*- 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 IslPropagationAngleTestCase1 : public TestCase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IslPropagationAngleTestCase1 ();
|
||||||
|
virtual ~IslPropagationAngleTestCase1 ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void DoRun (void);
|
||||||
|
};
|
||||||
|
|
||||||
|
IslPropagationAngleTestCase1::IslPropagationAngleTestCase1 ()
|
||||||
|
: TestCase ("Test LOS computation neighboring sats")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IslPropagationAngleTestCase1::~IslPropagationAngleTestCase1 ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
IslPropagationAngleTestCase1::DoRun (void)
|
||||||
|
{
|
||||||
|
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||||
|
a->SetPosition (Vector3D (IslPropagationLossModel::EARTH_RAD + 1000.0, 10, 0));
|
||||||
|
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||||
|
b->SetPosition (Vector3D (IslPropagationLossModel::EARTH_RAD + 1000.0, 0, 0));
|
||||||
|
|
||||||
|
NS_TEST_ASSERT_MSG_EQ (IslPropagationLossModel::GetLos (a, b), true, "LOS of neighboring satellites");
|
||||||
|
}
|
||||||
|
|
||||||
|
class IslPropagationAngleTestCase2 : public TestCase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IslPropagationAngleTestCase2 ();
|
||||||
|
virtual ~IslPropagationAngleTestCase2 ();
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual void DoRun (void);
|
||||||
|
};
|
||||||
|
|
||||||
|
IslPropagationAngleTestCase2::IslPropagationAngleTestCase2 ()
|
||||||
|
: TestCase ("Test LOS of sats without LOS")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
IslPropagationAngleTestCase2::~IslPropagationAngleTestCase2 ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
IslPropagationAngleTestCase2::DoRun (void)
|
||||||
|
{
|
||||||
|
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
||||||
|
a->SetPosition (Vector3D (IslPropagationLossModel::EARTH_RAD + 1000.0, 0, 0));
|
||||||
|
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
|
||||||
|
b->SetPosition (Vector3D (- (IslPropagationLossModel::EARTH_RAD + 1000.0), 0, 0));
|
||||||
|
|
||||||
|
NS_TEST_ASSERT_MSG_EQ (IslPropagationLossModel::GetLos (a, b), false, "LOS of opposing");
|
||||||
|
}
|
||||||
|
|
||||||
|
class IslPropagationTestSuite : public TestSuite
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IslPropagationTestSuite ();
|
||||||
|
};
|
||||||
|
|
||||||
|
IslPropagationTestSuite::IslPropagationTestSuite ()
|
||||||
|
: TestSuite ("isl-propagation", UNIT)
|
||||||
|
{
|
||||||
|
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
|
||||||
|
AddTestCase (new IslPropagationAngleTestCase1, TestCase::QUICK);
|
||||||
|
AddTestCase (new IslPropagationAngleTestCase2, TestCase::QUICK);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not forget to allocate an instance of this TestSuite
|
||||||
|
static IslPropagationTestSuite leoTestSuite;
|
13
wscript
13
wscript
|
@ -28,16 +28,17 @@ def build(bld):
|
||||||
|
|
||||||
module_test = bld.create_ns3_module_test_library('leo')
|
module_test = bld.create_ns3_module_test_library('leo')
|
||||||
module_test.source = [
|
module_test.source = [
|
||||||
'test/leo-test-suite.cc',
|
'test/ground-node-helper-test-suite.cc',
|
||||||
'test/leo-propagation-test-suite.cc',
|
|
||||||
'test/isl-test-suite.cc',
|
|
||||||
'test/isl-mock-channel-test-suite.cc',
|
'test/isl-mock-channel-test-suite.cc',
|
||||||
'test/leo-mock-channel-test-suite.cc',
|
'test/isl-propagation-test-suite.cc',
|
||||||
|
'test/isl-test-suite.cc',
|
||||||
'test/leo-input-fstream-container-test-suite.cc',
|
'test/leo-input-fstream-container-test-suite.cc',
|
||||||
'test/leo-mobility-test-suite.cc',
|
'test/leo-mobility-test-suite.cc',
|
||||||
|
'test/leo-mock-channel-test-suite.cc',
|
||||||
|
'test/leo-propagation-test-suite.cc',
|
||||||
|
'test/leo-test-suite.cc',
|
||||||
'test/satellite-node-helper-test-suite.cc',
|
'test/satellite-node-helper-test-suite.cc',
|
||||||
'test/ground-node-helper-test-suite.cc',
|
]
|
||||||
]
|
|
||||||
|
|
||||||
headers = bld(features='ns3header')
|
headers = bld(features='ns3header')
|
||||||
headers.module = 'leo'
|
headers.module = 'leo'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue