Changelog:

  • 14 Nov 2024: fix bug in access_point.py where sense() might sometimes crash
  • 20 Nov 2024: fix major bug in simtime.py where time would advance too quickly.
  • 21 Nov 2024: modify supplied mac.py to not import time to avoid confusion
  • 21 Nov 2024: specify recommended testing with around 20 packets/second to test with
  • 3 Dec 2024: use --mac argument correctly in examples

This is based on an assignment originally constructed by Brad Campbell.

If you downloaded simtime.py before noon 20 Nov, get an updated version here

1 Your Task

  1. Download the skeleton code at here [last updated 2024-11-20 noon]

    The skeleton code includes a simulator for a network where several randomly placed stations need to transmit packets to a central access point. The access point implements per-packet acknowledgments and simulatenously receives from each of 11 channels (frequencies). To simplify the assignmet, we will assume that acknowledgments are always received reliably.

    Your job is to improve the MAC protocol used by the stations to send a specified number of packets within a goal time computed by project.py.

    In the initial implementation, the stations make three attempts to transmit packets on wireless channel 1 at 0 dB of power.

    You can edit the code for the stations to more intelligently choose

    • when to (re)transmit;
    • which channels to use;
    • the transmit power;
    • how many time to retransmit.

    Unfortunately, you don’t have the capability to modify the access point, so you can’t implement features like RTS/CTS.

  2. Write a brief description of your chosen MAC protocol and how choose those settings; place this in a comment at the top in your mac.py.

  3. Test your code and produce a graph of your results as the number of stations used varies from 10 to 100 in increments of 5, graphing the total time needed to receive 150 packets. Label the axes of your graph. We recommend testing with around 20 packets/second.

    Place this graph in a file called graph.pdf or graph.png

  4. Submit your modified mac.py (with the comment) and your graph to the submission site.

2 Simulation Interface

The simulator uses a few files:

2.1 Station Interface

Inside of mac.py there are three functions provided by the generic station class that you will use to implement each MAC protocol. The NullMac implementation provides a simple example.

2.2 Command Line Interface

The simulator exposes many configuration options via the command line. The generic interface looks like:

./project.py <# stations> <pkts/s> <pkts> --mac <mac>

For example, to specify a stations transmission rate of 20 packets/second from eighteen stations using YourMac, where the access point is trying to collect 200 packets from each station:

./project.py 18 20 200 --mac YourMac

2.3 Simulator Specifics

There are a few helpful details about the simulator environment that are useful to know. These are simplifications that make the situation easier to model without compromising the ability to compare different MAC protocols.