EEET2368 - Lab 5 Guidelines (Week 9)
EEET2368 - Lab 5 Guidelines (Week 9)
Lab 5: ALOHA
Lab 5 Objectives
The objective of lab 5 is to:
Understand ALOHA in depth
Create an ALOHA simulator from scratch
Verify the simulator according to ALOHA theoretical throughput
Lab 5 Instructions
Read the materials in this manual carefully
There are questions as you go through the materials. Make sure that you answer these
questions in your lab report
Include MATLAB results and codes in your lab report
Make sure to label the figures and to annotate your code
This LAB report is group-based
Make sure that you perform this lab from scratch. It is not allowed to use a
pre-saved file from a colleague.
This lab will run over one session
Part 1 ALOHA
Background: ALOHA Protocol
The story of our first MAC starts out in Hawaii in the early 1970s. Some areas did not have
working telephone system. This did not make life more pleasant for researchers and engineers
in University of Hawaii who were trying to connect users on remote islands to the main
computer in Honolulu, see Figure 1. Stringing their own cables under the Pacific Ocean was
not in the cards, so they looked for a different solution and decided to use wireless
communication. And thus, ALOHA protocol was born. Remember from the lecture that there
are two types of ALOHA: pure and slotted. They differ with respect to whether time is
continuous, as in the pure version. Or divided into discrete slots into which all frames must fit,
as in slotted ALOHA.
The basic idea of pure ALOHA system is simple: let users transmit whenever they have data
to be sent. There will be collisions, of course, and the colliding frames will be damaged.
Senders need some way to find out if this is the case. In the ALOHA system, after each station
has sent its frame to the central computer, this computer rebroadcasts the frame to all of the
stations. A sending station can thus listen for the broadcast from the hub to see if its frame has
gotten through. If the frame was destroyed, the sender just waits a random amount of time and
sends it again.
Slotted ALOHA
As we saw in the lecture the throughput of pure ALOHA is quite low. Thus, slotted ALOHA
was introduced to increase the throughput. The slotted approach requires the users to agree on
slot boundaries. One way to achieve synchronization would be to have one special station emit
a tick at the start of each interval, like a clock. The throughput of slotted ALOHA is given by,
𝑆 𝐺𝑒 ,
The aim of this lab is to create our own ALOHA simulator using simple MATLAB commands,
as per the following methodology.
We are going to start by simulating a random traffic generated from a single ALOHA node.
Remember that in slotted ALOHA users are only allowed to transmit when the central
server’s clock ticks.
The will create a vector of length 100 with zeros and ones insides it (called a logical vector).
These zeros and ones represents the following:
o “1” packet is transmitted
o “0” no packet
Question 4: Visualize the vector using stem plotting and export the figure. Use proper
labelling for the x-axis and y-axis. You should get something like the plot in Figure 4.
Demonstrate the result to your lab tutor.
Now we will proceed by creating 4 remote nodes. A good practice is to make your code
scalable, that is, rather than creating the nodes using fixed names x1, x2, x3,x4, you can use a
matrix or cell form.
In the matrix form, the raw will represent your node ID (1,2,3,4) and the column will
represent the packet availability.
Note that the total traffic intensity 𝐺 is distributed equally among the users, where each user
is assumed to have a traffic intensity 𝑝 𝐺/𝑁. The total number of users is assumed to be
𝑁 4
Question 5: Visualize the traffic of all users using stem and subplot. Use a loop to plot the
traffic of the users. Identify when collisions are occurring? Your graph should look similar to
Figure 5 showing the traffic of Nodes 1,2 and 4 (we will plot the Received traffic later)
As we have obtained a good insight on how the traffic looks like, we would need now to
obtain the traffic as received by the central server. Since the matrix 𝑥 contains the traffic,
we need to find a way to detect the collisions. Have a look on the matrix in Figure 6 and give
a thought how to detect the collisions.
One way of detecting collisions (in the simulator, not in real life) is by summing the columns
and see if the summation exceeds 1 then we have a collision, check the below code,
The above code will plot the collisions in red color and overlay the success traffic in blue
color.
The most important metric of the system is the total number of successful packets with
respect to the total ticks. This should represent the system throughput 𝑆. In order to obtain
this, we need to count the number of ones in the Success vector,
Question 7 Increase the number of the simulated ticks to 10000 and run your script for
several times, record the throughput in each time and obtain the average ?
Compare this value to the theoretical value of 𝑆 that we get for loading of 𝐺 1
As we have learned from the lecture, that the theoretical throughput of ALOHA system is
given by, 𝑆 𝐺 𝑒 . In the following last step, we want to verify if our simulator matches
with the theoretical performance.
Start a new script and copy the below code and run it.
This code will gradually increase the traffic loading 𝐺 between 0 and 3 in steps of 0.1, and it
will obtain the simulated throughput 𝑆 . The second part of the code compares the simulated
throughput with the corresponding theoretical value. The result should look similar to the plot
in Figure 7
%%
for ctr1=1:length(G)
p=G(ctr1)/N; %Traffic intensity per node
x=rand(N,Tics)<p; %This vector will hold the traffic
%% The received traffic
Rx = sum(x); %This perform column-wise summation
Collision = Rx>1; %A value greater than one means collision
Success = Rx==1; %A value equal to one means a node is successful
S(ctr1) = sum(Success)/Tics; %Will give the throughput of the system
end
plot(G,S,'s');
hold on;
%% Theoretical
Spend the remaining time of the lab session studying the code carefully, you should have
already written a very similar code in your first script (Code 1).
Question 9: Add proper labels and legend to your plot and export your figure to your report.
Also save the final script as s000000_Lab05_Code2.m
Question 10: Reflect on the provided code and the simulation results.
Figure 7 A comparison between the simulated and theoretical performance of slotted ALOHA protocol
Question 11 Insure that you include the final code in your report as Code 2
Congratulations!! know you should know how to create your own ALOHA simulator