You must use the fprintf statement, and an example is shown below -

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 the that particular event (where the fprintf is written) is called

Example 1: Print remaining power of sensor 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 Zigbee project and replace the default libZigbee.dll by the modified one.

Create a scenario in WSN and simulate.

During simulation in console user can see the remaining power of each node along with the time.

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 user can notice that the positions of the nodes are displayed in the console w.r.t. the simulation time.