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

@ -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,