Simulation of a sensor network

The purpose of this project is to simulate a sensor network, i.e., an ad-hoc network whose terminals are, in general, fixed, and perform measurements of, e.g., temperature, humidity, pollution, etc.

A number of sensors k is given along with their Euclidean coordinates in an area of 100×100 square meters. The last sensor, indexed k, strategically located at the center of the area, is responsible for collecting all measurements and transmitting them via cable to some remote station.

Since all sensors are fixed on the territory, each sensor i is assigned in advance a signal power to transmit, at intervals of 2 seconds, the measurement to one of the neighboring sensors, which is at distance d_i and

  • propagates the message to another intermediate sensor on its path to k;
  • sends back to i a confirmation message.

The same happens for all sensors that propagate a measure coming from the initial node i toward the destination k. Each sensor which is at a distance of d_i or less will also receive that message, but will have to discard it.

In order to guarantee that every sensor gets its message to the base, every time a message sent by sensor j is not acknowledged within 5 seconds by the appropriate sensor h, sensor j must use twice the power and send a broadcast message, which must be propagated by all nodes that can detect that message except those that are farther from k than that node, i.e., those at distance not more than d_i \sqrt{2}.

Simulate the behaviour of k=25 sensors, whose coordinates are given by the following Cartesian product: \{0,25,50,75,100\}\times\{0,25,50,75,100\}. Report the average number of packets in the system under the following conditions:

  • all sensors are working;
  • all sensors are have a fault probability of 5% (i.e., on average 5% of the sensors are not working at all time).

Suppose d_i=25 for all sensors. Also, the appropriate sensor for sensor i is the one above it if its y position is 75 or 100, the one below it if its y position is 0 or 25, and, if the y coordinate is 50, the one closer to the central node (i.e. the one on the left if x_i > 50 and the one on the right if x < 50).