In order to make interaction between the nodes, there should be some kind of protocol to communicate. So I implement stop-and-wait protocol in this network.
And for that, there should be some timer and ack signals. Acorrding to Official Guide, I use
simtime_t timeout; // timeout
cMessage *timeoutEvent; // holds pointer to the timeout self-message
These two signals are designed to record the time when to send the message, and send the time-out message to the sender. The core function in this experiment is handleMessage(cMessage *msg);
-
initialize()
initialize the signals
simtime_t timeout;
andcMessage *timeoutEvent;
, and generate the message, makemsg_
to record that. -
sendACK(sdn_message *msg)
use the method to get the sender and send ack to it.
-
handleMessage(cMessage *msg)
- if it is a
msg
message, then it should have a choice- if this is the destination, then finish this message and start a new one
- else forward this message
- if it is a
ack
message, then delete the timer - if it is a
timeOut
message, then retransfer the message
- if it is a
-
generateMessage(char *a)
generate the kind of
a
message and return itthis method also set the source and destination for the message
-
forwardMessage(sdn_message *msg)
send the message to next random port
- How to reply to the message in OMNet++?
- use default method like
setName()
andgetName()
regularly forcMessage*
getVectorSize()
will return the total gates in network, whilegateSize("gate")
will only return the number of nodes attached to this node.