Need Help on creating a simple UDP packet to transmit to Radio

22 views
Skip to first unread message

THIHA KYAW

unread,
Sep 16, 2018, 10:07:34 AM9/16/18
to INET Framework Contributors


Dear,

I really need your help to solve the problem. I am trying to understand to create a packet using PACKET API in inet 4.0. 
Since this is a new API in inet 4.0. I believe the developer only can help me.

 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.

Screen Shot 2018-09-16 at 9.10.24 PM.png


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





Reply all
Reply to author
Forward
0 new messages