23 #define NS3_LOG_ENABLE 1
26 #include "ns3/config.h"
27 #include "ns3/uinteger.h"
28 #include "ns3/socket-factory.h"
29 #include "ns3/ipv4-raw-socket-factory.h"
30 #include "ns3/ipv6-raw-socket-factory.h"
31 #include "ns3/udp-socket-factory.h"
32 #include "ns3/simulator.h"
34 #include "ns3/simple-net-device.h"
35 #include "ns3/drop-tail-queue.h"
36 #include "ns3/socket.h"
37 #include "ns3/udp-socket.h"
41 #include "ns3/inet-socket-address.h"
42 #include "ns3/boolean.h"
44 #include "ns3/ipv6-static-routing.h"
45 #include "ns3/ipv6-list-routing.h"
46 #include "ns3/inet6-socket-address.h"
48 #include "ns3/arp-l3-protocol.h"
49 #include "ns3/ipv4-l3-protocol.h"
50 #include "ns3/icmpv4-l4-protocol.h"
51 #include "ns3/ipv4-list-routing.h"
52 #include "ns3/ipv4-static-routing.h"
53 #include "ns3/udp-l4-protocol.h"
55 #include "ns3/ipv6-l3-protocol.h"
56 #include "ns3/icmpv6-l4-protocol.h"
60 #include <netinet/in.h>
76 ipv6Routing->AddRoutingProtocol (ipv6staticRouting, 0);
109 virtual void DoRun (
void);
120 void HandleReadIcmpClient (
Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType,
121 uint8_t icmpCode,uint32_t icmpInfo);
123 void SetFill (uint8_t *fill, uint32_t fillSize, uint32_t dataSize);
130 :
TestCase (
"Verify the IPv6 layer 3 protocol fragmentation and reassembly")
154 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
169 while ((packet = socket->
RecvFrom (from)))
171 if (Inet6SocketAddress::IsMatchingType (from))
187 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
203 while ((packet = socket->
RecvFrom (from)))
205 if (Inet6SocketAddress::IsMatchingType (from))
214 uint8_t icmpTtl, uint8_t icmpType,
215 uint8_t icmpCode, uint32_t icmpInfo)
227 m_data =
new uint8_t [dataSize];
231 if (fillSize >= dataSize)
233 memcpy (
m_data, fill, dataSize);
238 while (filled + fillSize < dataSize)
240 memcpy (&
m_data[filled], fill, fillSize);
244 memcpy (&
m_data[filled], fill, dataSize - filled);
258 p = Create<Packet> (
m_size);
271 Ptr<Node> serverNode = CreateObject<Node> ();
276 serverDev = CreateObject<SimpleNetDevice> ();
277 serverDev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
280 serverDevErrorModel->
Disable ();
286 ipv6->
SetUp (netdev_idx);
291 Ptr<Node> clientNode = CreateObject<Node> ();
296 clientDev = CreateObject<SimpleNetDevice> ();
297 clientDev->
SetAddress (Mac48Address::ConvertFrom (Mac48Address::Allocate ()));
300 clientDevErrorModel->
Disable ();
306 ipv6->
SetUp (netdev_idx);
318 uint32_t packetSizes[5] = {2000, 2500, 5000, 10000, 65000};
321 uint8_t fillData[78];
322 for ( uint32_t k = 48; k <= 125; k++ )
324 fillData[k - 48] = k;
328 for (
int i = 0; i < 5; i++)
330 uint32_t packetSize = packetSizes[i];
332 SetFill (fillData, 78, packetSize);
339 uint8_t recvBuffer[65000];
344 "Packet size not correct: recvSize: " << recvSize <<
" packetSizes[" << i <<
"]: " << packetSizes[i] );
348 0,
"Packet content differs");
355 for (
int i = 0; i < 5; i++)
357 uint32_t packetSize = packetSizes[i];
359 SetFill (fillData, 78, packetSize);
366 uint8_t recvBuffer[65000];
371 "Packet size not correct: recvSize: " << recvSize <<
" packetSizes[" << i <<
"]: " << packetSizes[i] );
375 0,
"Packet content differs");
386 clientDevErrorModel->
Disable ();
387 serverDevErrorModel->
Enable ();
388 for (
int i = 1; i < 5; i++)
390 uint32_t packetSize = packetSizes[i];
392 SetFill (fillData, 78, packetSize);
395 serverDevErrorModel->
Reset ();
408 && (
m_icmpCode == Icmpv6Header::ICMPV6_FRAGTIME),
409 true,
"Client did not receive ICMPv6::TIME_EXCEEDED " <<
int(m_icmpType) <<
int(
m_icmpCode) );
413 Simulator::Destroy ();
Access to the IPv6 forwarding table, interfaces, and configuration.
IPv6 address associated with an interface.
uint32_t GetSize(void) const
Ptr< Packet > m_receivedPacketClient
void StartServer(Ptr< Node > ServerNode)
A sockets interface to UDP.
a polymophic address class
AttributeValue form of a Callback.
void RemoveAllPacketTags(void)
Remove all packet tags.
void HandleReadIcmpClient(Ipv6Address icmpSource, uint8_t icmpTtl, uint8_t icmpType, uint8_t icmpCode, uint32_t icmpInfo)
Ipv6FragmentationTestSuite()
virtual bool SetMtu(const uint16_t mtu)
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Ptr< Socket > m_socketServer
Ptr< Packet > m_receivedPacketServer
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void HandleReadClient(Ptr< Socket > socket)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
void Disable(void)
Disable the error model.
void AggregateObject(Ptr< Object > other)
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
void SetJumpingMode(bool mode)
Set if the odd packets are delayed (even ones are not delayed ever)
Ptr< Packet > Copy(void) const
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
void SetReceiveErrorModel(Ptr< ErrorModel > em)
Attach a receive ErrorModel to the SimpleNetDevice.
Ptr< Packet > m_sentPacketClient
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual child TestCase case to this TestCase.
void HandleReadServer(Ptr< Socket > socket)
Ptr< Packet > SendClient(void)
virtual uint32_t AddInterface(Ptr< NetDevice > device)=0
Add a NetDevice interface.
virtual void DoRun(void)
Implementation to actually run this TestCase.
virtual void RegisterExtensions()
Register the IPv6 Extensions.
Describes an IPv6 address.
void SetRoutingProtocol(Ptr< Ipv6RoutingProtocol > routingProtocol)
Set routing protocol for this stack.
uint32_t AddDevice(Ptr< NetDevice > device)
uint32_t GetId(void) const
virtual Ptr< Node > GetNode(void) const =0
Return the node this socket is associated with.
Ptr< Socket > m_socketClient
virtual void SetAddress(Address address)
Set the address of this interface.
void RemoveAllByteTags(void)
Remove all byte tags stored in this packet.
void SetFill(uint8_t *fill, uint32_t fillSize, uint32_t dataSize)
virtual void RegisterOptions()
Register the IPv6 Options.
Describes an IPv6 prefix.
virtual bool AddAddress(uint32_t interface, Ipv6InterfaceAddress address)=0
Add an address on the specified IPv6 interface.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
void SetJumpingTime(Time delay)
Set the delay for the odd packets (even ones are not delayed)
void StartClient(Ptr< Node > ClientNode)
Ipv6FragmentationTestSuite g_ipv6fragmentationTestSuite
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.
This test suite implements a Unit Test.
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
static void AddInternetStack(Ptr< Node > node)
void SetChannel(Ptr< SimpleChannel > channel)
Attach a channel to this net device.
void SetAttribute(std::string name, const AttributeValue &value)
Ptr< T > GetObject(void) const
a unique identifier for an interface.
void Enable(void)
Enable the error model.
virtual void SetUp(uint32_t interface)=0
Set the interface into the "up" state.