Changes between Version 15 and Version 16 of CSMAMAC


Ignore:
Timestamp:
Feb 7, 2008, 11:05:22 PM (16 years ago)
Author:
chunter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CSMAMAC

    v15 v16  
     1
    12= Carrier-Sense Medium Access Reference Design (CSMAMAC) =
    23
     
    6364=== Idle ===
    6465
    65 There are two purposes of this state: At the beginning of time the code must initialize the framework and WARP hardware, and in the steady state it must sit and wait for an event to take place. This state maps to the
     66There are two purposes of this state: At startup must initialize the framework and WARP hardware, and in the steady state it must sit and wait for an event to take place. This state maps to the
    6667
    6768{{{
     
    7273function of [source:/ResearchApps/MAC/CSMAMAC/csmaMac.c@L csmaMac.c].
    7374
    74 ==== Steady State ====
     75==== Startup ====
    7576This block of code calls the following [http://warp.rice.edu/WARP_API/warpmac_8c.html WARPMAC] functions:
    7677
     
    134135{{{
    135136#!c
    136 warpmac_enableCSMA();
    137 warpmac_enableEthernetInterrupt();
    138 }}}
    139 
    140 These function enable the carrier-sensing functionality of the hardware and the Ethernet interrupt.
    141 
    142 = Carrier-Sense Medium Access Reference Design (CSMAMAC) =
    143 
    144 The CSMAMAC is serves as the user-level MAC layer in [wiki:OFDMReferenceDesign reference design]. The basic algorithm is simple:
    145 
    146  * Do I have a packet to send?
    147        * If the medium is idle, send it, enter a timeout, and wait for an acknowledgment from the destination
    148        * If the medium is busy, enter a backoff period and wait for the medium to become idle
    149  * Did I receive a data packet?
    150        * If the packet pass checksum and is addressed to me, send an acknowledgment
    151  * Did no know acknowledgment happen during a timeout period?
    152        * If the maximum number of retransmits has not occurred, enter a backoff and try retransmitting
    153        * If the maximum number of retransmits has occurred, drop the packet
    154  * Did I wait through a backoff period?
    155        * If the medium is busy, retransmit, increment the total number of resends, enter a timeout, and wait for an acknowledgment from the destination
    156        * If the medium is busy, enter a backoff period and wait for the medium to become idle
    157 
    158 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.
    159 
    160 
    161 
    162 
    163 == Life of a Packet ==
    164 
    165 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/CSMAMAC/csmaMac.c@L csmaMac.c]. The API documentation for the code can be found here: [http://warp.rice.edu/WARP_API/csma_mac_8c.html CSMAMAC API]
    166 
    167 {{{
    168 #!html
    169 <map name="GraffleExport">
    170         <area shape=poly coords="106,224,154,250,106,276,59,250,106,224" href="#MediumState">
    171         <area shape=poly coords="681,414,728,440,681,466,633,440,681,414" href="#MaximumResends">
    172         <area shape=poly coords="681,318,728,344,681,370,634,344,681,318" href="#MediumState">
    173         <area shape=rect coords="690,508,784,545" href="#DropPacket">
    174         <area shape=rect coords="577,592,671,630" href="#IncrementResendCounter">
    175         <area shape=rect coords="577,508,671,546" href="#TransmitPacketviaPHY">
    176         <area shape=rect coords="319,508,414,545" href="#TransmitPacketviaPHY">
    177         <area shape=rect coords="3,326,97,364" href="#TransmitPacketviaPHY">
    178         <area shape=rect coords="691,130,785,168" href="#TimerExpired">
    179         <area shape=rect coords="375,131,470,168" href="#ReceivedPacketviaPHY">
    180         <area shape=rect coords="60,130,155,168" href="#AcceptedPacketfromSource">
    181         <area shape=rect coords="320,592,414,630" href="#DeliverPackettoSink">
    182         <area shape=rect coords="747,419,842,457" href="#SetBACKOFFTimer">
    183         <area shape=rect coords="577,677,671,715" href="#SetTIMEOUTTimer">
    184         <area shape=rect coords="116,326,210,364" href="#SetBACKOFFTimer">
    185         <area shape=poly coords="738,225,785,250,738,276,691,250,738,225" href="#TimerType">
    186         <area shape=rect coords="432,508,527,546" href="#ClearTIMEOUT">
    187         <area shape=poly coords="423,413,470,439,423,465,376,439,423,413" href="#PacketType">
    188         <area shape=rect coords="3,412,97,450" href="#SetTIMEOUTTimer">
    189         <area shape=poly coords="423,319,470,345,423,371,376,345,423,319" href="$DestinationAddress">
    190         <area shape=poly coords="423,225,470,250,423,276,376,250,423,225" href="#Checksum">
    191         <area shape=poly coords="393,45,453,45,465,62,453,79,393,79,380,62,393,45" href="#Idle">
    192 </map>
    193 
    194 
    195 
    196 <a style="padding:0; border:none" href="/trac/attachment/wiki/CSMAMAC/files/csmaMac_state.png"><img src="/trac/attachment/wiki/CSMAMAC/files/csmaMac_state.png?format=raw" usemap="#GraffleExport" align=left/></a>
    197 
    198 }}}
    199 
    200 ----
    201 
    202 Note: Through all of the following descriptions, a "-" is used in place of arguments to functions when those arguments are not important to the overall purpose of the description. Howeverm, that is not to say that these arguments can be changed to ''anything'' and have the code still compile and run successfully. Care must be taken in modifying the reference design.
    203 
    204 === Idle ===
    205 
    206 There are two purposes of this state: At startup must initialize the framework and WARP hardware, and in the steady state it must sit and wait for an event to take place. This state maps to the
    207 
    208 {{{
    209 #!c
    210 int main()
    211 }}}
    212 
    213 function of [source:/ResearchApps/MAC/CSMAMAC/csmaMac.c@L csmaMac.c].
    214 
    215 ==== Startup ====
    216 This block of code calls the following [http://warp.rice.edu/WARP_API/warpmac_8c.html WARPMAC] functions:
    217 
    218 {{{
    219 #!c
    220 warpmac_getMyId();
    221 }}}
    222 
    223 This function reads the current setting on the [wiki:HardwareUsersGuides/FPGABoard_v1.2/UserIO#DIPSwitch Dip Switches]. The value is used simply to identify the node in the network. For the purposes of the Reference Design, one node must be identified as "0" and the other as "1."
    224 
    225 {{{
    226 #!c
    227 warpmac_init()
    228 }}}
    229 
    230 This function sets reasonable default values for many of the parameters of the MAC, configures interrupts and exceptions, configures Ethernet, and finally initializes the custom peripherals such as the radio controller, the PHY, the packet detector, and the automatic gain control block.
    231 
    232 {{{
    233 #!c
    234 warpmac_setMacAddr(-);
    235 }}}
    236 
    237 This function sets the wireless MAC address of the node.
    238 
    239 {{{
    240 #!c
    241 warpmac_setMaxResend(-);
    242 warpmac_setMaxCW(-);
    243 warpmac_setTimeout(-);
    244 warpmac_setSlotTime(-);
    245 }}}
    246 
    247 These function set up internal parameters of the MAC. The maximum number of resends is the maximum number of times that a packet should be retransmitted, in the event of not receiving an acknowledgment. The maximum contention window defines "how random" backoffs should be in the worst case. The timeout time is the amount of time that the MAC should wait on an acknowledgment before retransmitting. Finally, the slot time is a length of the minimum contention window.
    248 
    249 {{{
    250 #!c
    251 warpmac_setRxBuffer(-,0);
    252 warpmac_setTxBuffer(1);
    253 }}}
    254 
    255 The newest version of the [wiki:OFDM OFDM PHY] supports a large chunk of memory that can be used to queue multiple packets. By default, the system is configured with enough memory to support 4 full-size packets. This block of code instructs the framework to use the first 1/4th of memory to receive packets into, and the second 1/4th of memory to send from. In principle, these functions can be used to help juggle packets in the event of a busy wireless medium. For example, one can receive into a separate piece of memory in order to avoid overwriting a packet that has not been processed by higher layers yet.
    256 
    257 
    258 {{{
    259 #!c
    260 warpmac_setGoodPacketHandler(receiveGoodPacket);
    261 warpmac_setBadPacketHandler(receiveBadPacket);
    262 warpmac_setTimerHandler(timerExpire);
    263 warpmac_setEmacHandler(ethernet_callback);
    264 }}}
    265 
    266 This block of code attaches user-level callbacks to interrupt service routines. These functions perform the behaviors that they sound like: receiving a packet that passes checksum, receiving a packet that fails checksum, processing a timer expiration, and handling Ethernet activity respectively.
    267 
    268 {{{
    269 #!c
    270 warpmac_setChannel(-, -);
    271 }}}
    272 
    273 This function sets the center frequency of the radio in either the 2.4 or 5 GHz spectrum.
    274 
    275 {{{
    276 #!c
    277137warpmac_setBaseRate(-)
    278138}}}