49#include "ns3/assert.h"
50#include "ns3/icmpv4.h"
51#include "ns3/icmpv6-header.h"
52#include "ns3/internet-stack-helper.h"
53#include "ns3/ipv4-address-helper.h"
54#include "ns3/ipv4-global-routing-helper.h"
55#include "ns3/ipv6-address-helper.h"
56#include "ns3/ipv6-routing-helper.h"
57#include "ns3/ipv6-static-routing-helper.h"
60#include "ns3/simple-net-device-helper.h"
61#include "ns3/simple-net-device.h"
62#include "ns3/simulator.h"
63#include "ns3/socket-factory.h"
64#include "ns3/socket.h"
66#include "ns3/uinteger.h"
100 void DoRun()
override;
105 :
TestCase(
"ICMP:EchoReply test case")
125 p->AddHeader(header);
131 " Unable to send ICMP Echo Packet");
138 Ptr<Packet> p = socket->RecvFrom(0xffffffff, 0, from);
142 p->RemoveHeader(ipv4);
146 p->RemoveHeader(icmp);
150 " The received Packet is not a ICMPV4_ECHO_REPLY");
168 rxDev->SetChannel(channel1);
169 txDev->SetChannel(channel1);
176 ipv4.SetBase(
"10.0.0.0",
"255.255.255.252");
199 " Unexpected ICMPV4_ECHO_REPLY packet size");
229 void DoRun()
override;
234 :
TestCase(
"ICMP:TimeExceedReply test case")
254 p->AddHeader(header);
260 " Unable to send ICMP Echo Packet");
267 Ptr<Packet> p = socket->RecvFrom(0xffffffff, 0, from);
271 p->RemoveHeader(ipv4);
276 "ICMP Time Exceed Response should come from 10.0.0.2");
279 p->RemoveHeader(icmp);
283 "The received packet is not a ICMPV4_TIME_EXCEEDED packet ");
308 devices = simpleHelper.
Install(n0n1, channel);
316 address.SetBase(
"10.0.0.0",
"255.255.255.255");
319 address.SetBase(
"10.0.1.0",
"255.255.255.255");
344 " Unexpected ICMP Time Exceed Response packet size");
374 void DoRun()
override;
379 :
TestCase(
"ICMPV6:EchoReply test case")
399 p->AddHeader(header);
405 " Unable to send ICMP Echo Packet");
418 p->RemoveHeader(ipv6);
422 "The received Packet is not an ICMPV6 packet");
424 p->RemoveHeader(icmpv6);
450 rxDev->SetChannel(channel1);
451 txDev->SetChannel(channel1);
482 " Unexpected ICMPV6_ECHO_REPLY packet size");
512 void DoRun()
override;
517 :
TestCase(
"ICMPV6:TimeExceed test case")
537 p->AddHeader(header);
541 socket->SendTo(p, 0, realTo);
554 p->RemoveHeader(ipv6);
558 "The received Packet is not an ICMPV6 packet");
561 p->RemoveHeader(icmpv6);
593 devices = simpleHelper.
Install(n0n1, channel);
603 address.NewNetwork();
607 interfaces.SetForwarding(1,
true);
608 interfaces.SetDefaultRouteInAllNodes(1);
625 socket->SetIpv6HopLimit(1);
637 " Unexpected ICMPV6_ECHO_REPLY packet size");
NodeContainer n1n2
Nodecontainer n1 + n2.
void DoRun() override
Implementation to actually run this TestCase.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
Ptr< Packet > m_receivedPacket
received packet
~IcmpEchoReplyTestCase() override
ICMP Time Exceed Reply Test.
~IcmpTimeExceedTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Ptr< Packet > m_receivedPacket
received packet
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
~IcmpV6EchoReplyTestCase() override
void DoRun() override
Implementation to actually run this TestCase.
Ptr< Packet > m_receivedPacket
received packet
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
IcmpV6EchoReplyTestCase()
ICMPV6 Time Exceed response test.
void DoRun() override
Implementation to actually run this TestCase.
~IcmpV6TimeExceedTestCase() override
void ReceivePkt(Ptr< Socket > socket)
Receive data.
IcmpV6TimeExceedTestCase()
Ptr< Packet > m_receivedPacket
received packet
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
a polymophic address class
void SetIdentifier(uint16_t id)
Set the Echo identifier.
void SetSequenceNumber(uint16_t seq)
Set the Echo sequence number.
void SetId(uint16_t id)
Set the ID of the packet.
void SetSeq(uint16_t seq)
Set the sequence number.
static bool IsMatchingType(const Address &addr)
If the address match.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
static Ipv4Address GetAny()
static void PopulateRoutingTables()
Build a routing database and initialize the routing tables of the nodes in the simulation.
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.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
Keep track of a set of IPv6 interfaces.
void SetForwarding(uint32_t i, bool state)
Set the state of the stack (act as a router or as an host) for the specified index.
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
Describes an IPv6 prefix.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
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.
void Add(const NodeContainer &nc)
Append the contents of another NodeContainer to the end of this container.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
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.
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 void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static void Run()
Run the simulation.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Hold an unsigned integer type.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Time Seconds(double value)
Construct a Time in the indicated unit.
static IcmpTestSuite icmpTestSuite
Static variable for test initialization.
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...