File Exchange

image thumbnail

matlab wsn code

version 1.0.1 (2.56 KB) by cesar silva
MATLAB WSN Code for a wsn find a shotestpath between two nodes and send data

36 Downloads

Updated 25 Nov 2019

GitHub view license on GitHub

MATLAB WSN Code for a wsn find a shortestpath between two nodes and send data. (you choose parameters - almost fully personalized)

Its WSN has range tolerance between nodes (you choose the range - in meters). As soon nodes establish conection, due range tolerance (position sorted randomly in a 1km x 1km terrain). The shorthest path alg get a route and starts send data from node 1 (source) to node 2 (target), till any node node involved in the route path die due energy failure (all nodes involved in route decreases its energy - also randomly defined). After a route failure, it gets next shortest route and keeps sending.. and so on, till no paths between source and target left....

Obviosuly it my code... i started with matlab 2 week ago, never heard about this program before. Surely code can be improved, but i respectfully makes it available for those that have urgent needings...

hope i can help someone (I do it from the deep of my heart). Now i go keep working on it... because i need to implement ACO (Ant colony Optimization) to it...

### IF SOMEONE CAN HELP ME... ###

my goal is to analise if ACO can improve network life time in comparion with an "extra routing engine" (Like shortest path, wich is an vector-distance routing engine, like AODV, RIP, etc).

Btw, i will be glad and happy with someone else help, if not, i think i can go by myself with some fell more dedication... hugs everyone.

NOTE: Of course code can be improved... i see lot of briliant matlab coders here... so, lets keep helping ppl... congratz!

Cite As

cesar silva (2020). matlab wsn code (https://github.com/cesarfgs/matlab-wsn-code), GitHub. Retrieved .

Comments and Ratings (10)

Hi Cesar,
Due to Plagiarism and Copyright issue as a learned colleague, I want to adapt part of this code below with another Algorithm as am looking in Wireless Sensor Network research.
I need your approval and a go ahead permission to be able to improve more on this code to delve into it deeper for my research....
Kindly give me an approval and a go-ahead and I will also reference you in this research as well, possibly ask what is your rationale for this code in explanation let me see if we are on the same page..
Thanks
Please email me approval : E-mail: aroseglinks@yahoo.co.uk
Thanks

cCan you please email me : aroseglinks@yahoo.co.uk

AMRU VG

can u please email the code for the above to vgamrutha1999@gmail.com?

cesar silva

AMRU VG. now i got what you mean!

Once they "Die" (power outage) they dont "come back" to scene. They recharge just while they are alive. It is a way to "force" devices to die anyway to decrease the available paths.

By the other hand, all devices recharge... but the recharge rate ALWAYS is lower than the energy used WHEN THEY ARE ON AN ACTIVE ROUTE. Once they "OUT", they just recharge, without use significant energy.

I mean that... (example) the "recharge rate" is 0.4, the energy usage in routing events is 0.5... for every moment (code loop) you can understand that there is a packet send + all nodes recharging (+0.4) + JUST NODES INVOLVED IN ROUTING WASTING ENERGY (-0.5)... there will be a moment that one of the nodes in path will die, resulting in a path unavailability... and so on till no more path (unavailable WSN).

So, same scenario is built with ACO... ACO keep "watching" nodes energy... as soon the ACO formula mathmaticaly find a better fitness in anothe route, it changes the route... What happens? PROBABILY new route dont have same nodes... it means that the PREDECESSOR ROUTE will "set its nodes free" just to recharge... because they will not being used in routing events... and so on.

LOT of routing protocols are madatory... they go by a route dont matter the result... (lower cost as example)... in this code... ACO energy "aware" takes the decision BEFORE nodes die... as result you have that no nodes die = no paths "gone = all paths available and/or will take looooot of time for it...

AMRU VG

for c = 1 : length(garbage.Outroutenodesidx)
rechargeblenode=garbage.Outroutenodesidx(c,1);
dataset.nodePosition(rechargeblenode,4)=dataset.nodePosition(rechargeblenode,4)+dataset.energyrecoveryperCicle*dataset.energyfactor*rand();
b=1;
end
line(dataset.nodePosition(1:2,2),dataset.nodePosition(1:2,3),'color','green','marker','o','linestyle','none','markersize',100)

why this part of the code is not working, means, dead node is not recharging...

cesar silva

Amrutha VG

yep bro... it is working! Whats up?

cesar silva

Deepak Raj

Yeap i did. I implemented it. ACO in WSN... energy-based ACO for routing path auto-election.... it avoid a route path run out of energy... it keeps all network "alive"

Amrutha VG

why suddenly recharge code is not working?

Deepak Raj

Hi
Have you implemented ant colony optimization. I am working on implementing AI in WSN.

Updates

1.0.1

Just changed the post's picture ! ;P

MATLAB Release Compatibility
Created with R2019a
Compatible with any release
Platform Compatibility
Windows macOS Linux