mirror of
https://gitlab.ibr.cs.tu-bs.de/tschuber/ns-3-leo.git
synced 2025-06-08 10:03:58 +02:00
Refactor tests for brevity
This commit is contained in:
parent
37631d0758
commit
4c008e32f0
5 changed files with 112 additions and 139 deletions
|
@ -133,6 +133,7 @@ int main (int argc, char *argv[])
|
||||||
if (routingProto == "epidemic")
|
if (routingProto == "epidemic")
|
||||||
{
|
{
|
||||||
EpidemicHelper epidemic;
|
EpidemicHelper epidemic;
|
||||||
|
//epidemic.Set ("BeaconInterval", TimeValue (MilliSeconds (100)));
|
||||||
stack.SetRoutingHelper (epidemic);
|
stack.SetRoutingHelper (epidemic);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -42,7 +42,7 @@ LeoCircularOrbitMobilityModel::GetTypeId ()
|
||||||
return tid;
|
return tid;
|
||||||
}
|
}
|
||||||
|
|
||||||
LeoCircularOrbitMobilityModel::LeoCircularOrbitMobilityModel() : MobilityModel (), m_latitude (0.0), m_offset (0.0), m_position ()
|
LeoCircularOrbitMobilityModel::LeoCircularOrbitMobilityModel() : MobilityModel (), m_longitude (0.0), m_offset (0.0), m_position ()
|
||||||
{
|
{
|
||||||
NS_LOG_FUNCTION_NOARGS ();
|
NS_LOG_FUNCTION_NOARGS ();
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ LeoCircularOrbitMobilityModel::RotatePlane (double a, const Vector3D &x) const
|
||||||
double
|
double
|
||||||
LeoCircularOrbitMobilityModel::CalcLatitude () const
|
LeoCircularOrbitMobilityModel::CalcLatitude () const
|
||||||
{
|
{
|
||||||
return m_latitude + ((Simulator::Now ().GetDouble () / Hours (24).GetDouble ()) * 2 * M_PI);
|
return m_longitude + ((Simulator::Now ().GetDouble () / Hours (24).GetDouble ()) * 2 * M_PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector
|
Vector
|
||||||
|
@ -169,7 +169,7 @@ LeoCircularOrbitMobilityModel::DoSetPosition (const Vector &position)
|
||||||
// this works nicely with MobilityHelper and GetPostion will still get the
|
// this works nicely with MobilityHelper and GetPostion will still get the
|
||||||
// correct position, but be aware that it will not be the same as supplied to
|
// correct position, but be aware that it will not be the same as supplied to
|
||||||
// SetPostion
|
// SetPostion
|
||||||
m_latitude = position.x;
|
m_longitude = position.x;
|
||||||
m_offset = position.y;
|
m_offset = position.y;
|
||||||
Update ();
|
Update ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,9 +56,9 @@ private:
|
||||||
double m_inclination;
|
double m_inclination;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Latitude in rad
|
* Longitudinal offset in rad
|
||||||
*/
|
*/
|
||||||
double m_latitude;
|
double m_longitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offset on the orbital plane in rad
|
* Offset on the orbital plane in rad
|
||||||
|
|
|
@ -14,137 +14,99 @@ using namespace ns3;
|
||||||
class LeoMockChannelTransmitUnknownTestCase : public TestCase
|
class LeoMockChannelTransmitUnknownTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoMockChannelTransmitUnknownTestCase ();
|
LeoMockChannelTransmitUnknownTestCase () : TestCase ("transmission from unknown source fails") {}
|
||||||
virtual ~LeoMockChannelTransmitUnknownTestCase ();
|
virtual ~LeoMockChannelTransmitUnknownTestCase () {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void DoRun (void);
|
virtual void DoRun (void)
|
||||||
|
{
|
||||||
|
Ptr<LeoMockChannel> channel = CreateObject<LeoMockChannel> ();
|
||||||
|
Packet *packet = new Packet ();
|
||||||
|
Ptr<Packet> p = Ptr<Packet>(packet);
|
||||||
|
Address destAddr;
|
||||||
|
Time txTime;
|
||||||
|
channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
|
||||||
|
channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel"));
|
||||||
|
bool result = channel->TransmitStart (p, 10000, destAddr, txTime);
|
||||||
|
|
||||||
|
NS_TEST_ASSERT_MSG_EQ (result, false, "unknown source fails to deliver");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LeoMockChannelTransmitUnknownTestCase::LeoMockChannelTransmitUnknownTestCase ()
|
|
||||||
: TestCase ("Test transmission to unkown destination")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LeoMockChannelTransmitUnknownTestCase::~LeoMockChannelTransmitUnknownTestCase ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
LeoMockChannelTransmitUnknownTestCase::DoRun (void)
|
|
||||||
{
|
|
||||||
Ptr<LeoMockChannel> channel = CreateObject<LeoMockChannel> ();
|
|
||||||
Packet *packet = new Packet ();
|
|
||||||
Ptr<Packet> p = Ptr<Packet>(packet);
|
|
||||||
Address destAddr;
|
|
||||||
Time txTime;
|
|
||||||
channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
|
|
||||||
channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel"));
|
|
||||||
bool result = channel->TransmitStart (p, 10000, destAddr, txTime);
|
|
||||||
|
|
||||||
NS_TEST_ASSERT_MSG_EQ (result, false, "Unknown source fails to deliver");
|
|
||||||
}
|
|
||||||
|
|
||||||
class LeoMockChannelTransmitKnownTestCase : public TestCase
|
class LeoMockChannelTransmitKnownTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoMockChannelTransmitKnownTestCase ();
|
LeoMockChannelTransmitKnownTestCase () : TestCase ("transmission from known source succeeds") {}
|
||||||
virtual ~LeoMockChannelTransmitKnownTestCase ();
|
virtual ~LeoMockChannelTransmitKnownTestCase () {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void DoRun (void);
|
virtual void DoRun (void)
|
||||||
|
{
|
||||||
|
Ptr<LeoMockChannel> channel = CreateObject<LeoMockChannel> ();
|
||||||
|
channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
|
||||||
|
channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel"));
|
||||||
|
|
||||||
|
Packet *packet = new Packet ();
|
||||||
|
Ptr<Packet> p = Ptr<Packet>(packet);
|
||||||
|
|
||||||
|
Ptr<Node> srcNode = CreateObject<Node> ();
|
||||||
|
Ptr<LeoMockNetDevice> srcDev = CreateObject<LeoMockNetDevice> ();
|
||||||
|
srcDev->SetNode (srcNode);
|
||||||
|
srcDev->SetDeviceType (LeoMockNetDevice::GND);
|
||||||
|
srcDev->SetAddress (Mac48Address::Allocate ());
|
||||||
|
int32_t srcId = channel->Attach (srcDev);
|
||||||
|
|
||||||
|
Ptr<Node> dstNode = CreateObject<Node> ();
|
||||||
|
Ptr<LeoMockNetDevice> dstDev = CreateObject<LeoMockNetDevice> ();
|
||||||
|
dstDev->SetNode (dstNode);
|
||||||
|
dstDev->SetDeviceType (LeoMockNetDevice::SAT);
|
||||||
|
dstDev->SetAddress (Mac48Address::Allocate ());
|
||||||
|
channel->Attach (dstDev);
|
||||||
|
|
||||||
|
Address destAddr = dstDev->GetAddress ();
|
||||||
|
Time txTime;
|
||||||
|
bool result = channel->TransmitStart (p, srcId, destAddr, txTime);
|
||||||
|
|
||||||
|
NS_TEST_ASSERT_MSG_EQ (result, true, "known source does not deliver");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LeoMockChannelTransmitKnownTestCase::LeoMockChannelTransmitKnownTestCase ()
|
|
||||||
: TestCase ("Test transmission to known destination")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LeoMockChannelTransmitKnownTestCase::~LeoMockChannelTransmitKnownTestCase ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
LeoMockChannelTransmitKnownTestCase::DoRun (void)
|
|
||||||
{
|
|
||||||
Ptr<LeoMockChannel> channel = CreateObject<LeoMockChannel> ();
|
|
||||||
channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
|
|
||||||
channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel"));
|
|
||||||
|
|
||||||
Packet *packet = new Packet ();
|
|
||||||
Ptr<Packet> p = Ptr<Packet>(packet);
|
|
||||||
|
|
||||||
Ptr<Node> srcNode = CreateObject<Node> ();
|
|
||||||
Ptr<LeoMockNetDevice> srcDev = CreateObject<LeoMockNetDevice> ();
|
|
||||||
srcDev->SetNode (srcNode);
|
|
||||||
srcDev->SetDeviceType (LeoMockNetDevice::GND);
|
|
||||||
srcDev->SetAddress (Mac48Address::Allocate ());
|
|
||||||
int32_t srcId = channel->Attach (srcDev);
|
|
||||||
|
|
||||||
Ptr<Node> dstNode = CreateObject<Node> ();
|
|
||||||
Ptr<LeoMockNetDevice> dstDev = CreateObject<LeoMockNetDevice> ();
|
|
||||||
dstDev->SetNode (dstNode);
|
|
||||||
dstDev->SetDeviceType (LeoMockNetDevice::SAT);
|
|
||||||
dstDev->SetAddress (Mac48Address::Allocate ());
|
|
||||||
channel->Attach (dstDev);
|
|
||||||
|
|
||||||
Address destAddr = dstDev->GetAddress ();
|
|
||||||
Time txTime;
|
|
||||||
bool result = channel->TransmitStart (p, srcId, destAddr, txTime);
|
|
||||||
|
|
||||||
NS_TEST_ASSERT_MSG_EQ (result, true, "Known source delivers");
|
|
||||||
}
|
|
||||||
|
|
||||||
class LeoMockChannelTransmitSpaceGroundTestCase : public TestCase
|
class LeoMockChannelTransmitSpaceGroundTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoMockChannelTransmitSpaceGroundTestCase ();
|
LeoMockChannelTransmitSpaceGroundTestCase () : TestCase ("space to ground transmission succeeds") {}
|
||||||
virtual ~LeoMockChannelTransmitSpaceGroundTestCase ();
|
virtual ~LeoMockChannelTransmitSpaceGroundTestCase () {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void DoRun (void);
|
virtual void DoRun (void)
|
||||||
|
{
|
||||||
|
Ptr<LeoMockChannel> channel = CreateObject<LeoMockChannel> ();
|
||||||
|
channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
|
||||||
|
channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel"));
|
||||||
|
|
||||||
|
Packet *packet = new Packet ();
|
||||||
|
Ptr<Packet> p = Ptr<Packet>(packet);
|
||||||
|
|
||||||
|
Ptr<Node> srcNode = CreateObject<Node> ();
|
||||||
|
Ptr<LeoMockNetDevice> srcDev = CreateObject<LeoMockNetDevice> ();
|
||||||
|
srcDev->SetNode (srcNode);
|
||||||
|
srcDev->SetDeviceType (LeoMockNetDevice::SAT);
|
||||||
|
srcDev->SetAddress (Mac48Address::Allocate ());
|
||||||
|
int32_t srcId = channel->Attach (srcDev);
|
||||||
|
|
||||||
|
Ptr<Node> dstNode = CreateObject<Node> ();
|
||||||
|
Ptr<LeoMockNetDevice> dstDev = CreateObject<LeoMockNetDevice> ();
|
||||||
|
dstDev->SetNode (dstNode);
|
||||||
|
dstDev->SetDeviceType (LeoMockNetDevice::GND);
|
||||||
|
dstDev->SetAddress (Mac48Address::Allocate ());
|
||||||
|
channel->Attach (dstDev);
|
||||||
|
|
||||||
|
Address destAddr = dstDev->GetAddress ();
|
||||||
|
Time txTime;
|
||||||
|
bool result = channel->TransmitStart (p, srcId, destAddr, txTime);
|
||||||
|
|
||||||
|
NS_TEST_ASSERT_MSG_EQ (result, true, "space to ground transmission failed");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
LeoMockChannelTransmitSpaceGroundTestCase::LeoMockChannelTransmitSpaceGroundTestCase ()
|
|
||||||
: TestCase ("Test transmission to known destination")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LeoMockChannelTransmitSpaceGroundTestCase::~LeoMockChannelTransmitSpaceGroundTestCase ()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
LeoMockChannelTransmitSpaceGroundTestCase::DoRun (void)
|
|
||||||
{
|
|
||||||
Ptr<LeoMockChannel> channel = CreateObject<LeoMockChannel> ();
|
|
||||||
channel->SetAttribute ("PropagationDelay", StringValue ("ns3::ConstantSpeedPropagationDelayModel"));
|
|
||||||
channel->SetAttribute ("PropagationLoss", StringValue ("ns3::LeoPropagationLossModel"));
|
|
||||||
|
|
||||||
Packet *packet = new Packet ();
|
|
||||||
Ptr<Packet> p = Ptr<Packet>(packet);
|
|
||||||
|
|
||||||
Ptr<Node> srcNode = CreateObject<Node> ();
|
|
||||||
Ptr<LeoMockNetDevice> srcDev = CreateObject<LeoMockNetDevice> ();
|
|
||||||
srcDev->SetNode (srcNode);
|
|
||||||
srcDev->SetDeviceType (LeoMockNetDevice::SAT);
|
|
||||||
srcDev->SetAddress (Mac48Address::Allocate ());
|
|
||||||
int32_t srcId = channel->Attach (srcDev);
|
|
||||||
|
|
||||||
Ptr<Node> dstNode = CreateObject<Node> ();
|
|
||||||
Ptr<LeoMockNetDevice> dstDev = CreateObject<LeoMockNetDevice> ();
|
|
||||||
dstDev->SetNode (dstNode);
|
|
||||||
dstDev->SetDeviceType (LeoMockNetDevice::GND);
|
|
||||||
dstDev->SetAddress (Mac48Address::Allocate ());
|
|
||||||
channel->Attach (dstDev);
|
|
||||||
|
|
||||||
Address destAddr = dstDev->GetAddress ();
|
|
||||||
Time txTime;
|
|
||||||
bool result = channel->TransmitStart (p, srcId, destAddr, txTime);
|
|
||||||
|
|
||||||
NS_TEST_ASSERT_MSG_EQ (result, true, "Space to ground destination delivers");
|
|
||||||
}
|
|
||||||
|
|
||||||
class LeoMockChannelTestSuite : public TestSuite
|
class LeoMockChannelTestSuite : public TestSuite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -154,11 +116,9 @@ public:
|
||||||
LeoMockChannelTestSuite::LeoMockChannelTestSuite ()
|
LeoMockChannelTestSuite::LeoMockChannelTestSuite ()
|
||||||
: TestSuite ("leo-mock-channel", UNIT)
|
: TestSuite ("leo-mock-channel", UNIT)
|
||||||
{
|
{
|
||||||
// TestDuration for TestCase can be QUICK, EXTENSIVE or TAKES_FOREVER
|
|
||||||
AddTestCase (new LeoMockChannelTransmitUnknownTestCase, TestCase::QUICK);
|
AddTestCase (new LeoMockChannelTransmitUnknownTestCase, TestCase::QUICK);
|
||||||
AddTestCase (new LeoMockChannelTransmitKnownTestCase, TestCase::QUICK);
|
AddTestCase (new LeoMockChannelTransmitKnownTestCase, TestCase::QUICK);
|
||||||
AddTestCase (new LeoMockChannelTransmitSpaceGroundTestCase, TestCase::QUICK);
|
AddTestCase (new LeoMockChannelTransmitSpaceGroundTestCase, TestCase::QUICK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do not forget to allocate an instance of this TestSuite
|
|
||||||
static LeoMockChannelTestSuite islMockChannelTestSuite;
|
static LeoMockChannelTestSuite islMockChannelTestSuite;
|
||||||
|
|
|
@ -14,7 +14,7 @@ using namespace ns3;
|
||||||
class LeoOrbitSpeedTestCase : public TestCase
|
class LeoOrbitSpeedTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoOrbitSpeedTestCase () : TestCase ("Test speed for 0 altitude") {}
|
LeoOrbitSpeedTestCase () : TestCase ("speed at 0 altitude is earth rotation speed") {}
|
||||||
virtual ~LeoOrbitSpeedTestCase () {}
|
virtual ~LeoOrbitSpeedTestCase () {}
|
||||||
private:
|
private:
|
||||||
virtual void DoRun (void)
|
virtual void DoRun (void)
|
||||||
|
@ -22,14 +22,14 @@ private:
|
||||||
Ptr<LeoCircularOrbitMobilityModel> mob = CreateObject<LeoCircularOrbitMobilityModel> ();
|
Ptr<LeoCircularOrbitMobilityModel> mob = CreateObject<LeoCircularOrbitMobilityModel> ();
|
||||||
mob->SetAttribute ("Altitude", DoubleValue (0.0));
|
mob->SetAttribute ("Altitude", DoubleValue (0.0));
|
||||||
|
|
||||||
NS_TEST_ASSERT_MSG_EQ ((uint64_t) mob->GetSpeed (), (uint64_t) 7909.79, "Unexpected velocity at earths surface");
|
NS_TEST_ASSERT_MSG_EQ ((uint64_t) mob->GetSpeed (), (uint64_t) 7909.79, "postion at 0 altitude is on surface");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LeoOrbitPositionTestCase : public TestCase
|
class LeoOrbitPositionTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoOrbitPositionTestCase () : TestCase ("Test position for 0 altitude and 1.0 inclination") {}
|
LeoOrbitPositionTestCase () : TestCase ("position is on surface") {}
|
||||||
virtual ~LeoOrbitPositionTestCase () {}
|
virtual ~LeoOrbitPositionTestCase () {}
|
||||||
private:
|
private:
|
||||||
virtual void DoRun (void)
|
virtual void DoRun (void)
|
||||||
|
@ -38,21 +38,21 @@ private:
|
||||||
mob->SetAttribute ("Altitude", DoubleValue (0.0));
|
mob->SetAttribute ("Altitude", DoubleValue (0.0));
|
||||||
mob->SetAttribute ("Inclination", DoubleValue (1.0));
|
mob->SetAttribute ("Inclination", DoubleValue (1.0));
|
||||||
|
|
||||||
NS_TEST_ASSERT_MSG_EQ_TOL (mob->GetPosition ().GetLength() / 1000, LEO_EARTH_RAD_KM, 0.1, "Unexpected position on earths surface for 1 deg inclination");
|
NS_TEST_ASSERT_MSG_EQ_TOL (mob->GetPosition ().GetLength() / 1000, LEO_EARTH_RAD_KM, 0.1, "unexpected position on earths surface for 1 deg inclination");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LeoOrbitProgressTestCase : public TestCase
|
class LeoOrbitProgressTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoOrbitProgressTestCase () : TestCase ("Test position shoudl not be the same after some time") {}
|
LeoOrbitProgressTestCase () : TestCase ("position changes over time") {}
|
||||||
virtual ~LeoOrbitProgressTestCase () {}
|
virtual ~LeoOrbitProgressTestCase () {}
|
||||||
private:
|
private:
|
||||||
void TestLengthPosition (double expl, double expx, Ptr<LeoCircularOrbitMobilityModel> mob)
|
void TestLengthPosition (double expl, double expx, Ptr<LeoCircularOrbitMobilityModel> mob)
|
||||||
{
|
{
|
||||||
Vector pos = mob->GetPosition ();
|
Vector pos = mob->GetPosition ();
|
||||||
NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (pos.GetLength () / 1000, expl, 0.001, "Distance to earth should be the same", __FILE__, __LINE__);
|
NS_TEST_EXPECT_MSG_EQ_TOL_INTERNAL (pos.GetLength () / 1000, expl, 0.001, "Distance to earth should be the same", __FILE__, __LINE__);
|
||||||
NS_TEST_EXPECT_MSG_NE_INTERNAL (pos.x, expx, "Position should not be equal", __FILE__, __LINE__);
|
NS_TEST_EXPECT_MSG_NE_INTERNAL (pos.x, expx, "position should not be equal", __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void DoRun (void)
|
virtual void DoRun (void)
|
||||||
|
@ -72,7 +72,7 @@ private:
|
||||||
class LeoOrbitLatitudeTestCase : public TestCase
|
class LeoOrbitLatitudeTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoOrbitLatitudeTestCase () : TestCase ("Test offset between neighboring satellites planes") {}
|
LeoOrbitLatitudeTestCase () : TestCase ("neighboring satellite planes have offset") {}
|
||||||
virtual ~LeoOrbitLatitudeTestCase () {}
|
virtual ~LeoOrbitLatitudeTestCase () {}
|
||||||
private:
|
private:
|
||||||
virtual void DoRun (void)
|
virtual void DoRun (void)
|
||||||
|
@ -86,14 +86,14 @@ private:
|
||||||
mob->SetPosition (Vector3D (20.0, 0, 0));
|
mob->SetPosition (Vector3D (20.0, 0, 0));
|
||||||
Vector pos2 = mob->GetPosition ();
|
Vector pos2 = mob->GetPosition ();
|
||||||
|
|
||||||
NS_TEST_ASSERT_MSG_NE (pos1.x, pos2.x, "Neighboring satellite should have different position");
|
NS_TEST_ASSERT_MSG_NE (pos1.x, pos2.x, "neighboring satellite planes should have different position");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LeoOrbitOffsetTestCase : public TestCase
|
class LeoOrbitOffsetTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoOrbitOffsetTestCase () : TestCase ("Test offset between neighboring satellites") {}
|
LeoOrbitOffsetTestCase () : TestCase ("neighboring satellites have offset") {}
|
||||||
virtual ~LeoOrbitOffsetTestCase () {}
|
virtual ~LeoOrbitOffsetTestCase () {}
|
||||||
private:
|
private:
|
||||||
virtual void DoRun (void)
|
virtual void DoRun (void)
|
||||||
|
@ -107,21 +107,19 @@ private:
|
||||||
mob->SetPosition (Vector3D (0, 20.0, 0));
|
mob->SetPosition (Vector3D (0, 20.0, 0));
|
||||||
Vector pos2 = mob->GetPosition ();
|
Vector pos2 = mob->GetPosition ();
|
||||||
|
|
||||||
NS_TEST_ASSERT_MSG_NE (pos1.x, pos2.x, "Neighboring satellite should have different position");
|
NS_TEST_ASSERT_MSG_NE (pos1.x, pos2.x, "neighboring satellite should have different position");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LeoOrbitTracingTestCase : public TestCase
|
class LeoOrbitTracingTestCase : public TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LeoOrbitTracingTestCase () : TestCase ("Test tracing of position changes") {}
|
LeoOrbitTracingTestCase () : TestCase ("position changes are traced") {}
|
||||||
virtual ~LeoOrbitTracingTestCase () {}
|
virtual ~LeoOrbitTracingTestCase () {}
|
||||||
static void CourseChange (std::string context, Ptr<const MobilityModel> position)
|
|
||||||
{
|
static uint64_t traced;
|
||||||
Vector pos = position->GetPosition ();
|
|
||||||
std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y
|
static void CourseChange (std::string context, Ptr<const MobilityModel> position);
|
||||||
<< ", z=" << pos.z << std::endl;
|
|
||||||
}
|
|
||||||
private:
|
private:
|
||||||
virtual void DoRun (void)
|
virtual void DoRun (void)
|
||||||
{
|
{
|
||||||
|
@ -142,13 +140,27 @@ private:
|
||||||
|
|
||||||
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
|
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
|
||||||
MakeCallback (&CourseChange));
|
MakeCallback (&CourseChange));
|
||||||
|
traced = 0;
|
||||||
|
|
||||||
Simulator::Stop (Seconds (100.0));
|
Simulator::Stop (Seconds (100.0));
|
||||||
Simulator::Run ();
|
Simulator::Run ();
|
||||||
|
|
||||||
|
NS_TEST_ASSERT_MSG_GT (traced, 8, "position not every time");
|
||||||
|
|
||||||
Simulator::Destroy ();
|
Simulator::Destroy ();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
uint64_t LeoOrbitTracingTestCase::traced = 0;
|
||||||
|
|
||||||
|
void LeoOrbitTracingTestCase::CourseChange (std::string context, Ptr<const MobilityModel> position)
|
||||||
|
{
|
||||||
|
traced ++;
|
||||||
|
Vector pos = position->GetPosition ();
|
||||||
|
std::cout << Simulator::Now () << ", pos=" << position << ", x=" << pos.x << ", y=" << pos.y
|
||||||
|
<< ", z=" << pos.z << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class LeoOrbitTestSuite : TestSuite
|
class LeoOrbitTestSuite : TestSuite
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue