mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 18:13:57 +02:00
Fix bugs and write data directly to file
This commit is contained in:
parent
f8804533cc
commit
bf59e66526
3 changed files with 34 additions and 21 deletions
|
@ -1,5 +1,7 @@
|
||||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include "ns3/core-module.h"
|
#include "ns3/core-module.h"
|
||||||
#include "ns3/mobility-module.h"
|
#include "ns3/mobility-module.h"
|
||||||
#include "ns3/leo-module.h"
|
#include "ns3/leo-module.h"
|
||||||
|
@ -8,14 +10,18 @@ using namespace ns3;
|
||||||
|
|
||||||
NS_LOG_COMPONENT_DEFINE ("LeoCircularOrbitTracingExample");
|
NS_LOG_COMPONENT_DEFINE ("LeoCircularOrbitTracingExample");
|
||||||
|
|
||||||
|
ofstream outfile ("leo-circular-orbit-tracing-example.csv");
|
||||||
|
|
||||||
void CourseChange (std::string context, Ptr<const MobilityModel> position)
|
void CourseChange (std::string context, Ptr<const MobilityModel> position)
|
||||||
{
|
{
|
||||||
Vector pos = position->GetPosition ();
|
Vector pos = position->GetPosition ();
|
||||||
Ptr<const Node> node = position->GetObject<Node> ();
|
Ptr<const Node> node = position->GetObject<Node> ();
|
||||||
std::cout << Simulator::Now () << "," << node->GetId () << "," << pos.x << "," << pos.y << "," << pos.z << "," << position->GetVelocity ().GetLength() << std::endl;
|
outfile << Simulator::Now () << "," << node->GetId () << "," << pos.x << "," << pos.y << "," << pos.z << "," << position->GetVelocity ().GetLength() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
for (double incl: { 70.0, 100.0 })
|
||||||
{
|
{
|
||||||
NodeContainer c;
|
NodeContainer c;
|
||||||
c.Create (600);
|
c.Create (600);
|
||||||
|
@ -26,14 +32,15 @@ int main(int argc, char *argv[])
|
||||||
"NumSatellites", IntegerValue (100));
|
"NumSatellites", IntegerValue (100));
|
||||||
mobility.SetMobilityModel ("ns3::LeoCircularOrbitMobilityModel",
|
mobility.SetMobilityModel ("ns3::LeoCircularOrbitMobilityModel",
|
||||||
"Altitude", DoubleValue (1200.0),
|
"Altitude", DoubleValue (1200.0),
|
||||||
"Inclination", DoubleValue (80.0),
|
"Inclination", DoubleValue (incl),
|
||||||
"Precision", TimeValue (Minutes (1)));
|
"Precision", TimeValue (Minutes (1)));
|
||||||
mobility.Install (c);
|
mobility.Install (c);
|
||||||
|
}
|
||||||
|
|
||||||
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
|
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
|
||||||
MakeCallback (&CourseChange));
|
MakeCallback (&CourseChange));
|
||||||
|
|
||||||
std::cout << "Time,Satellite,x,y,z,Speed" << std::endl;
|
outfile << "Time,Satellite,x,y,z,Speed" << std::endl;
|
||||||
|
|
||||||
Simulator::Stop (Minutes (60.0));
|
Simulator::Stop (Minutes (60.0));
|
||||||
Simulator::Run ();
|
Simulator::Run ();
|
||||||
|
|
|
@ -76,6 +76,7 @@ DotProduct (const Vector3D &l, const Vector3D &r)
|
||||||
double
|
double
|
||||||
LeoCircularOrbitMobilityModel::GetSpeed () const
|
LeoCircularOrbitMobilityModel::GetSpeed () const
|
||||||
{
|
{
|
||||||
|
// force non-retrograd movement
|
||||||
return sqrt (LEO_EARTH_GM_KM_E10 / m_orbitHeight) * 1e5;
|
return sqrt (LEO_EARTH_GM_KM_E10 / m_orbitHeight) * 1e5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,9 +91,14 @@ LeoCircularOrbitMobilityModel::DoGetVelocity () const
|
||||||
Vector3D
|
Vector3D
|
||||||
LeoCircularOrbitMobilityModel::PlaneNorm () const
|
LeoCircularOrbitMobilityModel::PlaneNorm () const
|
||||||
{
|
{
|
||||||
return Vector3D (sin (-m_inclination) * cos (m_latitude),
|
int sign = 1;
|
||||||
sin (-m_inclination) * sin (m_latitude),
|
if (m_inclination < M_PI/4)
|
||||||
cos (m_inclination));
|
{
|
||||||
|
sign = -1;
|
||||||
|
}
|
||||||
|
return Vector3D (sign * sin (-m_inclination) * cos (m_latitude),
|
||||||
|
sign * sin (-m_inclination) * sin (m_latitude),
|
||||||
|
sign * cos (m_inclination));
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
|
@ -173,7 +179,7 @@ void LeoCircularOrbitMobilityModel::SetAltitude (double h)
|
||||||
|
|
||||||
double LeoCircularOrbitMobilityModel::GetInclination () const
|
double LeoCircularOrbitMobilityModel::GetInclination () const
|
||||||
{
|
{
|
||||||
return (m_inclination / M_PI) * 180.0;
|
return (m_inclination / (M_PI)) * 180.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LeoCircularOrbitMobilityModel::SetInclination (double incl)
|
void LeoCircularOrbitMobilityModel::SetInclination (double incl)
|
||||||
|
|
|
@ -7,13 +7,13 @@ unset xtics
|
||||||
unset ytics
|
unset ytics
|
||||||
unset ztics
|
unset ztics
|
||||||
unset border
|
unset border
|
||||||
set hidden3d
|
|
||||||
unset key
|
unset key
|
||||||
set view equal xyz
|
set view equal xyz
|
||||||
|
|
||||||
n=600
|
# number of nodes per time slot
|
||||||
|
n=1200
|
||||||
|
|
||||||
do for [j=0:100] {
|
do for [j=0:100] {
|
||||||
set title 'time '.j
|
set title 'time '.j
|
||||||
splot 'somefile' using 3:4:5:2 every ::(j*n)::((j+1)*n)
|
splot 'leo-circular-orbit-tracing-example.csv' using 3:4:5:2 every ::(j*n)::((j+1)*n)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue