Using OMNeT++ I modified the UdpBasicApp.cc file adding this code:
cModule *mod = getModuleByPath("^.ppp[0].ppp.queue");
queueing::PacketQueue *queue = check_and_cast<queueing::PacketQueue*>(mod);
int e = queue->getNumPackets();
int f = queue->getMaxNumPackets();
simtime_t queueRetrieveTime = simTime();
Packet *queueRetrieve = new Packet("Queue_Info");
if(dontFragment)
queueRetrieve->addTag<FragmentationReq>()->setDontFragment(true);
const auto& payload1 = makeShared<QueueInfoMessage>();
payload1->setChunkLength(B(1000));
payload1->setQueueLength(e);
payload1->setQueueMaxLength(f);
payload1->setTimeOfRetrieve(queueRetrieveTime);
payload1->addTag<CreationTimeTag>()->setCreationTime(simTime());
queueRetrieve->insertAtBack(payload1);
L3Address destAddr1 = chooseDestAddr();
socket.sendTo(queueRetrieve, destAddr1, destPort);
I copied this from the handleMessage() function in UdpBasicApp.cc, and I've put this at the start of the already mentioned function, before everything else.
The message I'm trying to send is a message I created myself, and the QueueInfoMessage.msg file is this:
import inet.common.INETDefs;
import inet.common.packet.chunk.Chunk;
namespace inet;
cplusplus {{
const B YOUR_APP_HEADER_LENGTH = B(6);
}}
class QueueInfoMessage extends FieldsChunk
{
chunkLength = YOUR_APP_HEADER_LENGTH;
int queueLength;
int queueMaxLength;
simtime_t timeOfRetrieve;
uint32_t sequenceNumber;
}
As I've learned from this thread here.
When I run the simulation I get this error:
Cannot find serializer for inet::QueueInfoMessage in module (inet::Ipv4) Network.router3.ipv4.ip (id=...), ...
The message I created was copied from a standard message, ApplicationPacket.msg (used in the same handleMessage() function of the file), to be sure there were no errors, and I added some additional variables to do what I wanted to do.
Why do I get this error? (Btw I don't know what the serializer is or does)
question from:
https://stackoverflow.com/questions/65908146/omnet-cannot-find-serializer 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…