0% found this document useful (0 votes)
53 views7 pages

EEET2368 - Lab 5 Guidelines (Week 9)

Lab 5 focuses on understanding the ALOHA protocol and creating a simulator using MATLAB. The lab includes instructions for simulating both pure and slotted ALOHA, analyzing traffic, and comparing simulated throughput with theoretical values. Students are required to document their findings and include MATLAB code in their lab reports.

Uploaded by

himishamohta2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views7 pages

EEET2368 - Lab 5 Guidelines (Week 9)

Lab 5 focuses on understanding the ALOHA protocol and creating a simulator using MATLAB. The lab includes instructions for simulating both pure and slotted ALOHA, analyzing traffic, and comparing simulated throughput with theoretical values. Students are required to document their findings and include MATLAB code in their lab reports.

Uploaded by

himishamohta2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

EEET2368 Network Fundamentals and Applications

Lab 5: ALOHA

Prepared by: Dr. Akram Al-Hourani


Dr. Karina Gomez Chavez

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.

EEET2368 Network Fundamental and Applications, RMIT University Page 1 of 7


Figure 1 ALOHA basic layout

Question 1: Why does the waiting time to retransmit must be random?


Question 2: A snapshot of a possible traffic generated from 5 stations is shown below in Figure
2, identify the packets that are undergoing interference.

Figure 2 Traffic generated by 5 stations

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,
𝑆 𝐺𝑒 ,

where the throughput 𝑆 is measured in [successful packets / packet-interval]. The loading 𝐺


represent the intensity of the total traffic (successful and corrupted) arriving at the central
computer measured in [packets / packet-interval].

EEET2368 Network Fundamental and Applications, RMIT University Page 2 of 7


Question 3: Explain how to maximize the efficiency of the system, what is the highest possible
throughput in slotted ALOHA?, elaborate your answer.

The aim of this lab is to create our own ALOHA simulator using simple MATLAB commands,
as per the following methodology.

Methodology: Slotted ALOHA Simulator


We will quickly recall how to use Matlab. You will need first to locate Matlab on your machine,
if Matlab is not available on your local machine, you can use mydesktop cloud service from
http://mydesktop.rmit.edu.au/ (you can use any version of Matlab). The below figure (Figure
3) shows the basic environment of Matlab.
 Start by creating a new script from the Home tab.
 Start your script by clearing the current variables in the work space and cleaning the
command line:

clc %Cleans the command line


clear %Wipes the memory
close all %Closes all open figures

Figure 3 Matlab environment

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.

EEET2368 Network Fundamental and Applications, RMIT University Page 3 of 7


Imagine a node that tosses a coin at every tick, if it gets a face it transmits a packet otherwise
it keeps silent. Now imagine that the coin is biased (it is not 50%-50%), with some
probability 𝑝. Accordingly, the probability that a node will transmit in a given tick is 𝑝.

We will start by generating random packets by using the following command:

p=0.1; %Single node traffic intensity


x=rand(1,100)<p; %This logical vector will hold the traffic

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.

Figure 4 Traffic generated from a single packet

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.

N=4; %Nodes number


G=1.0; %Total traffic intensity
p=G/N; %Traffic intensity per node
Tics=100; %The number or clock ticks to simulate
x=rand(N,Tics)<p; %This vector will hold the traffic

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)

EEET2368 Network Fundamental and Applications, RMIT University Page 4 of 7


Hint
- Use the code stem(x(ctr,:)) to access the individual rows of the
matrix, where ctr is the loop counter.
- Use the code ylim([0.1 1.5]) to better visualize the stem plot and
to get rid of the zeros

Figure 5 The traffic of ALOHA’s 4 nodes

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.

Figure 6 The traffic matrix as received by the central computer

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,

Rx = sum(x); %This perform column-wise summation


Collision = Rx>1; %A value greater than one means a collision
Success = Rx==1; %A value equal to one means a node is successful
stem(Collision,'r',’fill’); %This will plot the collisions in red
hold on
stem(Success );
ylim([0.1 1.5]);

The above code will plot the collisions in red color and overlay the success traffic in blue
color.

EEET2368 Network Fundamental and Applications, RMIT University Page 5 of 7


Question 6: Add the overall traffic stem plot to your previous figure so the individual and
overall traffic will look like Figure 5. Export your figure and include it in your report.

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,

S = sum(Success)/Tics %Will give the throughput of the system

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

Save your current script as s000000_Lab05_Code1.m


Question 8 Insure that you include the final code in your report as Code 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

clc %Cleans the command line


clear %Wipes the memory
close all %Closes all open figure

%% Traffic of multiple nodes


G=0:0.1:3; %Total traffic intensity
N=50; %Nodes number
Tics=10000; %The number or clock ticks to simulate

%%
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

EEET2368 Network Fundamental and Applications, RMIT University Page 6 of 7


S_theoretical = G.*exp(-G);
plot(G,S_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

---------------------------------------- end of LAB 5 ----------------------------------------

EEET2368 Network Fundamental and Applications, RMIT University Page 7 of 7

You might also like