Algorithm 1: Fault Injector - A random function.
1: Begin.
2: randomTime ← randomGenerator(seed);
3: NewRandomEvent ← faultInjector(frameToCorrupt);
4: Scheduler.schedule(NewRandomEvent,randomTime);
5: CorruptNode.Update();
6: End.
scribed in line 2. A new eventis created and the action
associated with it is a frame corruption performed by
the fault injector as indicated in line 3. Finally the
NewRandomEvent which will perform the corruption
is inserted in the NS-2 scheduler and executed at the
defined instant as in line 4. An information about the
corruption occurred in a specific node is recorded as
described in line 5.
The fault injector achieves the frame corruption
as described in Algorithm:2, accessing the command
header of the frame as represented in line 5, and
changing a bit in the frame content, implying the drop
of these frames in the MAC level of the receiving
nodes. When the frame is received if the fault in-
jector is active, we can decide if a specific frame is
affected or any frame that a node receives will be
corrupted. The parameter frameToCorrupt repre-
sented on line 3 is previously defined and if desired
all the received frames can be affected defining the
frameToCorrupt to a specific value. An informa-
tion about the corruption occurred in a specific node
is recorded as described in line 6. This information
is used for a better control of the simulation events.
The fault injection may be performed in the coordi-
nator, which implies, depending on the type of frame
affected, that the whole network may be inaccessible,
in the specific case of affecting a MAC control frame.
In case we decide to affect a MAC control frame, af-
fecting specific network points, the fault injection can
be performed for example at non-coordinator nodes
tracking the reception of beacon frames. In the spe-
cific case, when we perform corruption in a MAC
control frame such as the beacon in the coordinator,
none of the nodes receives the beacon and therefore
the whole network will be inaccessible. Otherwise,
when the corruption is performed in the nodes that
should receive beacon frames, only the node that has
the fault injector component activated, i.e. beacon
corruptions occurring, cannot access the medium and
becomes inaccessible. The corruption of the frames
can be disabled, through the deactivation of the fault
injector on the tcl script, and the normal behaviour of
the network restored at any time.
6.2 Temporal Analysis Component
The temporal analysis component was designed to
Algorithm 2: Fault Injector Mechanism.
1: Begin.
2: MAC.Receive( f rame);
3: if f rame = frameToCorrupt then
4: for selected Fault Pattern do
5: CommandHeader( frame)− > error() = 1;
6: CorruptNode.Update();
7: end for
8: end if
9: End.
measure the temporal aspects of received frames,
from their duration to the effects of frames received
with errors during the network operation. In this pa-
per, we instrumented the temporal analysis compo-
nent to measure network inaccessibility events. As
the occurrence of network inaccessibility is related
with the MAC control frames (e.g., beacons), this
component was configured to monitor and capture in-
formation about such kind of frames.
Let us present an example to characterise how the
temporal analysis component works. We use the bea-
con frame as the frame to be monitored in such exam-
ple. When the received beacon is corrupted, the tem-
poral analysis component starts a timer to account the
related network inaccessibility period. When a new
beacon is received successfully, the timer is stopped
and the duration of such period is registered.
When the simulation is finished, the temporal
analysis component generates a report, regarding all
events captured during the simulation. The report is
utilised as input to a gnuplot script, which transform
the raw data within the report to a graphical represen-
tation of the captured events.
7 SIMULATING
INACCESSIBILITY
SCENARIOS
The simulation is defined in an OTcl script (Listing:1)
and is carried out in an one-hop star topology, where
all the nodes are within the range of each other.
In the script (Listing:1) we define that the first
node to start was the coordinator, specifying the val-
ues of its BO and SO in line 1. After the WnS is es-
tablished we start the nodes in line 2. Our temporal
analysis component is enabled on line 3, given the se-
lected scenario. The periodic beacon transmission is
initiated at the coordinator on line 4, taking the BO
and SO as arguments. At line 5 we enable the GTS
transmission for the node(1), which means that each
time this node have data to transmit will use the GTS
mechanism. Finally, at line 6 we start our fault injec-
ImprovingNS-2NetworkSimulatortoEvaluateIEEE802.15.4WirelessNetworksUnderErrorConditions
217