49#include "ns3/boolean.h"
50#include "ns3/data-rate.h"
51#include "ns3/error-model.h"
52#include "ns3/internet-stack-helper.h"
53#include "ns3/ipv4-address-helper.h"
54#include "ns3/ipv4-interface-container.h"
55#include "ns3/ipv6-address-helper.h"
56#include "ns3/ipv6-interface-container.h"
58#include "ns3/neighbor-cache-helper.h"
59#include "ns3/node-container.h"
60#include "ns3/nstime.h"
62#include "ns3/simple-net-device-helper.h"
63#include "ns3/simple-net-device.h"
64#include "ns3/simulator.h"
66#include "ns3/uinteger.h"
203 void DoRun()
override;
288 device0->SetMtu(
m_mtu);
290 device1->SetMtu(
m_mtu);
306 ipv4AddrHelper.
SetBase(
"10.0.0.0",
"255.255.255.0");
375 "Rtt sample not within 0.0001 ms of expected value of 20.0013 ms");
385 "Rtt sample not within 0.0001 ms of expected value of 20.0017 ms");
403 "configured interval didn't match the observed interval");
412 if (reason == Ping::DropReason::DROP_TIMEOUT)
418 NS_LOG_DEBUG(
"Destination host is unreachable " << seq);
422 NS_LOG_DEBUG(
"Destination network not reachable " << seq);
435 "Report transmit count does not equal expected");
441 "Report receive count does not equal expected");
447 "Report lost count does not equal expected");
454 "Report application not stopped at expected time");
522 netDev->SetReceiveErrorModel(errorModel);
547 "Traced Tx events do not equal expected");
553 "Traced Rtt events do not equal expected");
580 "1. Unlimited pings, no losses, StopApplication () with no packets in flight IPv4",
592 "1. Unlimited pings, no losses, StopApplication () with no packets in flight IPv6",
612 "2. Unlimited pings, no losses, StopApplication () with 1 packet in flight IPv4",
623 "2. Unlimited pings, no losses, StopApplication () with 1 packet in flight IPv6",
649 new PingTestCase(
"3. Test for operation of count attribute and exit "
650 "time after all pings were received, IPv4",
664 new PingTestCase(
"3. Test for operation of count attribute and exit "
665 "time after all pings were received, IPv6",
771 new PingTestCase(
"6. Test for behavior of ping to all-nodes multicast IPv6 address",
795 "7. Test behavior of first reply lost in a count-limited configuration, IPv4",
797 std::list<uint32_t> dropList{0};
811 "7. Test behavior of first reply lost in a count-limited configuration, IPv6",
840 "8. Test behavior of second reply lost in a count-limited configuration, IPv4",
842 std::list<uint32_t> dropList2{1};
856 "8. Test behavior of second reply lost in a count-limited configuration, IPv6",
885 "9. Test behavior of last reply lost in a count-limited configuration, IPv4",
887 std::list<uint32_t> dropList3{2};
901 "9. Test behavior of last reply lost in a count-limited configuration, IPv6",
Time m_interpacketInterval
Time between pings.
bool m_checkReportTime
Set to true to check the Time.
Time m_simulatorStopTime
Simulator stop time.
void RttTraceSink(uint16_t seq, Time rttSample)
Trace RTT events.
uint32_t m_sizeAttribute
Size of pings.
uint16_t m_expectedReportLoss
Expected reported Loss.
uint32_t m_countTraceRtt
Rtt trace counter.
uint32_t m_expectedReportTx
Expected reported Tx.
void SetStartTime(Time startTime)
Set the PING start time.
void SetStopTime(Time stopTime)
Set the PING stop time.
PingTestCase(std::string name, bool useIpv6)
Constructor.
uint32_t m_expectedTraceRtt
Expected Rtt trace sink calls.
void CheckReportTime(Time expectedTime)
Enable the check on average RTT.
void SetSimulatorStopTime(Time stopTime)
Set the Simulation stop time.
bool m_checkTraceTx
Set to true to check the Tx number.
void TxTraceSink(uint16_t seq, Ptr< Packet > p)
Trace TX events.
Ipv6InterfaceContainer m_ipv6Interfaces
The IPv6 interfaces.
uint32_t m_countTraceTx
Tx trace counter.
Time m_lastTx
Last ping Tx time.
void SetCount(uint32_t count)
Set the number of pings to send.
bool m_checkReportTransmitted
Set to true to check the Tx number.
Time m_expectedReportTime
Expected reported time.
void CheckReportTransmitted(uint32_t expectedReportTx)
Enable the check on Tx pings.
NodeContainer m_nodes
The simulation nodes.
bool m_checkReportLoss
Set to true to check the Loss number.
bool m_useIpv6
Use IPv6 (true) or IPv4 (false)
void ReportTraceSink(const Ping::PingReport &report)
Trace Report generation events.
void CheckReportLoss(uint16_t expectedReportLoss)
Enable the check on Lost pings.
bool m_checkReportReceived
Set to true to check the Rx number.
void DoRun() override
Implementation to actually run this TestCase.
Address m_destination
Destination address.
Time m_stopTime
Stop time.
void CheckTraceRtt(uint32_t expectedRtt)
Enable the check on Rtt event count in Rtt trace source.
uint32_t m_expectedTraceTx
Expected Tx trace sink calls.
bool m_checkTraceRtt
Set to true to check the Rtt number.
void SetInterval(Time interval)
Set the interval of pings.
void CheckReportReceived(uint32_t expectedReportRx)
Enable the check on Rx pings.
void DropTraceSink(uint16_t seq, Ping::DropReason reason)
Trace Drop events.
NetDeviceContainer m_devices
The NetDevices.
Ipv4InterfaceContainer m_ipv4Interfaces
The IPv4 interfaces.
uint32_t m_expectedReportRx
Expected reported Rx.
Time m_startTime
Start time.
void SetDestinationAddress(Address address)
Set the destination address (either IPv4 or IPv6).
void DoSetup() override
Implementation to do any local setup required for this TestCase.
std::list< uint32_t > m_dropList
Drop first reply (true)
uint32_t m_countAttribute
Number of pings to send.
void SetSize(uint32_t size)
Set the size of pings.
void DoTeardown() override
Implementation to do any local setup required for this TestCase.
void SetDropList(const std::list< uint32_t > &dropList)
Set the packet drop list on the Ping node's interface.
void CheckTraceTx(uint32_t expectedTx)
Enable the check on Tx pings counted in Tx trace source.
a polymophic address class
AttributeValue implementation for Address.
AttributeValue implementation for Boolean.
Class for representing data rates.
AttributeValue implementation for DataRate.
An implementation of the ICMPv6 protocol.
aggregate IP/TCP/UDP functionality to existing Nodes.
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ipv4 addresses are stored in host order in this class.
static Ipv4Address ConvertFrom(const Address &address)
static Ipv4Address GetBroadcast()
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Describes an IPv6 address.
bool IsLinkLocal() const
If the IPv6 address is a link-local address (fe80::/64).
static Ipv6Address GetAllNodesMulticast()
Get the "all nodes multicast" address.
bool IsLinkLocalMulticast() const
If the IPv6 address is link-local multicast (ff02::/16).
static Ipv6Address ConvertFrom(const Address &address)
Convert the Address object into an Ipv6Address ones.
Keep track of a set of IPv6 interfaces.
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
IPv6 layer implementation.
Describes an IPv6 prefix.
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
DropReason
Reason why a ping was dropped.
@ DROP_NET_UNREACHABLE
Received ICMP Destination Network Unreachable.
@ DROP_HOST_UNREACHABLE
Received ICMP Destination Host Unreachable.
Smart pointer class similar to boost::intrusive_ptr.
build a set of SimpleNetDevice objects
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
void SetChannel(std::string type, Ts &&... args)
Each net device must have a channel to pass packets through.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
Hold an unsigned integer type.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_ASSERT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report and...
#define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg)
Test that an actual value is greater than or equal to a limit and report and abort if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static PingTestSuite pingTestSuite
Static variable for test initialization.
constexpr bool USEIPV6_TRUE
constexpr bool USEIPV6_FALSE
A ping report provides all of the data that is typically output to the terminal when the application ...
uint16_t m_loss
Percentage of lost packets (decimal value 0-100)
uint32_t m_received
Number of echo replies received.
double m_rttMin
rtt min value
uint32_t m_transmitted
Number of echo requests sent.
double m_rttMax
rtt max value