Google Groups

generate message - help

Marco Jun 22, 2012 2:01 AM
Posted in group: OMNeT++ Users

Hi to all,

I have created my .msg file and I notice that the it generates automatically the _m.h and 
I have my .msg like this:

message Packet
int source; //id de source
int destination; //id de dest
int hopCount = 0;
int portsource; //port source
int portdestination; //port dest

My function generate message is like this:

Packet *PControl::generateMessage()
int src = getId(); // our module id
int dest = 0;
int portdest=0;
char msgname[40];
sprintf(msgname, "Pacote-%d-to-%d", src, dest);

cGate *Port = gate("gate$o",0);

Packet *msg = new Packet(msgname);
return msg;

After the message been generated I send it in the function forward message.
When this message arrives to the next computer or machine destination, instead of create a new message I want to add to this message (not to create a new one) the new src and destination and do again the: msg->setSource(src); msg->setDestination(dest); msg->setPortsource(Port->getId()); msg->setPortdestination(portdest);- but without lose the previous information already inserted. 

Please can someone tell me how can I do this and keep adding data to the message that will be travel between my machines in the network?
Here I use an "char msgname[40]" for the message that will grow because new fields will be added do you think this is the best variable to do this?

Advises will be very appreciated, please