diff --git a/examples/leo-delay-tracing-example.cc b/examples/leo-delay-tracing-example.cc index 7969fcc..0fa17e6 100644 --- a/examples/leo-delay-tracing-example.cc +++ b/examples/leo-delay-tracing-example.cc @@ -74,17 +74,18 @@ int main (int argc, char *argv[]) // Install internet stack on nodes AodvHelper aodv; - aodv.Set ("HelloInterval", TimeValue (Seconds (1))); - aodv.Set ("TtlStart", UintegerValue (10)); - aodv.Set ("TtlIncrement", UintegerValue (10)); - aodv.Set ("TtlThreshold", UintegerValue (100)); - aodv.Set ("RreqRetries", UintegerValue (100)); - aodv.Set ("RreqRateLimit", UintegerValue (10)); - aodv.Set ("RerrRateLimit", UintegerValue (10)); - aodv.Set ("ActiveRouteTimeout", TimeValue (Minutes (1))); - aodv.Set ("NextHopWait", TimeValue (MilliSeconds (200))); - aodv.Set ("NetDiameter", UintegerValue (1000)); - aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1))); + //aodv.Set ("HelloInterval", TimeValue (Minutes (1))); + aodv.Set ("TtlStart", UintegerValue (5)); + aodv.Set ("TtlIncrement", UintegerValue (5)); + aodv.Set ("TtlThreshold", UintegerValue (200)); + aodv.Set ("RreqRetries", UintegerValue (1000)); + aodv.Set ("RreqRateLimit", UintegerValue (100)); + //aodv.Set ("RerrRateLimit", UintegerValue (1)); + //aodv.Set ("ActiveRouteTimeout", TimeValue (Minutes (1))); + //aodv.Set ("NextHopWait", TimeValue (MilliSeconds (200))); + aodv.Set ("NetDiameter", UintegerValue (100)); + //aodv.Set ("AllowedHelloLoss", UintegerValue (10000)); + //aodv.Set ("PathDiscoveryTime", TimeValue (Seconds (1))); InternetStackHelper stack; stack.SetRoutingHelper (aodv); @@ -107,8 +108,8 @@ int main (int argc, char *argv[]) Address remote = stations.Get (1)->GetObject ()->GetAddress (1, 0).GetLocal ();//utIp.GetAddress (1, 0); std::cout << "REMOTE=" << Ipv4Address::ConvertFrom (remote); UdpClientHelper echoClient (remote, 9); - echoClient.SetAttribute ("MaxPackets", UintegerValue (360)); - echoClient.SetAttribute ("Interval", TimeValue (Seconds (10.0))); + echoClient.SetAttribute ("MaxPackets", UintegerValue (60)); + echoClient.SetAttribute ("Interval", TimeValue (Seconds (1))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024)); 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; 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::Destroy (); diff --git a/model/isl-propagation-loss-model.cc b/model/isl-propagation-loss-model.cc index bc2813f..b0d9f4e 100644 --- a/model/isl-propagation-loss-model.cc +++ b/model/isl-propagation-loss-model.cc @@ -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 - * Contributions: Timo Bingmann - * Contributions: Gary Pei for fixed RSS - * Contributions: Tom Hewer for two ray ground model - * Pavel Boyko 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 () .SetGroupName ("Leo") .AddConstructor () + .AddAttribute ("MaxDistance", + "Cut-off distance for signal propagation", + DoubleValue (1000.0), + MakeDoubleAccessor (&IslPropagationLossModel::SetCutoffDistance, + &IslPropagationLossModel::GetCutoffDistance), + MakeDoubleChecker ()) ; return tid; } @@ -53,33 +38,30 @@ IslPropagationLossModel::~IslPropagationLossModel () { } - -const double -IslPropagationLossModel::EARTH_RAD_E6 = 6.371; - bool -IslPropagationLossModel::GetLos (Ptr a, Ptr b) +IslPropagationLossModel::GetLos (Ptr moda, Ptr 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="<GetPosition () + <<";u="<GetPosition ()<<";"<GetPosition ()); return -1000.0; } - NS_LOG_INFO ("LOS;"<GetPosition ()<<";"<GetPosition ()); + NS_LOG_DEBUG ("LOS;"<GetPosition ()<<";"<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; +} }; diff --git a/model/isl-propagation-loss-model.h b/model/isl-propagation-loss-model.h index 49b841f..2bf0e19 100644 --- a/model/isl-propagation-loss-model.h +++ b/model/isl-propagation-loss-model.h @@ -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 - * Contributions: Timo Bingmann - * Contributions: Gary Pei for fixed RSS - * Contributions: Tom Hewer for two ray ground model - * Pavel Boyko for matrix - */ #ifndef ISL_PROPAGATION_LOSS_MODEL_H #define ISL_PROPAGATION_LOSS_MODEL_H @@ -28,13 +6,13 @@ #include #include +#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 a, Ptr 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. diff --git a/model/leo-propagation-loss-model.cc b/model/leo-propagation-loss-model.cc index 29761fe..b820be9 100644 --- a/model/leo-propagation-loss-model.cc +++ b/model/leo-propagation-loss-model.cc @@ -103,26 +103,26 @@ LeoPropagationLossModel::DoCalcRxPower (double txPowerDbm, Ptr 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="<