encapsulating several messages

127 views
Skip to first unread message

Jérôme Rousselot

unread,
Feb 7, 2010, 2:24:19 PM2/7/10
to omn...@googlegroups.com

Hi,

I want to implement an aggregation transport layer in mixim.

I am a bit confused by the omnet manual. At page 108, there is a
paragraph on "Encapsulating several messages", which is exactly what I
want to do. It suggests to define a message type with a "mesages"
std::list field to store message pointers.

So did I. Unfortunately, Omnet++ doesn't like it:
messages/AggrPkt.msg: Error: pointers not supported yet in 'AggrPkt'
which was to be expected after reading p.117 "Pointers: not supported
yet".

I am now declaring my abstract array as storing long values (using
reinterpret_cast to convert between long and *cMessage). I have one
weird compilation error: the call to setBitLength(int) is not
recognized:
error: ‘class AggrPkt’ has no member named ‘setBitLength’.

However, my class AggrPkt subclasses AggrPkt_Base, which subclasses
cMessage. The class is registered using Register_Class(AggrPkt).

Two questions:
1) why can't I call setBitLength (or any of the related methods) ?
2) is there a better approach to the problem than converting the pointer
addresses into long ?

Regards,

Jérôme


message AggrPkt {
@customize(true);
abstract long storedPackets[];
};

Ester Lopez

unread,
Feb 7, 2010, 5:09:54 PM2/7/10
to omn...@googlegroups.com
Hi Jerome,

Im not sure if AggrPkt_Base is a message that you have defined or it is defined by mixim, so maybe what i say its not correct, but setBitLength is a function of cPacket not cMessage, so if its not defined on AggrPkt_Base, then you have to define it yourself. If it was you who wrote AggrPkt_Base, then just change it so it extends cPacket instead of cMessage, and it should work.

On the other hand, i was doing something similar (encapsulating diferent messages in one). My code is like that:

cplusplus {{
typedef cMessage* pMsg;
}}
class noncobject pMsg;

message ServiceBrokerOfferList {
    //Number of offers the OfferList has
    int numOffers;
    //Pointer to the original request
    pMsg request;
    //Array with all the offers
    pMsg listOffers[];
}
It worked for me without problems. I hope you get your model working :)

Cheers,

Ester

2010/2/8 Jérôme Rousselot <jerome.r...@csem.ch>



--
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To post to this group, send email to omn...@googlegroups.com.
To unsubscribe from this group, send email to omnetpp+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/omnetpp?hl=en.


Jérôme Rousselot

unread,
Feb 8, 2010, 9:51:08 AM2/8/10
to omn...@googlegroups.com
Hi Ester,

thanks for your message ! I checked cmessage.h for setBitLength() but
didn't realize I was in the wrong class.

Now it's much better, but I have a problem with message ownership and
the copy constructor.
If I take ownership of the stored messages in my aggregation packet
(with take()), then when a copy of this aggregation packet is used to
retrieve the stored messages, the call to drop() fails.

So I put these calls in my Aggregation module (drop() before storing
each message and take() after retrieving them), but this leads to
segfaults at the upper layer when deleting the message. It seems that
the seg fault only happens after a few messages. I tried to take()
ownership in this upper module before deleting, but it didn't improve
things.
If I don't delete the messages, the simulation does work. But this isn't
a realistic approach.

Any idea on this ?

Regards,

Jérôme

> +unsub...@googlegroups.com.


> For more options, visit this group at
> http://groups.google.com/group/omnetpp?hl=en.
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "omnetpp" group.
> To post to this group, send email to omn...@googlegroups.com.
> To unsubscribe from this group, send email to omnetpp

> +unsub...@googlegroups.com.

Jérôme Rousselot

unread,
Feb 8, 2010, 10:32:06 AM2/8/10
to omn...@googlegroups.com
The solution to the ownership problem was to duplicate every stored
message in the copy constructor (as in cPacket::encapsulate() but for
several messages and without reference counting). Now it works !

Thanks,

Jérôme

Ester Lopez

unread,
Feb 8, 2010, 5:28:26 PM2/8/10
to omn...@googlegroups.com
Im glad it worked and that you got the answer, cause i had no idea :) (i dont need to copy the messages).

Cheers,
Ester

2010/2/9 Jérôme Rousselot <jerome.r...@csem.ch>
To unsubscribe from this group, send email to omnetpp+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages