2. In our network we can’t add more than two nodes.
The reason is that, Node.ned defines only one input
gate and one output gate.
The solution is to use gate vectors instead of single
gates.
A more advanced solution is to use inout gate, which
is basically an input and an output gate glued together.
3. Let’s modify our plan. When a node decides to
transmit a message, it have to select a random
destination. Therefore, we need to modify Node.cc
file.
4. Goto to “mynetwork”-> add more nodes -> connect
them to each other then run the experiment. As
follows:
5. Depending on the model domain, message objects
represent events, packets, commands, jobs, customers
or other kinds of entities.
There are cMessage and cPacket Classes.
The cPacket class extends cMessage.
cPacket is used for network packets (frames,
datagrams, transport packets, etc.) in a
communication network, and cMessage is used for
everything else.
For example, encapsulation and decapsulation
operations are only used with cPacket.
6. cMessage *msg = new cMessage();
cMessage *msg = new cMessage("timer");
cMessage *msg = new cMessage("timer", kind);
msg->setKind( kind );
msg->setBitLength( length );
msg->setTimestamp( simtime );
int K = msg->getKind();
int L = msg->getBitLength();
simtime_t T = msg->getTimestamp();
…etc
12. Example
Assume that the following cPacket was received as
“MACdata”.
MAC IP
After using the following decapsulation statement:
IP MAC
13. Assume that you want to add your own header
between IP and MAC.
MyHeader
MAC IP
Name ID Year
14. Assume that you want to add your own header
between IP and MAC.
MyHeader
MAC IP
Name ID Year
15. From Project Explorer: right-click on myproject ->
New -> Message Definition (.msg) -> name it
(myHeader) -> Next -> Select New Message File ->
Next -> Finish.
Add our fields:
Save and Build.
16. OMNet++ generates .cc and .h (myHeader_m.cc and
myHeader_m.h).
Your needs are generated.
How to use it.
17. To use your new message: At Node.cc
1. Include the needed header.
2. Use “myHeader” as “cPacket”
3. That is it!
Insert it between IP and MAC