Skip to main content
. 2017 Jun 7;17(6):1320. doi: 10.3390/s17061320
Algorithm 1 The modified CSMA/CA mechanism
  • Require: 

    NB=0,Rtrns=0,Tcca=8symbols, packet duration Tpkt;

  • Ensure: 

    Transmission success/failure.

  • 1:

    Listen to the channel;

  • 2:

    if (Beacon not received) then

  • 3:

        Wait for beacon;

  • 4:

    else

  • 5:

        CWi=CWMAXBi,MaxBi,nowBi,Max;

  • 6:

        Rbck = random(0,CWi);

  • 7:

        if (RtimeRbck+Tcca+Tpkt) then

  • 8:

            NB=NB+1;

  • 9:

            if (NB>NBmax) then

  • 10:

               Stop due to channel access failure;

  • 11:

            else

  • 12:

               go to step 1;

  • 13:

            end if

  • 14:

        else

  • 15:

            Access channel after Rbck duration;

  • 16:

            if (channel busy) then

  • 17:

               Switch to power saving mode for random(0,Tpkt) duration;

  • 18:

               NB=NB+1;

  • 19:

               if (NB>NBmax) then

  • 20:

                   Stop due to channel access failure;

  • 21:

               else

  • 22:

                   go to step 5;

  • 23:

               end if

  • 24:

            else

  • 25:

               Start transmission and wait for ACK;

  • 26:

               if (ACK is not received) then

  • 27:

                   Rtrns=Rtrns+1;

  • 28:

                   if RtrnsMAXRtrns then

  • 29:

                       Wait for next retransmission period and go to step 5;

  • 30:

                   else

  • 31:

                       Stop due to transmission failure;

  • 32:

                   end if

  • 33:

               end if

  • 34:

            end if

  • 35:

        end if

  • 36:

    end if