|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
62 #include "ns3/ipv4-address-helper.h"
63 #include "ns3/ipv6-address-helper.h"
64 #include "ns3/simple-net-device.h"
65 #include "ns3/simple-net-device-helper.h"
66 #include "ns3/simulator.h"
67 #include "ns3/icmpv6-header.h"
68 #include "ns3/icmpv4.h"
69 #include "ns3/socket.h"
70 #include "ns3/socket-factory.h"
71 #include "ns3/uinteger.h"
72 #include "ns3/assert.h"
74 #include "ns3/ipv4-global-routing-helper.h"
75 #include "ns3/ipv6-static-routing-helper.h"
76 #include "ns3/ipv6-routing-helper.h"
79 #include "ns3/internet-stack-helper.h"
116 virtual void DoRun (
void);
123 :
TestCase (
"ICMP:EchoReply test case")
145 header.
SetType (Icmpv4Header::ICMPV4_ECHO);
152 (
int) p->
GetSize (),
" Unable to send ICMP Echo Packet");
172 " The received Packet is not a ICMPV4_ECHO_REPLY");
188 n.Get (0)->AddDevice (txDev);
189 n.Get (1)->AddDevice (rxDev);
199 ipv4.
SetBase (
"10.0.0.0",
"255.255.255.252");
203 socket = Socket::CreateSocket (
n.Get (0), TypeId::LookupByName (
"ns3::Ipv4RawSocketFactory"));
219 Simulator::Destroy ();
248 virtual void DoRun (
void);
255 :
TestCase (
"ICMP:TimeExceedReply test case")
277 header.
SetType (Icmpv4Header::ICMPV4_ECHO);
284 (
int) p->
GetSize (),
" Unable to send ICMP Echo Packet");
300 "ICMP Time Exceed Response should come from 10.0.0.2");
306 "The received packet is not a ICMPV4_TIME_EXCEEDED packet ");
315 n0n1.
Add (
n.Get (0));
316 n0n1.
Add (
n.Get (1));
338 address.SetBase (
"10.0.0.0",
"255.255.255.255");
341 address.SetBase (
"10.0.1.0",
"255.255.255.255");
344 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
347 socket = Socket::CreateSocket (
n.Get (0), TypeId::LookupByName (
"ns3::Ipv4RawSocketFactory"));
363 Simulator::Destroy ();
392 virtual void DoRun (
void);
399 :
TestCase (
"ICMPV6:EchoReply test case")
421 header.
SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST);
428 (
int) p->
GetSize (),
" Unable to send ICMP Echo Packet");
440 if (Inet6SocketAddress::IsMatchingType (from))
446 Ipv6Header::IPV6_ICMPV6,
447 "The received Packet is not an ICMPV6 packet");
452 if (!(((
int)icmpv6.
GetType () >= 133) && ((
int)icmpv6.
GetType () <= 137)))
455 Icmpv6Header::ICMPV6_ECHO_REPLY,
456 "The received Packet is not a ICMPV6_ECHO_REPLY");
476 n.Get (0)->AddDevice (txDev);
477 n.Get (1)->AddDevice (rxDev);
491 socket = Socket::CreateSocket (
n.Get (0), TypeId::LookupByName (
"ns3::Ipv6RawSocketFactory"));
507 Simulator::Destroy ();
536 virtual void DoRun (
void);
543 :
TestCase (
"ICMPV6:TimeExceed test case")
565 header.
SetType (Icmpv6Header::ICMPV6_ECHO_REQUEST);
572 socket->
SendTo (p, 0, realTo);
584 if (Inet6SocketAddress::IsMatchingType (from))
591 Ipv6Header::IPV6_ICMPV6,
592 "The received Packet is not an ICMPV6 packet");
598 if (!(((
int)icmpv6.
GetType () >= 133) && ((
int)icmpv6.
GetType () <= 137)))
601 Icmpv6Header::ICMPV6_ERROR_TIME_EXCEEDED,
602 "The received Packet is not a ICMPV6_ERROR_TIME_EXCEEDED");
613 n0n1.
Add (
n.Get (0));
614 n0n1.
Add (
n.Get (1));
651 socket = Socket::CreateSocket (
n.Get (0), TypeId::LookupByName (
"ns3::Ipv6RawSocketFactory"));
668 Simulator::Destroy ();
holds a vector of ns3::NetDevice pointers
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SetIdentifier(uint16_t id)
Set the Echo identifier.
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
virtual ~IcmpV6EchoReplyTestCase()
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
uint32_t GetId(void) const
void AddHeader(const Header &header)
Add header to this packet.
virtual void DoRun(void)
Implementation to actually run this TestCase.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
void SetSequenceNumber(uint16_t seq)
Set the Echo sequence number.
ICMPV6 Time Exceed response test.
Ipv4 addresses are stored in host order in this class.
Ptr< Packet > m_receivedPacket
received packet
Describes an IPv6 address.
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
void SetDefaultRouteInAllNodes(uint32_t router)
Set the default route for all the devices (except the router itself).
virtual void DoRun(void)
Implementation to actually run this TestCase.
Helper class to auto-assign global IPv6 unicast addresses.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
void SetSeq(uint16_t seq)
Set the sequence number.
virtual void SetAddress(Address address)
Set the address of this interface.
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
ICMP Time Exceed Reply Test.
void Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
virtual void SetIpTtl(uint8_t ipTtl)
Manually set IP Time to Live field.
Ptr< Packet > m_receivedPacket
received packet
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
IcmpV6TimeExceedTestCase()
virtual ~IcmpTimeExceedTestCase()
a polymophic address class
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
IcmpV6EchoReplyTestCase()
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
Ipv6Address GetAddress(uint32_t i, uint32_t j) const
Get the address for the specified index.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Keep track of a set of IPv6 interfaces.
build a set of SimpleNetDevice objects
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
virtual ~IcmpV6TimeExceedTestCase()
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
void ReceivePkt(Ptr< Socket > socket)
Receive data.
virtual ~IcmpEchoReplyTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.
void SendData(Ptr< Socket > socket, Ipv4Address dst)
Send data.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
keep track of a set of node pointers.
void ReceivePkt(Ptr< Socket > socket)
Receive data.
virtual void SetIpv6HopLimit(uint8_t ipHopLimit)
Manually set IPv6 Hop Limit.
void SetId(uint16_t id)
Set the ID of the packet.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
void ReceivePkt(Ptr< Socket > socket)
Receive data.
Hold an unsigned integer type.
Ptr< Packet > m_receivedPacket
received packet
void SendData(Ptr< Socket > socket, Ipv6Address dst)
Send data.
Ptr< Packet > m_receivedPacket
received packet
Describes an IPv6 prefix.
aggregate IP/TCP/UDP functionality to existing Nodes.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
static IcmpTestSuite icmpTestSuite
Static variable for test initialization.
void SetNetDevicePointToPointMode(bool pointToPointMode)
SimpleNetDevice is Broadcast capable and ARP needing.