20#include <ns3/geographic-positions.h>
78 double originLongitude,
81 double maxDistFromOrigin,
86 void DoRun()
override;
94 static std::string
Name(
double originLatitude,
95 double originLongitude,
96 double maxDistFromOrigin);
107 double originLongitude,
108 double maxDistFromOrigin)
110 std::ostringstream oss;
111 oss <<
"origin latitude = " << originLatitude <<
" degrees, "
112 <<
"origin longitude = " << originLongitude <<
" degrees, "
113 <<
"max distance from origin = " << maxDistFromOrigin;
118 double originLongitude,
121 double maxDistFromOrigin,
123 :
TestCase(
Name(originLatitude, originLongitude, maxDistFromOrigin)),
124 m_originLatitude(originLatitude),
125 m_originLongitude(originLongitude),
126 m_maxAltitude(maxAltitude),
127 m_numPoints(numPoints),
128 m_maxDistFromOrigin(maxDistFromOrigin),
140 std::list<Vector> points =
141 GeographicPositions::RandCartesianPointsAroundGeographicPoint(
m_originLatitude,
151 GeographicPositions::SPHERE);
153 while (!points.empty())
155 randPoint = points.front();
159 double straightDistFromOrigin =
160 sqrt(pow(randPoint.x - origin.x, 2) + pow(randPoint.y - origin.y, 2) +
161 pow(randPoint.z - origin.z, 2));
164 double arcDistFromOrigin =
169 "random point (" << randPoint.x <<
", " << randPoint.y <<
", "
171 <<
") is outside of max radius from origin");
188 :
TestSuite(
"rand-cart-around-geo", UNIT)
190 NS_LOG_INFO(
"creating RandCartAroundGeoTestSuite");
193 for (
double originLatitude = -89.9; originLatitude <= 89.9; originLatitude += 35.96)
195 for (
double originLongitude = 0; originLongitude <= 360; originLongitude += 72)
197 for (
double maxDistFromOrigin = 1000; maxDistFromOrigin <= 1000000;
198 maxDistFromOrigin *= 10)
Rand Cart Around Geo Test Case.
double m_maxAltitude
maximum altitude
void DoRun() override
Implementation to actually run this TestCase.
double m_originLongitude
origin longitude
double m_originLatitude
origin latitude
~RandCartAroundGeoTestCase() override
static std::string Name(double originLatitude, double originLongitude, double maxDistFromOrigin)
name function
RandCartAroundGeoTestCase(double originLatitude, double originLongitude, double maxAltitude, int numPoints, double maxDistFromOrigin, Ptr< UniformRandomVariable > uniRand)
Constructor.
int m_numPoints
number of points
double m_maxDistFromOrigin
maximum distance from origin
Ptr< UniformRandomVariable > m_uniRand
random number
Rand Cart Around Geo Test Suite.
RandCartAroundGeoTestSuite()
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_TEST_ASSERT_MSG_LT(actual, limit, msg)
Test that an actual value is less than a limit and report and abort if not.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static RandCartAroundGeoTestSuite g_RandCartAroundGeoTestSuite
the test suite
static const double EARTH_RADIUS
earth's radius in meters if modeled as a perfect sphere
const double TOLERANCE
0.1 meter tolerance for testing, which is very small compared to the maximum distances from origin be...
static std::string Name(std::string str, uint32_t totalStreamSize, uint32_t sourceWriteSize, uint32_t serverReadSize, uint32_t serverWriteSize, uint32_t sourceReadSize, bool useIpv6)