| Applicable versions | NetSim Standard | NetSim Pro |
This can be achieved by adding delay during the network out event based on the type of control packet.
1. Open NetSim source codes through Visual Studio IDE by going to Your Work-> Workspace options-> Open Code.
2. Goto RPL project, and add a new function rpl_get_Delay_by_type() to the RPL_Message.c file as shown below:
double rpl_get_delay_by_type(NETSIM_ID type)
{
double delay = 0.0;
switch (type % 100)
{
case DODAG_Information_Object:
delay = 10 * MILLISECOND;
break;
case Destination_Advertisement_Object:
delay = 20 * MILLISECOND;
break;
case DODAG_Information_Solicitation:
delay = 30 * MILLISECOND;
break;
default:
fnNetSimError("Unknown rpl ctrl msg %d in %s",
pstruEventDetails->pPacket->nControlDataType,
__FUNCTION__);
break;
}
return delay;
}
The delay is currently set to 10, 20, and 30 milliseconds for DIO, DAO, and DIS messages respectively. This can be modified as per the user's requirement.
3. A function prototype is to be added to the beginning ofRPL_Message.c file as shown below:
#include "main.h"
#include "RPL.h"
#include "RPL_Message.h"
//Function definition
static void rpl_dodag_config_option_destroy(PRPL_DODAG_CONFIG_OPTION opt);
static PRPL_DODAG_CONFIG_OPTION rpl_dodag_config_option_copy(PRPL_DODAG_CONFIG_OPTION opt);
static PRPL_TARGET_OPTION rpl_rpl_target_option_copy(PRPL_TARGET_OPTION target);
static void rpl_rpl_target_option_destroy(PRPL_TARGET_OPTION target);
double rpl_get_delay_by_type(NETSIM_ID type);
4. The rpl_node_send_msg() function in the RPL_Message.c file as shown below (in red):
void rpl_node_send_msg(NETSIM_ID ndevid, NetSim_PACKET* packet)
{
NetSim_EVENTDETAILS pevent;
double delay = rpl_get_delay_by_type(packet->nControlDataType);
memset(&pevent, 0, sizeof pevent);
pevent.dEventTime = pstruEventDetails->dEventTime + delay;
pevent.dPacketSize = fnGetPacketSize(packet);
pevent.nDeviceId = ndevid;
pevent.nDeviceType = DEVICE_TYPE(ndevid);
pevent.nEventType = NETWORK_OUT_EVENT;
pevent.nPacketId = packet->nPacketId;
pevent.nProtocolId = NW_PROTOCOL_IPV6;
pevent.pPacket = packet;
fnpAddEvent(&pevent);
}
5. Right-click on the RPL project and click on rebuild. The DLLs will be automatically updated in the binary folder of the current workspace.