Random way point mobility model.
[G,F,X,Y,D,V,T] = NL_M_GraphRWP(G,F,X,Y,D,V,T,TM,VM)
Graph.
Graph handle.
X-coordinate of destinations.
Y-coordinate of destinations.
Distance vector between nodes current destination and their destination.
Speed vector.
Pause duration vector.
Maximal pause duration.
Maximal speed.
NL_M_GraphRWP simulates the random way point mobility model. The initial graph G is represented by its window handle F. Each node randomly selects a speed between . V gathers the selected speed for each node. Each node
moves to its destination located in
with its constant speed
. The distance between the current location and the destination is
. When the node reaches its destination, it waits there during T(i) time steps, and then it selects a new destination and a new speed. Then the node moves only when T(i)==0. When the node
reaches its destinations, T(i) is randomly selected between
. T is decremented after each simulation step (time incremental). The process is repeated until the end of the simulation.
n=100; cr=120; L=1000; nx=L*rand(1,n);//current x-coordinate of all nodes ny=L*rand(1,n);//current y-coordinate of all nodes name='mobility'; t=[]; h=[]; [g]=NL_G_MakeGraph(name,n,t,h,nx,ny);//creation of a network graph [h,t]=NL_M_Locality(g.node_x,g.node_y,cr);//application of NL_M_Locality g.head=h; g.tail=t; i=1;//window index name="mobility";//name f=NL_M_Background(i,name);//application of NL_M_Background r=10;//radius c=1;//color t=0; f=NL_M_GraphDisplayUpdate(g,i,r,c); vm=10; v=vm*rand(1,n);//velocity for each node destx=L*rand(1,n);//destination x-coordinate of all nodes desty=L*rand(1,n);//destination y-coordinate of all nodes Tnodes=zeros(1,n);//all nodes are moving d=sqrt((g.node_x-destx).^2+(g.node_y-desty).^2);//initialization of the distance vector Tmax=50;//max waiting time for i=1:300 [g,f,destx,desty,d,v,Tnodes]=NL_M_GraphRWP(g,f,destx,desty,d,v,Tnodes,Tmax,vm);//application of NL_M_GraphRWP end | ![]() | ![]() |