24 #include "ns3/packet.h" 25 #include "ns3/simulator.h" 26 #include "ns3/wimax-mac-header.h" 27 #include "ns3/mac-messages.h" 29 #include "ns3/wimax-connection.h" 46 virtual void DoRun (
void);
51 :
TestCase (
"Test the packet fragmentation and defragmentation.")
82 connectionTx->
Enqueue (packet, packetType, hdr);
84 uint32_t availableByteForFragment = 280;
85 for (
int i = 0; i < 4; i++)
88 if (connectionTx->
GetQueue ()->GetFirstPacketRequiredByte (packetType) > availableByteForFragment)
90 fragment = connectionTx->
Dequeue (packetType, availableByteForFragment);
94 fragment = connectionTx->
Dequeue (packetType);
100 uint8_t type = gnrcMacHdr.
GetType ();
108 fragment->RemoveHeader (fragSubhdr);
109 uint32_t fc = fragSubhdr.
GetFc ();
113 NS_TEST_EXPECT_MSG_EQ (((fc == 3 && i != 1) && (fc == 3 && i != 2)),
false,
"The fragment in not the middle one");
130 iter != fragmentsQueue.end (); ++iter)
142 Simulator::Destroy ();
158 :
TestSuite (
"wimax-fragmentation", UNIT)
static Ns3WimaxFragmentationTestSuite ns3WimaxFragmentationTestSuite
the test suite
Ns3WimaxFragmentationTestSuite()
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
const FragmentsQueue GetFragmentsQueue(void) const
get a queue of received fragments
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Mac Management messages Section 6.3.2.3 MAC Management messages page 42, Table 14 page 43...
void FragmentEnqueue(Ptr< const Packet > fragment)
enqueue a received packet (that is a fragment) into the fragments queue
Ns3WimaxFragmentationTestCase()
#define NS_TEST_EXPECT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report if not.
Class to represent WiMAX connections.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
void AddTestCase(TestCase *testCase, TestDuration duration=QUICK)
Add an individual child TestCase to this test suite.
Ns3 Wimax Fragmentation Test Suite.
Cid GetCid(void) const
Get CID function.
Ptr< WimaxMacQueue > GetQueue(void) const
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::list< Ptr< const Packet > > FragmentsQueue
Definition of Fragments Queue data type.
Ptr< Packet > Dequeue(MacHeaderType::HeaderType packetType=MacHeaderType::HEADER_TYPE_GENERIC)
dequeue a packet from the queue of the connection
Test the wimax packet fragmentation.
virtual ~Ns3WimaxFragmentationTestCase()
virtual void DoRun(void)
Implementation to actually run this TestCase.