mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 18:13:57 +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
|
@ -74,17 +74,18 @@ int main (int argc, char *argv[])
|
||||||
|
|
||||||
// Install internet stack on nodes
|
// Install internet stack on nodes
|
||||||
AodvHelper aodv;
|
AodvHelper aodv;
|
||||||
aodv.Set ("HelloInterval", TimeValue (Seconds (1)));
|
//aodv.Set ("HelloInterval", TimeValue (Minutes (1)));
|
||||||
aodv.Set ("TtlStart", UintegerValue (10));
|
aodv.Set ("TtlStart", UintegerValue (5));
|
||||||
aodv.Set ("TtlIncrement", UintegerValue (10));
|
aodv.Set ("TtlIncrement", UintegerValue (5));
|
||||||
aodv.Set ("TtlThreshold", UintegerValue (100));
|
aodv.Set ("TtlThreshold", UintegerValue (200));
|
||||||
aodv.Set ("RreqRetries", UintegerValue (100));
|
aodv.Set ("RreqRetries", UintegerValue (1000));
|
||||||
aodv.Set ("RreqRateLimit", UintegerValue (10));
|
aodv.Set ("RreqRateLimit", UintegerValue (100));
|
||||||
aodv.Set ("RerrRateLimit", UintegerValue (10));
|
//aodv.Set ("RerrRateLimit", UintegerValue (1));
|
||||||
aodv.Set ("ActiveRouteTimeout", TimeValue (Minutes (1)));
|
//aodv.Set ("ActiveRouteTimeout", TimeValue (Minutes (1)));
|
||||||
aodv.Set ("NextHopWait", TimeValue (MilliSeconds (200)));
|
//aodv.Set ("NextHopWait", TimeValue (MilliSeconds (200)));
|
||||||
aodv.Set ("NetDiameter", UintegerValue (1000));
|
aodv.Set ("NetDiameter", UintegerValue (100));
|
||||||
aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1)));
|
//aodv.Set ("AllowedHelloLoss", UintegerValue (10000));
|
||||||
|
//aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1)));
|
||||||
|
|
||||||
InternetStackHelper stack;
|
InternetStackHelper stack;
|
||||||
stack.SetRoutingHelper (aodv);
|
stack.SetRoutingHelper (aodv);
|
||||||
|
@ -107,8 +108,8 @@ int main (int argc, char *argv[])
|
||||||
Address remote = stations.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0);
|
Address remote = stations.Get (1)->GetObject<Ipv4> ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0);
|
||||||
std::cout << "REMOTE=" << Ipv4Address::ConvertFrom (remote);
|
std::cout << "REMOTE=" << Ipv4Address::ConvertFrom (remote);
|
||||||
UdpClientHelper echoClient (remote, 9);
|
UdpClientHelper echoClient (remote, 9);
|
||||||
echoClient.SetAttribute ("MaxPackets", UintegerValue (360));
|
echoClient.SetAttribute ("MaxPackets", UintegerValue (60));
|
||||||
echoClient.SetAttribute ("Interval", TimeValue (Seconds (10.0)));
|
echoClient.SetAttribute ("Interval", TimeValue (Seconds (1)));
|
||||||
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
|
||||||
clientApps.Add (echoClient.Install (stations.Get (3)));
|
clientApps.Add (echoClient.Install (stations.Get (3)));
|
||||||
|
|
||||||
|
@ -118,9 +119,11 @@ int main (int argc, char *argv[])
|
||||||
std::cout << "Context,Sequence Number,Timestamp,Delay" << std::endl;
|
std::cout << "Context,Sequence Number,Timestamp,Delay" << std::endl;
|
||||||
|
|
||||||
serverApps.Start (Seconds (1));
|
serverApps.Start (Seconds (1));
|
||||||
clientApps.Start (Seconds (2));
|
clientApps.Start (Seconds (1));
|
||||||
|
serverApps.Stop (Minutes (1));
|
||||||
|
clientApps.Stop (Minutes (1));
|
||||||
|
|
||||||
Simulator::Stop (Minutes (60));
|
Simulator::Stop (Minutes (1));
|
||||||
Simulator::Run ();
|
Simulator::Run ();
|
||||||
Simulator::Destroy ();
|
Simulator::Destroy ();
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,8 @@
|
||||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
/* -*- 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/log.h"
|
||||||
#include "ns3/mobility-model.h"
|
#include "ns3/mobility-model.h"
|
||||||
|
#include "ns3/double.h"
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
|
|
||||||
#include "isl-propagation-loss-model.h"
|
#include "isl-propagation-loss-model.h"
|
||||||
|
@ -41,6 +20,12 @@ IslPropagationLossModel::GetTypeId (void)
|
||||||
.SetParent<PropagationLossModel> ()
|
.SetParent<PropagationLossModel> ()
|
||||||
.SetGroupName ("Leo")
|
.SetGroupName ("Leo")
|
||||||
.AddConstructor<IslPropagationLossModel> ()
|
.AddConstructor<IslPropagationLossModel> ()
|
||||||
|
.AddAttribute ("MaxDistance",
|
||||||
|
"Cut-off distance for signal propagation",
|
||||||
|
DoubleValue (1000.0),
|
||||||
|
MakeDoubleAccessor (&IslPropagationLossModel::SetCutoffDistance,
|
||||||
|
&IslPropagationLossModel::GetCutoffDistance),
|
||||||
|
MakeDoubleChecker<double> ())
|
||||||
;
|
;
|
||||||
return tid;
|
return tid;
|
||||||
}
|
}
|
||||||
|
@ -53,33 +38,30 @@ IslPropagationLossModel::~IslPropagationLossModel ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const double
|
|
||||||
IslPropagationLossModel::EARTH_RAD_E6 = 6.371;
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IslPropagationLossModel::GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b)
|
IslPropagationLossModel::GetLos (Ptr<MobilityModel> moda, Ptr<MobilityModel> modb)
|
||||||
{
|
{
|
||||||
// origin of LOS
|
// origin of LOS
|
||||||
Vector3D o = a->GetPosition ();
|
Vector3D oc = moda->GetPosition ();
|
||||||
o = Vector3D (o.x / 1e6, o.y / 1e6, o.z / 1e6);
|
Vector3D bp = modb->GetPosition ();
|
||||||
double ol = o.GetLength ();
|
|
||||||
|
|
||||||
// second point of LOS
|
// direction unit vector
|
||||||
Vector3D bp = b->GetPosition ();
|
Vector3D u = Vector3D (bp.x - oc.x, bp.y - oc.y, bp.z - oc.z);
|
||||||
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);
|
|
||||||
u = Vector3D (u.x / u.GetLength (), u.y / u.GetLength (), u.z / u.GetLength ());
|
u = Vector3D (u.x / u.GetLength (), u.y / u.GetLength (), u.z / u.GetLength ());
|
||||||
|
|
||||||
// center point of sphere is 0
|
double a = u.x*u.x + u.y*u.y + u.z*u.z;
|
||||||
double uo = (u.x*o.x) + (u.y*o.y) + (u.z*o.z);
|
double b = 2.0 * (oc.x*u.x + oc.y*u.y + oc.z*u.z);
|
||||||
double delta = (uo*uo) - (ol*ol - (EARTH_RAD_E6*EARTH_RAD_E6));
|
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
|
double
|
||||||
|
@ -87,12 +69,13 @@ IslPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||||
Ptr<MobilityModel> a,
|
Ptr<MobilityModel> a,
|
||||||
Ptr<MobilityModel> b) const
|
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;
|
return -1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_LOG_INFO ("LOS;"<<a->GetPosition ()<<";"<<b->GetPosition ());
|
NS_LOG_DEBUG ("LOS;"<<a->GetPosition ()<<";"<<b->GetPosition ());
|
||||||
|
|
||||||
return txPowerDbm;
|
return txPowerDbm;
|
||||||
}
|
}
|
||||||
|
@ -103,4 +86,15 @@ IslPropagationLossModel::DoAssignStreams (int64_t stream)
|
||||||
return 0;
|
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; -*- */
|
/* -*- 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
|
#ifndef ISL_PROPAGATION_LOSS_MODEL_H
|
||||||
#define ISL_PROPAGATION_LOSS_MODEL_H
|
#define ISL_PROPAGATION_LOSS_MODEL_H
|
||||||
|
@ -28,13 +6,13 @@
|
||||||
#include <ns3/object.h>
|
#include <ns3/object.h>
|
||||||
#include <ns3/propagation-loss-model.h>
|
#include <ns3/propagation-loss-model.h>
|
||||||
|
|
||||||
|
#define LEO_EARTH_RAD 6.371009e6
|
||||||
|
|
||||||
namespace ns3 {
|
namespace ns3 {
|
||||||
|
|
||||||
class IslPropagationLossModel : public PropagationLossModel
|
class IslPropagationLossModel : public PropagationLossModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const double EARTH_RAD_E6;
|
|
||||||
|
|
||||||
static TypeId GetTypeId (void);
|
static TypeId GetTypeId (void);
|
||||||
IslPropagationLossModel ();
|
IslPropagationLossModel ();
|
||||||
virtual ~IslPropagationLossModel ();
|
virtual ~IslPropagationLossModel ();
|
||||||
|
@ -50,6 +28,14 @@ public:
|
||||||
*/
|
*/
|
||||||
static bool GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b);
|
static bool GetLos (Ptr<MobilityModel> a, Ptr<MobilityModel> b);
|
||||||
private:
|
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
|
* Returns the Rx Power taking into account only the particular
|
||||||
* PropagationLossModel.
|
* PropagationLossModel.
|
||||||
|
|
|
@ -103,26 +103,26 @@ LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm,
|
||||||
Ptr<MobilityModel> b) const
|
Ptr<MobilityModel> b) const
|
||||||
{
|
{
|
||||||
double distance = a->GetDistanceFrom (b);
|
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)
|
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;
|
return -1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double angle = GetAngle (a, b);
|
||||||
if (angle > m_elevationAngle / 2.0)
|
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;
|
return -1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// txPowerDbm includes tx antenna gain and losses
|
// txPowerDbm includes tx antenna gain and losses
|
||||||
// receiver loss and gain added at net device
|
// receiver loss and gain added at net device
|
||||||
// P_{RX} = P_{TX} + G_{TX} - L_{TX} - L_{FS} - L_M + G_{RX} - L_{RX}
|
// 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;
|
return rxc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue