Difference between revisions of "RoutesMobilityModel"

From Nsnam
Jump to: navigation, search
(Documentation)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
= Project Overview  =
+
= Overview  =
* Student:  [mailto:1090678@isep.ipp.pt Tiago Cerqueira]
+
Mobility trace generation in ns-3 is done either by using the Mobility module included in NS-3 or by importing mobility traces generated by third party programs in a compatible format. The Mobility module included in ns-3 gives programmers the building blocks to create simple or complex traces, but is hindered by the fact that creating complex traces using the current module alone takes too long, even for simulations with just a couple of mobility capable nodes. As for mobility traces generated by third party programs, such as SUMO, they can involve too much work for their generation, especially when the researcher's interest - and expertise - is more on the data communication than on the traffic simulation. Using the Google Maps API it is possible to generate complex mobility traces, simply by providing a start and end point.
* Mentors:  [mailto:tomh@tomh.org Tom Henderson] and [mailto:scarpen@ncsu.edu Scott Carpenter]
+
 
* On-Site mentor [mailto:michele.albano@gmail.com Michele Albano]
+
The RoutesMobilityModel generates realistic mobility traces by querying the Google Maps Directions API and requesting directions between two (or more) points. The information obtained from the Google Maps services, used in tandem with the ns3::WaypointMobilityModel, allows the simulator to generate realistic mobility traces based on real-world locations and road networks. The purpose of this module is to bridge the gap between the highly complex but realistic SUMO and the synthetic mobility models available in ns-3.  
* Abstract: Mobility trace generation in ns-3 is done either by using the Mobility module included in NS-3 or by importing mobility traces generated by third party programs in a compatible format. The Mobility module included in ns-3 gives programmers the building blocks to create simple or complex traces, but is hindered by the fact that creating complex traces using the current module alone takes too long, even for simulations with just a couple of mobility capable nodes. As for mobility traces generated by third party programs, such as SUMO, they can involve too much work for their generation, especially when the researcher's interest - and expertise - is more on the data communication than on the traffic simulation. Using the Google Maps API it is possible to generate complex mobility traces, simply by providing a start and end point. Since the API is robust, well documented and supported, it can be assumed it will be available in the future.
+
* About me: I'm a bachelor's student, currently doing an internship at CISTER (Research Center in Real-Time and Embedded Computing Systems) as part of my course's curriculum, where I'm working closely with ns-3. As part of my internship, I’ll be working closely with VANET simulations in ns-3.
+
  
 
= Approach =
 
= Approach =
I plan to download a mobility trace as the XML output of the Google Maps Directions API. This API provides its user with an encoded polyline string, which can be easily transformed into geographical coordinates. These, in turn, can be transformed into Cartesian coordinates for use with the NS-3 mobility module. I plan to use in particular ns3::Waypoint and ns3::WaypointMobilityModule classes to import the data contained in the XML trace into the simulator.
 
I plan to allow easy integration for other APIs, if needed, but I'm not going to implement it in this project.
 
I will also provide examples with different wireless technologies, such as LTE and 802.11p/WAVE.
 
 
= Deliverables =
 
I plan to add classes to the Mobility model to contact the Google API and parse the information received into geographical coordinates. By converting those coordinates to Cartesian coordinates it is then possible to create mobility waypoints
 
It is also possible to provide a rough simulation for the speed at which a node can travel between given waypoints, by considering the speed limits in the tract for a car, and using default values for cycling, walking, and public transportation.
 
= Plan =
 
Each Milestone includes a period of half a week dedicated to test that milestone.
 
* First and second week – Design the application and further study its implementation
 
* Third and fourth weeks – Implement the design skeleton and implement methods for specifying the information to access and to convert that information to a format that NS-3 can understand
 
* Fifth and sixth weeks – Implement methods for converting the information given by Google Maps into waypoints in order to generate a trace based on the Google Maps route. Develop an algorithm to set up reasonable values for the speed of the car/person between two waypoints.
 
* Seventh and eight weeks – Perform exhaustive testing to the functionalities implemented.
 
* Ninth and tenth weeks – Correct existing bugs and prepare patch
 
= Code repository =
 
My code can be found [https://bitbucket.org/TiagoCerqueira/routesmobilitymodel here]
 
= Status Reports =
 
Per agreement with my mentors, I opted for status reports instead of weekly reviews.
 
The idea behind these code reviews is to post one once I accomplish a milestone.
 
== First Status Report ==
 
I set my first milestone as being able to generate a mobility trace given real world start and endpoints (street names, for example), from the ns3 simulation environment.
 
=== Notes ===
 
The ns3::WaypointMobilityModel works by adding ns3::Waypoints to a dequeue sequentially.
 
  
 
The Google Maps Directions service, however, provides an XML that contains the following concepts:
 
The Google Maps Directions service, however, provides an XML that contains the following concepts:
Line 37: Line 12:
 
* Point - A latitude/longitude set
 
* Point - A latitude/longitude set
  
To create a mobility trace, my module uses a list of Legs, each one containing a list of Steps and these, in turn, with a list of points.
 
  
At the time, the ns3::WaypointMobilityModel defines a journey as an ordered (by time) sequence of ns3::Waypoints.
+
The RoutesMobilityModel module relies on the module ns3::WaypointMobilityModel in order to import the mobility routes retrieved from the external information services. Our module creates ns3::Waypoints that model the routes used to travel between two (or more) real world locations, and later on they are interpreted as the waypoints the vehi- cles move through during the simulation.
My module defines journey as a list of Legs, with each Leg having a list of Steps and each Step with a list of Points.
+
=== Module Design ===
+
In order to provide a robust module, it was crucial to design it in such a way that it could be possible to add support for other APIs (such as the OpenStreetMaps's). To achieve this, the Strategy design pattern was used.
+
  
=== Use Cases ===
+
The information retrieved from the Google Maps Directions API contains, among other information, a polyline for each step of the route requested. It also contains the duration (the time it would take to go from the beginning to the end) for the step. The module decodes the polyline, thus creating a list of geographical coordinates, which are, in turn, converted to Cartesian coordinates. In order to model the speed of a node, implemented by setting the times for the ns3::Waypoints, we distributed the duration of the step in proportion to the distance traveled between two waypoints.
I identified the following use cases:
+
  
==== Create mobility trace for a node ====
+
[[File:General_overview_of_the_RoutesMobilityModel.png]]
*Name: Create mobility trace for a node
+
*Actors: User
+
*Description: The user is able to request the module to generate a mobility trace for a single node, based on a given real world route.
+
  
*Preconditions:
+
== Design ==
# The user has internet access
+
The module described in this page provides an interface to convert information from a travel planning service.  Currently, only the Google Maps services are implemented however the module was built in order to accommodate different travel planning services, such as OpenStreetMaps, and locations databases. To this end, the Strategy software design pattern was used in the module design.
# The user possesses a valid API key
+
# The Google Maps Directions service identifies correctly the start and endpoint provided
+
  
==== Create mobility traces for various nodes ====
+
The Strategy design pattern is also instrumental for easing up the implementation of new services that provide direction information or locations. In fact, the only required effort on part of the developer is the implementation of the provided interfaces and the usage of the provided model classes (ns3::Leg, ns3::Step, ns3::Point and ns3::Place) to represent the information retrieved by the implemented service.
* Name: Create mobility traces for various nodes
+
* Actors: User
+
* Description: The user is able to request the module to generate a mobility trace for a fixed number of nodes, based on a real world route.
+
*Preconditions:
+
# The user has internet access
+
# The user possesses a valid API key
+
# The user provides a list or an array of start and endpoint tokens correctly
+
# The user provides the same number of start and endpoint tokens as nodes in the node container
+
# The Google Maps Directions service identifies correctly the start and endpoint provided
+
  
==== Automatic creation of mobility traces for a node container ====
+
= Code repository =
* Name: Automatic creation of mobility traces for a node container
+
My code can be found [https://bitbucket.org/TiagoCerqueira/routesmobilitymodel here]
* Actors: User
+
* Description: The user is able to request the module to generate a mobility trace for various nodes, based on a real world route.
+
 
+
This use case will require further study as how to implement it in a way that it is able to generate mobility traces for all nodes in a numerous node container (1000 nodes, for example).
+
 
+
I'm planning on using the Google Maps Places service to generate the start and endpoint tokens required, but due to a few limitations of the service, I'll need to find a workaround to support numerous node containers.
+
 
+
For this iteration, this feature was not implemented
+
=== Summary ===
+
In summary, these past weeks I achieved the following:
+
* Designed the module
+
* Coded the classes responsible for performing the API request and treat the information received into a format ns3 can understand
+
* Coded use cases: "Create mobility trace for a node" and "Create mobility traces for various nodes"
+
* Documented the application using Doxygen and with UML Diagrams
+
Bellow, you can view the class diagram, the use case diagram and the sequence diagram for the "Create mobility trace for a node" use case.
+
<gallery>
+
File:RoutesMobilityModel_Class_Diagram.jpeg|Class diagram
+
File:Use_Case_diagram.jpeg|Use Case diagram
+
File:Sequence_diagram.jpeg|Sequence diagram
+
</gallery>
+
== Second Status Report ==
+
For this second status report, my milestones where: Providing an offline mode to the module, automatic generation of mobility traces for a node container of any size, the ability to redirect a node to a different destination dynamically and implementing error handling and logging.
+
 
+
=== A few notes on the Google Maps Places API ===
+
The Google Maps Places API was chosen to provide the module with start and endpoints. The idea was to use this huge database to gather a huge number of start and endpoints and use this in conjunction with the previously developed functionalities.
+
 
+
Unfortunately, due to a limitation of the API, only 60 addresses can be returned in a single search. In order to achieve automatic generation of mobility traces for a node container of any size, the user must input a list with tokens of latitude and longitude.
+
 
+
Another approach might be to use every address of those 60 addresses and creates mobility traces using every one of them as start and endpoints. This would generate mobility traces for 3540 nodes, but the mobility trace might be too geographically compact, and the nodes would essentially keep traveling using many of the same streets/freeways, etc. This was not implemented at this time, but could be implemented in the future.
+
 
+
=== Changes to the Module Design ===
+
In order to allow the addition of other sources of information of real-world places, I used the Strategy Design Pattern.
+
To perform automatic generation of mobility traces for an entire node container, I had to add the following classes to my model:
+
ns3::PlacesApiConnect - An interface for the connection of an API with real-world locations.
+
ns3::GoogleMapsPlacesApiConnect - An implementation of the above interface, responsible for performing the connection to the Google Maps Places service
+
ns3::Place - A logical representation of a real-world location.
+
ns3::SaxPlacesHandler - The parser responsible for parsing the information retrieved from the Google Maps Places service
+
 
+
=== Changes to the Use Cases ===
+
For this status report, I'm adding a couple of use case suggestions made by my mentors.
+
==== Create mobility trace for nodes ====
+
*Name: Create mobility trace for a node
+
*Actors: User
+
*Description: The user is able to request the module to generate a mobility trace for a single node, based on a given real world route.
+
 
+
*Preconditions:
+
# The user has internet access
+
# The user possesses a valid API key
+
# The Google Maps Directions service identifies correctly the start and endpoint provided
+
 
+
==== Automatic creation of mobility traces for a node container ====
+
* Name: Automatic creation of mobility traces for a node container
+
* Actors: User
+
* Description: The user is able to request the module to generate a mobility trace for various nodes, based on a real world route.
+
*Preconditions:
+
# The user has internet access
+
# The user possesses a valid API key
+
# The user provides the correct coordinates
+
 
+
==== Create a mobility trace for a node using a local XML file ====
+
* Name: Create a mobility trace for a node using a local XML file
+
* Actors: User
+
* Description: The user is able to generate a mobility trace based on a XML file downloaded to the local filesystem.
+
* Preconditions:
+
# The file exists and is valid
+
 
+
==== Create mobility traces with dynamic node redirections ====
+
* Name: Create mobility traces with dynamic node redirections
+
* Actors: User
+
* Description: The user is able to generate a mobility trace for a node that, at a specified point in time, is redirected to another destination.
+
* Preconditions:
+
# The user has internet access.
+
# The user has provided valid start and endpoints. The redirection address must also be valid.
+
# The Google Maps Directions service identifies correctly the start point, the end point and the redirection address.
+
 
+
=== Summary ===
+
In summary, these past few weeks I've achieved the following:
+
* Implemented every use case mentioned, such as node redirection, automatic mobility trace generation and an offline mode.
+
* Documented every function introduced with Doxygen
+
* Implemented error handling
+
* Implemented logging
+
* Updated UML documentation
+
  
 
=== Documentation ===
 
=== Documentation ===
In addition to the Doxygen documentation, the existing UML documentation was updated to include the new functionalities.
+
This module has been documented using Doxygen and UML. The UML diagrams for the current release are shown below.
Bellow, you can view the final class diagram, the final use case diagram, the sequence diagram for the "Create mobility trace for a single node" use case and the sequence diagram for the "Automatic creation of mobility traces for a node container" use case.
+
 
+
 
Additional documentation was created using sphynx, which documents the module in further detail. This documentation will be available in the ns-3 models documentation once the module is released.
 
Additional documentation was created using sphynx, which documents the module in further detail. This documentation will be available in the ns-3 models documentation once the module is released.
 
<gallery>
 
<gallery>

Revision as of 00:28, 15 June 2015

Main Page - Current Development - Developer FAQ - Tools - Related Projects - Project Ideas - Summer Projects

Installation - Troubleshooting - User FAQ - HOWTOs - Samples - Models - Education - Contributed Code - Papers

Overview

Mobility trace generation in ns-3 is done either by using the Mobility module included in NS-3 or by importing mobility traces generated by third party programs in a compatible format. The Mobility module included in ns-3 gives programmers the building blocks to create simple or complex traces, but is hindered by the fact that creating complex traces using the current module alone takes too long, even for simulations with just a couple of mobility capable nodes. As for mobility traces generated by third party programs, such as SUMO, they can involve too much work for their generation, especially when the researcher's interest - and expertise - is more on the data communication than on the traffic simulation. Using the Google Maps API it is possible to generate complex mobility traces, simply by providing a start and end point.

The RoutesMobilityModel generates realistic mobility traces by querying the Google Maps Directions API and requesting directions between two (or more) points. The information obtained from the Google Maps services, used in tandem with the ns3::WaypointMobilityModel, allows the simulator to generate realistic mobility traces based on real-world locations and road networks. The purpose of this module is to bridge the gap between the highly complex but realistic SUMO and the synthetic mobility models available in ns-3.

Approach

The Google Maps Directions service, however, provides an XML that contains the following concepts:

  • Leg - A Leg is a list of Steps. Legs only occur if the user specifies a Waypoint (A to B, passing through C)
  • Step - A Step contains Points encoded in a polyline
  • Point - A latitude/longitude set


The RoutesMobilityModel module relies on the module ns3::WaypointMobilityModel in order to import the mobility routes retrieved from the external information services. Our module creates ns3::Waypoints that model the routes used to travel between two (or more) real world locations, and later on they are interpreted as the waypoints the vehi- cles move through during the simulation.

The information retrieved from the Google Maps Directions API contains, among other information, a polyline for each step of the route requested. It also contains the duration (the time it would take to go from the beginning to the end) for the step. The module decodes the polyline, thus creating a list of geographical coordinates, which are, in turn, converted to Cartesian coordinates. In order to model the speed of a node, implemented by setting the times for the ns3::Waypoints, we distributed the duration of the step in proportion to the distance traveled between two waypoints.

File:General overview of the RoutesMobilityModel.png

Design

The module described in this page provides an interface to convert information from a travel planning service. Currently, only the Google Maps services are implemented however the module was built in order to accommodate different travel planning services, such as OpenStreetMaps, and locations databases. To this end, the Strategy software design pattern was used in the module design.

The Strategy design pattern is also instrumental for easing up the implementation of new services that provide direction information or locations. In fact, the only required effort on part of the developer is the implementation of the provided interfaces and the usage of the provided model classes (ns3::Leg, ns3::Step, ns3::Point and ns3::Place) to represent the information retrieved by the implemented service.

Code repository

My code can be found here

Documentation

This module has been documented using Doxygen and UML. The UML diagrams for the current release are shown below. Additional documentation was created using sphynx, which documents the module in further detail. This documentation will be available in the ns-3 models documentation once the module is released.

Dependencies

This module is dependent of the following libraries:

  • libcurlpp
  • Xerces-C++
  • GeographicLib