How to fail a node in NetSim

In this section we explain node failure using MANET-DSR as an example

Using Device Id, Identify the Device ID of the particular device.

The fn_NetSim_DSR_Run( ) is the main function to handle all the protocol functionalities

DSR_Run( )

strcpy(pszFilepath,pszIOPath);
strcat(pszFilepath,”/Output.txt”);
fp = fopen(pszFilepath,”r”);
i=0;
if(fp)
{
while(fgets(pszConfigInput,500,fp)!= NULL)
{
sscanf(pszConfigInput,”%d %d”,&NodeArray[i],&TimeArray[i]);
i+=1;
}
}

for(i=0;i<100;i++) if((pstruEventDetails->nDeviceId == NodeArray[i])&&(pstruEventDetails->dEventTime >= TimeArray[i]))
// Node failure happens after a value of time storted in an array
{ // This just returns instead of running DSR functionality when the node is failed
pstruEventDetails->nInterfaceId = 0;
return 0;
}

Note: Add the above lines of code after the variable declarations in the function
Build the .dll by clicking Build ->Build Solution. (The dll will be created inside the Visual studio project->Debug)

Leave a Reply

Your email address will not be published.