| Applicable Versions | NetSim Standard | NetSim Pro |
| Applicable Releases | v11 | v12
| v13 |
NetSim comes with the underlying protocol source codes which can be modified by the user. The source codes can be accessed from <NetSim_Install_Directory>/src/Simulation path. Various parameters that are set in the GUI and those that are calculated and updated during run time can be accessed to write your own code in NetSim. The following are some of the commonly used device parameters and methods to access them in the code.
Velocity:
In the mobility project, Mobility.h file contains the structure stru_NetSim_MobilityVar which has the variable velocity defined.
For usage you can refer:
File: GroupMobility.c
Function: fn_NetSim_MoveGroup()
Where velocity is retrieved for calculations:
pstruMobilityVar->dVelocity;
Location and Direction:
To access the current location of any device, you can use the API:
DEVICE_POSITION(DeviceId)->X
DEVICE_POSITION(DeviceId)->Y
Energy Level:
The energy level of the devices is handled by the BatteryModel project which provides API's such as:
battery_get_remaining_energy(ptrBATTERY battery);
battery_get_consumed_energy(ptrBATTERY battery, int mode);
Where,
battery is the variable associated with the device whose battery information is to be retrieved,
mode refers to either transmission, reception, idle or sleep for which the energy consumption is to be retrieved.
Distance:
Distance between any two devices can be calculated using the API:
fn_NetSim_Utilities_CalculateDistance(NetSim_COORDINATES* coordinate1,NetSim_COORDINATES* coordinates2);
For usage refer, IEEE802.11 project ,IEEE802_11_Phy.c file:
double d=fn_NetSim_Utilities_CalculateDistance(DEVICE_POSITION(tx),DEVICE_POSITION(rx));
Related Knowledgebase articles: