TranLuongTuanAnh / contiki-2.7

RPL TOTAL ENERGY METRIC OBJECT IMPLEMENTATION IN CONTIKI 2.7
Other
1 stars 3 forks source link

RPL code difference from the original one to use total energy #1

Open tommasogiannoni opened 4 years ago

tommasogiannoni commented 4 years ago

What is the files modified for use rpl total energy metrics and hou to include this metric in project simulation ?

Thanks

TranLuongTuanAnh commented 4 years ago

The main files that modified is contiki-2.7/core/net/rpl/rpl-mrhof.c My solution is very simple as code below

#elif RPL_DAG_MC == RPL_DAG_MC_TOTALENERGY
  return p->mc.obj.total_energy + get_total_energy_consumption();  

You must set RPL_DAG_MC value to RPL_DAG_MC_TOTALENERGY mode

tommasogiannoni commented 4 years ago

I added RPL_DAG_MC_TOTALENERGY but cooja don't find it.

What file i need to change to add a new metrics ? i changed:

rpl-mrhof.c by adding: #elif RPL_DAG_MC == RPL_DAG_MC_TOTALENERGY printf("TOTAL ENERGY METRIC LOADED"); return p->mc.obj.total_energy + get_total_energy_consumption();

rpl.h by adding #define RPL_DAG_MC_TOTALENERGY 9 /* Node Total Energy Comsumption */

and set the file: rpl-conf.h with this parameters: #define RPL_CONF_DAG_MC 9 that is the TOTAL ENERGY METRICS in rpl.h

#ifdef RPL_CONF_DAG_MC
#define RPL_DAG_MC RPL_CONF_DAG_MC
#else
#define RPL_DAG_MC RPL_DAG_MC_TOTALENERGY // <--- THIS 
#endif /* RPL_CONF_DAG_MC */

But when i run simulation the code printf("TOTAL ENERGY METRIC LOADED"); it is never executed.

Why ?