-----------------------------------
Alohasim
-----------------------------------
Alohasim is a time-driven simulator of shared access to a communication channel with pure and slotted Aloha protocol written in C. The networked terminals transmit packets randomly, at any time (pure Aloha) or at time intervals multiple of the duration of a packet (Slotted Aloha). It can simulate the presence of a digipeater which retransmits the intact packets it receives on the same channel. When the digipeater repeats a packet, the terminal stations do not transmit.
Alohasim is released under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version, and is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
The transmission channel is simulated by an
array of integers having a number of elements equal to the duration of the
simulation. Each bit, except the most significant one, is
associated with a terminal of the network; the most significant bit is
reserved for the digipeater, if present. When a terminal on the
network transmits, the corresponding bit of the current time slot and of
the subsequent time slots occupied by the packet are set to 1 with a
logical OR, and the traffic counter is incremented. If the
simulation is of the "pure Aloha" type, the transmission of each terminal
can start at any time. The situation described is illustrated by the
following figure, which represents the content of the array during a "pure
Aloha" simulation:
If the simulation operates in "Slotted aloha" mode, the start of transmission can only take place at precise moments in time, multiples of the duration of a packet.
When the digipeater is activated, each valid packet is immediately repeated. During the repetition the transmission of the terminals is inhibited.
The throughput check is done by analyzing the previous time slots; if there is only one packet in the PACLEN previous time slots (being PACLEN the duration of a packet expressed in time slots), the throughput counter is incremented. To avoid incorrect counts when a station issues two valid packets in succession, valid packets are deleted from the array immediately after being detected (the situation is not shown in the previous figures).
The simulation is repeated with increasing
transmission rate. At each step, normalized traffic and normalized
throughput are recorded and printed on the screen.
At the end of the simulation, if requested, the result can be exported in
graphic form (graph of the normalized throughput as a function of
normalized traffic) and/or in a CSV file. The graphic output
consists of an image file in "xbm" format (monochrome, 512x512 pixels),
which can be viewed and converted to other formats using external
conversion software (eg The GIMP). The CSV file uses the
semicolon ";" as a separator, and can be read by the most common
spreadsheets.
It is possible to set the following simulation parameters by changing them
in the source file and recompiling it:
The duration of the simulation, by varying
the DURATION parameter;
The length of a packet, by varying the PACLEN parameter;
The number of terminals connected to the shared channel, by varying the
BITS parameter;
The maximum transmission rate, by varying the MAXRATE parameter.
The higher the DURATION, PACLEN and BITS values the more accurate the simulation, but the more time and computational resources are required.
The simulation parameters are currently set as follows:
DURATION 524287
PACLEN 32
BITS 32
MAXRATE 255
The current settings ensure an accurate result, at the expense of simulation duration and computational resources.
An acceptable result which requires less computing resources can be obtained by setting the parameters in the source file as follows:
DURATION 131071
PACLEN 16
BITS 24
MAXRATE 255
and then by recompiling the source code and
running the simulation.
The results of the simulations are reported below (normalized throughput as a function of normalized traffic). The theoretical reference curves are also shown on each graph. The theoretical curves without digipeater in the two cases "pure Aloha" and "Slotted Aloha" are those foreseen by the theory; the curves in the two cases with the digipeater are obtained from the previous ones by applying the "renormalization" procedure described in the paragraph 3.1 "An APRS network with a single isofrequency digipeater" of the document "APRS Performance and limits" published on this site.
Pure Aloha without digipeater
The simulation result is in excellent agreement with the theoretical curve s = G * exp (-2G), which provides for a maximum throughput of 18.4% in correspondence with normalized traffic G equal to 50% of the transmission channel capacity.
Slotted Aloha without digipeater
Also in this case the simulation result is in excellent agreement with the theoretical curve s = G * exp (-G), which provides for a maximum throughput equal to 36.8% in correspondence with a normalized traffic G equal to 100% of the transmission channel capacity.
Pure Aloha with digipeater
The simulation result confirms the reduced
impact of the digipeater in the case of access to the shared channel with
pure Aloha protocol, in accordance with the provisions of paragraph 3.1
"An APRS network with a single isofrequency digipeater" of the document
"APRS Performance and limits" (maximum normalized throughput equal to
15.5% corresponding to a normalized traffic equal to 42.2% of the
transmission channel capacity).
The presence of the digipeater in fact involves a reduction of the overall
throughput by only 3 percentage points (-3%) in correspondence with an
overall traffic just below that expected for pure Aloha (-8%).
Slotted Aloha with digipeater
The simulation, in this case, shows that the impact of the digipeater is more significant than in the case of slotted Aloha without the repeater, resulting in a reduction of the maximum normalized throughput by 10% compared to Slotted Aloha access without digipeater. Also the corresponding normalized traffic is strongly reduced (-30%).
Here is the link to the source code: alohasim.c
You can easily compile the source code for your platform with a C compiler. The source code is written in plain C, no extra libraries or header files are required. Popular free compilers you can use are MinGW for Windows platforms and gcc for Linux and Mac OS X.
And here are the links to the previous images in "xbm" format:
Pure aloha without digipeater: alohasim-p-n.xbm
Slotted aloha without digipeater: alohasim-s-n.xbm
Pure aloha with digipeater: alohasim-p-y.xbm
Slotted aloha with digipeater: alohasim-s-y.xbm
The main menu: starting the simulation
End of the simulation