22 #include "ns3/abort.h"
24 #include "ns3/uinteger.h"
25 #include "ns3/inet-socket-address.h"
26 #include "ns3/point-to-point-helper.h"
27 #include "ns3/internet-stack-helper.h"
28 #include "ns3/ipv4-address-helper.h"
29 #include "ns3/ipv4-header.h"
30 #include "ns3/packet-sink-helper.h"
31 #include "ns3/udp-client-server-helper.h"
32 #include "ns3/udp-header.h"
33 #include "ns3/simulator.h"
34 #include "ns3/wimax-helper.h"
35 #include "ns3/mobility-helper.h"
36 #include "ns3/global-route-manager.h"
37 #include "ns3/wimax-tlv.h"
38 #include "ns3/ipcs-classifier-record.h"
39 #include "ns3/service-flow.h"
40 #include "ns3/wimax-connection.h"
55 virtual void DoRun (
void);
59 Ns3WimaxFragmentationTestCase::Ns3WimaxFragmentationTestCase ()
60 :
TestCase (
"Test the packet fragmentation and defragmentation.")
64 Ns3WimaxFragmentationTestCase::~Ns3WimaxFragmentationTestCase ()
88 hdr.SetCid (connectionTx->GetCid ());
91 connectionTx->
Enqueue (packet, packetType, hdr);
93 uint32_t availableByteForFragment = 280;
94 for (
int i = 0; i < 4; i++)
97 if (connectionTx->
GetQueue ()->GetFirstPacketRequiredByte (packetType) > availableByteForFragment)
99 fragment = connectionTx->
Dequeue (packetType, availableByteForFragment);
103 fragment = connectionTx->
Dequeue (packetType);
109 uint8_t type = gnrcMacHdr.GetType ();
113 NS_TEST_EXPECT_MSG_EQ (((type >> 2) & 1), 1,
"The packet is not a fragment");
117 fragment->RemoveHeader (fragSubhdr);
118 uint32_t fc = fragSubhdr.GetFc ();
120 NS_TEST_EXPECT_MSG_EQ ((fc == 1 && i != 0),
false,
"The fragment in not the first one");
121 NS_TEST_EXPECT_MSG_EQ ((fc == 2 && i != 3),
false,
"The fragment in not the latest one");
122 NS_TEST_EXPECT_MSG_EQ (((fc == 3 && i != 1) && (fc == 3 && i != 2)),
false,
"The fragment in not the middle one");
135 WimaxConnection::FragmentsQueue fragmentsQueue = connectionRx->
GetFragmentsQueue ();
138 for (std::list<
Ptr<const Packet> >::const_iterator iter = fragmentsQueue.begin ();
139 iter != fragmentsQueue.end (); ++iter)
146 NS_TEST_EXPECT_MSG_EQ (fullPacket->
GetSize (), 1000,
"The defragmentation is incorrect");
151 Simulator::Destroy ();
161 Ns3WimaxFragmentationTestSuite::Ns3WimaxFragmentationTestSuite ()
162 :
TestSuite (
"wimax-fragmentation", UNIT)
uint32_t RemoveHeader(Header &header)
void FragmentEnqueue(Ptr< const Packet > fragment)
enqueue a received packet (that is a fragment) into the fragments queue
uint32_t GetSize(void) const
Ptr< WimaxMacQueue > GetQueue(void) const
void AddAtEnd(Ptr< const Packet > packet)
const FragmentsQueue GetFragmentsQueue(void) const
get a queue of received fragments
void ClearFragmentsQueue(void)
delete all enqueued fragments
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, const GenericMacHeader &hdr)
enqueue a packet in the queue of the connection
void AddTestCase(TestCase *testCase) NS_DEPRECATED
Add an individual test case to this test suite.
Ptr< Packet > Dequeue(MacHeaderType::HeaderType packetType=MacHeaderType::HEADER_TYPE_GENERIC)
dequeue a packet from the queue of the connection
virtual void DoRun(void)
Implementation to actually run this test case.