<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.nsnam.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Muditraajgupta</id>
	<title>Nsnam - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.nsnam.org/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Muditraajgupta"/>
	<link rel="alternate" type="text/html" href="https://www.nsnam.org/wiki/Special:Contributions/Muditraajgupta"/>
	<updated>2026-05-05T12:15:34Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6987</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6987"/>
		<updated>2012-08-23T22:21:33Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, ''' Java Block'''  (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp here]) and ''' C++  bloc'''k (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_002.bmp here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram]. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the '''class which uses the portico Java API to communicate with the portico RTI'''. At present the '''sequence of events''' followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] '''handles Callbacks from RTI''' whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This '''class is a Java Side link between the Java Block and C++ Block'''. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
As the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram] shows, it consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
'''The Helper''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are '''used to initialise the federation, shared objects and attributes''',  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
'''The Synchroniser''' consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is '''responsible for synchronising the event times with the RTI clock'''. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
'''Link To Rti''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the '''class that implements sockets in C++''' and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This '''script is written to remind the end-user of the path variables''' to set. The script '''also provides a waf like build system to build java code'''. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this [https://www.nsnam.org/wiki/index.php/HLAExample tutorial].&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The '''ns-3 hla model can be checked without creating a federate in other simulator'''. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All '''scripts that use HLA should also have a corresponding .fed file''', which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates '''how to create a shared object using the HLA API and how to publish the object'''. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and '''sets simulator to RTI simulator Implementation'''. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found [https://www.nsnam.org/wiki/index.php/HLAExample here]. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you '''need to use HLA interfaces with some ns-3 model''' and use the attributes shared with other federates in your model. The example uses a '''simple mobility model''' and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Packages =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to '''package installation documents''' from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
Once the packages are set up. You need to '''set two environment variables''':&lt;br /&gt;
&lt;br /&gt;
* JAVA_PATH=/path/to/your/jdk/install&lt;br /&gt;
* JAR_PATH=/path/to/portico.jar file&lt;br /&gt;
&lt;br /&gt;
Try and set both of these as your system wide variables, a small [https://help.ubuntu.com/community/EnvironmentVariables post] talks about this for Ubuntu.  &lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Once you are done '''create a new ns-3 script that uses HLA helper classes''' along with other models, say ns3-hla-script.cc. Write''' an object description file''' similar to one in the examples, Ns3HlaScript.fed. '''Copy both in $ns3/scratch/ folder'''. '''Open two terminal windows''', lets call them JavaShell and CppShell. &lt;br /&gt;
&lt;br /&gt;
For '''running your ns-3 script''' use the following command, in any shell (say CppShell):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ ./waf --run scratch/ns3-hla-script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, once you receive the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ Connecting to RTI ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Start Java code''' in the other shell (JavaShell). There is hla.sh script in your $ns3 folder, it provides a waf like build to the java code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
JavaShell$ ./hla.sh --clean&lt;br /&gt;
JavaShell$ Removing HLA Bindings and Old Log files&lt;br /&gt;
JavaShell$ ./hla.sh --build&lt;br /&gt;
JavaShell$ Building HLA interfaces&lt;br /&gt;
JavaShell$ ./hla.sh --run scratch/Ns3HlaScript&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using HLA for the first time, you will have to '''build it first using the &amp;quot;--build&amp;quot;''' command. '''&amp;quot;--clean&amp;quot; will remove old files'''. If HLA (java) is build once you can just '''run your scripts using &amp;quot;--run&amp;quot;'''. The scripts mimics waf build system for the convenience of the user. &lt;br /&gt;
&lt;br /&gt;
This will get your ns-3 federate started. Once you are done with this you can start your other federates or if other federates are running on the same federation, ns-3 federate will just join them automatically. &lt;br /&gt;
&lt;br /&gt;
Again a small tutorial on using HLA in ns3 from writing code to running can be found [https://www.nsnam.org/wiki/index.php/HLAExample here].&lt;br /&gt;
&lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
The deliverables mentioned above in the &amp;quot;components&amp;quot; section&lt;br /&gt;
&lt;br /&gt;
* HLA API&lt;br /&gt;
* Synchroniser&lt;br /&gt;
* Ns3Federate and Ns3Federate Ambassador&lt;br /&gt;
* C++ and Java Links to the C++ Java connecting pipe&lt;br /&gt;
* Scripts, Tests and Examples &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= Limitations =&lt;br /&gt;
&lt;br /&gt;
* Ns-3 as a source - At present ns-3 acts as a sink while in a federation. This means that ns-3 can only receive updates on the objects but cannot modify the attributes of the object. The source property was not added because of two reasons, firstly, because we could not identify a scenario in which such a feature would be useful and secondly, due to the limited time span of GSoC.  Although, adding a source property will be similar to sink property and can be implemented by adding a &amp;quot;RTI register object instance&amp;quot; and &amp;quot;Update Values&amp;quot; functions.&lt;br /&gt;
&lt;br /&gt;
* In a federations federates communicate using objects and interactions at present the code supports publishing objects and interactions can be added, if required by writing functions for interactions that mimic object functions.      &lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6969</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6969"/>
		<updated>2012-08-23T10:57:46Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* ns-3 script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will be referring to it.&lt;br /&gt;
&lt;br /&gt;
Using the hla API is quite intuitive and if you understand the concept it is quit straightforward. To begin with, you create an object of hla helper in your script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HlaHelper hla;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the initial values of the hla parameters as discussed above. Function in line number 74 sets the DefaultParameters similar to the example shipped with the code. You MUST set the values according to your requirements, your federation requirements and external federation requirements.For setting various values, just set them using various setter functions like on line 83,192,202,212,222,232. These are for initialization and there meanings are explained in the above section. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hla.SetFomFile(&amp;quot;SimpleSharedObjectExample.fed&amp;quot;);&lt;br /&gt;
hla.SetSyncPhrase(&amp;quot;ReadyToRun&amp;quot;);&lt;br /&gt;
hla.FederationName(&amp;quot;ExampleFederation&amp;quot;);&lt;br /&gt;
hla.FederateName(&amp;quot;ns3&amp;quot;);&lt;br /&gt;
hla.SetRtiTimeResolution(&amp;quot;1.0&amp;quot;);&lt;br /&gt;
hla.SetSeconds(&amp;quot;10&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
or &lt;br /&gt;
&lt;br /&gt;
hla.DefaultParameters();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you are done setting you default values, you need to create an object that you can share, it can be easily done using function on line 95 :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int ObjectHandle;&lt;br /&gt;
ObjectHandle = hla.CreateSharedObject(&amp;quot;PingPong&amp;quot;,&amp;quot;2&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above command creates a shared object &amp;quot;PingPong&amp;quot; and the object has two characteristics. It also returns an Object Handle (ObjectHandle) of int type used to identify the object. Next we need to set these characteristics or attributes, we can use function on line number 107 to so this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int AttributeHandle1, AttributeHandle2; &lt;br /&gt;
AttributeHandle1 = hla.AddAttributeOfSharedObject(&amp;quot;Msg&amp;quot;,ObjectHandle);&lt;br /&gt;
AttributeHandle2 = hla.AddAttributeOfSharedObject(&amp;quot;MsgType&amp;quot;,ObjectHandle);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will add two values &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot; to the Object &amp;quot;PingPong&amp;quot;. Now we are done with the object and it's attribute. Let's publish it and create an ns3 Federate.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hla.Start();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will do the required, but before this we must change simulator implementation to RTI Simulator. This can be done using:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GlobalValue::Bind (&amp;quot;SimulatorImplementationType&amp;quot;, StringValue (&amp;quot;ns3::RtiSimulatorImpl&amp;quot;));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, now we are done with creating a federation, once the simulation start you can access values of the published object and other details related to the federation using the API functions at line 173,161,149,137,125 and 116. The values and time advance requests are handles by callbacks and simulator, so user does not have to specify anything for it. ns-3 will synchronise with the RTI and all values will be updated if anything changes in other federates.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all your objects under the ObjectRoot class, this is done basically to encapsulate all shared Object (classes) created by ns-3 into ObjectRoot class and add attributes as follows. The basic structure of the file should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(objects &lt;br /&gt;
  (class ObjectRoot &lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
     )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please refer to portico documentation for more details on the .fed files.&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;br /&gt;
&lt;br /&gt;
The first way to test the code is run two shells one with simple-shared-object-example.cc (in shell 1, say CppShell) and SimpleSharedObjectExample.fed( in shell 2, say JavaShell) as mentioned above. The following will be observed:&lt;br /&gt;
&lt;br /&gt;
in Cpp Shell, if sockets are initialised properly you will get: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
***** Ready To Connect To RTI and launch/join Federation&lt;br /&gt;
&lt;br /&gt;
Connecting ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now start the JavaShell and now run the code using ./hla.sh (as mentioned in the above section)in the other shell, If your fed file is in the right place and the sockets are initialised properly you will get:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected ...&lt;br /&gt;
Receiving Initialization Message ..&lt;br /&gt;
Setting Initial Values ...&lt;br /&gt;
&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It also confirms that your values were received through the socket and received by the Java Program (Initial Values). This is a good time(***) to launch other federates&lt;br /&gt;
&lt;br /&gt;
and the CppShell will show:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected&lt;br /&gt;
&lt;br /&gt;
Sending intialization message&lt;br /&gt;
&lt;br /&gt;
Waiting for Start Signal..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter### once in JavaShell it will:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Created Federation&lt;br /&gt;
ns3  : Joined Federation as ns3&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Continue &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
connect to the RTI and when you press enter again it will send a start signal to CppShell. It checks if ns3 Federate is able to create and join a federation or not. It will start the simulation and if the RTI time&amp;gt;ns3Time it will process all events&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Start Signal Received&lt;br /&gt;
&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
0&lt;br /&gt;
Event Time Missed, Ns3 Time More Than RTI Time&lt;br /&gt;
Processing Event ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the output of the event is displayed. If RTI Time&amp;lt;ns3Time it will ask the event to wait and send a time advance request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
1000000000&lt;br /&gt;
Event in Future, Ns3 Time Less Than RTI Time&lt;br /&gt;
Wait For a Time Advance Signal from RTI ...&lt;br /&gt;
&lt;br /&gt;
Sending Time Advance Request to RTI ...&lt;br /&gt;
&lt;br /&gt;
Time Advance Request Sent&lt;br /&gt;
&lt;br /&gt;
Time Advance Granted&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the request is grated it will execute the event and the event specific log will be displayed. If there is a change in the object values, a callback will log the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Value of Shared Object (any attribute) changed ...&lt;br /&gt;
Updating ...&lt;br /&gt;
Updated&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At time (***) is the best time to start an external federate. There is an external federate along with the code in test/SystemIntegration, although there is an issue which might pop up at present (related to RTI) but if no it can be started at time (***) in another shell, lets call it external&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
external$ cd $ns3/src/hla/test/SystemIntegration/dummy&lt;br /&gt;
external$ ./linux.sh execute &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should start the federate. After a bit of logging it will ask you to press&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dummy  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter it will wait for other federates (like ns3) and when we press enter in step (###), we will force ns3 to join the federation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Registered Sync Point, waiting for federation ... &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and in the $JavaShell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Cannot create federation, federation already exists &lt;br /&gt;
ns3  : Joining Federation as ns3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the ns3 and dummy federates will be synchronised. Dummy will change the value of PinPong every second and will be reflected on $CppShell and $JavaShell&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6968</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6968"/>
		<updated>2012-08-23T10:35:36Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* ns-3 script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will be referring to it.&lt;br /&gt;
&lt;br /&gt;
Using the hla API is quite intuitive and if you understand the concept it is quit straightforward. To begin with, you create an object of hla helper in your script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HlaHelper hla;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now set the initial values of the hla parameters as discussed above. Function in line number 74 sets the DefaultParameters similar to the example shipped with the code. You MUST set the values according to your requirements, your federation requirements and external federation requirements.For setting various values, just set them using various setter functions like on line 83,192,202,212,222,232. These are for initialization and there meanings are explained in the above section. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hla.SetFomFile(&amp;quot;SimpleSharedObjectExample.fed&amp;quot;);&lt;br /&gt;
hla.SetSyncPhrase(&amp;quot;ReadyToRun&amp;quot;);&lt;br /&gt;
hla.FederationName(&amp;quot;ExampleFederation&amp;quot;);&lt;br /&gt;
hla.FederateName(&amp;quot;ns3&amp;quot;);&lt;br /&gt;
hla.SetRtiTimeResolution(&amp;quot;1.0&amp;quot;);&lt;br /&gt;
hla.SetSeconds(&amp;quot;10&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
or &lt;br /&gt;
&lt;br /&gt;
hla.DefaultParameters();&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once you are done setting you default values, you need to create an object that you can share, it can be easily done using function on line :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
int ObjectHandle;&lt;br /&gt;
ObjectHandle = hla.CreateSharedObject(&amp;quot;PingPong&amp;quot;,&amp;quot;2&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above command creates a shared object &amp;quot;PingPong&amp;quot; and the object has two characteristics. It also returns an Object Handle (ObjectHandle) of int type used to identify the object. Next we need to set these characteristics or attributes, we can use function on line number  to so this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hla.AddAttributeOfSharedObject()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all your objects under the ObjectRoot class, this is done basically to encapsulate all shared Object (classes) created by ns-3 into ObjectRoot class and add attributes as follows. The basic structure of the file should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(objects &lt;br /&gt;
  (class ObjectRoot &lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
     )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please refer to portico documentation for more details on the .fed files.&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;br /&gt;
&lt;br /&gt;
The first way to test the code is run two shells one with simple-shared-object-example.cc (in shell 1, say CppShell) and SimpleSharedObjectExample.fed( in shell 2, say JavaShell) as mentioned above. The following will be observed:&lt;br /&gt;
&lt;br /&gt;
in Cpp Shell, if sockets are initialised properly you will get: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
***** Ready To Connect To RTI and launch/join Federation&lt;br /&gt;
&lt;br /&gt;
Connecting ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now start the JavaShell and now run the code using ./hla.sh (as mentioned in the above section)in the other shell, If your fed file is in the right place and the sockets are initialised properly you will get:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected ...&lt;br /&gt;
Receiving Initialization Message ..&lt;br /&gt;
Setting Initial Values ...&lt;br /&gt;
&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It also confirms that your values were received through the socket and received by the Java Program (Initial Values). This is a good time(***) to launch other federates&lt;br /&gt;
&lt;br /&gt;
and the CppShell will show:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected&lt;br /&gt;
&lt;br /&gt;
Sending intialization message&lt;br /&gt;
&lt;br /&gt;
Waiting for Start Signal..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter### once in JavaShell it will:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Created Federation&lt;br /&gt;
ns3  : Joined Federation as ns3&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Continue &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
connect to the RTI and when you press enter again it will send a start signal to CppShell. It checks if ns3 Federate is able to create and join a federation or not. It will start the simulation and if the RTI time&amp;gt;ns3Time it will process all events&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Start Signal Received&lt;br /&gt;
&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
0&lt;br /&gt;
Event Time Missed, Ns3 Time More Than RTI Time&lt;br /&gt;
Processing Event ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the output of the event is displayed. If RTI Time&amp;lt;ns3Time it will ask the event to wait and send a time advance request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
1000000000&lt;br /&gt;
Event in Future, Ns3 Time Less Than RTI Time&lt;br /&gt;
Wait For a Time Advance Signal from RTI ...&lt;br /&gt;
&lt;br /&gt;
Sending Time Advance Request to RTI ...&lt;br /&gt;
&lt;br /&gt;
Time Advance Request Sent&lt;br /&gt;
&lt;br /&gt;
Time Advance Granted&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the request is grated it will execute the event and the event specific log will be displayed. If there is a change in the object values, a callback will log the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Value of Shared Object (any attribute) changed ...&lt;br /&gt;
Updating ...&lt;br /&gt;
Updated&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At time (***) is the best time to start an external federate. There is an external federate along with the code in test/SystemIntegration, although there is an issue which might pop up at present (related to RTI) but if no it can be started at time (***) in another shell, lets call it external&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
external$ cd $ns3/src/hla/test/SystemIntegration/dummy&lt;br /&gt;
external$ ./linux.sh execute &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should start the federate. After a bit of logging it will ask you to press&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dummy  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter it will wait for other federates (like ns3) and when we press enter in step (###), we will force ns3 to join the federation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Registered Sync Point, waiting for federation ... &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and in the $JavaShell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Cannot create federation, federation already exists &lt;br /&gt;
ns3  : Joining Federation as ns3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the ns3 and dummy federates will be synchronised. Dummy will change the value of PinPong every second and will be reflected on $CppShell and $JavaShell&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6967</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6967"/>
		<updated>2012-08-23T09:00:52Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all your objects under the ObjectRoot class, this is done basically to encapsulate all shared Object (classes) created by ns-3 into ObjectRoot class and add attributes as follows. The basic structure of the file should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(objects &lt;br /&gt;
  (class ObjectRoot &lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
     )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please refer to portico documentation for more details on the .fed files.&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;br /&gt;
&lt;br /&gt;
The first way to test the code is run two shells one with simple-shared-object-example.cc (in shell 1, say CppShell) and SimpleSharedObjectExample.fed( in shell 2, say JavaShell) as mentioned above. The following will be observed:&lt;br /&gt;
&lt;br /&gt;
in Cpp Shell, if sockets are initialised properly you will get: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
***** Ready To Connect To RTI and launch/join Federation&lt;br /&gt;
&lt;br /&gt;
Connecting ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now start the JavaShell and now run the code using ./hla.sh (as mentioned in the above section)in the other shell, If your fed file is in the right place and the sockets are initialised properly you will get:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected ...&lt;br /&gt;
Receiving Initialization Message ..&lt;br /&gt;
Setting Initial Values ...&lt;br /&gt;
&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It also confirms that your values were received through the socket and received by the Java Program (Initial Values). This is a good time(***) to launch other federates&lt;br /&gt;
&lt;br /&gt;
and the CppShell will show:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected&lt;br /&gt;
&lt;br /&gt;
Sending intialization message&lt;br /&gt;
&lt;br /&gt;
Waiting for Start Signal..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter### once in JavaShell it will:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Created Federation&lt;br /&gt;
ns3  : Joined Federation as ns3&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Continue &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
connect to the RTI and when you press enter again it will send a start signal to CppShell. It checks if ns3 Federate is able to create and join a federation or not. It will start the simulation and if the RTI time&amp;gt;ns3Time it will process all events&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Start Signal Received&lt;br /&gt;
&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
0&lt;br /&gt;
Event Time Missed, Ns3 Time More Than RTI Time&lt;br /&gt;
Processing Event ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the output of the event is displayed. If RTI Time&amp;lt;ns3Time it will ask the event to wait and send a time advance request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
1000000000&lt;br /&gt;
Event in Future, Ns3 Time Less Than RTI Time&lt;br /&gt;
Wait For a Time Advance Signal from RTI ...&lt;br /&gt;
&lt;br /&gt;
Sending Time Advance Request to RTI ...&lt;br /&gt;
&lt;br /&gt;
Time Advance Request Sent&lt;br /&gt;
&lt;br /&gt;
Time Advance Granted&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the request is grated it will execute the event and the event specific log will be displayed. If there is a change in the object values, a callback will log the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Value of Shared Object (any attribute) changed ...&lt;br /&gt;
Updating ...&lt;br /&gt;
Updated&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At time (***) is the best time to start an external federate. There is an external federate along with the code in test/SystemIntegration, although there is an issue which might pop up at present (related to RTI) but if no it can be started at time (***) in another shell, lets call it external&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
external$ cd $ns3/src/hla/test/SystemIntegration/dummy&lt;br /&gt;
external$ ./linux.sh execute &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should start the federate. After a bit of logging it will ask you to press&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dummy  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter it will wait for other federates (like ns3) and when we press enter in step (###), we will force ns3 to join the federation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Registered Sync Point, waiting for federation ... &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and in the $JavaShell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Cannot create federation, federation already exists &lt;br /&gt;
ns3  : Joining Federation as ns3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the ns3 and dummy federates will be synchronised. Dummy will change the value of PinPong every second and will be reflected on $CppShell and $JavaShell&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6966</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6966"/>
		<updated>2012-08-23T09:00:20Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all your objects under the ObjectRoot class, this is done basically to encapsulate all shared Object (classes) created by ns-3 into ObjectRoot class and add attributes as follows. The basic structure of the file should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(objects &lt;br /&gt;
  (class ObjectRoot &lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
     )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please refer to portico documentation for more details on the .fed files.&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;br /&gt;
&lt;br /&gt;
The first way to test the code is run two shells one with simple-shared-object-example.cc (in shell 1, say CppShell) and SimpleSharedObjectExample.fed( in shell 2, say JavaShell) as mentioned above. The following will be observed:&lt;br /&gt;
&lt;br /&gt;
in Cpp Shell, if sockets are initialised properly you will get: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
***** Ready To Connect To RTI and launch/join Federation&lt;br /&gt;
&lt;br /&gt;
Connecting ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now start the JavaShell and now run the code using ./hla.sh (as mentioned in the above section)in the other shell, If your fed file is in the right place and the sockets are initialised properly you will get:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected ...&lt;br /&gt;
Receiving Initialization Message ..&lt;br /&gt;
Setting Initial Values ...&lt;br /&gt;
&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It also confirms that your values were received through the socket and received by the Java Program (Initial Values). This is a good time(***) to launch other federates&lt;br /&gt;
&lt;br /&gt;
and the CppShell will show:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected&lt;br /&gt;
&lt;br /&gt;
Sending intialization message&lt;br /&gt;
&lt;br /&gt;
Waiting for Start Signal..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter### once in JavaShell it will:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Created Federation&lt;br /&gt;
ns3  : Joined Federation as ns3&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Continue &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
connect to the RTI and when you press enter again it will send a start signal to CppShell. It checks if ns3 Federate is able to create and join a federation or not. It will start the simulation and if the RTI time&amp;gt;ns3Time it will process all events&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Start Signal Received&lt;br /&gt;
&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
0&lt;br /&gt;
Event Time Missed, Ns3 Time More Than RTI Time&lt;br /&gt;
Processing Event ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the output of the event is displayed. If RTI Time&amp;lt;ns3Time it will ask the event to wait and send a time advance request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
1000000000&lt;br /&gt;
Event in Future, Ns3 Time Less Than RTI Time&lt;br /&gt;
Wait For a Time Advance Signal from RTI ...&lt;br /&gt;
&lt;br /&gt;
Sending Time Advance Request to RTI ...&lt;br /&gt;
&lt;br /&gt;
Time Advance Request Sent&lt;br /&gt;
&lt;br /&gt;
Time Advance Granted&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the request is grated it will execute the event and the event specific log will be displayed. If there is a change in the object values, a callback will log the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Value of Shared Object (any attribute) changed ...&lt;br /&gt;
Updating ...&lt;br /&gt;
Updated&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At time (***) is the best time to start an external federate. There is an external federate along with the code in test/SystemIntegration, although there is an issue which might pop up at present (related to RTI) but if no it can be started at time (***) in another shell, lets call it external&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
external$ cd $ns3/src/hla/test/SystemIntegration/dummy&lt;br /&gt;
external$ ./linux.sh execute &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should start the federate. After a bit of logging it will ask you to press&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dummy  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter it will wait for other federates (like ns3) and when we press enter in step (###), we will force ns3 to join the federation &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Registered Sync Point, waiting for federation ... &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and in the $JavaShell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Cannot create federation, federation already exixts &lt;br /&gt;
ns3  : Joining Federation as ns3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now the ns3 and dummy federates will be synchronised. Dummy will change the value of PinPong every second and will be reflected on $CppShell and $JavaShell&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6965</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6965"/>
		<updated>2012-08-23T08:50:56Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all your objects under the ObjectRoot class, this is done basically to encapsulate all shared Object (classes) created by ns-3 into ObjectRoot class and add attributes as follows. The basic structure of the file should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(objects &lt;br /&gt;
  (class ObjectRoot &lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
     )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please refer to portico documentation for more details on the .fed files.&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;br /&gt;
&lt;br /&gt;
The first way to test the code is run two shells one with simple-shared-object-example.cc (in shell 1, say CppShell) and SimpleSharedObjectExample.fed( in shell 2, say JavaShell) as mentioned above. The following will be observed:&lt;br /&gt;
&lt;br /&gt;
in Cpp Shell, if sockets are initialised properly you will get: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
***** Ready To Connect To RTI and launch/join Federation&lt;br /&gt;
&lt;br /&gt;
Connecting ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now start the JavaShell and now run the code using ./hla.sh (as mentioned in the above section)in the other shell, If your fed file is in the right place and the sockets are initialised properly you will get:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected ...&lt;br /&gt;
Receiving Initialization Message ..&lt;br /&gt;
Setting Initial Values ...&lt;br /&gt;
&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It also confirms that your values were received through the socket and received by the Java Program (Initial Values)&lt;br /&gt;
&lt;br /&gt;
and the CppShell will show:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected&lt;br /&gt;
&lt;br /&gt;
Sending intialization message&lt;br /&gt;
&lt;br /&gt;
Waiting for Start Signal..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter*** once in JavaShell it will:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Created Federation&lt;br /&gt;
ns3  : Joined Federation as ns3&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Continue &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
connect to the RTI and when you press enter again it will send a start signal to CppShell. It checks if ns3 Federate is able to create and join a federation or not. It will start the simulation and if the RTI time&amp;gt;ns3Time it will process all events&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Start Signal Received&lt;br /&gt;
&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
0&lt;br /&gt;
Event Time Missed, Ns3 Time More Than RTI Time&lt;br /&gt;
Processing Event ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the output of the event is displayed. If RTI Time&amp;lt;ns3Time it will ask the event to wait and send a time advance request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
1000000000&lt;br /&gt;
Event in Future, Ns3 Time Less Than RTI Time&lt;br /&gt;
Wait For a Time Advance Signal from RTI ...&lt;br /&gt;
&lt;br /&gt;
Sending Time Advance Request to RTI ...&lt;br /&gt;
&lt;br /&gt;
Time Advance Request Sent&lt;br /&gt;
&lt;br /&gt;
Time Advance Granted&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the request is grated it will execute the event and the event specific log will be displayed. If there is a change in the object values, a callback will log the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Value of Shared Object (any attribute) changed ...&lt;br /&gt;
Updating ...&lt;br /&gt;
Updated&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At time (***) is the best time to start an external federate. There is an external federate along with the code in test/SystemIntegration, although there is an issue which might pop up at present (related to RTI) but if no it can be started at time (***) in another shell, lets call it external&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
external$ cd $ns3/src/hla/test/SystemIntegration/dummy&lt;br /&gt;
external$ ./linux.sh execute &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should start the federate.&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6964</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6964"/>
		<updated>2012-08-23T08:45:07Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all your objects under the ObjectRoot class, this is done basically to encapsulate all shared Object (classes) created by ns-3 into ObjectRoot class and add attributes as follows. The basic structure of the file should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(objects &lt;br /&gt;
  (class ObjectRoot &lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
     )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please refer to portico documentation for more details on the .fed files.&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;br /&gt;
&lt;br /&gt;
The first way to test the code is run two shells one with simple-shared-object-example.cc (in shell 1, say CppShell) and SimpleSharedObjectExample.fed( in shell 2, say JavaShell) as mentioned above. The following will be observed:&lt;br /&gt;
&lt;br /&gt;
in Cpp Shell, if sockets are initialised properly you will get: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
***** Ready To Connect To RTI and launch/join Federation&lt;br /&gt;
&lt;br /&gt;
Connecting ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now start the JavaShell and now run the code using ./hla.sh (as mentioned in the above section)in the other shell, If your fed file is in the right place and the sockets are initialised properly you will get:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected ...&lt;br /&gt;
Receiving Initialization Message ..&lt;br /&gt;
Setting Initial Values ...&lt;br /&gt;
&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Connect To RTI &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It also confirms that your values were received through the socket and received by the Java Program (Initial Values)&lt;br /&gt;
&lt;br /&gt;
and the CppShell will show:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Connected&lt;br /&gt;
&lt;br /&gt;
Sending intialization message&lt;br /&gt;
&lt;br /&gt;
Waiting for Start Signal..&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
when you press enter*** once in JavaShell it will:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ns3  : Connecting ...&lt;br /&gt;
ns3  : Connected&lt;br /&gt;
ns3  : Created Federation&lt;br /&gt;
ns3  : Joined Federation as ns3&lt;br /&gt;
ns3  :  &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; Press Enter to Continue &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
connect to the RTI and when you press enter again it will send a start signal to CppShell. It will start the simulation and if the RTI time&amp;gt;ns3Time it will process all events&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Start Signal Received&lt;br /&gt;
&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
0&lt;br /&gt;
Event Time Missed, Ns3 Time More Than RTI Time&lt;br /&gt;
Processing Event ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and the output of the event is displayed. If RTI Time&amp;lt;ns3Time it will ask the event to wait and send a time advance request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Present Time (in ns):&lt;br /&gt;
1000000000&lt;br /&gt;
Event in Future, Ns3 Time Less Than RTI Time&lt;br /&gt;
Wait For a Time Advance Signal from RTI ...&lt;br /&gt;
&lt;br /&gt;
Sending Time Advance Request to RTI ...&lt;br /&gt;
&lt;br /&gt;
Time Advance Request Sent&lt;br /&gt;
&lt;br /&gt;
Time Advance Granted&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once the request is grated it will execute the event and the event specific log will be displayed. If there is a change in the object values, a callback will log the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Value of Shared Object (any attribute) changed ...&lt;br /&gt;
Updating ...&lt;br /&gt;
Updated&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At time (***) is the best time to start an external federate.&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6946</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6946"/>
		<updated>2012-08-20T12:12:45Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all your objects under the ObjectRoot class, this is done basically to encapsulate all shared Object (classes) created by ns-3 into ObjectRoot class and add attributes as follows. The basic structure of the file should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(objects &lt;br /&gt;
  (class ObjectRoot &lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
     )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please refer to portico documentation for more details on the .fed files.&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;br /&gt;
&lt;br /&gt;
The first way to test the code is run two shells one with simple-shared-object-example.cc (in shell 1, say CppShell) and SimpleSharedObjectExample.fed( in shell 2, say JavaShell) as mentioned above. The following will be observed:&lt;br /&gt;
&lt;br /&gt;
in Cpp Shell&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
***** Ready To Connect To RTI and launch/join Federation&lt;br /&gt;
&lt;br /&gt;
Connecting ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now start the JavaShell and now run the code using ./hla.sh&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6945</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6945"/>
		<updated>2012-08-20T10:58:37Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Object Model file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
List all your objects under the ObjectRoot class, this is done basically to encapsulate all shared Object (classes) created by ns-3 into ObjectRoot class and add attributes as follows. The basic structure of the file should be like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(objects &lt;br /&gt;
  (class ObjectRoot &lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    (class ...&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
      (attribute ...)&lt;br /&gt;
    .....&lt;br /&gt;
    .....&lt;br /&gt;
     )&lt;br /&gt;
  )&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please refer to portico documentation for more details on the .fed files.&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6944</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6944"/>
		<updated>2012-08-20T10:52:27Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Object Model file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed SimpleSharedObjectExample.fed] was used for this tutorial. Please make sure you list all objects that you are using and their attributes in the .fed file in similar order. It is used by the RTI. Please note that you have to include these three lines at the beginning. This is because the Portico FED parser want it to be like this. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
(FED&lt;br /&gt;
(Federation Portico-Test)&lt;br /&gt;
(FEDversion v1.3)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6943</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6943"/>
		<updated>2012-08-20T10:44:31Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Running */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you have created your .cc and .fed file you can easily run the simulation according to instructions [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage here]. So, as it is clear from the section, we will look deeper into the three commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --clean&lt;br /&gt;
$ Cleaning log files and jar &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will clear all your files that are generated using your java code. This will include .class files and .jar files. It will also clear all log files. These log files are created by the Run Time Interface, in this case portico. The files can be found in $build/src/hla/model/ns3Federate. It will log the following message&lt;br /&gt;
&lt;br /&gt;
Next is, &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --build&lt;br /&gt;
$ Building HLA interfaces&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It will compile hla module code written in java and will save it in $build/src/hla/model/ns3Federate. Make sure you build ns-3 first by using ./waf, before building hla. To run a specific simulation you can use. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./hla.sh --run scratch/SimpleSharedObjectExample&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure you '''copied your .fed to $ns/scratch''' and also you are '''using the .fed file name''' in the --run command. Also please '''follow the sequence''' in which you start the two shells as given in the Wiki [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Usage Instructions]&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6942</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6942"/>
		<updated>2012-08-20T10:28:38Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Before Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here] as set the mentioned environment variables.&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you are creating your .cc and .fed file you can easily run the simulation&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6941</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6941"/>
		<updated>2012-08-20T10:27:56Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, ''' Java Block'''  (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp here]) and ''' C++  bloc'''k (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_002.bmp here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram]. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the '''class which uses the portico Java API to communicate with the portico RTI'''. At present the '''sequence of events''' followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] '''handles Callbacks from RTI''' whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This '''class is a Java Side link between the Java Block and C++ Block'''. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
As the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram] shows, it consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
'''The Helper''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are '''used to initialise the federation, shared objects and attributes''',  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
'''The Synchroniser''' consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is '''responsible for synchronising the event times with the RTI clock'''. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
'''Link To Rti''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the '''class that implements sockets in C++''' and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This '''script is written to remind the end-user of the path variables''' to set. The script '''also provides a waf like build system to build java code'''. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this [https://www.nsnam.org/wiki/index.php/HLAExample tutorial].&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The '''ns-3 hla model can be checked without creating a federate in other simulator'''. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All '''scripts that use HLA should also have a corresponding .fed file''', which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates '''how to create a shared object using the HLA API and how to publish the object'''. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and '''sets simulator to RTI simulator Implementation'''. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found [https://www.nsnam.org/wiki/index.php/HLAExample here]. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you '''need to use HLA interfaces with some ns-3 model''' and use the attributes shared with other federates in your model. The example uses a '''simple mobility model''' and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Packages =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to '''package installation documents''' from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
Once the packages are set up. You need to '''set two environment variables''':&lt;br /&gt;
&lt;br /&gt;
* JAVA_PATH=/path/to/your/jdk/install&lt;br /&gt;
* JAR_PATH=/path/to/portico.jar file&lt;br /&gt;
&lt;br /&gt;
Try and set both of these as your system wide variables, a small [https://help.ubuntu.com/community/EnvironmentVariables post] talks about this for Ubuntu.  &lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Once you are done '''create a new ns-3 script that uses HLA helper classes''' along with other models, say ns3-hla-script.cc. Write''' an object description file''' similar to one in the examples, Ns3HlaScript.fed. '''Copy both in $ns3/scratch/ folder'''. '''Open two terminal windows''', lets call them JavaShell and CppShell. &lt;br /&gt;
&lt;br /&gt;
For '''running your ns-3 script''' use the following command, in any shell (say CppShell):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ ./waf --run scratch/ns3-hla-script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, once you receive the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ Connecting to RTI ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Start Java code''' in the other shell (JavaShell). There is hla.sh script in your $ns3 folder, it provides a waf like build to the java code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
JavaShell$ ./hla.sh --clean&lt;br /&gt;
JavaShell$ Removing HLA Bindings and Old Log files&lt;br /&gt;
JavaShell$ ./hla.sh --build&lt;br /&gt;
JavaShell$ Building HLA interfaces&lt;br /&gt;
JavaShell$ ./hla.sh --run scratch/Ns3HlaScript&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using HLA for the first time, you will have to '''build it first using the &amp;quot;--build&amp;quot;''' command. '''&amp;quot;--clean&amp;quot; will remove old files'''. If HLA (java) is build once you can just '''run your scripts using &amp;quot;--run&amp;quot;'''. The scripts mimics waf build system for the convenience of the user. &lt;br /&gt;
&lt;br /&gt;
This will get your ns-3 federate started. Once you are done with this you can start your other federates or if other federates are running on the same federation, ns-3 federate will just join them automatically. &lt;br /&gt;
&lt;br /&gt;
Again a small tutorial on using HLA in ns3 from writing code to running can be found [https://www.nsnam.org/wiki/index.php/HLAExample here].&lt;br /&gt;
&lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
The deliverables mentioned above in the &amp;quot;components&amp;quot; section&lt;br /&gt;
&lt;br /&gt;
* HLA API&lt;br /&gt;
* Synchroniser&lt;br /&gt;
* Ns3Federate and Ns3Federate Ambassador&lt;br /&gt;
* C++ and Java Links to the C++ Java connecting pipe&lt;br /&gt;
* Scripts, Tests and Examples &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6940</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6940"/>
		<updated>2012-08-20T10:25:17Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Running */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
Once you are creating your .cc and .fed file you can easily run the simulation&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6939</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6939"/>
		<updated>2012-08-20T07:52:31Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* ns-3 script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
The source code of the script can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc here]. Functions from the src/hla/helper will be used here. It is good to have [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h this] file open along side in another tab. It has doxygen and thus you can easily figure out the API calls, we will referring to it.&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6938</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6938"/>
		<updated>2012-08-20T07:39:30Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Description */ mi&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation message. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6937</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6937"/>
		<updated>2012-08-20T07:37:15Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Description */ b&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation method. Let us first look as what variable we have at our disposal, let's look at the initialisation variables and common terms: &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
* Object Name : Name of the Object you are sharing&lt;br /&gt;
* Object Attributes : A property of the shared object &lt;br /&gt;
* Object Handle : Unique federate wide identifier for an object&lt;br /&gt;
* Attribute Handle : Unique federate wide identifier for the attribute&lt;br /&gt;
* Attribute Value : Value the attributes presently (RTI Time) posses&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''. Hla model will take care of these events.     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are created and published. After defining the object model in .fed file you have to create an object and attributes. You can create any number of objects (the helper uses a dynamic memory allocation) and add any number of attributes (again dynamic). You have to '''specify''' the '''name''' of the object and the '''number of attributes''' it will have. Once you create an object you are '''object handle''' is issued. This can used in future for listing all attributes of the object and accessing object name. Similarly, attributes can be added to object by specifying '''Attribute Name''' and '''Object Handle''' and it will return a similar '''Attribute Handle'''. All Objects are to be published and subscribed with the RTI. All events are taken care by the hla model&lt;br /&gt;
&lt;br /&gt;
== Synchronisation and Update ==&lt;br /&gt;
&lt;br /&gt;
Whenever a time advance is required the hla model is designed to send it to the RTI and whenever the Time Advance Grant is approved it is handled by the hla model. For this functionality you have use a '''RTI simulator implementation'''. Whenever a value is changed in the RTI the hla model automatically updates the value in ns3, so the value of the shared object's attribute '''attribute value''' you are using is the one which is known to all federates and is in the federation. Again handled by the hla model.&lt;br /&gt;
&lt;br /&gt;
More low-level implementation details of the hla model can be found [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components here]  &lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6936</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6936"/>
		<updated>2012-08-20T07:21:13Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation method. Let us first look as what variable we have at our disposal, let's look at the initialisation variables . &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
&lt;br /&gt;
The above variables are used for '''initialisation'''. Ns-3 will '''create a federation &amp;lt;FederationName&amp;gt; or join''' the same if already created by other federates. It will '''register''' in the federation as '''federate &amp;lt;FederateName&amp;gt;''' and '''with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt;''' and RTI will use the '''object model in &amp;lt;FomFileName&amp;gt;'''. The simulation will run for '''&amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds''' and will '''advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;'''     &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are published, subscribed and used.&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6935</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6935"/>
		<updated>2012-08-20T07:09:12Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object '''PingPong''' with attributes '''Msg''' and '''MsgType'''. Before we could start with this we need to send an initialisation method. Let us first look as what variable we have at our disposal, let's look at the initialisation variables . &lt;br /&gt;
&lt;br /&gt;
* Seconds : Number of Times time advance request is expected. &lt;br /&gt;
* SyncPhase : The string that is used by federates for synchronisation in RTI.&lt;br /&gt;
* Fomfile : Name of the file that has the object model&lt;br /&gt;
* FederationName : Name of the federation (Should be same in all federates)&lt;br /&gt;
* FederateName : Name of the federate (ns3)&lt;br /&gt;
* RtiTimeResolution : What time steps are required by the model (Default is 1.0)&lt;br /&gt;
&lt;br /&gt;
== Initilisation ==&lt;br /&gt;
 &lt;br /&gt;
The above variables are used for initialisation. Ns-3 will create a federation &amp;lt;FederationName&amp;gt; or can join the same if already created by other federates. It will register in the federation as federate &amp;lt;FederateName&amp;gt; and with a synchronisation phrase &amp;lt;SyncPhrase&amp;gt; and RTI will use the object model in &amp;lt;FomFileName&amp;gt;. The simulation will run for &amp;lt;Seconds&amp;gt;*&amp;lt;RtiTimeResolution&amp;gt; seconds and will advance in &amp;lt;RtiTimeResolutionSteps&amp;gt;      &lt;br /&gt;
&lt;br /&gt;
== Objects ==&lt;br /&gt;
&lt;br /&gt;
Now lets look at how the objects are published, subscribed and used.&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6933</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6933"/>
		<updated>2012-08-20T02:00:24Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Description */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
The objective here is to make a simple ns-3 script that publishes and subscribes to an object ```PingPong``` with attributes ```Msg``` and ```MsgType```. Before we could start with this we need to send an initialisation method. Let us first look as what variable we have at our disposal and what is their importance. &lt;br /&gt;
&lt;br /&gt;
* g_Seconds : Number of Times time advance request is expected. Normally, can be taken as length of simulation&lt;br /&gt;
* g_SyncPhase : The string that is used by federates for synchronisation in RTI&lt;br /&gt;
* g_Fomfile : Name of the file that has the object model&lt;br /&gt;
* g_FederationName : Name of the federation&lt;br /&gt;
* g_FederateName : Name of the federate produced&lt;br /&gt;
*&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6932</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6932"/>
		<updated>2012-08-20T01:47:55Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Testing with external federate */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
= Testing =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6931</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6931"/>
		<updated>2012-08-20T01:47:32Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Running the Simulation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running =&lt;br /&gt;
&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6930</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6930"/>
		<updated>2012-08-20T01:47:11Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Writing the Object Model file */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
= Object Model file =&lt;br /&gt;
&lt;br /&gt;
= Running the Simulation =&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6929</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6929"/>
		<updated>2012-08-20T01:46:53Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Writing the ns-3 script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
= ns-3 script =&lt;br /&gt;
&lt;br /&gt;
= Writing the Object Model file =&lt;br /&gt;
= Running the Simulation =&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6928</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6928"/>
		<updated>2012-08-20T01:46:33Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Writing the ns-3 script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Description =&lt;br /&gt;
&lt;br /&gt;
= Writing the ns-3 script =&lt;br /&gt;
&lt;br /&gt;
= Writing the Object Model file =&lt;br /&gt;
= Running the Simulation =&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6927</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6927"/>
		<updated>2012-08-20T01:44:56Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Before Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Packages here]&lt;br /&gt;
&lt;br /&gt;
= Writing the ns-3 script =&lt;br /&gt;
= Writing the Object Model file =&lt;br /&gt;
= Running the Simulation =&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6926</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6926"/>
		<updated>2012-08-20T01:44:24Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Before Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts. Please download and install the required packages listed [ here]&lt;br /&gt;
&lt;br /&gt;
= Writing the ns-3 script =&lt;br /&gt;
= Writing the Object Model file =&lt;br /&gt;
= Running the Simulation =&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6925</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6925"/>
		<updated>2012-08-20T01:43:50Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, ''' Java Block'''  (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp here]) and ''' C++  bloc'''k (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_002.bmp here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram]. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the '''class which uses the portico Java API to communicate with the portico RTI'''. At present the '''sequence of events''' followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] '''handles Callbacks from RTI''' whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This '''class is a Java Side link between the Java Block and C++ Block'''. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
As the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram] shows, it consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
'''The Helper''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are '''used to initialise the federation, shared objects and attributes''',  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
'''The Synchroniser''' consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is '''responsible for synchronising the event times with the RTI clock'''. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
'''Link To Rti''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the '''class that implements sockets in C++''' and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This '''script is written to remind the end-user of the path variables''' to set. The script '''also provides a waf like build system to build java code'''. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this [https://www.nsnam.org/wiki/index.php/HLAExample tutorial].&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The '''ns-3 hla model can be checked without creating a federate in other simulator'''. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All '''scripts that use HLA should also have a corresponding .fed file''', which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates '''how to create a shared object using the HLA API and how to publish the object'''. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and '''sets simulator to RTI simulator Implementation'''. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found [https://www.nsnam.org/wiki/index.php/HLAExample here]. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you '''need to use HLA interfaces with some ns-3 model''' and use the attributes shared with other federates in your model. The example uses a '''simple mobility model''' and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Packages =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to '''package installation documents''' from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
Once the packages are set up. You need to '''set two environment variables''':&lt;br /&gt;
&lt;br /&gt;
* JAVA_PATH=/path/to/your/jdk/install&lt;br /&gt;
* JAR_PATH=/path/to/portico.jar file&lt;br /&gt;
&lt;br /&gt;
Try and set both of these as your system wide variables, a small [https://help.ubuntu.com/community/EnvironmentVariables post] talks about this for Ubuntu.   &lt;br /&gt;
&lt;br /&gt;
Once you are done '''create a new ns-3 script that uses HLA helper classes''' along with other models, say ns3-hla-script.cc. Write''' an object description file''' similar to one in the examples, Ns3HlaScript.fed. '''Copy both in $ns3/scratch/ folder'''. '''Open two terminal windows''', lets call them JavaShell and CppShell. &lt;br /&gt;
&lt;br /&gt;
For '''running your ns-3 script''' use the following command, in any shell (say CppShell):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ ./waf --run scratch/ns3-hla-script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, once you receive the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ Connecting to RTI ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Start Java code''' in the other shell (JavaShell). There is hla.sh script in your $ns3 folder, it provides a waf like build to the java code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
JavaShell$ ./hla.sh --clean&lt;br /&gt;
JavaShell$ Removing HLA Bindings and Old Log files&lt;br /&gt;
JavaShell$ ./hla.sh --build&lt;br /&gt;
JavaShell$ Building HLA interfaces&lt;br /&gt;
JavaShell$ ./hla.sh --run scratch/Ns3HlaScript&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using HLA for the first time, you will have to '''build it first using the &amp;quot;--build&amp;quot;''' command. '''&amp;quot;--clean&amp;quot; will remove old files'''. If HLA (java) is build once you can just '''run your scripts using &amp;quot;--run&amp;quot;'''. The scripts mimics waf build system for the convenience of the user. &lt;br /&gt;
&lt;br /&gt;
This will get your ns-3 federate started. Once you are done with this you can start your other federates or if other federates are running on the same federation, ns-3 federate will just join them automatically. &lt;br /&gt;
&lt;br /&gt;
Again a small tutorial on using HLA in ns3 from writing code to running can be found [https://www.nsnam.org/wiki/index.php/HLAExample here].&lt;br /&gt;
&lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
The deliverables mentioned above in the &amp;quot;components&amp;quot; section&lt;br /&gt;
&lt;br /&gt;
* HLA API&lt;br /&gt;
* Synchroniser&lt;br /&gt;
* Ns3Federate and Ns3Federate Ambassador&lt;br /&gt;
* C++ and Java Links to the C++ Java connecting pipe&lt;br /&gt;
* Scripts, Tests and Examples &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6924</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6924"/>
		<updated>2012-08-20T01:41:44Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* What are we making? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Before Getting Started =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc .cc] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
The tutorial will assume that you have a working copy on ns-3 with hla which can be obtained [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here] and familiarity with writing and running ns-3 scripts.&lt;br /&gt;
&lt;br /&gt;
= Writing the ns-3 script =&lt;br /&gt;
= Writing the Object Model file =&lt;br /&gt;
= Running the Simulation =&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6923</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6923"/>
		<updated>2012-08-20T01:36:35Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* What are we making? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= What are we making? =&lt;br /&gt;
&lt;br /&gt;
The tutorial will talk about using hla model for ns-3 to make ns-3 participate in distributed simulation with other federates through a Run Time infrastructure. The code for the tutorial can be found in [ .cc] and [ .fed] files. We will be referring to the ns-3 hla model [https://www.nsnam.org/wiki/index.php/GSOC2012HLA Wiki], it has mostly model related explanation, only few sub-sections are required for the tutorial. Information about [http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA] and [http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]. on Wikipedia. &lt;br /&gt;
&lt;br /&gt;
If you want to know more about the source code of the hla model, please read the [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Design design] and see the diagram [https://docs.google.com/open?id=0ByV--ZuE60tCSC1SZVlLQllZdVk here] and [https://docs.google.com/open?id=0ByV--ZuE60tCSFZVWDA3dmpLMDQ here]. Also reading [https://www.nsnam.org/wiki/index.php/GSOC2012HLA#Components this] would be useful. The code can be found [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/ here].&lt;br /&gt;
&lt;br /&gt;
= Writing the ns-3 script =&lt;br /&gt;
= Writing the Object Model file =&lt;br /&gt;
= Running the Simulation =&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6922</id>
		<title>HLAExample</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=HLAExample&amp;diff=6922"/>
		<updated>2012-08-19T23:49:14Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: int&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= What are we making? =&lt;br /&gt;
= Writing the ns-3 script =&lt;br /&gt;
= Writing the Object Model file =&lt;br /&gt;
= Running the Simulation =&lt;br /&gt;
= Testing with external federate =&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLAMidTerm&amp;diff=6921</id>
		<title>GSOC2012HLAMidTerm</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLAMidTerm&amp;diff=6921"/>
		<updated>2012-08-19T22:29:56Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Known Issues/Limitations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Mid-Term Report=&lt;br /&gt;
&lt;br /&gt;
The detail design, weekly progress and deliverable are available on the [http://www.nsnam.org/wiki/index.php/GSOC2012HLA wiki]. &lt;br /&gt;
The code produced during this period can be accessed [http://code.nsnam.org/muditraajgupta/ns-3-hla/ns-3-dev/ here]&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
&lt;br /&gt;
We deviated from out initial plan as a more efficient and easy method of doing the same was found. A new design was chalked out after the new plans and interaction with the community of other software (poRTIco) used. Some time was lost in the process. After the new plan we started with integration of RTI and writing a RTI client for ns-3. Once the work for the RTI client was completed, a class to handle callbacks from RTI was implemented. Once this was done a dummy federate was written to test the behaviour of ns3 federate. This was followed by development of an entry module (link-to-rti) to read from the client. At present the hla module is created which can be used used for testing. It contains all the RTI files and also a test dummy federate. There is no requirement of installing/downloading any other package, user can clone the repository and test the code.  Bulk of the work that requires integration with RTI is completed and ns-3 is receiving messages from other federates. Moreover, timing is also dealt with. Next steps involve writing a HLA API and synchronisation. We would like to get synchronisation out of the way as soon as possible. Next steps also include writing documentation and tests for the created module.&lt;br /&gt;
&lt;br /&gt;
It might appear from the initial proposal that we are behind schedule and may be one (1.1) deliverable short. But most of the functionality of the missing deliverable is incorporated in the new deliverable. Everything else is on schedule and till mid-term we have almost everything which requires the use of external packages done. Some time was lost in making the execution easy for the user, as the project uses external package so methods of simplifying the usage were incorporated in the code and also some supporting scripts were added. This was not dealt in the initial proposal. So, from now the development would be faster as all the supporting frame work is ready and majority of the work of integration, learning and using external package, testing and supporting programs/scripts are ready.&lt;br /&gt;
&lt;br /&gt;
==Achieved Goals==&lt;br /&gt;
&lt;br /&gt;
===A new Scheduler (not being used)===&lt;br /&gt;
&lt;br /&gt;
During the first week of GSoC we worked on a RTI sheduler. This scheduler was suppose to receive messages from RTI through ns-3 federate and had map data structure. It was suppose to convert these messages received into ns-3 events. After few days we analysed the design and figured out that there could be a easier way of doing this by just modifying an implementation of src/syncronization.cc that is wall-clock-syncronizer.cc and using a real-time-simulater-impl.cc as a simulator. Thus, we changed our design a bit.&lt;br /&gt;
&lt;br /&gt;
By the end of second week the new design was ready and we were in touch with the portico community and discussed the project. After input from them we finalised the design. We chucked the RTI scheduler module, although some part of the code was reusable.&lt;br /&gt;
&lt;br /&gt;
===ns3 client for communicating with RTI===&lt;br /&gt;
&lt;br /&gt;
Next, we worked on getting portico up and running some example federates and creating a federation using two or more federates. Then using the poRTIco documentation we wrote some ns3Federate. ns3Federate basically has the definition for setting up a federation and enabling various features for ns-3 like time definitions. It also creates objects, sets basic attributes and publish and subscribe these objects. Objects can also be registered and deleted through this. It also contains the main simulation loop with all the above mentioned events in order.&lt;br /&gt;
&lt;br /&gt;
After ns3Federate we worked with ns3FedAmb (Federate Ambassador), this basically handles callbacks which the RTI (poRTIco in our case) sends them to ns-3 as and when an object is published, subscribed, deleted or any attribute is changed. A callback is also received in case of a time advance request grant. So, all in all the two classes provide an interface to communicate with the RTI and help in basic synchronisation of the events with other federates by receiving time advance granted callbacks. &lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
&lt;br /&gt;
Once we were through with this, we had a lot of code but nothing to test it. So, we worked on developing another set of federate and federate ambassador, called dummy and dummyFederateAmbassador. The features of these two were similar to ns-3 but this federate also had a small simulation. It changed the attributes of the object published by ns-3, it changed the MsgType i.e. the type of message to be sent and the Msg i.e. actual text (planning to change it to data rate and delay), so when this federate was run in parallel with ns-3 federate, various functions could be easily tested, like if ns-3 is receiving callbacks when the attributes are changed? and is the changed values of the attributes reflected? After getting rid of some initial bugs everything worked fine.&lt;br /&gt;
&lt;br /&gt;
===Getting data from the client to ns3===&lt;br /&gt;
&lt;br /&gt;
Next aim was to get these callbacks and messages into ns-3 main code (C++). So a C++ class was created, server.cc. Further, in ns3FedAmb sockets were added. A master - slave configuration was set up between ns3FedAmb and server.cc. When simulation was to be started, finished, object attributes are updated, new objects are published or time advance is granted  ns3FedAmb sends a specific string to a given port along with the accompanied message. Server.cc was a simple test program, it reads throgh a port (same as ns3FedAmb) and accordingly take decision. Like on time advance a variable RTI_CLK is incremented. Rest functions for now were only for proof of concept. We also implemented a different thread which hears from ns3FedAmb and main thread can work on something else. It is a requirement since when ns-3 will be handling events from other simulator, it will also have it's own work/events.&lt;br /&gt;
&lt;br /&gt;
===Testing===&lt;br /&gt;
&lt;br /&gt;
Next, we integrated this server.cc code to one of the ns-3 examples for fun (It could later help in developing the HLA API) now a ns-3 example first.cc receives messages from RTI, thus other federates. We tested this by running ns3Fedrate in one shell and parallel running dummy in another shell and first.cc in another. Object was published by ns-3 and dummy both and modified by dummy at each iteration. These changes were transferred to ns3Fedrate and subsequently first.cc and that too keeping time in mind, i.e. synchronised. A  very crude form of HLA established.&lt;br /&gt;
&lt;br /&gt;
After this we started refining the server.cc and changed it to link-to-rti.cc and link-to-rti.h. The work on this is still under progress, the idea is that this could be included by hla and user can have API access to these function. &lt;br /&gt;
&lt;br /&gt;
==Future Goals==&lt;br /&gt;
&lt;br /&gt;
Once link-to-rti is complete we plan to work on Synchronisation and API simultaneously. Then we plan to write some examples to demonstrate the use of API and possible an API test.&lt;br /&gt;
&lt;br /&gt;
===Synchronisation ===&lt;br /&gt;
&lt;br /&gt;
(20th July)&lt;br /&gt;
Synchronisation as of now looks pretty straight forward, although we do have to check it. It seems that just by using the real-time-simulator-impl.cc as the default simulator for hla and changing a synchronizer.cc implementation, i.e. wall-clock-synchronizer.cc to send RTI time as real time, events could be scheduled to RTI time. Moreover, a single function GerRealTime() at presents gives real time, changing it to fetch the value of RTI_CLK might do the trick.&lt;br /&gt;
&lt;br /&gt;
===HLA API Design ===&lt;br /&gt;
&lt;br /&gt;
(27th August)&lt;br /&gt;
API will be designed for accessing various functions of link-to-rti and also giving the user option to create publishable objects, set and read characteristics. It can easily be used by user in ns-3 scripts in order to access HLA functionalities&lt;br /&gt;
&lt;br /&gt;
===Examples===&lt;br /&gt;
&lt;br /&gt;
(3rd August)&lt;br /&gt;
Some ns-3 script to demonstrate the use of HLA API will be written to explain the functionality to user.&lt;br /&gt;
&lt;br /&gt;
===Testing and Documenting===&lt;br /&gt;
&lt;br /&gt;
Rest of the time of the program will be devoted to testing and documenting the code and adding new functionalities (as mentioned in the proposal)&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6920</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6920"/>
		<updated>2012-08-19T22:24:51Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, ''' Java Block'''  (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp here]) and ''' C++  bloc'''k (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_002.bmp here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram]. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the '''class which uses the portico Java API to communicate with the portico RTI'''. At present the '''sequence of events''' followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] '''handles Callbacks from RTI''' whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This '''class is a Java Side link between the Java Block and C++ Block'''. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
As the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram] shows, it consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
'''The Helper''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are '''used to initialise the federation, shared objects and attributes''',  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
'''The Synchroniser''' consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is '''responsible for synchronising the event times with the RTI clock'''. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
'''Link To Rti''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the '''class that implements sockets in C++''' and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This '''script is written to remind the end-user of the path variables''' to set. The script '''also provides a waf like build system to build java code'''. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this [https://www.nsnam.org/wiki/index.php/HLAExample tutorial].&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The '''ns-3 hla model can be checked without creating a federate in other simulator'''. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All '''scripts that use HLA should also have a corresponding .fed file''', which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates '''how to create a shared object using the HLA API and how to publish the object'''. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and '''sets simulator to RTI simulator Implementation'''. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found [https://www.nsnam.org/wiki/index.php/HLAExample here]. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you '''need to use HLA interfaces with some ns-3 model''' and use the attributes shared with other federates in your model. The example uses a '''simple mobility model''' and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to '''package installation documents''' from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
Once the packages are set up. You need to '''set two environment variables''':&lt;br /&gt;
&lt;br /&gt;
* JAVA_PATH=/path/to/your/jdk/install&lt;br /&gt;
* JAR_PATH=/path/to/portico.jar file&lt;br /&gt;
&lt;br /&gt;
Try and set both of these as your system wide variables, a small [https://help.ubuntu.com/community/EnvironmentVariables post] talks about this for Ubuntu.   &lt;br /&gt;
&lt;br /&gt;
Once you are done '''create a new ns-3 script that uses HLA helper classes''' along with other models, say ns3-hla-script.cc. Write''' an object description file''' similar to one in the examples, Ns3HlaScript.fed. '''Copy both in $ns3/scratch/ folder'''. '''Open two terminal windows''', lets call them JavaShell and CppShell. &lt;br /&gt;
&lt;br /&gt;
For '''running your ns-3 script''' use the following command, in any shell (say CppShell):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ ./waf --run scratch/ns3-hla-script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, once you receive the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ Connecting to RTI ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Start Java code''' in the other shell (JavaShell). There is hla.sh script in your $ns3 folder, it provides a waf like build to the java code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
JavaShell$ ./hla.sh --clean&lt;br /&gt;
JavaShell$ Removing HLA Bindings and Old Log files&lt;br /&gt;
JavaShell$ ./hla.sh --build&lt;br /&gt;
JavaShell$ Building HLA interfaces&lt;br /&gt;
JavaShell$ ./hla.sh --run scratch/Ns3HlaScript&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using HLA for the first time, you will have to '''build it first using the &amp;quot;--build&amp;quot;''' command. '''&amp;quot;--clean&amp;quot; will remove old files'''. If HLA (java) is build once you can just '''run your scripts using &amp;quot;--run&amp;quot;'''. The scripts mimics waf build system for the convenience of the user. &lt;br /&gt;
&lt;br /&gt;
This will get your ns-3 federate started. Once you are done with this you can start your other federates or if other federates are running on the same federation, ns-3 federate will just join them automatically. &lt;br /&gt;
&lt;br /&gt;
Again a small tutorial on using HLA in ns3 from writing code to running can be found [https://www.nsnam.org/wiki/index.php/HLAExample here].&lt;br /&gt;
&lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
The deliverables mentioned above in the &amp;quot;components&amp;quot; section&lt;br /&gt;
&lt;br /&gt;
* HLA API&lt;br /&gt;
* Synchroniser&lt;br /&gt;
* Ns3Federate and Ns3Federate Ambassador&lt;br /&gt;
* C++ and Java Links to the C++ Java connecting pipe&lt;br /&gt;
* Scripts, Tests and Examples &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6919</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6919"/>
		<updated>2012-08-19T22:22:07Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, ''' Java Block'''  (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp here]) and ''' C++  bloc'''k (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_002.bmp here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram]. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the '''class which uses the portico Java API to communicate with the portico RTI'''. At present the '''sequence of events''' followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] '''handles Callbacks from RTI''' whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This '''class is a Java Side link between the Java Block and C++ Block'''. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
As the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram] shows, it consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
'''The Helper''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are '''used to initialise the federation, shared objects and attributes''',  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
'''The Synchroniser''' consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is '''responsible for synchronising the event times with the RTI clock'''. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
'''Link To Rti''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the '''class that implements sockets in C++''' and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This '''script is written to remind the end-user of the path variables''' to set. The script '''also provides a waf like build system to build java code'''. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The '''ns-3 hla model can be checked without creating a federate in other simulator'''. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All '''scripts that use HLA should also have a corresponding .fed file''', which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates '''how to create a shared object using the HLA API and how to publish the object'''. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and '''sets simulator to RTI simulator Implementation'''. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you '''need to use HLA interfaces with some ns-3 model''' and use the attributes shared with other federates in your model. The example uses a '''simple mobility model''' and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to '''package installation documents''' from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
Once the packages are set up. You need to '''set two environment variables''':&lt;br /&gt;
&lt;br /&gt;
* JAVA_PATH=/path/to/your/jdk/install&lt;br /&gt;
* JAR_PATH=/path/to/portico.jar file&lt;br /&gt;
&lt;br /&gt;
Try and set both of these as your system wide variables, a small [https://help.ubuntu.com/community/EnvironmentVariables post] talks about this for Ubuntu.   &lt;br /&gt;
&lt;br /&gt;
Once you are done '''create a new ns-3 script that uses HLA helper classes''' along with other models, say ns3-hla-script.cc. Write''' an object description file''' similar to one in the examples, Ns3HlaScript.fed. '''Copy both in $ns3/scratch/ folder'''. '''Open two terminal windows''', lets call them JavaShell and CppShell. &lt;br /&gt;
&lt;br /&gt;
For '''running your ns-3 script''' use the following command, in any shell (say CppShell):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ ./waf --run scratch/ns3-hla-script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, once you receive the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ Connecting to RTI ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Start Java code''' in the other shell (JavaShell). There is hla.sh script in your $ns3 folder, it provides a waf like build to the java code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
JavaShell$ ./hla.sh --clean&lt;br /&gt;
JavaShell$ Removing HLA Bindings and Old Log files&lt;br /&gt;
JavaShell$ ./hla.sh --build&lt;br /&gt;
JavaShell$ Building HLA interfaces&lt;br /&gt;
JavaShell$ ./hla.sh --run scratch/Ns3HlaScript&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using HLA for the first time, you will have to '''build it first using the &amp;quot;--build&amp;quot;''' command. '''&amp;quot;--clean&amp;quot; will remove old files'''. If HLA (java) is build once you can just '''run your scripts using &amp;quot;--run&amp;quot;'''. The scripts mimics waf build system for the convenience of the user. &lt;br /&gt;
&lt;br /&gt;
This will get your ns-3 federate started. Once you are done with this you can start your other federates or if other federates are running on the same federation, ns-3 federate will just join them automatically. &lt;br /&gt;
&lt;br /&gt;
Again a small tutorial on using HLA in ns3 from writing code to running can be found here.&lt;br /&gt;
&lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
The deliverables mentioned above in the &amp;quot;components&amp;quot; section&lt;br /&gt;
&lt;br /&gt;
* HLA API&lt;br /&gt;
* Synchroniser&lt;br /&gt;
* Ns3Federate and Ns3Federate Ambassador&lt;br /&gt;
* C++ and Java Links to the C++ Java connecting pipe&lt;br /&gt;
* Scripts, Tests and Examples &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6918</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6918"/>
		<updated>2012-08-19T22:17:26Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, ''' Java Block'''  (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp here]) and ''' C++  bloc'''k (please see a conceptual diagram [http://ns-3-review.googlecode.com/svn/wiki/Selection_002.bmp here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram]. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the '''class which uses the portico Java API to communicate with the portico RTI'''. At present the '''sequence of events''' followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] '''handles Callbacks from RTI''' whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This '''class is a Java Side link between the Java Block and C++ Block'''. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
As the [http://ns-3-review.googlecode.com/svn/wiki/Selection_001.bmp diagram] shows, it consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
'''The Helper''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are '''used to initialise the federation, shared objects and attributes''',  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
'''The Synchroniser''' consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is '''responsible for synchronising the event times with the RTI clock'''. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
'''Link To Rti''' [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the '''class that implements sockets in C++''' and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This '''script is written to remind the end-user of the path variables''' to set. The script '''also provides a waf like build system to build java code'''. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The '''ns-3 hla model can be checked without creating a federate in other simulator'''. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All '''scripts that use HLA should also have a corresponding .fed file''', which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates '''how to create a shared object using the HLA API and how to publish the object'''. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and '''sets simulator to RTI simulator Implementation'''. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you '''need to use HLA interfaces with some ns-3 model''' and use the attributes shared with other federates in your model. The example uses a '''simple mobility model''' and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to '''package installation documents''' from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
Once the packages are set up. You need to '''set two environment variables''':&lt;br /&gt;
&lt;br /&gt;
* JAVA_PATH=/path/to/your/jdk/install&lt;br /&gt;
* JAR_PATH=/path/to/portico.jar file&lt;br /&gt;
&lt;br /&gt;
Try and set both of these as your system wide variables, a small [https://help.ubuntu.com/community/EnvironmentVariables post] talks about this for Ubuntu.   &lt;br /&gt;
&lt;br /&gt;
Once you are done '''create a new ns-3 script that uses HLA helper classes''' along with other models, say ns3-hla-script.cc. Write''' an object description file''' similar to one in the examples, Ns3HlaScript.fed. '''Copy both in $ns3/scratch/ folder'''. '''Open two terminal windows''', lets call them JavaShell and CppShell. &lt;br /&gt;
&lt;br /&gt;
For '''running your ns-3 script''' use the following command, in any shell (say CppShell):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ ./waf --run scratch/ns3-hla-script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, once you receive the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ Connecting to RTI ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Start Java code''' in the other shell (JavaShell). There is hla.sh script in your $ns3 folder, it provides a waf like build to the java code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
JavaShell$ ./hla.sh --clean&lt;br /&gt;
JavaShell$ Removing HLA Bindings and Old Log files&lt;br /&gt;
JavaShell$ ./hla.sh --build&lt;br /&gt;
JavaShell$ Building HLA interfaces&lt;br /&gt;
JavaShell$ ./hla.sh --run scratch/Ns3HlaScript&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using HLA for the first time, you will have to '''build it first using the &amp;quot;--build&amp;quot;''' command. '''&amp;quot;--clean will remove old files&amp;quot;'''. If HLA (java) is build once you can just '''run your scripts using &amp;quot;--run&amp;quot;'''. The scripts mimics waf build system for the convenience of the user. &lt;br /&gt;
&lt;br /&gt;
This will get your ns-3 federate started. Once you are done with this you can start your other federates or if other federates are running on the same federation, ns-3 federate will just join them automatically. &lt;br /&gt;
&lt;br /&gt;
Again a small tutorial on using HLA in ns3 from writing code to running can be found here.&lt;br /&gt;
&lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6917</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6917"/>
		<updated>2012-08-19T21:59:16Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Usage */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The ns-3 hla model can be checked without creating a federate in other simulator. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All scripts that use HLA should also have a corresponding .fed file, which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates how to create a shared object using the HLA API and how to publish the object. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and sets simulator to RTI simulator Implementation. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you need to use HLA interfaces with some ns-3 model and use the attributes shared with other federates in your model. The example uses a simple mobility models and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to package installation documents from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
Once the packages are set up. You need to set two environment variables:&lt;br /&gt;
&lt;br /&gt;
* JAVA_PATH=/path/to/your/jdk/install&lt;br /&gt;
* JAR_PATH=/path/to/portico.jar file&lt;br /&gt;
&lt;br /&gt;
Try and set both of these as your system wide variables, a small [https://help.ubuntu.com/community/EnvironmentVariables post] talks about this for Ubuntu.   &lt;br /&gt;
&lt;br /&gt;
Once you are done create a new ns-3 script that uses HLA helper classes along with other models, say ns3-hla-script.cc. Write an object description file similar to one in the examples, Ns3HlaScript.fed. Copy both in $ns3/scratch/ folder. Open two terminal windows, lets call them JavaShell and CppShell. &lt;br /&gt;
&lt;br /&gt;
For running your ns-3 script use the following command, in any shell (say CppShell):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ ./waf --run scratch/ns3-hla-script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, once you receive the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ Connecting to RTI ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Java code in the other shell (JavaShell). There is hla.sh script in your $ns3 folder, it provides a waf like build to the java code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
JavaShell$ ./hla.sh --clean&lt;br /&gt;
JavaShell$ Removing HLA Bindings and Old Log files&lt;br /&gt;
JavaShell$ ./hla.sh --build&lt;br /&gt;
JavaShell$ Building HLA interfaces&lt;br /&gt;
JavaShell$ ./hla.sh --run scratch/Ns3HlaScript&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you are using HLA for the first time, you will have to build it first using the &amp;quot;--build&amp;quot; command. &amp;quot;--clean will remove old files&amp;quot;. If HLA (java) is build once you can just run your scripts using &amp;quot;--run&amp;quot;. The scripts mimics waf build system for the convenience of the user. &lt;br /&gt;
&lt;br /&gt;
This will get your ns-3 federate started. Once you are done with this you can start your other federates or if other federates are running on the same federation, ns-3 federate will just join them automatically. &lt;br /&gt;
&lt;br /&gt;
Again a small tutorial on using HLA in ns3 from writing code to running can be found here.&lt;br /&gt;
&lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6916</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6916"/>
		<updated>2012-08-19T21:52:24Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/Run-Time_Infrastructure_%28simulation%29 RTI]'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The ns-3 hla model can be checked without creating a federate in other simulator. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All scripts that use HLA should also have a corresponding .fed file, which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates how to create a shared object using the HLA API and how to publish the object. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and sets simulator to RTI simulator Implementation. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you need to use HLA interfaces with some ns-3 model and use the attributes shared with other federates in your model. The example uses a simple mobility models and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to package installation documents from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
Once the packages are set up. You need to set two environment variables:&lt;br /&gt;
&lt;br /&gt;
* JAVA_PATH=/path/to/your/jdk/install&lt;br /&gt;
* JAR_PATH=/path/to/portico.jar file&lt;br /&gt;
&lt;br /&gt;
Try and set both of these as your system wide variables, a small [https://help.ubuntu.com/community/EnvironmentVariables post] talks about this for Ubuntu.   &lt;br /&gt;
&lt;br /&gt;
Once you are done create a new ns-3 script that uses HLA helper classes along with other models, say ns3-hla-script.cc. Write an object description file similar to one in the examples, Ns3HlaScript.fed. Copy both in $ns3/scratch/ folder. Open two terminal windows, lets call them JavaShell and CppShell. &lt;br /&gt;
&lt;br /&gt;
For running your ns-3 script use the following command, in any shell (say CppShell):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ ./waf --run scratch/ns3-hla-script&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, once you receive the following message:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CppShell$ Connecting to RTI ...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Start Java code in the other shell (JavaShell). There is hla.sh script in your $ns3 folder, it provides a waf like build to the java code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
JavaShell$ ./hla.sh --clean&lt;br /&gt;
JavaShell$ Removing HLA Bindings and Old Log files&lt;br /&gt;
JavaShell$ ./hla.sh --build&lt;br /&gt;
JavaShell$ Building HLA interfaces&lt;br /&gt;
JavaShell$ ./hla.sh --run scratch/Ns3HlaScript&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6915</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6915"/>
		<updated>2012-08-19T21:34:59Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''[http://en.wikipedia.org/wiki/High-level_architecture_%28simulation%29 HLA]''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The ns-3 hla model can be checked without creating a federate in other simulator. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All scripts that use HLA should also have a corresponding .fed file, which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates how to create a shared object using the HLA API and how to publish the object. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and sets simulator to RTI simulator Implementation. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you need to use HLA interfaces with some ns-3 model and use the attributes shared with other federates in your model. The example uses a simple mobility models and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
* Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
* Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
* Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to package installation documents from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6914</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6914"/>
		<updated>2012-08-19T21:33:22Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The ns-3 hla model can be checked without creating a federate in other simulator. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All scripts that use HLA should also have a corresponding .fed file, which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates how to create a shared object using the HLA API and how to publish the object. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and sets simulator to RTI simulator Implementation. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you need to use HLA interfaces with some ns-3 model and use the attributes shared with other federates in your model. The example uses a simple mobility models and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&lt;br /&gt;
Ns-3 scripts can use HLA API and RTI Simulator Implementation to communicate with other federates. HLA module uses the following external packages/software:&lt;br /&gt;
&lt;br /&gt;
1. Get and Install [http://www.oracle.com/technetwork/java/javase/downloads/index.html Java]&lt;br /&gt;
2. Get and Install RTI - [http://www.porticoproject.org/index.php?title=Main_Page Portico]&lt;br /&gt;
3. Get and Install [http://msgpack.org/ MessagePack] for [https://github.com/msgpack/msgpack-c C++] and [https://github.com/msgpack/msgpack-java Java]&lt;br /&gt;
&lt;br /&gt;
Please refer to package installation documents from respective websites (You just need portico.jar for portico).&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
= Deliverables =&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6913</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6913"/>
		<updated>2012-08-19T21:23:01Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Examples */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The ns-3 hla model can be checked without creating a federate in other simulator. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All scripts that use HLA should also have a corresponding .fed file, which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/simple-shared-object-example.cc example] demonstrates how to create a shared object using the HLA API and how to publish the object. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and sets simulator to RTI simulator Implementation. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you need to use HLA interfaces with some ns-3 model and use the attributes shared with other federates in your model. The example uses a simple mobility models and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it.&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6912</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6912"/>
		<updated>2012-08-19T21:21:15Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: f&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
The hla model at present has a dummy federate. It has two classes [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederate.java Federate] and [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/dummyFederateAmbassador.java FederateAbassador]. The ns-3 hla model can be checked without creating a federate in other simulator. This federates just creates a federation and modify a shared object PingPong 's attributes - Msg and MsgType. These attributes are toggles every second. The values are:&lt;br /&gt;
&lt;br /&gt;
* MsgType : Ping, Pong&lt;br /&gt;
* Msg : &amp;quot;Client: Hello!!!&amp;quot;, &amp;quot;Server: Hello!!!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be executed using [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/test/SystemIntegration/linux.sh this] helper script&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All scripts that use HLA should also have a corresponding .fed file, which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to create a shared object using the HLA API and how to publish the object. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and sets simulator to RTI simulator Implementation. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you need to use HLA interfaces with some ns-3 model and use the attributes shared with other federates in your model. The example uses a simple mobility models and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it. &lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6911</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6911"/>
		<updated>2012-08-19T21:12:35Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: k&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Components=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* System Integration Test&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
All scripts that use HLA should also have a corresponding .fed file, which is nothing but a simple object description. This [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/examples/SimpleSharedObjectExample.fed .fed] file used for the examples and can be modified for more scripts. It contains the shared object &amp;quot;PingPong&amp;quot; and two attributes &amp;quot;Msg&amp;quot; and &amp;quot;MsgType&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* Simple Shared Object Example&lt;br /&gt;
&lt;br /&gt;
This example demonstrates how to create a shared object using the HLA API and how to publish the object. The example creates a simple object PingPong with attributes Msg and MsgType and shares with other federates and sets simulator to RTI simulator Implementation. It demonstrates the concepts of Class Handles and Attribute Handles. A tutorial on the model can be found here. &lt;br /&gt;
&lt;br /&gt;
* Shared Object With CallBack&lt;br /&gt;
&lt;br /&gt;
In a real scenario you need to use HLA interfaces with some ns-3 model and use the attributes shared with other federates in your model. The example uses a simple mobility models and prints the object's attributes in the Callback function. One can see the attribute changes when the external federate modify it. &lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6910</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6910"/>
		<updated>2012-08-19T20:42:42Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Java Block */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Deliverables=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
&lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* Validation Test 1 (V1): Communication with other Federates (dummy)&lt;br /&gt;
* System Integration Test 1 (S1): Message Passing between ns3Federate Ambassador and ns3 link-to-rti&lt;br /&gt;
* System Integration Test 2(S2): Message Passing between RTI and ns3FederateAmbassador&lt;br /&gt;
* Unit Test 1 (U1): Checking ns3Federate (Java Sockets)&lt;br /&gt;
* Unit Test 2 (U2): Checking link-to-rti (C++ sockets) &lt;br /&gt;
* API (API1) test is to be done with the final HLA RTI API.&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
Note: The '''bold''' text details the changes/progress from initial deliverables&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
'''New Expected Deliverables'''&lt;br /&gt;
* Synchronisation&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6909</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6909"/>
		<updated>2012-08-19T20:41:36Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Deliverables=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
 &lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* Validation Test 1 (V1): Communication with other Federates (dummy)&lt;br /&gt;
* System Integration Test 1 (S1): Message Passing between ns3Federate Ambassador and ns3 link-to-rti&lt;br /&gt;
* System Integration Test 2(S2): Message Passing between RTI and ns3FederateAmbassador&lt;br /&gt;
* Unit Test 1 (U1): Checking ns3Federate (Java Sockets)&lt;br /&gt;
* Unit Test 2 (U2): Checking link-to-rti (C++ sockets) &lt;br /&gt;
* API (API1) test is to be done with the final HLA RTI API.&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
Note: The '''bold''' text details the changes/progress from initial deliverables&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
'''New Expected Deliverables'''&lt;br /&gt;
* Synchronisation&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6908</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6908"/>
		<updated>2012-08-19T20:39:20Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.  &lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Deliverables=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
* Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
 &lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block. The code is well documented in doxygen format.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates. &lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
Link To Rti [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/link-to-rti.h .h] is the class that implements sockets in C++ and communicates with the Java code.It has following functions for:&lt;br /&gt;
&lt;br /&gt;
* Multi threading: It is implemented for simultaneous listening and sending of messages over the socket. &lt;br /&gt;
* Packing and Sending: It uses Message Pack for serialisation of the attributes of the object, implements various functions for sending data.&lt;br /&gt;
* Callbacks: The class handle callbacks from RTI (Time Advance, Update, Start Signal)    &lt;br /&gt;
   &lt;br /&gt;
== Helper Scripts ==&lt;br /&gt;
&lt;br /&gt;
Apart from regular ns-3 helper scripts, HLA module needs a helper script [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/hla.sh hla.sh]. This script is written to remind the end-user of the path variables to set. The script also provides a waf like build system to build java code. User does not require build tools like ant and maven for building java code and producing .class and .jar files. Once ns3 is build, this script can be used to automatically create .class and .jar files in $ns3/build/src/hla/model and running the java code. It has commands like:&lt;br /&gt;
&lt;br /&gt;
* ./hla.sh --clean (Cleans .class, .jar files and RTI log files)&lt;br /&gt;
* ./hla.sh --build (Builds HLA interfaces, Java Code)&lt;br /&gt;
* ./hla.sh --run scratch/&amp;lt;filename&amp;gt; (.fed file has to be in scratch directory)&lt;br /&gt;
&lt;br /&gt;
To know more about usage read below or this tutorial.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
* Validation Test 1 (V1): Communication with other Federates (dummy)&lt;br /&gt;
* System Integration Test 1 (S1): Message Passing between ns3Federate Ambassador and ns3 link-to-rti&lt;br /&gt;
* System Integration Test 2(S2): Message Passing between RTI and ns3FederateAmbassador&lt;br /&gt;
* Unit Test 1 (U1): Checking ns3Federate (Java Sockets)&lt;br /&gt;
* Unit Test 2 (U2): Checking link-to-rti (C++ sockets) &lt;br /&gt;
* API (API1) test is to be done with the final HLA RTI API.&lt;br /&gt;
&lt;br /&gt;
== Deliverables ==&lt;br /&gt;
&lt;br /&gt;
Note: The '''bold''' text details the changes/progress from initial deliverables&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
'''New Expected Deliverables'''&lt;br /&gt;
* Synchronisation&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6907</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6907"/>
		<updated>2012-08-19T19:00:08Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: Deliv&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.  &lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Deliverables=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
1. Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
2. Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
 &lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates.&lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].&lt;br /&gt;
&lt;br /&gt;
The Synchroniser is responsible for synchronising the event times with the RTI clock. The RTI Synchroniser is inspired by the wall-clock-synchronizer-impl, in it's case it fetches the RTI time from the RTI clock variable maintained in LinkToRti class. It is used by the functions in RTI Simulator Implementation. Whenever an event has to happen, this code block checks if the event time is more than the time in RTI. If yes, the event is processed and if no the a Time Advance Request is sent to the RTI. Other standard functions for simulator implementation are also present, quite similar to realtime-simulator-impl.&lt;br /&gt;
&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
== Testing approach ==&lt;br /&gt;
&lt;br /&gt;
* Validation Test 1 (V1): Communication with other Federates (dummy)&lt;br /&gt;
* System Integration Test 1 (S1): Message Passing between ns3Federate Ambassador and ns3 link-to-rti&lt;br /&gt;
* System Integration Test 2(S2): Message Passing between RTI and ns3FederateAmbassador&lt;br /&gt;
* Unit Test 1 (U1): Checking ns3Federate (Java Sockets)&lt;br /&gt;
* Unit Test 2 (U2): Checking link-to-rti (C++ sockets) &lt;br /&gt;
* API (API1) test is to be done with the final HLA RTI API.&lt;br /&gt;
&lt;br /&gt;
= Deliverables  =&lt;br /&gt;
&lt;br /&gt;
Note: The '''bold''' text details the changes/progress from initial deliverables&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
'''New Expected Deliverables'''&lt;br /&gt;
* Synchronisation&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6906</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6906"/>
		<updated>2012-08-19T18:50:41Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.  &lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
=Deliverables=&lt;br /&gt;
&lt;br /&gt;
==Java Block==&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
1. Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
2. Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
 &lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain functions to set various variables that are used to initialise the Federation and shared objects and attributes,  It also has functions to access the variables and their values. So basically,&lt;br /&gt;
&lt;br /&gt;
* Setters (Set values like federation name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
* Getters (Retrieve current values of attributes, their parents, modified time etc.)&lt;br /&gt;
&lt;br /&gt;
The values of Hla Helper are updated as and when they are changed by the other federates.&lt;br /&gt;
&lt;br /&gt;
The Synchroniser consists of two classes RTI Simulator Implementation [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-simulator-impl.h .h] and RTI clock Synchroniser [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/rti-clock-synchronizer.h .h].  &lt;br /&gt;
&lt;br /&gt;
* ns3Federate  &lt;br /&gt;
* ns3FedAmb&lt;br /&gt;
* JavaLink&lt;br /&gt;
&lt;br /&gt;
'''ns3Federate:'''&lt;br /&gt;
&lt;br /&gt;
It takes care of the creating a federation (if not created else joining it), registering ns3 as a Federate and running the main simulation loop. It also deals with publishing, deleting and registering objects and interaction in the RTI. &lt;br /&gt;
&lt;br /&gt;
'''ns3FedAmb'''&lt;br /&gt;
&lt;br /&gt;
This segment is also responsible for creating a port and communicating with the LinkToRti code (C++) This basically handles callbacks from the RTI. These callbacks include notification when attribute of an object is changed, new object is added/registered or deleted and when a time advance request is granted. A server – client paradigm is implemented between ns3FedAmb and link-to-rti. It is implemented by using sockets. &lt;br /&gt;
&lt;br /&gt;
===link-to-rti===&lt;br /&gt;
&lt;br /&gt;
A message server is set up and appropriate sockets are used get messages from ns3FedAmb. It also acts as an entry level module to ns3 code and links ns3Federate with HLA API. It also controls time values and maintains a RTI_CLOCK. &lt;br /&gt;
&lt;br /&gt;
===Synchronisation===&lt;br /&gt;
&lt;br /&gt;
There is still a lot of debate in the synchronisation of the RTI clock with ns-3. The present approach finalised and yet to be tested looks like making a minor change in wall-clock-syncronizer.cc by changing the GetRealTime to GetRtiTime (which fetches RTI_CLOCK value) and using the real time simulator with almost no modification. Since it will wait for an event to process till real time has been reached (i.e RTI_CLOCK is the new real time). So the function process_one_event will take care of event scheduling.    &lt;br /&gt;
&lt;br /&gt;
===HLA API===&lt;br /&gt;
&lt;br /&gt;
HLA API will be designed to access various features of ns-3-hla like initialise ns-3 Federate, Create Object, Add Attributes to Object, Accessing Attributes of Object.&lt;br /&gt;
&lt;br /&gt;
== Testing approach ==&lt;br /&gt;
&lt;br /&gt;
* Validation Test 1 (V1): Communication with other Federates (dummy)&lt;br /&gt;
* System Integration Test 1 (S1): Message Passing between ns3Federate Ambassador and ns3 link-to-rti&lt;br /&gt;
* System Integration Test 2(S2): Message Passing between RTI and ns3FederateAmbassador&lt;br /&gt;
* Unit Test 1 (U1): Checking ns3Federate (Java Sockets)&lt;br /&gt;
* Unit Test 2 (U2): Checking link-to-rti (C++ sockets) &lt;br /&gt;
* API (API1) test is to be done with the final HLA RTI API.&lt;br /&gt;
&lt;br /&gt;
= Deliverables  =&lt;br /&gt;
&lt;br /&gt;
Note: The '''bold''' text details the changes/progress from initial deliverables&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
'''New Expected Deliverables'''&lt;br /&gt;
* Synchronisation&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6905</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6905"/>
		<updated>2012-08-19T12:48:40Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: helper&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.  &lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
==Deliverables==&lt;br /&gt;
&lt;br /&gt;
===Java Block===&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
1. Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
2. Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
 &lt;br /&gt;
==C++ Block== &lt;br /&gt;
&lt;br /&gt;
It Consists of basically two parts: The Synchroniser and The Helper. It also has a class which act as a C++ link to the connection between Java and C++ block.&lt;br /&gt;
&lt;br /&gt;
The Helper [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.cc .cc] [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/helper/hla-helper.h .h] contain   &lt;br /&gt;
It consists of basically two parts - &lt;br /&gt;
&lt;br /&gt;
* ns3Federate  &lt;br /&gt;
* ns3FedAmb&lt;br /&gt;
* JavaLink&lt;br /&gt;
&lt;br /&gt;
'''ns3Federate:'''&lt;br /&gt;
&lt;br /&gt;
It takes care of the creating a federation (if not created else joining it), registering ns3 as a Federate and running the main simulation loop. It also deals with publishing, deleting and registering objects and interaction in the RTI. &lt;br /&gt;
&lt;br /&gt;
'''ns3FedAmb'''&lt;br /&gt;
&lt;br /&gt;
This segment is also responsible for creating a port and communicating with the LinkToRti code (C++) This basically handles callbacks from the RTI. These callbacks include notification when attribute of an object is changed, new object is added/registered or deleted and when a time advance request is granted. A server – client paradigm is implemented between ns3FedAmb and link-to-rti. It is implemented by using sockets. &lt;br /&gt;
&lt;br /&gt;
===link-to-rti===&lt;br /&gt;
&lt;br /&gt;
A message server is set up and appropriate sockets are used get messages from ns3FedAmb. It also acts as an entry level module to ns3 code and links ns3Federate with HLA API. It also controls time values and maintains a RTI_CLOCK. &lt;br /&gt;
&lt;br /&gt;
===Synchronisation===&lt;br /&gt;
&lt;br /&gt;
There is still a lot of debate in the synchronisation of the RTI clock with ns-3. The present approach finalised and yet to be tested looks like making a minor change in wall-clock-syncronizer.cc by changing the GetRealTime to GetRtiTime (which fetches RTI_CLOCK value) and using the real time simulator with almost no modification. Since it will wait for an event to process till real time has been reached (i.e RTI_CLOCK is the new real time). So the function process_one_event will take care of event scheduling.    &lt;br /&gt;
&lt;br /&gt;
===HLA API===&lt;br /&gt;
&lt;br /&gt;
HLA API will be designed to access various features of ns-3-hla like initialise ns-3 Federate, Create Object, Add Attributes to Object, Accessing Attributes of Object.&lt;br /&gt;
&lt;br /&gt;
== Testing approach ==&lt;br /&gt;
&lt;br /&gt;
* Validation Test 1 (V1): Communication with other Federates (dummy)&lt;br /&gt;
* System Integration Test 1 (S1): Message Passing between ns3Federate Ambassador and ns3 link-to-rti&lt;br /&gt;
* System Integration Test 2(S2): Message Passing between RTI and ns3FederateAmbassador&lt;br /&gt;
* Unit Test 1 (U1): Checking ns3Federate (Java Sockets)&lt;br /&gt;
* Unit Test 2 (U2): Checking link-to-rti (C++ sockets) &lt;br /&gt;
* API (API1) test is to be done with the final HLA RTI API.&lt;br /&gt;
&lt;br /&gt;
= Deliverables  =&lt;br /&gt;
&lt;br /&gt;
Note: The '''bold''' text details the changes/progress from initial deliverables&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
'''New Expected Deliverables'''&lt;br /&gt;
* Synchronisation&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6904</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6904"/>
		<updated>2012-08-19T08:28:36Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.  &lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
'''Java Block'''&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]. This class is a Java Side link between the Java Block and C++ Block. It has various utility functions to set up a socket connection and receive and send messages. It also has various Getter methods to extract the value of the incoming messages into variables. It basically has functions for:&lt;br /&gt;
&lt;br /&gt;
1. Socket Communication (Establish Connection, Notify Changes to ns-3, Start ns-3, Send Time Advance to C++ block, read Time Advance, Initial Values)&lt;br /&gt;
2. Getters (Extract Values like Federation Name, Federate Name, Fom File, Object Name, Attribute Names etc.)&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
In order to make ns-3 IEEE 1516 a new HLA compliant scheduler for ns-3 (rtiScheduler), has to be designed along with ns3FederateAmbassador.&lt;br /&gt;
&lt;br /&gt;
* 1. Ns3Federate&lt;br /&gt;
* 2. LinkToRti&lt;br /&gt;
* 3. Synchronising &lt;br /&gt;
* 4. HLA Helper&lt;br /&gt;
&lt;br /&gt;
There is a possibility of a two way communication between ns-3 and the other federates, but in the approach mentioned ns-3 is only used as a sink and not a source. This is so because in previous discussions with the mentor a conclusion was drawn that if ns-3 would also be used as a source, it will complicate things. The only-sink methodology can be extended to source and sink after GSoC, but adding it in the GSoC timeframe would be a bit over &lt;br /&gt;
ambitious. Although, it will definitely be a part of post-GSoC plans.     &lt;br /&gt;
&lt;br /&gt;
===Ns3Federate===&lt;br /&gt;
&lt;br /&gt;
It consists of basically two parts - &lt;br /&gt;
&lt;br /&gt;
* ns3Federate  &lt;br /&gt;
* ns3FedAmb&lt;br /&gt;
* JavaLink&lt;br /&gt;
&lt;br /&gt;
'''ns3Federate:'''&lt;br /&gt;
&lt;br /&gt;
It takes care of the creating a federation (if not created else joining it), registering ns3 as a Federate and running the main simulation loop. It also deals with publishing, deleting and registering objects and interaction in the RTI. &lt;br /&gt;
&lt;br /&gt;
'''ns3FedAmb'''&lt;br /&gt;
&lt;br /&gt;
This segment is also responsible for creating a port and communicating with the LinkToRti code (C++) This basically handles callbacks from the RTI. These callbacks include notification when attribute of an object is changed, new object is added/registered or deleted and when a time advance request is granted. A server – client paradigm is implemented between ns3FedAmb and link-to-rti. It is implemented by using sockets. &lt;br /&gt;
&lt;br /&gt;
===link-to-rti===&lt;br /&gt;
&lt;br /&gt;
A message server is set up and appropriate sockets are used get messages from ns3FedAmb. It also acts as an entry level module to ns3 code and links ns3Federate with HLA API. It also controls time values and maintains a RTI_CLOCK. &lt;br /&gt;
&lt;br /&gt;
===Synchronisation===&lt;br /&gt;
&lt;br /&gt;
There is still a lot of debate in the synchronisation of the RTI clock with ns-3. The present approach finalised and yet to be tested looks like making a minor change in wall-clock-syncronizer.cc by changing the GetRealTime to GetRtiTime (which fetches RTI_CLOCK value) and using the real time simulator with almost no modification. Since it will wait for an event to process till real time has been reached (i.e RTI_CLOCK is the new real time). So the function process_one_event will take care of event scheduling.    &lt;br /&gt;
&lt;br /&gt;
===HLA API===&lt;br /&gt;
&lt;br /&gt;
HLA API will be designed to access various features of ns-3-hla like initialise ns-3 Federate, Create Object, Add Attributes to Object, Accessing Attributes of Object.&lt;br /&gt;
&lt;br /&gt;
== Testing approach ==&lt;br /&gt;
&lt;br /&gt;
* Validation Test 1 (V1): Communication with other Federates (dummy)&lt;br /&gt;
* System Integration Test 1 (S1): Message Passing between ns3Federate Ambassador and ns3 link-to-rti&lt;br /&gt;
* System Integration Test 2(S2): Message Passing between RTI and ns3FederateAmbassador&lt;br /&gt;
* Unit Test 1 (U1): Checking ns3Federate (Java Sockets)&lt;br /&gt;
* Unit Test 2 (U2): Checking link-to-rti (C++ sockets) &lt;br /&gt;
* API (API1) test is to be done with the final HLA RTI API.&lt;br /&gt;
&lt;br /&gt;
= Deliverables  =&lt;br /&gt;
&lt;br /&gt;
Note: The '''bold''' text details the changes/progress from initial deliverables&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
'''New Expected Deliverables'''&lt;br /&gt;
* Synchronisation&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
	<entry>
		<id>https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6903</id>
		<title>GSOC2012HLA</title>
		<link rel="alternate" type="text/html" href="https://www.nsnam.org/mediawiki/index.php?title=GSOC2012HLA&amp;diff=6903"/>
		<updated>2012-08-19T08:19:51Z</updated>

		<summary type="html">&lt;p&gt;Muditraajgupta: /* Design */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= HLA interfaces for ns-3: Introduction =&lt;br /&gt;
&lt;br /&gt;
* Student: [mailto:mudit.raaj.gupta@gmail.com Mudit Raj Gupta]&lt;br /&gt;
* Mentors: [mailto:tpecorella@mac.com Tommaso Pecorella]&lt;br /&gt;
* Code: http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/codeRev/&lt;br /&gt;
* Mid-Term Report:https://www.nsnam.org/wiki/index.php/GSOC2012HLAMidTerm&lt;br /&gt;
* Abstract: The project deals with developing interfaces for High Level Architecture (HLA) for ns-3 project and thus enabling it to participate in a distributed simulation (Federation) involving various federates over Run Time infrastructure (RTI). The project involves three phases. Firstly, creating a Federate and Federate Ambassador for ns-3 to communicate with the RTI. Secondly, creating a synchroniser and simulator implementation that uses time from the RTI clock. Finally, creating a helper classes and modules to simplify the process of sharing and using objects in a distributed simulation. Detail proposal and initial plan can be found here [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here].&lt;br /&gt;
* About me: I'm a fourth year student presently working for my M.Sc (H) in Chemistry and B.E. (H) in Electronics and Instrumentation Engineering at Birla Institute of Technology and Science - Pilani. I am interested in modelling and simulation of complex systems, learning in multi-agent systems and evolutionary algorithms. &lt;br /&gt;
&lt;br /&gt;
= Design =&lt;br /&gt;
&lt;br /&gt;
'''HLA''' &lt;br /&gt;
&lt;br /&gt;
HLA, which is an IEEE standard, facilitates interoperability among simulations and promotes reuse of simulation models. Using HLA, a large-scale distributed simulation can be constructed by linking together a number of distributed simulation components (or federates) into an aggregate simulation (federation). [2].&lt;br /&gt;
&lt;br /&gt;
'''RTI'''&lt;br /&gt;
&lt;br /&gt;
Run-time infrastructure (RTI) is a middleware that is required when implementing the High Level Architecture. RTI is the fundamental component of HLA. It provides a set of software services that are necessary to support federates to coordinate their operations and data exchange during a runtime execution. In other sense, it is the implementation of the HLA interface specification but is not itself part of specification&lt;br /&gt;
&lt;br /&gt;
Federates can communicate to RTI through RTI ambassador. Request of a service from/to federate to/from any other federate is done through interactions. There are two basic ways to communicate:&lt;br /&gt;
&lt;br /&gt;
* Interchange messages between federates&lt;br /&gt;
* Publication of objects that are shared between federates&lt;br /&gt;
&lt;br /&gt;
poRTIco is an open-source Java implementation of the above mentioned standard and it offers libraries to implement a federate ambassador. It is an interface between the RTI and the simulator. Federates can communicate to RTI through RTI ambassador.&lt;br /&gt;
&lt;br /&gt;
'''Ns-3 HLA Model'''&lt;br /&gt;
&lt;br /&gt;
The HLA model of ns-3 can be divided into two blocks, Java Block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]) and C++ block (please see a conceptual diagram [http://www.google-melange.com/gsoc/proposal/review/google/gsoc2012/muditrajgupta/45002 here]). &lt;br /&gt;
&lt;br /&gt;
The User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.&lt;br /&gt;
&lt;br /&gt;
User Creates a script to share an object with other simulator using RTI and HLA interfaces. The first phase is to use the Rti Simulator implementation as it is responsible for synchronisation of RTI Clock with ns-3 clock. Next, use the HLA API provided in Helper to communicate with Rti and create a shared object.  &lt;br /&gt;
&lt;br /&gt;
This is how it looks on the surface. The HlaHelper talks with LinkToRti, to send the details of the object and other information through a socket and proper serialisation framework (MsgPack) to Java Block. The Synchroniser part also communicates with LinkToRti in order to receive messages from RTI.&lt;br /&gt;
	&lt;br /&gt;
The messages from C++ blocks travels to JAVA through sockets and are serialised using Message Pack, a standard tool for serialisation, de-serialisation. These are now handled by class j. This is in turn parsed and used by ns3 Federate to initialise the federate and j also is used by ns3FedAmb when it receives a call back from RTI. The two classes handles communication with RTI&lt;br /&gt;
&lt;br /&gt;
'''Java Block'''&lt;br /&gt;
&lt;br /&gt;
As it is quite clear from the diagram. The Java block communicates with the RTI. The [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3Federate.java Ns3Federate] is the class which uses the portico Java API to communicate with the portico RTI. At present the sequence of events followed by Ns-3 Federate are are follows: &lt;br /&gt;
&lt;br /&gt;
* Create Federation&lt;br /&gt;
* Join Federation&lt;br /&gt;
* Synchronise with RTI&lt;br /&gt;
* Enable Time Policies&lt;br /&gt;
* Start Signal for C++ Block&lt;br /&gt;
* Publish and Subscribe to Objects&lt;br /&gt;
* Wait for ns-3 C++ Block Time Advance Request&lt;br /&gt;
* Send Time Advance Requests To RTI&lt;br /&gt;
* Resign From Federation&lt;br /&gt;
* Destroy Federation&lt;br /&gt;
&lt;br /&gt;
The other class [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/ns3FedAmb.java Ns3FedAmb] handles Callbacks from RTI whenever an event occurs that is initiated by the other federate or RTI has to convey a request grant. The Call backs supported at present are:&lt;br /&gt;
&lt;br /&gt;
* Synchronisation (Synchronised, Registered, Failed, Ready)&lt;br /&gt;
* Time (Time Advance Request Granted, Time Policies Enabled)&lt;br /&gt;
* Object (Object Discovered, Object Attributes Changed, Object Deleted)&lt;br /&gt;
 &lt;br /&gt;
An other helper class is [http://code.nsnam.org/muditraajgupta/ns-3-dev-hla/file/528951a6288c/codeRev/src/hla/model/j.java j]&lt;br /&gt;
&lt;br /&gt;
In order to make ns-3 IEEE 1516 a new HLA compliant scheduler for ns-3 (rtiScheduler), has to be designed along with ns3FederateAmbassador.&lt;br /&gt;
&lt;br /&gt;
* 1. Ns3Federate&lt;br /&gt;
* 2. LinkToRti&lt;br /&gt;
* 3. Synchronising &lt;br /&gt;
* 4. HLA Helper&lt;br /&gt;
&lt;br /&gt;
There is a possibility of a two way communication between ns-3 and the other federates, but in the approach mentioned ns-3 is only used as a sink and not a source. This is so because in previous discussions with the mentor a conclusion was drawn that if ns-3 would also be used as a source, it will complicate things. The only-sink methodology can be extended to source and sink after GSoC, but adding it in the GSoC timeframe would be a bit over &lt;br /&gt;
ambitious. Although, it will definitely be a part of post-GSoC plans.     &lt;br /&gt;
&lt;br /&gt;
===Ns3Federate===&lt;br /&gt;
&lt;br /&gt;
It consists of basically two parts - &lt;br /&gt;
&lt;br /&gt;
* ns3Federate  &lt;br /&gt;
* ns3FedAmb&lt;br /&gt;
* JavaLink&lt;br /&gt;
&lt;br /&gt;
'''ns3Federate:'''&lt;br /&gt;
&lt;br /&gt;
It takes care of the creating a federation (if not created else joining it), registering ns3 as a Federate and running the main simulation loop. It also deals with publishing, deleting and registering objects and interaction in the RTI. &lt;br /&gt;
&lt;br /&gt;
'''ns3FedAmb'''&lt;br /&gt;
&lt;br /&gt;
This segment is also responsible for creating a port and communicating with the LinkToRti code (C++) This basically handles callbacks from the RTI. These callbacks include notification when attribute of an object is changed, new object is added/registered or deleted and when a time advance request is granted. A server – client paradigm is implemented between ns3FedAmb and link-to-rti. It is implemented by using sockets. &lt;br /&gt;
&lt;br /&gt;
===link-to-rti===&lt;br /&gt;
&lt;br /&gt;
A message server is set up and appropriate sockets are used get messages from ns3FedAmb. It also acts as an entry level module to ns3 code and links ns3Federate with HLA API. It also controls time values and maintains a RTI_CLOCK. &lt;br /&gt;
&lt;br /&gt;
===Synchronisation===&lt;br /&gt;
&lt;br /&gt;
There is still a lot of debate in the synchronisation of the RTI clock with ns-3. The present approach finalised and yet to be tested looks like making a minor change in wall-clock-syncronizer.cc by changing the GetRealTime to GetRtiTime (which fetches RTI_CLOCK value) and using the real time simulator with almost no modification. Since it will wait for an event to process till real time has been reached (i.e RTI_CLOCK is the new real time). So the function process_one_event will take care of event scheduling.    &lt;br /&gt;
&lt;br /&gt;
===HLA API===&lt;br /&gt;
&lt;br /&gt;
HLA API will be designed to access various features of ns-3-hla like initialise ns-3 Federate, Create Object, Add Attributes to Object, Accessing Attributes of Object.&lt;br /&gt;
&lt;br /&gt;
== Testing approach ==&lt;br /&gt;
&lt;br /&gt;
* Validation Test 1 (V1): Communication with other Federates (dummy)&lt;br /&gt;
* System Integration Test 1 (S1): Message Passing between ns3Federate Ambassador and ns3 link-to-rti&lt;br /&gt;
* System Integration Test 2(S2): Message Passing between RTI and ns3FederateAmbassador&lt;br /&gt;
* Unit Test 1 (U1): Checking ns3Federate (Java Sockets)&lt;br /&gt;
* Unit Test 2 (U2): Checking link-to-rti (C++ sockets) &lt;br /&gt;
* API (API1) test is to be done with the final HLA RTI API.&lt;br /&gt;
&lt;br /&gt;
= Deliverables  =&lt;br /&gt;
&lt;br /&gt;
Note: The '''bold''' text details the changes/progress from initial deliverables&lt;br /&gt;
&lt;br /&gt;
* 1.0 rtiScheduler ('''renamed link-to-rti''')&lt;br /&gt;
**1.1 The class will be the sub class of the base class ns3::Scheduler and all virtual functions defined would be written like – Insert, PeakNext, IsEmpty, Remove, Remove. Activating a thread responsible to receive messages from the ns3FederateAmbassador and uses them appropriately. ('''chucked''')&lt;br /&gt;
**1.2 Setting up a message server and using appropriate sockets to get messages from ns3FederateAmbassador('''Done''')&lt;br /&gt;
**1.3 Handling/decoding messages received ('''Done''')&lt;br /&gt;
**1.4 Generating and Sending Time advance Request and taking proper action on the request being granted from the RTI. ('''Done''') &lt;br /&gt;
&lt;br /&gt;
* 2.0 ns3FederateAmbassador ('''Ns3Federate''') &lt;br /&gt;
**2.1 Define socket communication with link-to-rti ('''Done''')&lt;br /&gt;
**2.2 Define Semantics for other federates to send message to ns-3 ('''Done''')&lt;br /&gt;
**2.3 Define ambassador for ns3 according to poRTIco definition and adding various functions to interface with poRTIco to receive messages and send request and various other functions  ('''Done''')&lt;br /&gt;
**2.4 Integrate all the above classes and write a test code to run the ns3FederateAmbassador. ('''Done''')&lt;br /&gt;
&lt;br /&gt;
* 3.0 HLA API&lt;br /&gt;
**3.1 Writing the Informer function and update HLA class ('''Done, link-to-rti has functions to make it similar to informer''')&lt;br /&gt;
**3.2 Writing HLA API for the designed system&lt;br /&gt;
&lt;br /&gt;
* 4.0 Complex Network Simulation&lt;br /&gt;
**4.1 Writing a demo model which is HLA compliant ('''Done, created dummy federate''')&lt;br /&gt;
**4.2 Writing a ns3 model which is HLA compliant and using both simultaneously &lt;br /&gt;
&lt;br /&gt;
* 0.0  If time permits/future plans (post GSoC)&lt;br /&gt;
**0.1 Adding the possibility of object publication and sharing in the existing code and integrating it. ('''Done, publishing objects''')&lt;br /&gt;
**0.2 Addition of a functionality in which ns-3 will also be used as a source. &lt;br /&gt;
**0.3 Making more refined and complex model in which ns-3 will be a federate.&lt;br /&gt;
&lt;br /&gt;
'''New Expected Deliverables'''&lt;br /&gt;
* Synchronisation&lt;br /&gt;
&lt;br /&gt;
= Usage = &lt;br /&gt;
&lt;br /&gt;
= Weekly Progress =&lt;br /&gt;
&lt;br /&gt;
* '''Week 1 : May.21 -- May.27'''&lt;br /&gt;
 * Read Code related to Scheduler and various implementations like Map Scheduler and List Scheduler&lt;br /&gt;
 * Started Coding on RTI Scheduler, implemented basic functions (similar to Map Scheduler)&lt;br /&gt;
 * Read about MessagePack Message Format.&lt;br /&gt;
&lt;br /&gt;
* '''Week 2 : May.28 -- Jun.03'''&lt;br /&gt;
 * Changed the default scheduler from map to list and finally rti by small changes in simulator.cc&lt;br /&gt;
 * Modified map-scheduler and wrote a basic rti-scheduler.cc and rti-scheduler.h implementing scheduler.cc it is basic skeleton for implementing thread for handling RTI request. Tried making thread in the class, some problems.&lt;br /&gt;
 * Tested. Discussed progress with the mentor and figured out a flaw in design.&lt;br /&gt;
 * no scheduler required, last 10 days work not so useful. &lt;br /&gt;
 * Finalised a new design started working fresh. &lt;br /&gt;
     &lt;br /&gt;
* '''Week 3 : Jun.4  -- Jun.10''' &lt;br /&gt;
 * Installed portico and ran demo programs in JAVA&lt;br /&gt;
 * Tested with multiple federates, wrote a simple dummy federate. &lt;br /&gt;
 &lt;br /&gt;
*''' Week 4 : Jun.11 -- Jun.17'''&lt;br /&gt;
 * Completed work on writing ns3Federate and ns3FederateAmbassador in JAVA using portico&lt;br /&gt;
 * Added functionality to dummy by sharing object between the two federates and changing attributes&lt;br /&gt;
 * Wrote a test for checking socket implementation &lt;br /&gt;
 &lt;br /&gt;
* '''Week 5 : Jun.18 -- Jun.24'''&lt;br /&gt;
 * Integrating the server code to one of the NS3 examples.&lt;br /&gt;
 * Tested and debugged of the entire code. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 6 : Jun.25 -- Jul.01'''&lt;br /&gt;
 * Completed work on writing a C++ code for reading socket values&lt;br /&gt;
 * Completed work on integrating the above code with link-to-rti and decoding messages&lt;br /&gt;
 * Completed '''deliverable 1.2 and 1.3'''&lt;br /&gt;
&lt;br /&gt;
* '''Week 7 : Jul.02 -- Jul.08''' &lt;br /&gt;
 * Migrated code repo from code.google.com to code.nsnam.org&lt;br /&gt;
 * Time advance request handled and wrote various functions to decode the RTI messages&lt;br /&gt;
 * Created various functions to start simulation, stop simulation and RTI_CLOCK&lt;br /&gt;
 &lt;br /&gt;
* '''Week 8 : Jul.09 -- Jul.15''' &lt;br /&gt;
 * Finding and designing  the best way to synchronise ns-3 with RTI &lt;br /&gt;
 * Read about JNI basics&lt;br /&gt;
 &lt;br /&gt;
* '''Week 9 : Jul.16 -- Jul.22''' &lt;br /&gt;
 * Modified realtime-simulator-impl to schedule events according to RTI time and send time advance requests.&lt;br /&gt;
 * Modified wall-clock-syncronizer to fetch RTI time.&lt;br /&gt;
 * Tested the new implementation and synchronisation. &lt;br /&gt;
 * Designed the basic API&lt;br /&gt;
&lt;br /&gt;
* '''Week 10 : Jul.23 -- Jul.29''' &lt;br /&gt;
 * Started working on the HLA API, some issues to be discussed with the mentor.&lt;br /&gt;
 * Started working on hla-interface, it creates an object and add attributes to the attributes vector which is published by and modified by other federates&lt;br /&gt;
 * Created an example (not completely working), just to have an idea ho create various components of the API&lt;br /&gt;
 * Read about callbacks in ns-3 and Mobility. &lt;br /&gt;
 &lt;br /&gt;
* '''Week 11 : Jul.30 -- Aug.6''' &lt;br /&gt;
 * Read documentation about Mobility model&lt;br /&gt;
 * Tried an alternate RTI - CERTI, downloaded, build and tried a few example&lt;br /&gt;
 * Tried using the C++ API of portico&lt;br /&gt;
 * Read through and tried a few xmlparsers and MessagePack&lt;br /&gt;
 * Further modified the design of the API&lt;br /&gt;
&lt;br /&gt;
* '''Week 12 : Aug.7 -- Aug.12''' &lt;br /&gt;
 * Finally went with portico and JAVA API&lt;br /&gt;
 * Read and implemented msgpack for serialisation  &lt;br /&gt;
 * Designed the basic API (Helper)&lt;br /&gt;
&lt;br /&gt;
* '''Week 13 : Aug.13 -- Aug.19''' &lt;br /&gt;
 * Cleaning Code&lt;br /&gt;
 * Completing documentation&lt;br /&gt;
 * Preparing code for review&lt;br /&gt;
&lt;br /&gt;
= References =&lt;br /&gt;
&lt;br /&gt;
* [1] http://www.cs.bham.ac.uk/research/projects/hlarepast/&lt;br /&gt;
* [2] Distributed Repast Agent Based Simulation with HLA - R. Minson and G. K. Theodoropoulos, CONCURRENCY AND COMPUTATION: PRACTICE AND EXPERIENCE&lt;br /&gt;
* [3] Large Scale Agent Based Simulation on the Grid - Dan Chena , Georgios K. Theodoropoulos, Stephen J. Turner, Wentong Cai, Robert Minson, Future Generation Computer Systems, 24 (2008), 658-51&lt;br /&gt;
* [4] MobileOnRealEnvironment-GIS: a federated mobile network simulator of mobile nodes on real geographic data- Emiliano Casalicchio, Emanuele Galli and Vittorio Ottaviani Dipartimento di Informatica, Sistemi e Produzione (DISP), 2009 13th IEEE/ACM International Symposium on Distributed Simulation and Real Time Applications&lt;br /&gt;
* [5] http://porticoproject.org/index.php?title=Main_Page&lt;br /&gt;
* [6] http://msgpack.org/&lt;/div&gt;</summary>
		<author><name>Muditraajgupta</name></author>
	</entry>
</feed>