Clear channel assessments are performed automatically by the CC2420 radio
stack before any and every transmission, unless you explicitly disable it.
In the CC2420 radio, a CSMA strategy is implemented where initial and
congestion backoffs are set for random lengths of time to prevent
transmissions from taking place at the same time.  These backoffs use an
alarm that fires asynchronously, interrupting any code you have executing,
unless you have your code in an atomic block.  

When the backoff timer fires, the radio chip itself is responsible for
sampling the channel to make sure the channel is clear before proceeding
with a transmission.  

There is a case where two radios attempt to transmit at exactly the same
time, sample the channel and see it's clear, and proceed to collide.  This
doesn't happen too often, but it does exist.  

If the channel is found to be in use at the time it is sampled, a congestion
backoff will allow the radio to wait for a random period of time before
trying again.

If you are attempting to add in your own channel sharing CSMA functionality
in the application layer to make sure the channel is clear before sending,
you'll find it to be of no use:  the initial backoff set in the radio stack
will automatically cause a significant delay before sending the packet.  By
the time the packet begins transmitting out of the radio, it could be
several milliseconds after you gave the initial command to send.  

-David



-----Original Message-----
From: Hui Kang [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 17, 2008 1:27 PM
To: David Moss
Subject: Re: CCA Check in application layer.

David Moss wrote:
> Yes, I think it essentially reads the CCA pin as well.  Indeed that's what
> PowerCycleP uses to see if something else is transmitting on the channel.

>   
But there is still a problem. When two nodes start the loop at the same 
time, they will not receive any message. Then when exiting the loop, 
they start sending message together, which causes some collision. Is 
this correct?

- Hui
> -David
>
>
>
> -----Original Message-----
> From: Hui Kang [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, July 17, 2008 1:04 PM
> To: David Moss
> Subject: Re: CCA Check in application layer.
>
> Hi, David,
> I find the interface ReceiveIndicator may be more suitable; it is used 
> by PowerCycleP.
>
> - Hui
> David Moss wrote:
>   
>> Is this in a while() loop?  In other words, how fast are you sampling?
>> Message transmissions can be on the order of ~1 ms.  
>>
>> If you have a node sitting there checking the CCA pin, and another node
>> transmitting nearby, do you see the LED's toggle from the CCA pin
>>     
> toggling?
>   
>> Take a look at the PowerCycleP module in the low power listening
>> implementation. It monitors the channel for activity using the CCA pin to
>> determine if there is a transmitter on the channel, and it may be a good
>> example of how to set something like this up.
>>
>> -David
>>
>>
>>
>>
>> -----Original Message-----
>> From: Hui Kang [mailto:[EMAIL PROTECTED] 
>> Sent: Thursday, July 17, 2008 11:52 AM
>> To: David Moss
>> Subject: Re: CCA Check in application layer.
>>
>> David Moss wrote:
>>   
>>     
>>> If you want to check the channel *before* sending a packet, you can
>>>       
> sample
>   
>>> the CCA pin directly.  This GeneralIO is provided by HplCC2420PinsC.
>>>
>>> The code you're looking at here actually sends a packet, if the channel
>>>       
> is
>   
>>> immediately found to be clear.  If you're not doing so already, you must
>>> also acquire the SPI bus resource before sending commands over SPI. 
>>>
>>> -David
>>>   
>>>     
>>>       
>> David,
>> thanks for your reply.
>> I use the interface GeneralIO as CCA and wire it to HplCC2420PinsC. My 
>> code is
>> if ( call CCA.get() ) {
>>     // toggle Blue led and send message
>> }
>> else {
>>     // toggle Red led
>> }
>> Now I use three motes and find even when the three motes transmit 
>> message at the same time (they blink blue led together), CCA.get( ) 
>> still returns true -  it does not detect other motes is transmitting. Is 
>> there any problem? Thanks.
>>
>> - Hui Kang
>>   
>>     
>>> -----Original Message-----
>>> From: Hui Kang [mailto:[EMAIL PROTECTED] 
>>> Sent: Thursday, July 17, 2008 10:26 AM
>>> To: David Moss
>>> Cc: [email protected]
>>> Subject: CCA Check in application layer.
>>>
>>> Dear All:
>>> In my tinyos-2.x application, I would like to check the channel before 
>>> sending a packet. By copying the following code from CC2420TransmitP.nc,

>>> I found the congest is always set as TRUE even I have only one mote turn

>>> on. Could anyone help to solve this problem or any other smarter way to 
>>> check CCA? Thanks.
>>>
>>> uint8_t status;
>>> bool congestion = TRUE;
>>>      
>>> atomic{
>>>             call CSN.clr();
>>>
>>>         status = call STXONCCA.strobe();
>>>         if ( !( status & CC2420_STATUS_TX_ACTIVE ) ) {
>>>             status = call SNOP.strobe();
>>>           if ( status & CC2420_STATUS_TX_ACTIVE ) {
>>>               congestion = FALSE;
>>>           }
>>>         }
>>>         call CSN.set();
>>> }
>>>
>>> - Hui
>>>
>>>
>>>
>>>
>>>
>>>   
>>>     
>>>       
>>
>>
>>
>>   
>>     
>
>
>
>
>
>   




_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to