Changes between Version 14 and Version 15 of CSMAMAC


Ignore:
Timestamp:
Feb 7, 2008, 11:01:09 PM (14 years ago)
Author:
chunter
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CSMAMAC

    v14 v15  
    108108{{{
    109109#!c
    110 warpmac_setRxBuffer(&rxBuffer,0);
     110warpmac_setRxBuffer(-,0);
    111111warpmac_setTxBuffer(1);
    112112}}}
    113113
    114 The newest version of the [wiki:OFDM PHY]
    115 
     114The 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.
     115
     116
     117{{{
     118#!c
     119warpmac_setGoodPacketHandler(receiveGoodPacket);
     120warpmac_setBadPacketHandler(receiveBadPacket);
     121warpmac_setTimerHandler(timerExpire);
     122warpmac_setEmacHandler(ethernet_callback);
     123}}}
     124
     125This 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.
     126
     127{{{
     128#!c
     129warpmac_setChannel(-, -);
     130}}}
     131
     132This function sets the center frequency of the radio in either the 2.4 or 5 GHz spectrum.
     133
     134{{{
     135#!c
     136warpmac_enableCSMA();
     137warpmac_enableEthernetInterrupt();
     138}}}
     139
     140These function enable the carrier-sensing functionality of the hardware and the Ethernet interrupt.
     141
     142= Carrier-Sense Medium Access Reference Design (CSMAMAC) =
     143
     144The 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
     158This 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
     165Below 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
     202Note: 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
     206There 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
    116207
    117208{{{
     
    120211}}}
    121212
    122 
    123 {{{
    124 #!c
    125 int main()
    126 }}}
    127 
    128 
    129 {{{
    130 #!c
    131 int main()
    132 }}}
    133 
    134 
    135 ----
     213function of [source:/ResearchApps/MAC/CSMAMAC/csmaMac.c@L csmaMac.c].
     214
     215==== Startup ====
     216This block of code calls the following [http://warp.rice.edu/WARP_API/warpmac_8c.html WARPMAC] functions:
     217
     218{{{
     219#!c
     220warpmac_getMyId();
     221}}}
     222
     223This 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
     227warpmac_init()
     228}}}
     229
     230This 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
     234warpmac_setMacAddr(-);
     235}}}
     236
     237This function sets the wireless MAC address of the node.
     238
     239{{{
     240#!c
     241warpmac_setMaxResend(-);
     242warpmac_setMaxCW(-);
     243warpmac_setTimeout(-);
     244warpmac_setSlotTime(-);
     245}}}
     246
     247These 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
     251warpmac_setRxBuffer(-,0);
     252warpmac_setTxBuffer(1);
     253}}}
     254
     255The 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
     260warpmac_setGoodPacketHandler(receiveGoodPacket);
     261warpmac_setBadPacketHandler(receiveBadPacket);
     262warpmac_setTimerHandler(timerExpire);
     263warpmac_setEmacHandler(ethernet_callback);
     264}}}
     265
     266This 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
     270warpmac_setChannel(-, -);
     271}}}
     272
     273This function sets the center frequency of the radio in either the 2.4 or 5 GHz spectrum.
     274
     275{{{
     276#!c
     277warpmac_setBaseRate(-)
     278}}}
     279
     280Finally, the base rate modulation order is set. This rate must be agreed upon by all nodes in the network ''a priori.'' Within the base rate symbols is a field that specifies the modulation order of the rest of the packet (i.e. the full rate symbols). This enables dynamic modulation for autorate systems.
     281
     282==== Steady State ====
     283
     284The steady state behavior of the "Idle" state is very simple: it's nothing. At the bottom of the main function is a while loop that spins in place, waiting for an interrupt service routine to be called by a hardware event.
     285
     286
     287
     288----
     289
     290
    136291
    137292=== Accepted Packet from Source ===