Version 6 (Anthony Rowe, 03/04/2007 08:18 pm)

1 1 Anthony Rowe
= BMAC =
2 1 Anthony Rowe
3 5 Anthony Rowe
BMAC is a low-power listen CSMA (lpl-csma) protocol.  More information can be found in the original [http://www.polastre.com/papers/sensys04-bmac.pdf BMAC paper]. The main idea about low-power-listen CSMA is that instead of leaving the receiver on 100% the radio is active for short bursts used to check for channel activity.  If activity is detected, the radio remains on in order to receive the data. In order to ensure that a neighboring node receives the message, an extended preamble the length of the check interval is required.  
4 3 Anthony Rowe
5 2 Anthony Rowe
6 1 Anthony Rowe
7 4 Anthony Rowe
There is a trade-off between checking more often or sending a longer preamble. For any particular sampling point (sensor sampling rate etc) there is an energy optimal checking rate. 
8 1 Anthony Rowe
9 4 Anthony Rowe
10 4 Anthony Rowe
11 4 Anthony Rowe
Using the optimal radio checking rate derived from the best energy efficiency at a particular sampling point you can see the following life-time relationship.
12 4 Anthony Rowe
13 1 Anthony Rowe
14 5 Anthony Rowe
15 5 Anthony Rowe
16 6 Anthony Rowe
The current Nano-RK implementation of BMAC has no internal transmit or receive buffers. Applications or higher level network layers must provide their own transmit and receive buffers.  BMAC will pass transmit buffers directly to the basic_rf transmit functions where additional information like a CRC checksum is added.  When data is received, BMAC will store this data in the last set receive buffer until the bmac_rx_release() function is called by a higher layer or application.  The reception of a packet will generate a signal notifying any waiting tasks that the packet is ready. Received packets can be checked in a polling fashion using the bmac_rx_status() function, or a task can suspend until a packet arrives using the bmac_rx_packet_get() function.  Timeouts on packet reception can be achieved using the wait until next wakeup configuration commands provided by Nano-RK.  If a timeout occurs, bmac_wait_until_rx_packet() will return an error code.  To allow efficient network layer development, the receive buffer can be changed using the bmac_rx_pkt_set_buffer() function. This should only be done after a packet is received or at startup.  If a new receive buffer pointer has been set, it is then safe to call bmac_rx_pkt_release() indicating that the BMAC task is allowed to buffer new packets at that memory location.
17 2 Anthony Rowe
18 1 Anthony Rowe
19 6 Anthony Rowe
20 6 Anthony Rowe
The application or network layer is required to allocate static buffers:
21 6 Anthony Rowe
22 6 Anthony Rowe
23 6 Anthony Rowe
   uint8_t tx_buf[RF_MAX_PAYLOAD_SIZE];
24 6 Anthony Rowe
   uint8_t rx_buf[RF_MAX_PAYLOAD_SIZE];
25 6 Anthony Rowe
26 6 Anthony Rowe
27 6 Anthony Rowe
28 6 Anthony Rowe
Here is a sample of how you initialize BMAC (found in the basic_bmac sample project):
29 6 Anthony Rowe
30 6 Anthony Rowe
31 6 Anthony Rowe
  // init bmac on channel 25 
32 6 Anthony Rowe
33 6 Anthony Rowe
  // This sets the next RX buffer.
34 6 Anthony Rowe
  // This can be called at anytime before releaseing the packet
35 6 Anthony Rowe
  // if you wish to do a zero-copy buffer switch
36 6 Anthony Rowe
37 6 Anthony Rowe