Omnet++ simulation of a simple ACK protocol.
We will be simulating three nodes connected in series, where the rightmost node(sender) wants to transmit data across to the leftmost one(receiver). Messages will be crossing the middle node that will act as a bridge between the other two nodes and will route each message in the appropriate output interface. Also messages sent will be holding a sequence number and each time receiver gets a message is sending back to the sender an acknowledgment(ACK). Sender on his side to prevent the loss of a packet(message) will be having a timer set up each time transmitting a new packet. If the ACK doesn’t come by the time timer expires, sender will be transmitting again the packet with the last sequence number.
We are using Omnet++ for this simulation, code is written very much in C++, and Ned language needed to configure the network part.
File: Vic.ned ; describing network modules and sub-modules, as well their gates and connections.

File: Md.cc ; describing the operational part of the module Md we defined previously and actions taken in various circumstances.


In every omnetpp Project it is required to have a file named “ omnetpp.ini” and in our example is a very simple one just defining the name of the network to be simulated.
File : omnetpp.ini ; required into every omnetpp project.

A screenshot of the whole network is below:

To simulate a probabilistic packet loss in sub-module ‘c’ we are invoking a call in Md.cc: if(uniform(0,1) < 0.1) { /*packet loss stuff*/ }, and by that if in a uniform distribution call the value between zero and one happens to be less than 0.1 then we assume the packet is lost and sub-module ‘c’ is not sending an ACK; to simulate the event of timeout.
