Applicable Versions
NetSim StandardNetSim Pro

Applicable Releases

fprintf() statement can be used to print to NetSim console using the default file descriptor stderr

fprintf(stderr, "The value of the variable X is %d\n", X);

You may insert such a line at a suitable place. Note that NetSim is a discrete event simulator and hence you may see this line printed multiple times, each time that particular event (where the fprintf is written) is called.

Example 1: Printing remaining power of sensors in WSN

Inside fn_NetSim_Zigbee_ChangeRadioState() function present in ChangeRadioState.c file add following codes

fprintf (stderr,"\nNode Name\tRemaining_Power \t Time\n");

fprintf(stderr,"\n%s\t%lf mW\t%lf ms\n\n", NETWORK->ppstruDeviceList[nDeviceId-1]->szDeviceName,pstruDevicePower[nDeviceId-1]->dRemainingPower,pstruEventDetails->dEventTime);


Note: Use _getch() for NetSim v10.

Rebuild the Zigbee project and replace the default libZigbee.dll by the modified one.

Create a scenario in WSN and simulate.

During simulation, the user can see the remaining power of each node along printed to simulation console along with the timestamp.

Example 2: Print node positions in MANET

Open Mobility Project, and in Mobility.c and go to fn_NetSim_Mobility_Run() function. Inside the default, case add following codes

fprintf(stderr,"\n The position of %s at time %.2lfms is X=%.2lf and Y = %.2lf \n",DEVICE_NAME(pstruEventDetails->nDeviceId),





Note: Use _getch() for NetSim v10.

Build Mobility project and replace libMobility.dll inside the binary folder of NetSim installation directory.

Create a scenario in MANET and configure the mobility model of the nodes.

During simulation, the user can notice that the positions of the nodes are displayed in the console w.r.t. the simulation time.