std::ostringstream str;
Packet *packet = new Packet(str.str().c_str());
const auto& payload = makeShared<ApplicationPacket>();
payload->setChunkLength(B(par("packetLength")));
payload->setSequenceNumber(0);
auto macAddressReq = packet->addTag<MacAddressReq>(); // add new tag for MAC
macAddressReq->setSrcAddress(SrcAddress); // source is our MAC address
macAddressReq->setDestAddress(DestAddress); // destination is next hop
auto interfaceReq = packet->addTag<InterfaceReq>(); // add tag for dispatch
interfaceReq->setInterfaceId(1); // set designated interface
auto packetProtocolTag = packet->addTagIfAbsent<PacketProtocolTag>();
packetProtocolTag->setProtocol(&Protocol::ipv4); // set protocol of packet
encapsulate(packet);
send(packet, "radioOut");
There is no error in compilation but there is an error during simulation.
I am sure the error is due to packet creation. I am trying to understand based on developers-guides. But It doesn't have much information to solve the problem.
https://inet.omnetpp.org/docs/developers-guide/index.html
Please help me how I can solve the issue.
Thank you.
Regards,
Thiha Kyaw