Applicable Versions | Netsim Standard | Netsim Pro |
Applicable Releases | v11 | v12 | v13 |
Energy consumption is calculated individually for each sensor node that is part of the network scenario during various Radio States such as SLEEP, TRX_ON_BUSY, RX_ON_IDLE, RX_ON_BUSY, RX_OFF.
Based on the calculations done, NetSim provides a detailed Battery Model Metrics table that provides energy consumption of each device with respect to Transmission, Reception, Idle Mode, Sleep Mode, etc.
It also provides information about the node's initial energy, consumed energy and remaining energy. However, remaining energy may also include harvested energy if energy harvesting is turned on.
{
NETSIM_ID deviceId;
NETSIM_ID interfaceId;
double initialEnergy;
double consumedEnergy;
double remainingEnergy;
double rechargingEnergy;
double voltage;
double rechargingCurrent;
int modeCount;
ptrBATTERYMODE mode;
int currentMode;
double modeChangedTime;
void* animHandle;
struct stru_battery* next;
}BATTERY, *ptrBATTERY;
int mode,
double time)
{
bool ret;
ptrBATTERYMODE pm = battery_find_mode(battery, battery->currentMode);
double r = battery->voltage*battery->rechargingCurrent*(time - battery->modeChangedTime) / 1000000;
double c = battery->voltage*pm->current*(time - battery->modeChangedTime) / 1000000;
battery->rechargingEnergy += r;
battery->remainingEnergy += r;
battery->modeChangedTime = time;
declspec(dllexport) void battery_metrics(PMETRICSWRITER metricsWriter)
{
ptrBATTERY b;
static bool isCalled = false;
if (isCalled)
return;
isCalled = true;
if (!firstBattery)
return; // No battery is added
PMETRICSNODE menu = init_metrics_node(MetricsNode_Menu, "Battery model", NULL);
PMETRICSNODE table = init_metrics_node(MetricsNode_Table, "Battery model", NULL);
add_node_to_menu(menu, table);
char modeList[BUFSIZ]="";
sprintf(modeList, "Device Name#1,Initial energy(mJ)#1,Consumed energy(mJ)#1,Remaining Energy(mJ)#1,Recharging Energy(mJ)#1,");
prepare_mode_list(modeList);
add_table_heading_special(table, modeList);
b = firstBattery;
while (b)
.
.
.
.
{
add_table_row_formatted(false, table,
"%s,%lf,%lf,%lf,%lf,",
DEVICE_NAME(b->deviceId),
b->initialEnergy,
b->consumedEnergy,
b->remainingEnergy,
b->rechargingEnergy);
add_to_table(table, index);
b = b->next;
index++;
}
The default settings in the energy model in NetSim IoT/ WSN library is based on Table 1 in the following paper: