mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 18:13:57 +02:00
Fix LOS computation for ISL
This commit is contained in:
parent
bf59e66526
commit
0f49ceb4aa
10 changed files with 37 additions and 22 deletions
|
@ -4,7 +4,10 @@ def build(bld):
|
||||||
if not bld.env['ENABLE_EXAMPLES']:
|
if not bld.env['ENABLE_EXAMPLES']:
|
||||||
return;
|
return;
|
||||||
|
|
||||||
obj = bld.create_ns3_program('leo-circular-orbit-trace',
|
obj = bld.create_ns3_program('leo-circular-orbit',
|
||||||
['core', 'leo', 'mobility'])
|
['core', 'leo', 'mobility'])
|
||||||
obj.source = 'leo-circular-orbit-tracing-example.cc'
|
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'
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "ns3/names.h"
|
#include "ns3/names.h"
|
||||||
#include "ns3/assert.h"
|
#include "ns3/assert.h"
|
||||||
#include "ns3/string.h"
|
#include "ns3/string.h"
|
||||||
|
#include "ns3/data-rate.h"
|
||||||
|
|
||||||
#include "../model/leo-mock-channel.h"
|
#include "../model/leo-mock-channel.h"
|
||||||
#include "../model/leo-mock-net-device.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 ("RxLoss", DoubleValue (rxGain));
|
||||||
m_satDeviceFactory.Set ("RxGain", DoubleValue (rxLoss));
|
m_satDeviceFactory.Set ("RxGain", DoubleValue (rxLoss));
|
||||||
|
|
||||||
m_gndDeviceFactory.Set ("DataRate", DoubleValue (dataRate));
|
m_gndDeviceFactory.Set ("DataRate", DataRateValue (DataRate (dataRate)));
|
||||||
m_satDeviceFactory.Set ("DataRate", DoubleValue (dataRate));
|
m_satDeviceFactory.Set ("DataRate", DataRateValue (DataRate (dataRate)));
|
||||||
|
|
||||||
m_propagationLossFactory.Set ("ElevationAngle", DoubleValue (elevationAngle));
|
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 ("AtmosphericLoss", DoubleValue (atmosphericLoss));
|
||||||
m_propagationLossFactory.Set ("LinkMargin", DoubleValue (linkMargin));
|
m_propagationLossFactory.Set ("LinkMargin", DoubleValue (linkMargin));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,25 +55,29 @@ IslPropagationLossModel::~IslPropagationLossModel ()
|
||||||
|
|
||||||
|
|
||||||
const double
|
const double
|
||||||
IslPropagationLossModel::EARTH_RAD = 6.3781E6;
|
IslPropagationLossModel::EARTH_RAD_E6 = 6.371;
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IslPropagationLossModel::GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
|
IslPropagationLossModel::GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
|
||||||
{
|
{
|
||||||
// origin of LOS
|
// origin of LOS
|
||||||
Vector3D o = a->GetPosition ();
|
Vector3D o = a->GetPosition ();
|
||||||
|
o = Vector3D (o.x / 1e6, o.y / 1e6, o.z / 1e6);
|
||||||
double ol = o.GetLength ();
|
double ol = o.GetLength ();
|
||||||
|
|
||||||
// second point of LOS
|
// second point of LOS
|
||||||
Vector3D bp = b->GetPosition ();
|
Vector3D bp = b->GetPosition ();
|
||||||
double bl = bp.GetLength ();
|
bp = Vector3D (bp.x / 1e6, bp.y / 1e6, bp.z / 1e6);
|
||||||
|
|
||||||
// unit vector
|
// 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
|
// center point of sphere is 0
|
||||||
double uo = (u.x*o.x) + (u.y*o.y) + (u.z*o.z);
|
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;
|
return delta < 0;
|
||||||
}
|
}
|
||||||
|
@ -83,15 +87,14 @@ IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||||
Ptr<MobilityModel> a,
|
Ptr<MobilityModel> a,
|
||||||
Ptr<MobilityModel> b) const
|
Ptr<MobilityModel> b) const
|
||||||
{
|
{
|
||||||
// primitivec cut-of at 1000 km
|
|
||||||
if (!GetLos (a, b))
|
if (!GetLos (a, b))
|
||||||
{
|
{
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
double rxc = 0.0;//-m_variable->GetValue ();
|
NS_LOG_INFO ("LOS;"<<a->GetPosition ()<<";"<<b->GetPosition ());
|
||||||
NS_LOG_DEBUG ("attenuation coefficient="<<rxc<<"Db");
|
|
||||||
return txPowerDbm + rxc;
|
return txPowerDbm;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t
|
int64_t
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace ns3 {
|
||||||
class IslPropagationLossModel : public PropagationLossModel
|
class IslPropagationLossModel : public PropagationLossModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const double EARTH_RAD;
|
static const double EARTH_RAD_E6;
|
||||||
|
|
||||||
static TypeId GetTypeId (void);
|
static TypeId GetTypeId (void);
|
||||||
IslPropagationLossModel ();
|
IslPropagationLossModel ();
|
||||||
|
|
|
@ -92,6 +92,7 @@ Vector3D
|
||||||
LeoCircularOrbitMobilityModel::PlaneNorm () const
|
LeoCircularOrbitMobilityModel::PlaneNorm () const
|
||||||
{
|
{
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
|
// ensure correct gradient (not against earth rotation)
|
||||||
if (m_inclination < M_PI/4)
|
if (m_inclination < M_PI/4)
|
||||||
{
|
{
|
||||||
sign = -1;
|
sign = -1;
|
||||||
|
|
|
@ -26,12 +26,12 @@ LeoMockNetDevice::GetTypeId (void)
|
||||||
MakeEnumChecker (
|
MakeEnumChecker (
|
||||||
DeviceType::GND, "ns3::LeoMockNetDevice::NetDeviceType::GND",
|
DeviceType::GND, "ns3::LeoMockNetDevice::NetDeviceType::GND",
|
||||||
DeviceType::SAT, "ns3::LeoMockNetDevice::NetDeviceType::SAT"))
|
DeviceType::SAT, "ns3::LeoMockNetDevice::NetDeviceType::SAT"))
|
||||||
.AddAttribute ("ReceiverGain",
|
.AddAttribute ("RxGain",
|
||||||
"Receiver gain in dBm",
|
"Receiver gain in dBm",
|
||||||
DoubleValue (0.0),
|
DoubleValue (0.0),
|
||||||
MakeDoubleAccessor (&LeoMockNetDevice::m_rxGain),
|
MakeDoubleAccessor (&LeoMockNetDevice::m_rxGain),
|
||||||
MakeDoubleChecker<double> ())
|
MakeDoubleChecker<double> ())
|
||||||
.AddAttribute ("ReceiverLoss",
|
.AddAttribute ("RxLoss",
|
||||||
"Receiver loss in dBm",
|
"Receiver loss in dBm",
|
||||||
DoubleValue (0.0),
|
DoubleValue (0.0),
|
||||||
MakeDoubleAccessor (&LeoMockNetDevice::m_rxLoss),
|
MakeDoubleAccessor (&LeoMockNetDevice::m_rxLoss),
|
||||||
|
|
|
@ -23,7 +23,7 @@ LeoPropagationLossModel::GetTypeId (void)
|
||||||
.AddConstructor<LeoPropagationLossModel> ()
|
.AddConstructor<LeoPropagationLossModel> ()
|
||||||
.AddAttribute ("MaxDistance",
|
.AddAttribute ("MaxDistance",
|
||||||
"Cut-off distance for signal propagation",
|
"Cut-off distance for signal propagation",
|
||||||
DoubleValue (1000000.0),
|
DoubleValue (100000.0),
|
||||||
MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance),
|
MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance),
|
||||||
MakeDoubleChecker<double> ())
|
MakeDoubleChecker<double> ())
|
||||||
.AddAttribute ("ElevationAngle",
|
.AddAttribute ("ElevationAngle",
|
||||||
|
|
|
@ -171,8 +171,8 @@ MockChannel::Deliver (
|
||||||
NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime);
|
NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime);
|
||||||
Time delay = txTime;
|
Time delay = txTime;
|
||||||
|
|
||||||
Ptr<MobilityModel> srcMob = src->GetObject<MobilityModel> ();
|
Ptr<MobilityModel> srcMob = src->GetNode ()->GetObject<MobilityModel> ();
|
||||||
Ptr<MobilityModel> dstMob = dst->GetObject<MobilityModel> ();
|
Ptr<MobilityModel> dstMob = dst->GetNode ()->GetObject<MobilityModel> ();
|
||||||
|
|
||||||
double txPower = src->GetTxPower ();
|
double txPower = src->GetTxPower ();
|
||||||
double rxPower = txPower;
|
double rxPower = txPower;
|
||||||
|
@ -191,6 +191,10 @@ MockChannel::Deliver (
|
||||||
}
|
}
|
||||||
delay += GetPropagationDelay (srcMob, dstMob, txTime);
|
delay += GetPropagationDelay (srcMob, dstMob, txTime);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
|
Simulator::ScheduleWithContext (dst->GetNode ()->GetId (),
|
||||||
delay,
|
delay,
|
||||||
|
|
|
@ -26,13 +26,15 @@ IslPropagationAngleTestCase1::~IslPropagationAngleTestCase1 ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define EARTH_RAD 6.3781e6
|
||||||
|
|
||||||
void
|
void
|
||||||
IslPropagationAngleTestCase1::DoRun (void)
|
IslPropagationAngleTestCase1::DoRun (void)
|
||||||
{
|
{
|
||||||
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
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> ();
|
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");
|
NS_TEST_ASSERT_MSG_EQ (IslPropagationLossModel::GetLos (a, b), true, "LOS of neighboring satellites");
|
||||||
}
|
}
|
||||||
|
@ -60,9 +62,9 @@ void
|
||||||
IslPropagationAngleTestCase2::DoRun (void)
|
IslPropagationAngleTestCase2::DoRun (void)
|
||||||
{
|
{
|
||||||
Ptr<ConstantPositionMobilityModel> a = CreateObject<ConstantPositionMobilityModel> ();
|
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> ();
|
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");
|
NS_TEST_ASSERT_MSG_EQ (IslPropagationLossModel::GetLos (a, b), false, "LOS of opposing");
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ unset ytics
|
||||||
unset ztics
|
unset ztics
|
||||||
unset border
|
unset border
|
||||||
unset key
|
unset key
|
||||||
|
set hidden3d
|
||||||
set view equal xyz
|
set view equal xyz
|
||||||
|
|
||||||
# number of nodes per time slot
|
# number of nodes per time slot
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue