13 February 2024 0 2K Report

i havea custom message class(Custom.msg) file with content message Custom {

float xPos;

float yPos;

} so i am trying to send the packet from one node to the another node using the UdpBasicApp. In sendpacket() i have written like this myMessage.setXPos(currentPosition.x);

myMessage.setYPos(currentPosition.y); omnetpp::cMemCommBuffer *buffer;

myMessage.parsimPack(&buffer); std::ostringstream str;

str setChunkLength(B(par("messageLength")));

payload->setSequenceNumber(numSent);

payload->addTag()->setCreationTime(simTime());

auto bytesChunk = makeShared();

packet->insertAtBack(payload);

L3Address destAddr = chooseDestAddr();

emit(packetSentSignal, packet);

socket.sendTo(packet, destAddr, destPort);

numSent++;... but this is not actually working.. please give me some suggestions... from serializing to sending the packet .. on of the challenging part is here .. i amusing the socket. sendTo() fucntion, which is capable of sending only the inetpacket, but i am trying to send the custom packet .. how can i ...?

More Veera Lanka's questions See All
Similar questions and discussions