Demonstrates the slot efficiency of the slotted ALOHA protocol.
- Nodes transimit new packets according to a Poisson process and retransmit packets after some random time if collision is detected
- Time is slotted, and a packet can only be transmitted at the beginning of the slot
- After transmitting a packet, the node transmits a new packet after a random time offset, regardless of whether the transmission was successful or not
- The random time offset follows the uniform distribution within [0, W)
- Simulates N senders for 100,000 time slots
- The slot efficiency is defined as
# of successful slots / # of total slotssuccessful slotmeans that there is one and only one transmitted packet in the slot- No transmission or two or more transmission in a slot is considered not successful
- Implements the slotted ALOHA simulation
- Plots the slot efficiency graph while varying the number of nodes
Nfrom 1 to 32, with thewindow size8, 16, 32
Each node has a ttl field, to determine its transmission pointUses venv for python2.7.
$ uname -a
Linux ubuntu 4.15.0-29-generic #31~16.04.1-Ubuntu SMP Wed Jul 18 08:54:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
$ python --version
Python 2.7.12matplotlib==2.2.4
To successfully build and run the program, make sure you have the right packages.
import random
import matplotlib.pyplot as pltInstall with the following commands.
sudo apt-get install python-matplotlibIt's a python script. No building required.
Format
python aloha.py- James Sung - Initial work - sjkywalker
- Copyright © 2018 James Sung. All rights reserved.