Effacer les filtres
Effacer les filtres

I have used the following code to create a wsn virtual structure with 4*4 grid-cells and have deployed 100 nodes in it. Each cell is headed by a cluster-head which is in center of the cell i.e their are a total of 16 cluster-heads. Now , what i want

4 vues (au cours des 30 derniers jours)
I have used the following code to create a wsn virtual structure with 4*4 grid-cells and have deployed 100 nodes in it. Each cell is headed by a cluster-head which is in center of the cell i.e their are a total of 16 cluster-heads. Now , what i want to do is that after the initial cell-header election, each cell-header should notify its status not only to the surrounding nodes within its cell but also to the nodes which are slightly beyond the cell boundary and associate themselves to the closest one. Nodes that will receive notifications from multiple cell-headers should also share the information of the secondary cell-header with their primary cell-header. In this way, each cell-header will form adjacencies with neighboring cell-headers using gateway nodes. The attached pic. will more clearly show the set of cell-header nodes together with the gateway nodes that will form a chain like virtual backbone structure.
% WSN Grid structure with 4*4 cells made
NrGrid = 4;
x = linspace(0, 100, NrGrid+1);
[X,Y] = meshgrid(x);
figure(1)
plot(X,Y,'k')
hold on
plot(Y,X,'k')
hold off
set(gca, 'Box','off', 'XTick',[], 'YTick',[])
axis square
% grid formation ends
% Nodes deployment started
NrGrid = 4;
coords = rand(100,2) * NrGrid + 1;
scatter(coords(:,1),coords(:,2));
set(gca, 'XTick', 1:NrGrid+1, 'YTick', 1:NrGrid+1)
grid on
% Nodes deployment ends
%All good upto here
%cluster head selection on basis of most near to the center
[XC, YC] = ndgrid(1/2:NrGrid+1/2, 1/2:NrGrid+1/2);
center_idx = zeros(NrGrid, NrGrid);
k=NrGrid^2;
for K = 1 : numel(XC)
xc = XC(K);
yc = YC(K);
dists = sqrt((coords(:,1)-xc).^2 + (coords(:,2)-yc).^2);
[mindist, minidx] = min(dists);
center_idx(k) = minidx;
end
%cluster head selection ends

Réponses (1)

Walter Roberson
Walter Roberson le 24 Juin 2015
You have to stop this asking us to do your project a step at a time. The only code you have contributed to this is the part that ends with "% grid formation ends", and all of that code is irrelevant. The plot gets immediately overwritten by the scatter() plot which establishes the grid itself ("grid on")
The code structure you have been following assumes that before you even get going that all of the nodes know where they are in grid coordinates, and know where their cell-heads are, and know who they can hear or not. In a real WSN, none of those conditions would hold, not unless the positions were all pre-planned and the sensors carefully positioned. And if you were going to do that pre-planning, why use rand() to position the nodes rather than placing them in computationally "nice" positions such as exactly at vertices of a rectangular grid?
The fact that you are taking random node positions to start implies that you need to simulate the nodes discovering each other, and simulate electing cell heads. That needs to be done by simulating sending signals in the presence of noise (generally), and signal barriers and (eventually) simulating multipath. And you need to simulate passing signals between nodes to arrive at the sink node. You will probably want to run routing protocols of various sorts that take into account signal strength and quality, and load.
But the first thing you have to write to get any further is simulating sending out signals and having them received by multiple nodes; then you need to simulate adding noise that differs for the various paths so soon thereafter you need to add error detection and correction code while keeping in mind that some errors will be too big to correct.
It is not very useful to start writing protocols for determining cell heads before you have written a simulation for noise and imperfect error correction. You can write protocols for perfect conditions, but you end up needing to throw most of those protocols out as soon as you start including the possibility that packets might not get through or that reception might be delayed: better to write the protocol from the start to include those possibilities.
Realistic WSN would worry about latency of transmission and the possibility that a signal can be "in flight" for multiple rounds of your processing loop: measuring latency gets to be fairly important for some of the more sophisticated algorithms. Synchronizing the clocks of all of the nodes requires interesting algorithms.

Catégories

En savoir plus sur WSNs dans Help Center et File Exchange

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by