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

#include <CsmaCaMacHeaderSerializer.h>

Inheritance diagram for inet::CsmaCaMacTrailerSerializer:
inet::FieldsChunkSerializer inet::ChunkSerializer

Public Member Functions

 CsmaCaMacTrailerSerializer ()
 
- Public Member Functions inherited from inet::FieldsChunkSerializer
virtual void serialize (MemoryOutputStream &stream, const Ptr< const Chunk > &chunk, b offset, b length) const override
 Serializes a chunk into a stream by writing the bytes representing the chunk at the end of the stream. More...
 
virtual const Ptr< Chunkdeserialize (MemoryInputStream &stream, const std::type_info &typeInfo) const override
 Deserializes a chunk from a stream by reading the bytes at the current position of the stream. More...
 

Protected Member Functions

virtual void serialize (MemoryOutputStream &stream, const Ptr< const Chunk > &chunk) const override
 Serializes a chunk into a stream by writing all bytes representing the chunk at the end of the stream. More...
 
virtual const Ptr< Chunkdeserialize (MemoryInputStream &stream) const override
 Deserializes a chunk from a stream by reading the bytes at the current position of the stream. More...
 

Additional Inherited Members

- Static Public Attributes inherited from inet::ChunkSerializer
static b totalSerializedLength = b(0)
 
static b totalDeserializedLength = b(0)
 

Constructor & Destructor Documentation

◆ CsmaCaMacTrailerSerializer()

inet::CsmaCaMacTrailerSerializer::CsmaCaMacTrailerSerializer ( )
inline
36 : FieldsChunkSerializer() {}

Member Function Documentation

◆ deserialize()

const Ptr< Chunk > inet::CsmaCaMacTrailerSerializer::deserialize ( MemoryInputStream stream) const
overrideprotectedvirtual

Deserializes a chunk from a stream by reading the bytes at the current position of the stream.

The current stream position is updated according to the length of the returned chunk.

Implements inet::FieldsChunkSerializer.

90 {
91  auto macTrailer = makeShared<CsmaCaMacTrailer>();
92  auto fcs = stream.readUint32Be();
93  macTrailer->setFcs(fcs);
94  macTrailer->setFcsMode(FCS_COMPUTED);
95  return macTrailer;
96 }

◆ serialize()

void inet::CsmaCaMacTrailerSerializer::serialize ( MemoryOutputStream stream,
const Ptr< const Chunk > &  chunk 
) const
overrideprotectedvirtual

Serializes a chunk into a stream by writing all bytes representing the chunk at the end of the stream.

Implements inet::FieldsChunkSerializer.

81 {
82  const auto& macTrailer = dynamicPtrCast<const CsmaCaMacTrailer>(chunk);
83  auto fcsMode = macTrailer->getFcsMode();
84  if (fcsMode != FCS_COMPUTED)
85  throw cRuntimeError("Cannot serialize CsmaCaMacTrailer without properly computed FCS, try changing the value of the fcsMode parameter (e.g. in the CsmaCaMac module)");
86  stream.writeUint32Be(macTrailer->getFcs());
87 }

The documentation for this class was generated from the following files:
inet::FCS_COMPUTED
@ FCS_COMPUTED
Definition: FcsMode_m.h:59