= Carrier-Sense Medium Access Reference Design (CSMAMAC) =
The CSMAMAC is serves as the user-level MAC layer in [wiki:OFDMReferenceDesign reference design]. The basic algorithm is simple:
* Do I have a packet to send?
* If the medium is idle, send it, enter a timeout, and wait for an acknowledgment from the destination
* If the medium is busy, enter a backoff period and wait for the medium to become idle
* Did I receive a data packet?
* If the packet pass checksum and is addressed to me, send an acknowledgment
* Did no know acknowledgment happen during a timeout period?
* If the maximum number of retransmits has not occurred, enter a backoff and try retransmitting
* If the maximum number of retransmits has occurred, drop the packet
* Did I wait through a backoff period?
* If the medium is busy, retransmit, increment the total number of resends, enter a timeout, and wait for an acknowledgment from the destination
* If the medium is busy, enter a backoff period and wait for the medium to become idle
This simple algorithm encompasses much of the behavior in commercial 802.11 MAC/PHY chipsets. This algorithm lends itself nicely to a state diagram, which in turn, translates into C-code that can be executed in the PowerPC of the FPGA on WARP. In the following section, we track the "Life of a Packet" as it might journey through these states.
== Life of a Packet ==
Below is the state-machine representation of the above algorithm. Each state can be "clicked" and is described in detail in the accompanying link. The up-to-date code can be found here: [source:/ResearchApps/MAC/ACKMAC/csmaMac.c@L csmaMac.c]
{{{
#!html
}}}
=== Idle ===
=== Accepted Packet from Source ===
=== Medium State ===
=== Transmit Packet via PHY ===
=== Set TIMEOUT Timer ===
=== Set BACKOFF Timer ===
=== Received Packet via PHY ===
=== Checksum ===
=== Destination Address ===
=== Packet Type ===
=== Clear TIMEOUT ===
=== Deliver Packet to Sink ===
=== Timer Expired ===
=== Timer Type ===
=== Medium State ===
=== Maximum Resends ===
=== Drop Packet ===
=== Increment Resend Counter ===