GTNS is a discrete-event network simulator targeted primarily for research and educational use.
GTNS is written in Visual C++ programming language and supports different network topologies. This simulator was first produced to implement locally multipath adaptive routing (LMAR) protocol, classified as a new reactive distance vector routing protocol for MANETs. LMAR can find an ad-hoc path without selfish nodes and wormholes using an exhaustive search algorithm in polynomial time. Also when the primary path fails, it discovers an alternative safe path if network graph remains connected after eliminating selfish/malicious nodes. The key feature of LMAR to seek safe route free of selfish and malicious nodes in polynomial time is its searching algorithm and flooding stage that its generated traffic is equi-loaded compared to single-path routing protocols but its security efficiency to bypass the attacks is much better than the other multi-path routing protocols. LMAR concept is introduced to provide the security feature known as availability and a simulator has been developed to analyze its behavior in complex network environments . Then we have added detection mechanism to the simulator, which can detect selfish nodes in network. The proposed algorithm is resilient against collision and can be used in networks which wireless nodes use directional antennas and it also defend against an attack that malicious nodes try to break communications by relaying the packets in a specific direction. Some game theoretic strategies to enforce cooperation in network have been implemented in GTNS, for example Forwarding-Ratio Strategy, TFT-Strategy and ERTFT. This tutorial helps new users to get familiar with GTNS and run different network scenarios.
Getting Started with GTNS:
After debugging GTNS simulator you can see the following window:
Figure 1- GTNS simulator environment
To implement your own network you can click on Network-Router as you can see in figure 2 and 3 you can add one node by clicking on add button, or you can add different number of nodes, randomly placed over screen by clicking the Self-Generate button. In figure 4 you can see a sample network topology created by adding 5 nodes to the network. You can change the default preferences of node by clicking on Default Preferences button, or you can change different parameters of any node in the network by clicking on that node in the screen. Any node in the network can be deleted or you can change its parameters during simulation or you can force it as a selfish node. Figure 5 shows different parameters of nodes that can be changed. You can change the router's caption, its coverage range, delay, X_axis and Y_axis of the router in the screen, the length and width of router image and battery power of any router can be changed in the network.
Figure 2- Network-Router button
Figure 3- Network-Router-Self-Generate button
Figure 4- A sample of network topology created by adding 5 nodes in GTNS environment
Figure 5- Editing node parameters by clicking on any node on the screen
Creating Links between nodes in GTNS:
As it is seen in figure 6 you can add links between nodes by clicking on Network-Link-Self-Generate button. All nodes which are in the coverage range of each other will be connected with a full-duplex link.
You can also add links between any two nodes in network by clicking on Network-Link-Add. Figure 7 shows different parameters that can be changed by clicking this button. You can select two routers that you want to make a link between them and frequency and duplicity of the link. You can add wormhole links between any two nodes by creating links between nodes which are not in the coverage range of each other. During simulation you can add or delete a specific link between any two nodes in network.
Figure 8 shows a sample topology created by using Link-Self-Generate button.
Figure 6- Adding links between nodes in GTNS simulator
Figure 7- Different parameters that can be changed by clicking Link-Add button
Figure 8- A sample network created by adding self-generate links between 10 nodes in GTNS
Adding Traffic to network:
As you see from figure 9, you can add traffic between any two nodes in network by clicking Network-Traffic-Add. Figure 10 shows different parameters that you can change when you want to add traffic between any two source and destination node in network. You can select routing protocol and start time of traffic sparks.
Figure 9- Adding traffic to the network
In GTNS you can add random traffic to network. Figure 11 shows the window when you click on Network-Traffic-Self-Generate-Ad-hoc. You can select the starting and stopping time of random traffic generated, and number of connections during this interval. Data traffic rate and different protocols can be selected in this window.
Figure 10- different parameters that can be changed during adding traffic between any two nodes
Figure 11- Different parameters that can be selected by adding random traffic in network
Simulation in GTNS:
To simulate the network created in GTNS, you should click on Simulation-Profile button as you can see in figure 12. Then the Simulation window will be opened where you can see the clock and view events. Figure 13 shows Simulation window. You can also change the speed of simulation by moving Master and slave speed buttons.
By clicking on Resume button you can run the simulation and see different packet exchange in network.
For example we have created one connection between node 1 and 64. After clicking Resume button node 1 will broadcast RReq packets. Figure 14 shows broadcasting of RReq packets, when RReq passes a link, it will become blue. When the first RReq packet reaches to destination, node 64 will broadcast RRep packets. Figure 15 shows broadcasting of RRep packets. Links become yellow when RRep packets pass them.
Figure 12- A sample grid network topology and simulation button in GTNS
Figure 13- Simulation-Profile window
Figure 14- A sample grid network topology and broadcasting of RReq packets
Figure 15- A sample grid network topology and broadcasting of RRep packets
Afterwards node 1 sends the traffic towards node 64 by choosing the shortest path in its routing table. The intermediate nodes send the traffic towards their first index entry, the best path. The purple line in Figure 16 shows the forwarding path from the source to the destination (this line is overwritten by the return path of ACK packet). The ACK packet traverses the reverse path (the green line) back to the source, as the intermediate nodes set the reverse hop back to the source in their routing tables. So the green line of reverse path over-color the purple line of forwarding path.
Figure 16: Established connection with the shortest path
You can see different statistic results of the simulation by clicking on Simulation-Statistic button as shown in figure 17. Figure 18 shows the Statistics window opened when you click on this button. You can see different parameters of network. For example you can see number of data packets that have been forwarded by intermediate nodes in Data Trans. No, you can see number of forwarded RReq and RRep packets in the fields RReq Trans. No and RRep Trans. No respectively. Also number of data packets and number of Ack packets generated during simulation are shown in Gen. Data No. CN and Gen. Ack No. CN. Number of established connections and total power of network after simulation and number of ad-hoc nodes and selfish nodes of type 1 and 2 and clock of the system is shown in this window.
Also after clicking on Simulation-Statistics button, the results of simulation will be saved in my_file.txt file. An example of this file and simulation results of some simulations are shown in figure 19.
Figure 17- Simulation-Statistics button in GTNS
Figure 18- The Statistics window which shows the simulation results created in GTNS
Figure 19- Simulation results written in my_file.txt in GTNS
 F. Farhat, M. R. Pakravan, M. Salmasizadeh, M. R. Aref, "Locally Multipath Adaptive Routing Protocol Resilient to Selfishness and Wormholes", ISPEC 2010: 187-200.