Mat Lab Interface
Mat Lab Interface
m FILE)
4. Place PlotDAG.m file inside the installation folder of MATLAB i.e. “C:\Program
Files\MATLAB\R2016a”, (Note: PlotDAG.m is provided in the folder)
5. Open RPL.c file and add fn_netsim_matlab_init() and
fn_netsim_matlab_DODDAG_Init() inside fn_NetSim_RPL_Init() and
fn_netsim_matlab_Finish() inside fn_NetSim_WLAN_Finish ().
double fn_netsim_matlab_init();
double fn_netsim_matlab_DODDAG_Init();
double fn_netsim_matlab_DODDAG_run();
double fn_netsim_matlab_finish();
7. Go to the Neighbor.c file. Inside Function void choose_parents_and_siblings(NETSIM_ID d)
add fn_netsim_matlab_DODDAG_run() below rpl_add_route_to_parent()
10. To compile a MATLAB engine application in the Microsoft Visual Studio 2015 environment, Right
click on the RPL project and select PROPERTIES in the solution explorer. Once this window has
opened, make the following changes:
a. Under C/C++ General, add the following directory to the field ADDITIONAL INCLUDE
DIRECTORIES: <Path where MATLAB is installed>\extern\include
b. Under C/C++ Precompiled Headers, select "Not Using Precompiled Headers".
c. Under Linker General, add the directory to the field ADDITIONAL LIBRARY DIRECTORIES:
<Path where MATLAB is installed>\extern\lib\win64\microsoft
(Note: To run this code 64- bit version of MATLAB must be installed in your system. If you are interfacing
for the first time then open command window and go to the <NetSim installed directory>\bin and type
matlab -regserver)
12. Now replace the newly built libRPL.dll from the DLL folder, into the NetSim bin folder. Please
ensure you rename the original libRPL.dll file to retain a copy of the original file.
A plot will open, showing the DODAG when the simulation is started and the first
route is formed between sink node and the sensor. And the DODAG will be
dynamically updated.
Initially formed DODAG
DODAG formed after some time due to movement in sensors
After simulation press any key in the NetSim command window to close the MATLAB