简体   繁体   中英

How to create a custom INET packet?

I want to create a custom packet class that is an INET packet. For example, to create a custom Omnet cPacket i would use

class myPacket : public ::omnetpp::cPacket
{

Is there a way to do so for an INET packet?

I have tried the following but i keep getting errors.

class myPacket : public inet::Packet
{
class myPacket : public INET_API::inet::Packet
{
class myPacket : public Packet
{

The reason why i want a INET packet is because i want to send it using the sendTo function, but that function only takes in a packet of type INET. Also, the receiving module would be INET's Radio which also takes in INET packets.

It's a better practice not to create the packet class, but to create a .msg file and let msgc (message compiler) do the class creation. In msg file you can extend Packet, and import inet.common.packet.Packet, but you would probably prefer to extend Chunk, FieldsChunk, or similar more specific classes which requires import inet.common.packet.chunk.Chunk. If you create your own class, without ,msg files, I assume you can extend from inet::Packet, and #include "inet/common/packet/Packet.h", but I can't say that I tried that directly. The documentation is not too clear, but you may find good information on generating custom packets here: https://inet.omnetpp.org/docs/developers-guide/ch-packets.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM