mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 01:53:58 +02:00
More fixes on propagation model
This commit is contained in:
parent
ad22221f42
commit
df97dfa3e4
4 changed files with 71 additions and 88 deletions
|
@ -1,29 +1,8 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005,2006,2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
* Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
|
||||
* Contributions: Gary Pei <guangyu.pei@boeing.com> for fixed RSS
|
||||
* Contributions: Tom Hewer <tomhewer@mac.com> for two ray ground model
|
||||
* Pavel Boyko <boyko@iitp.ru> for matrix
|
||||
*/
|
||||
|
||||
#include "ns3/log.h"
|
||||
#include "ns3/mobility-model.h"
|
||||
#include "ns3/double.h"
|
||||
#include "math.h"
|
||||
|
||||
#include "isl-propagation-loss-model.h"
|
||||
|
@ -41,6 +20,12 @@ IslPropagationLossModel::GetTypeId (void)
|
|||
.SetParent<PropagationLossModel> ()
|
||||
.SetGroupName ("Leo")
|
||||
.AddConstructor<IslPropagationLossModel> ()
|
||||
.AddAttribute ("MaxDistance",
|
||||
"Cut-off distance for signal propagation",
|
||||
DoubleValue (1000.0),
|
||||
MakeDoubleAccessor (&IslPropagationLossModel::SetCutoffDistance,
|
||||
&IslPropagationLossModel::GetCutoffDistance),
|
||||
MakeDoubleChecker<double> ())
|
||||
;
|
||||
return tid;
|
||||
}
|
||||
|
@ -53,33 +38,30 @@ IslPropagationLossModel::~IslPropagationLossModel ()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
const double
|
||||
IslPropagationLossModel::EARTH_RAD_E6 = 6.371;
|
||||
|
||||
bool
|
||||
IslPropagationLossModel::GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
|
||||
IslPropagationLossModel::GetLos (Ptr<MobilityModel> moda, Ptr<MobilityModel> modb)
|
||||
{
|
||||
// origin of LOS
|
||||
Vector3D o = a->GetPosition ();
|
||||
o = Vector3D (o.x / 1e6, o.y / 1e6, o.z / 1e6);
|
||||
double ol = o.GetLength ();
|
||||
Vector3D oc = moda->GetPosition ();
|
||||
Vector3D bp = modb->GetPosition ();
|
||||
|
||||
// second point of LOS
|
||||
Vector3D bp = b->GetPosition ();
|
||||
bp = Vector3D (bp.x / 1e6, bp.y / 1e6, bp.z / 1e6);
|
||||
|
||||
// unit vector
|
||||
Vector3D u = Vector3D (o.x-bp.x, o.y-bp.y, o.z-bp.z);
|
||||
// direction unit vector
|
||||
Vector3D u = Vector3D (bp.x - oc.x, bp.y - oc.y, bp.z - oc.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_E6*EARTH_RAD_E6));
|
||||
double a = u.x*u.x + u.y*u.y + u.z*u.z;
|
||||
double b = 2.0 * (oc.x*u.x + oc.y*u.y + oc.z*u.z);
|
||||
double c = (oc.x*oc.x + oc.y*oc.y + oc.z*oc.z) - (LEO_EARTH_RAD*LEO_EARTH_RAD);
|
||||
double discriminant = b*b - 4*a*c;
|
||||
|
||||
//NS_LOG_DEBUG ("a_pos="<<o<<";b_pos"<<bp<<";delta="<<delta);
|
||||
NS_LOG_DEBUG ("a_pos="<<moda->GetPosition ()<<";b_pos"<<modb->GetPosition ()
|
||||
<<";u="<<u
|
||||
<<";a="<<a
|
||||
<<";b="<<b
|
||||
<<";c="<<c
|
||||
<<";disc="<<discriminant);
|
||||
|
||||
return delta < 0;
|
||||
return discriminant < 0;
|
||||
}
|
||||
|
||||
double
|
||||
|
@ -87,12 +69,13 @@ IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
|||
Ptr<MobilityModel> a,
|
||||
Ptr<MobilityModel> b) const
|
||||
{
|
||||
if (!GetLos (a, b))
|
||||
if (a->GetDistanceFrom (b) > m_cutoffDistance || !GetLos (a, b))
|
||||
{
|
||||
NS_LOG_DEBUG ("DROP;"<<a->GetPosition ()<<";"<<b->GetPosition ());
|
||||
return -1000.0;
|
||||
}
|
||||
|
||||
NS_LOG_INFO ("LOS;"<<a->GetPosition ()<<";"<<b->GetPosition ());
|
||||
NS_LOG_DEBUG ("LOS;"<<a->GetPosition ()<<";"<<b->GetPosition ());
|
||||
|
||||
return txPowerDbm;
|
||||
}
|
||||
|
@ -103,4 +86,15 @@ IslPropagationLossModel::DoAssignStreams (int64_t stream)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
IslPropagationLossModel::SetCutoffDistance (double d)
|
||||
{
|
||||
m_cutoffDistance = d * 1000.0;
|
||||
}
|
||||
|
||||
double
|
||||
IslPropagationLossModel::GetCutoffDistance () const
|
||||
{
|
||||
return m_cutoffDistance / 1000.0;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,26 +1,4 @@
|
|||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2005,2006,2007 INRIA
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
||||
* Contributions: Timo Bingmann <timo.bingmann@student.kit.edu>
|
||||
* Contributions: Gary Pei <guangyu.pei@boeing.com> for fixed RSS
|
||||
* Contributions: Tom Hewer <tomhewer@mac.com> for two ray ground model
|
||||
* Pavel Boyko <boyko@iitp.ru> for matrix
|
||||
*/
|
||||
|
||||
#ifndef ISL_PROPAGATION_LOSS_MODEL_H
|
||||
#define ISL_PROPAGATION_LOSS_MODEL_H
|
||||
|
@ -28,13 +6,13 @@
|
|||
#include <ns3/object.h>
|
||||
#include <ns3/propagation-loss-model.h>
|
||||
|
||||
#define LEO_EARTH_RAD 6.371009e6
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
class IslPropagationLossModel : public PropagationLossModel
|
||||
{
|
||||
public:
|
||||
static const double EARTH_RAD_E6;
|
||||
|
||||
static TypeId GetTypeId (void);
|
||||
IslPropagationLossModel ();
|
||||
virtual ~IslPropagationLossModel ();
|
||||
|
@ -50,6 +28,14 @@ public:
|
|||
*/
|
||||
static bool GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b);
|
||||
private:
|
||||
/**
|
||||
* Cutoff distance for signal
|
||||
*/
|
||||
double m_cutoffDistance;
|
||||
|
||||
void SetCutoffDistance (double d);
|
||||
double GetCutoffDistance () const;
|
||||
|
||||
/**
|
||||
* Returns the Rx Power taking into account only the particular
|
||||
* PropagationLossModel.
|
||||
|
|
|
@ -103,26 +103,26 @@ LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
|||
Ptr<MobilityModel> b) const
|
||||
{
|
||||
double distance = a->GetDistanceFrom (b);
|
||||
double angle = GetAngle (a, b);
|
||||
double rxc = txPowerDbm - m_atmosphericLoss - m_freeSpacePathLoss - m_linkMargin;
|
||||
|
||||
NS_LOG_DEBUG ("LEO propagation: a=" << a->GetPosition () << " b=" << b->GetPosition () << " m_cutOff="<<m_cutoffDistance<<" m_angle="<<m_elevationAngle<<" dist=" << distance << "angle=" << angle << "rxc=" << rxc);
|
||||
|
||||
if (distance > m_cutoffDistance)
|
||||
{
|
||||
NS_LOG_DEBUG ("LEO DROP DISTANCE: " << distance);
|
||||
NS_LOG_DEBUG ("LEO DROP distance: a=" << a->GetPosition () << " b=" << b->GetPosition () << " m_cutOff="<<m_cutoffDistance<<" dist=" << distance);
|
||||
|
||||
return -1000.0;
|
||||
}
|
||||
|
||||
double angle = GetAngle (a, b);
|
||||
if (angle > m_elevationAngle / 2.0)
|
||||
{
|
||||
NS_LOG_DEBUG ("LEO DROP ANGLE: " << angle <<"; " << distance);
|
||||
NS_LOG_DEBUG ("LEO DROP angle: a=" << a->GetPosition () << " b=" << b->GetPosition () << " m_cutOff="<<m_cutoffDistance<<" m_angle="<<m_elevationAngle<<" dist=" << distance << "angle=" << angle);
|
||||
return -1000.0;
|
||||
}
|
||||
|
||||
// txPowerDbm includes tx antenna gain and losses
|
||||
// receiver loss and gain added at net device
|
||||
// P_{RX} = P_{TX} + G_{TX} - L_{TX} - L_{FS} - L_M + G_{RX} - L_{RX}
|
||||
double rxc = txPowerDbm - m_atmosphericLoss - m_freeSpacePathLoss - m_linkMargin;
|
||||
NS_LOG_INFO ("LEO TRANSMIT: angle=" << angle <<";distance=" << distance << ";rxc=" << rxc);
|
||||
|
||||
return rxc;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue