Do I need a serializer/deserializer?

26 views
Skip to first unread message

Juan

unread,
May 22, 2023, 7:55:19 AM5/22/23
to OMNeT++ Users
I have implemented a new type of message

class HelloMsg extends FieldsChunk
{
    chunkLength = HEADER_LENGTH;
    int s = 0;
    string name;
}

  • Then I get this error when sending it:
  • " Implicit data reinterpretation via chunk serialization/deserialization (inet::ieee80211::Ieee80211DataHeader -> inet::HelloMsg) is disabled to prevent unexpected behavior due to reinterpretation and unpredictable performance degradation due to overhead  (you may consider changing the Chunk::enableImplicitChunkSerialization flag or passing the PF_ALLOW_SERIALIZATION flag"
  • So I set the flag:     header->enableImplicitChunkSerialization = true;
  • But then I get another one: Cannot find serializer for inet::HelloMsg
  • So I guess I need a serializer/deserializer. I write both, but the deserializer is not able to extract the data properly (if I print it, it shows 2048 for an int, e.g.) . Can someone tell me what I'm doing wrong?
  • Serializer
    • stream.writeUint16Be(sampleMsg->getS());
    • stream.writeString(sampleMsg->getName());
  • Deserializer
    • auto sampleMsg = makeShared<HelloMsg>();
    • sampleMsg->setS(stream.readUint16Be());
    • sampleMsg->setName(stream.readString().c_str());
Thank you


Reply all
Reply to author
Forward
0 new messages