diff --git a/examples/wscript b/examples/wscript index 51903d1..f07fd36 100644 --- a/examples/wscript +++ b/examples/wscript @@ -4,7 +4,10 @@ def build(bld): if not bld.env['ENABLE_EXAMPLES']: return; - obj = bld.create_ns3_program('leo-circular-orbit-trace', + obj = bld.create_ns3_program('leo-circular-orbit', ['core', 'leo', 'mobility']) 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' diff --git a/helper/leo-channel-helper.cc b/helper/leo-channel-helper.cc index 4d729b5..7a12444 100644 --- a/helper/leo-channel-helper.cc +++ b/helper/leo-channel-helper.cc @@ -8,6 +8,7 @@ #include "ns3/names.h" #include "ns3/assert.h" #include "ns3/string.h" +#include "ns3/data-rate.h" #include "../model/leo-mock-channel.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 ("RxGain", DoubleValue (rxLoss)); - m_gndDeviceFactory.Set ("DataRate", DoubleValue (dataRate)); - m_satDeviceFactory.Set ("DataRate", DoubleValue (dataRate)); + m_gndDeviceFactory.Set ("DataRate", DataRateValue (DataRate (dataRate))); + m_satDeviceFactory.Set ("DataRate", DataRateValue (DataRate (dataRate))); 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 ("LinkMargin", DoubleValue (linkMargin)); } diff --git a/model/isl-propagation-loss-model.cc b/model/isl-propagation-loss-model.cc index 9b379a5..681e22e 100644 --- a/model/isl-propagation-loss-model.cc +++ b/model/isl-propagation-loss-model.cc @@ -55,25 +55,29 @@ IslPropagationLossModel::~IslPropagationLossModel () const double -IslPropagationLossModel::EARTH_RAD = 6.3781E6; +IslPropagationLossModel::EARTH_RAD_E6 = 6.371; bool IslPropagationLossModel::GetLos (Ptr a, Ptr 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="< a, Ptr 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="<GetPosition ()<<";"<GetPosition ()); + + return txPowerDbm; } int64_t diff --git a/model/isl-propagation-loss-model.h b/model/isl-propagation-loss-model.h index 3eba95c..49b841f 100644 --- a/model/isl-propagation-loss-model.h +++ b/model/isl-propagation-loss-model.h @@ -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 (); diff --git a/model/leo-circular-orbit-mobility-model.cc b/model/leo-circular-orbit-mobility-model.cc index 684f20a..fb4b89c 100644 --- a/model/leo-circular-orbit-mobility-model.cc +++ b/model/leo-circular-orbit-mobility-model.cc @@ -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; diff --git a/model/leo-mock-net-device.cc b/model/leo-mock-net-device.cc index 2a36f43..6b279e6 100644 --- a/model/leo-mock-net-device.cc +++ b/model/leo-mock-net-device.cc @@ -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 ()) - .AddAttribute ("ReceiverLoss", + .AddAttribute ("RxLoss", "Receiver loss in dBm", DoubleValue (0.0), MakeDoubleAccessor (&LeoMockNetDevice::m_rxLoss), diff --git a/model/leo-propagation-loss-model.cc b/model/leo-propagation-loss-model.cc index 94e30bc..7557b3c 100644 --- a/model/leo-propagation-loss-model.cc +++ b/model/leo-propagation-loss-model.cc @@ -23,7 +23,7 @@ LeoPropagationLossModel::GetTypeId (void) .AddConstructor () .AddAttribute ("MaxDistance", "Cut-off distance for signal propagation", - DoubleValue (1000000.0), + DoubleValue (100000.0), MakeDoubleAccessor (&LeoPropagationLossModel::m_cutoffDistance), MakeDoubleChecker ()) .AddAttribute ("ElevationAngle", diff --git a/model/mock-channel.cc b/model/mock-channel.cc index b8f32ff..fb28161 100644 --- a/model/mock-channel.cc +++ b/model/mock-channel.cc @@ -171,8 +171,8 @@ MockChannel::Deliver ( NS_LOG_FUNCTION (this << p << src->GetAddress () << dst->GetAddress () << txTime); Time delay = txTime; - Ptr srcMob = src->GetObject (); - Ptr dstMob = dst->GetObject (); + Ptr srcMob = src->GetNode ()->GetObject (); + Ptr dstMob = dst->GetNode ()->GetObject (); 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, diff --git a/test/isl-propagation-test-suite.cc b/test/isl-propagation-test-suite.cc index bc3fff8..c7a1c74 100644 --- a/test/isl-propagation-test-suite.cc +++ b/test/isl-propagation-test-suite.cc @@ -26,13 +26,15 @@ IslPropagationAngleTestCase1::~IslPropagationAngleTestCase1 () { } +#define EARTH_RAD 6.3781e6 + void IslPropagationAngleTestCase1::DoRun (void) { Ptr a = CreateObject (); - a->SetPosition (Vector3D (IslPropagationLossModel::EARTH_RAD + 1000.0, 10, 0)); + a->SetPosition (Vector3D (EARTH_RAD + 1.0e6, 10, 0)); Ptr b = CreateObject (); - 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"); } @@ -60,9 +62,9 @@ void IslPropagationAngleTestCase2::DoRun (void) { Ptr a = CreateObject (); - a->SetPosition (Vector3D (IslPropagationLossModel::EARTH_RAD + 1000.0, 0, 0)); + a->SetPosition (Vector3D (EARTH_RAD + 1.0e6, 0, 0)); Ptr b = CreateObject (); - 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"); } diff --git a/utils/plot-satellites.gnuplot b/utils/plot-satellites.gnuplot index 7e4ed2f..f39ac76 100644 --- a/utils/plot-satellites.gnuplot +++ b/utils/plot-satellites.gnuplot @@ -8,6 +8,7 @@ unset ytics unset ztics unset border unset key +set hidden3d set view equal xyz # number of nodes per time slot