开发者

How can I send a .msg through gates in omnet?

In order to implement tcp/ip simulation I have for each layer create packets.

Since the omnet send function only supports sending cMessage object while I subclassed from cMessage using .msg definitions, I can't find a way to send that packet through a gate without losing data.

For example, for the application layer I want to add destAddress and packetLength so I created:

message AppPacket
{
   int pktLength;
   int destAddress;
}

Now, I've created .cc, .h classes in omnet to implement it:

class AppPacket : public cMessage { ... }

After I have a new AppPacket with all the needed data, I want to send it to a lower layer (to the transport layer)开发者_开发技巧 but I can't since the send function only sends cMessage objects.

What can I do? I thought the whole point of Message is to help us implement network packets.


The .cc and .h files for your AppPacket will be generated automaticaly. You're right about the type that send function takes, but notice, that your class inherits the cMessage object so AppPacket is also a cMessage! Look at the exemplary code which sends custom message from tcpApp:

CustomMsg *msg = new CustomMsg("data");
msg->setByteLength(numBytes);
msg->setExpectedReplyLength(expectedReplyBytes);
msg->setServerClose(serverClose);
msg->setContent("message-specific-content");

socket.send(msg);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜