The ns-3 code generator project aims to provide a quick and easy way to automatically generate valid ns-3 C++ simulation scripts. It incorporates the CodeSynthesis XSD product to validate and generate the XML to C++ data bindings to allow for easier parsing of the XML file used to define a network topology. The code generator can be invoked stand alone from the command line, or integrated into a larger system that requires ns-3 code generation capability.
- Build / install
You need the CodeSynthesis XSD library to compile and use ns-3 code generator. XSD utilizes the Xerces XML parser, so that needs to be installed also.
If not already installed, the code generator depends on SQLite3, and GNOME XML, they can be installed by issuing the following commands (Ubuntu);
$ sudo apt-get install sqlite sqlite3 libsqlite3-dev
$ sudo apt-get install libxml2 libxml2-dev
To build the project: Make sure a valid XML instance specification (XML Schema) file is colocated with the Makefile. An example would be;
TopologySchema.xsd XML Schema which describes a network topology.
Then simply issue:
$ make
Issuing the make command will generate the following files;
TopologySchema.hxx
TopologySchema.ixx
TopologySchema.cxx
C++ types that represent the given vocabulary, a set of parsing functions that convert XML documents to a tree-like in-memory object model, and a set of serialization functions that convert the object model back to XML. These are generated by XSD from TopologySchema.xsd.
Other files;
ns-3-codegenerator.cxx
Is the main program for the project. It first calls one of the parsing functions that constructs the object model from the input file. It then makes the API calls to generate the ns-3 compliant code.
- Execute
Make sure the XML Schema file (TopologySchema.xsd) is colocated with the code generator executable.
Then simply issue:
$ ./ns-3-codegenerator filename.xml output_filename
The filename.xml contains a high level description of a network topology. The provided output filename contains the ns-3 C++ statements that can be executed in ns-3 environment.
To generate the XML class documentation (you need doxygen tool):
$ make docs
The HTML generated documentation is located in the same directory.
- ns-3
The output_filename file that is generated can then be executed in the ns-3 simulation environment. See ns-3 documentation for how to run an ns-3 script.
Note - If you generate an ns-3 script with any of the COSEM applications, your ns-3 install will need to include those helper/models. The DLMS/COSEM repository can be found at;
https://github.com/joaopedrotaveira/dlms-cosem-ns-3
Copyright (c) 2016 Idaho National Laboratory
Copyright (c) 2009 University of Strasbourg
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA