Finding Exhibits You Can Visit with NS-3 Application

Introduction

Imagine you are visiting a museum. A guided tour application (which helps you discover the museum) for your mobile phone is provided by the museum.
The application will provide information about the exhibits inside the museum based on your location.

The application will display the exhibits you can visit within a radius of your location. The exhibits which are outside of the radius will not be displayed on the smartphone.
The smartphone identifies its location inside the museum based on the signal it receives from the access points installed in the building. 
Additionally, the application will display the distance the visitor walked into the museum.

The behaviour of the application will be implemented using NS‐3.

The project includes:

1. Finding the distance between the client and access point.
2. Finding client’s coordinates using trilateration.
3. Trilateration error.
4. Detecting exhibits the client can visit within a specific radius.
5. Printing the distance visitor travelled.


Finding the distance between the client and access point

Consider one visitor and one access point (AP) inside the museum. As the visitor approaches and leaves the AP’s area the strength of the signal the visitor receives from the AP modifies.

Screen Shot 2014-12-04 at 15.17.28

The formula to calculate distances was simplified because AP’s coordinates are x=0.0, y=0.0

 


Finding client’s coordinates using trilateration.

Consider one visitor and a grid of APs. The visitor senses the signal received from all the surrounding APs. Using the outputted data from the previous task we calculate the location of the client using trilateration.

Screen Shot 2014-12-04 at 15.28.17

calculateTrilateration() method

 

The g_mapBeacons map stores MAC address and signal strength of the APs sending beacons. Each time client node receives a beacon g_mapBeacons map is updated. Knowing the power we are able to tell the distance between client and AP. We iterate through the map. For every power, we want to find the corresponding distance. Then the program takes the data from the map and saves it into a variable. We know the only power of the signal from APs, so we check with data from task 1 (loaded from powerToDistanceMaping.dat file) what is the corresponding distance. We loop through g_powers to find value, which is very close. The distances_vector stores identified distances. The coordinates_vector stores coordinates of AP’s MAC address which send the beacon. When we find the value of the distance which is very close to the one we are looking for, we break from the loop.

 

We need coordinates of three access points and distances of ap from client to calculate the position of the client using trilateration formula. The positionX and positionY are variables with coordinates of the client. If the client doesn’t receive enough data – not enough beacons, the message that there is not enough data is printed.


Trilateration error.

We can draw several conclusions from the comparison of the X and Y coordinates taken from the simulator and calculated by the trilateration method. 

First of all, as the distance increases, the deviation of errors increased as well, mostly in the X coordinates. This is due to the fact that a slight discrepancy in the distance vs signal strength data increases by the distance. Also, the client node was moving away from the beacons, which made the measurements of the X distance increasingly difficult as the angle they looked at the client node started to decrease. In an extreme situation, if the client node was let’s say at coordinates 0,1000, the trilateration would not be that efficient. In an ideal situation, the beacons look at the client node at wider angles to provide better quality. Deviation in Y coordinates was more easily picked up, as two beacons were further away from the X axis (-15, -10 and -20, 10). 

Secondly, after calculating the standard error we could clearly see that while we had 0.39193 standard error on the X coordinate, we had only 0.15217 on the Y coordinate.

Thirdly, when measuring the signal strength and various distances in step one, we didn’t have proper measurements at 0.5 and 1.0 meters. These two measurements showed almost no signal strength decrease, which shouldn’t be the case. As we used the chart later to measure the distance of the client node at the trilateration phase, the errors peaked at these distance (see chart ‘Squared error in Y Coordinates’). 

We could draw more predictions by running the trilateration several times, thus increasing our data points.  More datapoint could provide better feedback, and at a later stage, a correction algorithm could be developed to increase the quality of our trilateration application.

Screen Shot 2014-12-04 at 15.41.55

Screen Shot 2014-12-04 at 15.42.35


Detecting exhibits the client can visit within a specific radius.

To identify the exhibits within the circle we need to compare the distance between the client and the exhibit to the radius of the circle. If the distance is smaller than the radius, the program will print exhibits, if bigger it will not print them. We can calculate the distance using the same formula like in task 1, using coordinates of the client and coordinates of the exhibits. To save some computing power it is better to compare the sum of squares to the squared radius, instead of using sqrt.

Coordinates x of exhibits are stored in the ex-array, coordinates y in the ey array. The eNames array stores names of exhibits. They all have the same length. We can use for loop to iterate through all three arrays, calculate sumSquares and squared Radius for each position. If statement within for loop checks if the exhibit is inside the circle. If sumSquares is smaller or equal than the squared radius of the circle, the name, distance and coordinates of the exhibit are printed.

 

Screen Shot 2014-12-04 at 15.51.38


Printing the distance visitor travelled.

The client’s positions, calculated by trilateration are stored in the path_vector as a px and py coordinates.

 

Once the simulation is over, program prints number of points which were detected (added to path_vector), their coordinates and distances between them. At the end, path length is printed.
The same formula as in task 1 was used to calculate distances between points.
To print path length and points, we are iterating with for loop through the path_vector. At each iteration, the distance between two points is calculated and added to the overall path length.

Screen Shot 2014-12-04 at 16.00.51

Screen Shot 2014-12-04 at 16.01.53


Program

 

 

Tagged: