NetSwap - 5. Implementation
5.5 Problems and Restrictions of NS-2
5.5.1 Timer
As NS-2 is a discrete simulator it means that it has its own timers independent
of the timers on the machine it is running on. Therefore it has its own set of
routines and functions to access and utilise the time during the running of a
simulation.
Timers can be implemented in both C++ code and in Tcl scripts, they are most
often used in agents, but the framework is general enough to be used by other
objects.
The use of timers was initially needed in the interface polling process of the
NetSwap driver, the idea being a poll packet is sent out to an interface and a
timer is set (for example 3 seconds) and if the poll reply came back within the
time set the poll was successful, otherwise failed.
Each time a timer was implemented it would throw a ?Segmentation Fault? at the
point where a poll packet reached its destined interface node. This was a
strange error, and the only explanation for this could be to do with the fact
that the timer was initialised inside an object, which in this case is a NetSwap
agent, and when this agent object gets deleted, so too does the timer, after its
packets are finished with.

After many failed attempts at getting a timer to successfully expire without the
fault, it was decided to implement a different solution as seen in the code
above.
5.5.2 Addressing Scheme
It was very surprising to find that NS-2 did not support 16-bit
IP addresses (e.g. 192.168.0.56) as standard in its nodes; instead each node is
simply numbered in sequence order with integer numbers (e.g. 3). This did not
cause a problem in implementing the NetSwap agents but it would have been
preferable to have had a hierarchical routing system and to be able to assign
subnet ranges.
It was later found that NS-2 does have prevision for 16-bit IP addresses, but by
this time the NetSwap solution had already progressed on the default addressing
scheme.
5.5.4 GPRS Patch
A GPRS patch has been implemented by Richa Jain at IITB, which
claims to include to ability add GPRS features to wireless nodes, so far the
patch supports, mobile node to base station interactions.
The focus is on handling of the radio resources and on the network stack i.e.
the Link Layer (LL), the Radio Link Control (RLC) and the Medium Access Control
(MAC) (channels, TDMA slot structure, pkt tx and rx, call set-up and handling,
slot handling, collisions, error model, handling ARPS) operating between the
mobile node and the base station. [ISI04]
The problem with the GPRS patch is that it is not yet completed, and as a result
it is very hard to install, and does not allow the user to create simulations
which use GPRS as well as other wireless protocols such as WiFi, therefore it is
not of much use in this project. Another problem is that it will only work on an
older version of NS-2 (against NS 2.1b7a)