This code is implementation of Aloha and Slotted Aloha. First version of the protocol "Pure ALOHA" was quite simple: If you have data to send, send the data If the message collides with another transmission, try resending "later" on collision, sender waits random time before trying again An improvement to the original ALOHA protocol was "Slotted ALOHA", which introduced discrete time slots and increased the maximum throughput. A station can send only at the beginning of a time slot, and thus collisions are reduced. In this case, we only need to worry about the transmission-attempts within 1 frame-time and not 2 consecutive frame-times, since collisions can only occur during each time slot.