Fix LOS computation for ISL

This commit is contained in:
Tim Schubert 2020-08-17 22:50:58 +02:00
parent bf59e66526
commit 0f49ceb4aa
10 changed files with 37 additions and 22 deletions

View file

@ -4,7 +4,10 @@ def build(bld):
if not bld.env['ENABLE_EXAMPLES']:
return;
obj = bld.create_ns3_program('leo-circular-orbit-trace',
obj = bld.create_ns3_program('leo-circular-orbit',
['core', 'leo', 'mobility'])
obj.source = 'leo-circular-orbit-tracing-example.cc'
obj = bld.create_ns3_program('leo-delay',
['core', 'leo', 'mobility', 'aodv'])
obj.source = 'leo-delay-tracing-example.cc'

View file

@ -8,6 +8,7 @@
#include "ns3/names.h"
#include "ns3/assert.h"
#include "ns3/string.h"
#include "ns3/data-rate.h"
#include "../model/leo-mock-channel.h"
#include "../model/leo-mock-net-device.h"
@ -119,11 +120,11 @@ LeoChannelHelper::SetConstellationAttributes (double eirp,
m_satDeviceFactory.Set ("RxLoss", DoubleValue (rxGain));
m_satDeviceFactory.Set ("RxGain", DoubleValue (rxLoss));
m_gndDeviceFactory.Set ("DataRate", DoubleValue (dataRate));
m_satDeviceFactory.Set ("DataRate", DoubleValue (dataRate));
m_gndDeviceFactory.Set ("DataRate", DataRateValue (DataRate (dataRate)));
m_satDeviceFactory.Set ("DataRate", DataRateValue (DataRate (dataRate)));
m_propagationLossFactory.Set ("ElevationAngle", DoubleValue (elevationAngle));
m_propagationLossFactory.Set ("FreeSpaceLoss", DoubleValue (fspl));
m_propagationLossFactory.Set ("FreeSpacePathLoss", DoubleValue (fspl));
m_propagationLossFactory.Set ("AtmosphericLoss", DoubleValue (atmosphericLoss));
m_propagationLossFactory.Set ("LinkMargin", DoubleValue (linkMargin));
}

View file

@ -55,25 +55,29 @@ IslPropagationLossModel::~IslPropagationLossModel ()
const double
IslPropagationLossModel::EARTH_RAD = 6.3781E6;
IslPropagationLossModel::EARTH_RAD_E6 = 6.371;
bool
IslPropagationLossModel::GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
{
// origin of LOS
Vector3D o = a->GetPosition ();
o = Vector3D (o.x / 1e6, o.y / 1e6, o.z / 1e6);
double ol = o.GetLength ();
// second point of LOS
Vector3D bp = b->GetPosition ();
double bl = bp.GetLength ();
bp = Vector3D (bp.x / 1e6, bp.y / 1e6, bp.z / 1e6);
// unit vector
Vector3D u = Vector3D ((o.x-bp.x)/bl, (o.y-bp.y)/bl, (o.z-bp.z)/bl);
Vector3D u = Vector3D (o.x-bp.x, o.y-bp.y, o.z-bp.z);
u = Vector3D (u.x / u.GetLength (), u.y / u.GetLength (), u.z / u.GetLength ());
// 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));
double delta = (uo*uo) - (ol*ol - (EARTH_RAD_E6*EARTH_RAD_E6));
//NS_LOG_DEBUG ("a_pos="<<o<<";b_pos"<<bp<<";delta="<<delta);
return delta < 0;
}
@ -83,15 +87,14 @@ IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
Ptr<MobilityModel> a,
Ptr<MobilityModel> b) const
{
// primitivec cut-of at 1000 km
if (!GetLos (a, b))
{
return 0.0;
}
double rxc = 0.0;//-m_variable->GetValue ();
NS_LOG_DEBUG ("attenuation coefficient="<<rxc<<"Db");
return txPowerDbm + rxc;
NS_LOG_INFO ("LOS;"<<a->GetPosition ()<<";"<<b->GetPosition ());
return txPowerDbm;
}
int64_t

View file

@ -33,7 +33,7 @@ namespace ns3 {
class IslPropagationLossModel : public PropagationLossModel
{
public:
static const double EARTH_RAD;
static const double EARTH_RAD_E6;
static TypeId GetTypeId (void);
IslPropagationLossModel ();

View file

@ -92,6 +92,7 @@ Vector3D
LeoCircularOrbitMobilityModel::PlaneNorm () const
{
int sign = 1;
// ensure correct gradient (not against earth rotation)
if (m_inclination < M_PI/4)
{
sign = -1;

View file

@ -26,12 +26,12 @@ LeoMockNetDevice::GetTypeId (void)
MakeEnumChecker (
DeviceType::GND, "ns3::LeoMockNetDevice::NetDeviceType::GND",
DeviceType::SAT, "ns3::LeoMockNetDevice::NetDeviceType::SAT"))
.AddAttribute ("ReceiverGain",
.AddAttribute ("RxGain",
"Receiver gain in dBm",
DoubleValue (0.0),
MakeDoubleAccessor (&LeoMockNetDevice::m_rxGain),
MakeDoubleChecker<double> ())
.AddAttribute ("ReceiverLoss",
.AddAttribute ("RxLoss",
"Receiver loss in dBm",
DoubleValue (0.0),
MakeDoubleAccessor (&LeoMockNetDevice::m_rxLoss),

View file

@ -23,7 +23,7 @@ LeoPropagationLossModel::GetTypeId (void)
.AddConstructor<LeoPropagationLossModel> ()
.AddAttribute ("MaxDistance",
"Cut-off distance for signal propagation",
DoubleValue (1000000.0),
DoubleValue (100000.0),
MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance),
MakeDoubleChecker<double> ())
.AddAttribute ("ElevationAngle",

View file

@ -171,8 +171,8 @@ MockChannel::Deliver (
NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime);
Time delay = txTime;
Ptr<MobilityModel> srcMob = src->GetObject<MobilityModel> ();
Ptr<MobilityModel> dstMob = dst->GetObject<MobilityModel> ();
Ptr<MobilityModel> srcMob = src->GetNode ()->GetObject<MobilityModel> ();
Ptr<MobilityModel> dstMob = dst->GetNode ()->GetObject<MobilityModel> ();
double txPower = src->GetTxPower ();
double rxPower = txPower;
@ -191,6 +191,10 @@ MockChannel::Deliver (
}
delay += GetPropagationDelay (srcMob, dstMob, txTime);
}
else
{
return false;
}
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
delay,

View file

@ -26,13 +26,15 @@ IslPropagationAngleTestCase1::~IslPropagationAngleTestCase1 ()
{
}
#define EARTH_RAD 6.3781e6
void
IslPropagationAngleTestCase1::DoRun (void)
{
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
a->SetPosition (Vector3D (IslPropagationLossModel::EARTH_RAD + 1000.0, 10, 0));
a->SetPosition (Vector3D (EARTH_RAD + 1.0e6, 10, 0));
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
b->SetPosition (Vector3D (IslPropagationLossModel::EARTH_RAD + 1000.0, 0, 0));
b->SetPosition (Vector3D (EARTH_RAD + 1.0e6, 0, 0));
NS_TEST_ASSERT_MSG_EQ (IslPropagationLossModel::GetLos (a, b), true, "LOS of neighboring satellites");
}
@ -60,9 +62,9 @@ void
IslPropagationAngleTestCase2::DoRun (void)
{
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
a->SetPosition (Vector3D (IslPropagationLossModel::EARTH_RAD + 1000.0, 0, 0));
a->SetPosition (Vector3D (EARTH_RAD + 1.0e6, 0, 0));
Ptr<ConstantPositionMobilityModel> b = CreateObject<ConstantPositionMobilityModel> ();
b->SetPosition (Vector3D (- (IslPropagationLossModel::EARTH_RAD + 1000.0), 0, 0));
b->SetPosition (Vector3D (- (EARTH_RAD + 1.0e6), 0, 0));
NS_TEST_ASSERT_MSG_EQ (IslPropagationLossModel::GetLos (a, b), false, "LOS of opposing");
}

View file

@ -8,6 +8,7 @@ unset ytics
unset ztics
unset border
unset key
set hidden3d
set view equal xyz
# number of nodes per time slot