Applicable Versions
NetSim StandardNetSim Pro


Applicable Releases
v12
v13


AODV protocol implementation in NetSim is based on RFC 3561 (https://tools.ietf.org/html/rfc3561). This protocol is supported in NetSim for technologies such as MANET, WSN and IoT. 


The Ad hoc On-Demand Distance Vector (AODV) routing protocol is intended for use by mobile nodes in an ad hoc network. It offers quick adaptation to dynamic link conditions, low processing and memory overhead, low network utilization, and determines unicast routes to destinations within the ad hoc network.


Route table update logs can be obtained for each node in a NetSim network, by modifying the underlying source codes of AODV protocol as explained below. The logs obtained can be directly accessed from the results dashboard of NetSim after the Simulation.


Please follow the steps given below to modify AODV source codes to obtain log files:

1. Open NetSim Source codes using the open code button from Open Simulation->Workspace options

2. Go to AODV project in the solution explorer and open AODV.c  file Add the following code ( shown in red) in the function fn_NetSim_AODV_Init()


_declspec(dllexport) int fn_NetSim_AODV_Init()

{

    fn_NetSim_AODV_Init_F();


    for (int i = 0; i < NETWORK->nDeviceCount; i++)

    {

        if (isAodvConfigured(i + 1, 1))

            fn_NetSim_AODV_Route_Table_Update_Log(i + 1, "w+");

    }

    return 0;

}

 

Note: In v13, comment return statement in the AODV_init() function:

//return fn_NetSim_AODV_Init_F();


2. Open Routetable.c file and add the following function definition at the end of the file

 

int fn_NetSim_AODV_Route_Table_Update_Log(NETSIM_ID devid, char* filemode)

{

       char AODV_Log_filename[BUFSIZ];

       FILE* AODV_log_fp;

       sprintf(AODV_Log_filename, "%s\\%s_AODV_log.txt", pszIOLogPath ,    DEVICE_NAME(devid));

       AODV_log_fp = fopen(AODV_Log_filename, filemode);

       if (AODV_log_fp  && !strcmp(filemode,"w+"))

       {

              fprintf(AODV_log_fp, "DestinationIPAddress,DestinationSequenceNumber,NetworkInterface,HopCount,NextHop,Lifetime");

              fclose(AODV_log_fp);

       }

       else if (AODV_log_fp && !strcmp(filemode, "a+"))

       {

              AODV_ROUTETABLE* table = AODV_DEV_VAR(devid)->routeTable;

              while (table)

              {

                     (table->DestinationIPAddress)->str_ip;

                     fprintf(AODV_log_fp, "\n\n TIME(micro sec)  %f", pstruEventDetails->dEventTime);              

                     fprintf(AODV_log_fp, "\n %s, %d,%d,%d,%s,%f", (table->DestinationIPAddress)->str_ip, table->DestinationSequenceNumber, table->NetworkInterface, table->HopCount, (table->NextHop)->str_ip, table->Lifetime);               

                     table = (AODV_ROUTETABLE*)LIST_NEXT(table);

              }

              fclose(AODV_log_fp);

       }

 

       return 0;

}


3. In the function fn_NetSim_AODV_InsertInRouteTable() the function call to the above function is made at the end of the function as follows


int fn_NetSim_AODV_InsertInRouteTable(NETSIM_IPAddress ip,

    unsigned int seqNumber,

    unsigned int hopCount,

    NETSIM_IPAddress nextHop,

    double lifeTime,

    NetSim_EVENTDETAILS* pstruEventDetails)

{

    AODV_DEVICE_VAR* devVar = AODV_DEV_VAR(pstruEventDetails->nDeviceId);

    AODV_ROUTETABLE* table = devVar->routeTable;

    while(table)

    {

        if(!IP_COMPARE(table->DestinationIPAddress,ip))

        {

.

.

if(!table->NextHop)

        table->NextHop = IP_COPY(nextHop);

    table->routingFlags = AODV_RoutingFlag_Valid;

    if(table->DestinationSequenceNumber)

        table->ValidDestinationSequenceNumberflag = true;


//AODV DEVICE LOG

              fn_NetSim_AODV_Route_Table_Update_Log(pstruEventDetails->nDeviceId, "a+");

          return 1;

}


4. In the function fn_NetSim_AODV_UpdateRouteTable following codes are added

 

int fn_NetSim_AODV_UpdateRouteTable(NETSIM_IPAddress ip,

       double lifetime,

       NetSim_EVENTDETAILS* pstruEventDetails)

{

       //AODV DEVICE LOG

       double AODV_log_lifetime = 0;

 

       AODV_ROUTETABLE* table = AODV_DEV_VAR(pstruEventDetails->nDeviceId)->routeTable;

       while (table)

       {

              if (!IP_COMPARE(table->NextHop, ip) || !IP_COMPARE(table->DestinationIPAddress, ip))

              {

                     //AODV DEVICE LOG

                     AODV_log_lifetime = table->Lifetime;

 

                     table->Lifetime = max(table->Lifetime, lifetime);

              }

              table = LIST_NEXT(table);

       }

 

       //AODV DEVICE LOG

       if(AODV_log_lifetime < lifetime)

       fn_NetSim_AODV_Route_Table_Update_Log(pstruEventDetails->nDeviceId, "a+");

 

       return 1;

}

5. In the  fn_NetSim_AODV_ActiveRouteTimeout() function call is made

 

       //AODV DEVICE LOG

       fn_NetSim_AODV_Route_Table_Update_Log(pstruEventDetails->nDeviceId, "a+");

       

       if(!flag)

              IP_FREE(dest);

       return 1;


6. After modifying the AODV source codes as explained above, right click on the AODV project and select rebuild. Ensure that you have set the platform settings in Visual studio to win32/x64 as per the build of NetSim that you have installed, before building.


7. Upon successful build, running simulations involving MANET protocol will generate individual log files for each node which can be accessed from the results dashboard as shown below:


 

Individual log files contain the route table entries of a specific node at different points of simulation time along with time stamps: