Skip to main content
. 2015 Dec 3;15(12):30221–30239. doi: 10.3390/s151229800
Algorithm 1 A M-Level contention window tuning algorithm with a minimum tuning rate of γ.
Initialization
  • 1:

    unsigned slot_cnt=0, idle_slot_cnt=0, k;

  • 2:

    double cw=CW_MIN, vector_inc[M], vector_dec[M];

  • 3:

    for k=0;k<M;k++ do

  • 4:

     vector_inc[k]=PI(32,θ·γk);

  • 5:

     vector_dec[k]=PI(32,θ/γk);

  • 6:

    end for

Algorithm Body
  • 1:

    while 1 do

  • 2:

     if detecting an idle slot then

  • 3:

      slot_cnt++;

  • 4:

      if the slot is over with idle then

  • 5:

       idle_slot_cnt++;

  • 6:

      end if

  • 7:

     end if

  • 8:

    end while

  • 9:

    while 1 do

  • 10:

     if before generating a new backoff period then

  • 11:

      if slot_cnt−idle_slot_cnt≥5 then

  • 12:

       for k=0;k<M;k++ do

  • 13:

        if idle_slot_cnt/slot_cnt<vector_inc[k] then

  • 14:

         cw=cw*γ;

  • 15:

        end if

  • 16:

        if idle_slot_cnt/slot_cnt>vector_dec[k] then

  • 17:

         cw=cw/γ;

  • 18:

        end if

  • 19:

       end for

  • 20:

       slot_cnt=0, idle_slot_cnt=0;

  • 21:

      end if

  • 22:

     end if

  • 23:

    end while