INET Framework for OMNeT++/OMNEST
inet::ReassemblyBuffer Class Reference

This class provides functionality for reassembling out of order data chunks for protocols supporting fragmentation. More...

#include <ReassemblyBuffer.h>

Inheritance diagram for inet::ReassemblyBuffer:
inet::ChunkBuffer

Public Member Functions

 ReassemblyBuffer (b expectedLength=b(-1))
 
 ReassemblyBuffer (const ReassemblyBuffer &other)
 
b getExpectedLength () const
 Returns the expected data length. More...
 
void setExpectedLength (b expectedLength)
 Changes the expected data length. More...
 
bool isComplete () const
 Returns true if all data is present for reassembling the data chunk. More...
 
const Ptr< const ChunkgetReassembledData () const
 Returns the reassembled data chunk if all data is present in the buffer, otherwise throws an exception. More...
 
- Public Member Functions inherited from inet::ChunkBuffer
 ChunkBuffer (const char *name=nullptr)
 
 ChunkBuffer (const ChunkBuffer &other)
 
virtual ChunkBufferdup () const override
 
bool isEmpty () const
 Returns true if the buffer is completely empty. More...
 
int getNumRegions () const
 Returns the number non-overlapping, non-connecting but continuous regions. More...
 
b getRegionLength (int index) const
 Returns the length of the given region. More...
 
b getRegionStartOffset (int index) const
 Returns the start offset of the given region. More...
 
b getRegionEndOffset (int index) const
 Returns the end offset of the given region. More...
 
const Ptr< const Chunk > & getRegionData (int index) const
 Returns the data of the given region in its current representation. More...
 
void replace (b offset, const Ptr< const Chunk > &chunk)
 Replaces the stored data at the provided offset with the data in the chunk. More...
 
void clear (b offset, b length)
 Erases the stored data at the provided offset and length. More...
 
void clear ()
 Erases all of the stored data. More...
 
virtual std::string str () const override
 Returns a human readable string representation. More...
 

Protected Attributes

b expectedLength
 The total length of the reassembled data chunk. More...
 
- Protected Attributes inherited from inet::ChunkBuffer
std::vector< Regionregions
 The list of non-overlapping, non-connecting but continuous regions. More...
 

Additional Inherited Members

- Protected Member Functions inherited from inet::ChunkBuffer
RegiongetRegion (int i) const
 
void eraseEmptyRegions (std::vector< Region >::iterator begin, std::vector< Region >::iterator end)
 
void sliceRegions (Region &newRegion)
 
void mergeRegions (Region &previousRegion, Region &nextRegion)
 

Detailed Description

This class provides functionality for reassembling out of order data chunks for protocols supporting fragmentation.

The reassembling algorithm requires the expected length of the non-fragmented data chunk. It assumes that the non-fragmented data chunk starts at 0 offset. If all data becomes available up to the expected length, then the defragmentation is considered complete.

Constructor & Destructor Documentation

◆ ReassemblyBuffer() [1/2]

inet::ReassemblyBuffer::ReassemblyBuffer ( b  expectedLength = b(-1))
inline

◆ ReassemblyBuffer() [2/2]

inet::ReassemblyBuffer::ReassemblyBuffer ( const ReassemblyBuffer other)
inline
32 : ChunkBuffer(other), expectedLength(other.expectedLength) {}

Member Function Documentation

◆ getExpectedLength()

b inet::ReassemblyBuffer::getExpectedLength ( ) const
inline

Returns the expected data length.

37 { return expectedLength; }

◆ getReassembledData()

const Ptr<const Chunk> inet::ReassemblyBuffer::getReassembledData ( ) const
inline

Returns the reassembled data chunk if all data is present in the buffer, otherwise throws an exception.

55  {
56  if (!isComplete())
57  throw cRuntimeError("Reassembly is incomplete");
58  else
59  return regions[0].data;
60  }

Referenced by inet::Ipv4FragBuf::addFragment(), and inet::Ipv6FragBuf::addFragment().

◆ isComplete()

bool inet::ReassemblyBuffer::isComplete ( ) const
inline

Returns true if all data is present for reassembling the data chunk.

47  {
48  return regions.size() == 1 && regions[0].offset == b(0) && regions[0].data->getChunkLength() == expectedLength;
49  }

Referenced by inet::Ipv4FragBuf::addFragment(), and inet::Ipv6FragBuf::addFragment().

◆ setExpectedLength()

void inet::ReassemblyBuffer::setExpectedLength ( b  expectedLength)
inline

Changes the expected data length.

42 { this->expectedLength = expectedLength; }

Referenced by inet::Ipv4FragBuf::addFragment(), and inet::Ipv6FragBuf::addFragment().

Member Data Documentation

◆ expectedLength

b inet::ReassemblyBuffer::expectedLength
protected

The total length of the reassembled data chunk.


The documentation for this class was generated from the following file:
inet::ChunkBuffer::ChunkBuffer
ChunkBuffer(const char *name=nullptr)
Definition: ChunkBuffer.cc:17
inet::ReassemblyBuffer::isComplete
bool isComplete() const
Returns true if all data is present for reassembling the data chunk.
Definition: ReassemblyBuffer.h:47
inet::units::values::b
value< int64_t, units::b > b
Definition: Units.h:1241
inet::ReassemblyBuffer::expectedLength
b expectedLength
The total length of the reassembled data chunk.
Definition: ReassemblyBuffer.h:28
inet::ChunkBuffer::regions
std::vector< Region > regions
The list of non-overlapping, non-connecting but continuous regions.
Definition: ChunkBuffer.h:66