Enhanced Binary Exponential Backoff Algorithm for Fair Channel Access in Ad Hoc Networks

The Binary Exponential Backoff Algorithm prevents packet collisions during simultaneous access by randomizing moments at stations attempting to access the wireless channels. However, this randomization does not completely eliminate packet collisions, leading to reduced system throughput and increased packet delay and drop. Also, the BEB Algorithm results in unfair channel access among stations.

A mobile Ad hoc network is a group of wireless nodes that can dynamically arrange themselves into an arbitrary and temporary topology without the need for a pre-existing infrastructure to form a network. The node may move dynamically while communicating and makes the node incalculable.  The node can leave the topology network briskly.

Usually, this network is used in applications such as Emergency Operations, Environmental Control, and Military Applications where there is no centralized network infrastructure management or support, such as routers or Base Stations In the IEEE 802.11 standard, the distributed coordination function (DCF) algorithm is an efficient and fundamental algorithm that ensures the best MANET compatibility with evolving topology challenges. Based on the carrier sense multiple access with collision avoidance (CSMA/CA) protocol, the DCF shares access to the medium, which follows the basic principle of “listening before talking”. The BEB Algorithm is employed in DCF. After the collision, the node wishing to retransmit waits for a random amount of time which is known as the Backoff Time. Here, the node having small BT will first access the medium relative to the node with the higher BT.

Distributed Coordination Function:

This function is used to prevent collision using CSMA/CA and RTS/CTS acknowledgement frames. At the time of transmission, the sender waits for DIFS (Distributed Coordination Function Interframe Spacing) time. If the channel is idle it sends the data frame i.e RTS ACK frame while the receiver waits for the SIFS (Short Inter-Frame Spacing) amount of time and then sends the CTS frame receipt to the sender. If the channel is busy, the station waits for the channel until it is sensed idle for a DIFS time. At this point, it generates random BT to send the data frame.

Binary Exponential Backoff Algorithm:

Upon successful data transmission, the function CW() is invoked to adjust the CW to CWmin. During data collisions, the node invokes the function Double CW() to double the CW until it is equal to or greater than CWmax.

If the node attempts to send data unsuccessfully seven times, the function CW() is also invoked to adjust CW to CWmin due to which packet delay and drop increases also reduce the probability of retransmission of the data frames. Also, the fairness problem occurs.

Fairness Problem:

If the Backoff time of a supposed node A is low as compared to node B then node A will reach zero first and reset the contention window to a minimum, due to which the first node transmits having a higher probability of transmitting its node again and again.

Consider a file “aaa.txt”. In this file, generate the 0s and 1s. Here, 0s mean unsuccessful, and 1s mean successful. Below is the text file:

1010011000100011

Below is the implementation of the above approach:

C++
// C++ program for the above approach
#include <iostream>
#include <fstream>
#include <string>
#include <ctime>

using namespace std;

// Driver Code
int main()
{
    // Slot time
    float slot_time = 0.00000166;

    int CWmin = 32, CWmax = 1024;

    int k;
    int i, Curr_BW = 32, counter = 0;
    float BT, Total_Backoff_time = 0;

    fstream fp;
    string f_name = "aaa.txt";
    char ch;
    int x = 0, y = 0;

    fp.open(f_name, ios::in | ios::out);

    // Open File
    if (!fp) {
        cout << f_name << " does not exists \n";
        return 0;
    }

    // Otherwise
    else {
        cout << f_name << ": opened in read mode.\n\n";
    }

    // Read characters from the file
    while (fp.get(ch)) {

        // End-of-file is reached
        if (ch == '1' || ch == '0') {
            cout << "frame " << ch << " \n ";
        }

        // If the character is 1
        if (ch == '1') {

            x = x + 1;
            cout << "successful Transmission\n";
            Curr_BW = CWmin;
            cout << "the current window is : " << Curr_BW << "\n";

            BT = Curr_BW * slot_time;
            cout << " =>the backoff time is : " << BT << " \n";

            counter = 0;
        }

        // If the character is 0
        else if (ch == '0') {

            y = y + 1;
            if (counter < 7) {

                cout << "UNsuccessful Transmission\n";

                Curr_BW = Curr_BW * 2;

                if (Curr_BW > CWmax) {

                    Curr_BW = CWmax;
                }
                cout << "the current window is : " << Curr_BW << "\n";

                counter = counter + 1;
                cout << "counter is  : " << counter << " \n ";

                BT = Curr_BW * slot_time;

                cout << " =>the backoff time is : " << BT << " \n";
            }

            // Otherwise
            else {

                Curr_BW = CWmin;
                cout << "the current window is : " << Curr_BW << "\n";

                BT = Curr_BW * slot_time;
                cout << " =>the backoff time is : " << BT << " \n";
            }
        }

        if (ch == '1' || ch == '0') {

            // Find the Backoff Time
            Total_Backoff_time = Total_Backoff_time + BT;

            cout << "\n";

            // Print the time
            cout << "=>  Total Back_off time for frame is : " << Total_Backoff_time << " \n ";
            cout << "\n\n";
        }
    }

    // Print the success and unsuccess number
    cout << " success num : " << x << "\n";
    cout << " unsuccess num : " << y << "\n";

    return 0;
}
C
// C program for the above approach
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// Driver Code
int main()
{
    // Slot time
    float slot_time = 0.00000166;

    int CWmin = 32, CWmax = 1024;

    int k;
    int i, Curr_BW = 32, counter = 0;
    float BT, Total_Backoff_time = 0;

    FILE* fp;
    char* f_name = "aaa.txt";
    char ch;
    int x = 0, y = 0;

    fp = fopen(f_name, "r+");

    // Open File
    if (fp == NULL) {
        printf("%s does not exists"
               " \n",
               f_name);
        return 0;
    }

    // Otherwise
    else {
        printf("%s: opened in read"
               " mode.\n\n",
               f_name);
    }

    // Read characters from the file
    while ((ch = fgetc(fp)) != EOF) {

        // End-of-file is reached
        if (ch == '1' || ch == '0') {
            printf("frame %c \n ", ch);
        }

        // If the character is 1
        if (ch == '1') {

            x = x + 1;
            printf("successful "
                   "Transmission\n");
            Curr_BW = CWmin;
            printf("the current "
                   "window is : %d\n",
                   Curr_BW);

            BT = Curr_BW * slot_time;
            printf(" =>the backoff"
                   " time is : %0.8f"
                   " \n",
                   BT);

            counter = 0;
        }

        // If the character is 0
        else if (ch == '0') {

            y = y + 1;
            if (counter < 7) {

                printf("UNsuccessful "
                       "Transmission\n");

                Curr_BW = Curr_BW * 2;

                if (Curr_BW > CWmax) {

                    Curr_BW = CWmax;
                }
                printf("the current "
                       "window is :"
                       " %d\n",
                       Curr_BW);

                counter = counter + 1;
                printf("counter is  :"
                       " %d \n ",
                       counter);

                BT = Curr_BW * slot_time;

                printf(" =>the backoff"
                       " time is : %0.8f"
                       " \n",
                       BT);
            }

            // Otherwise
            else {

                Curr_BW = CWmin;
                printf("the current"
                       " window is :"
                       " %d\n",
                       Curr_BW);

                BT = Curr_BW * slot_time;
                printf(" =>the backoff"
                       " time is : %0.8f"
                       " \n",
                       BT);
            }
        }

        if (ch == '1' || ch == '0') {

            // Find the Backoff Time
            Total_Backoff_time = Total_Backoff_time + BT;

            printf("\n");

            // Print the time
            printf("=>  Total Back_off"
                   " time for frame is : "
                   " %0.8f \n ",
                   Total_Backoff_time);
            printf("\n\n");
        }
    }

    // Print the success and
    // unsuccess number
    printf(" success num : %d\n", x);
    printf(" unsuccess num : %d\n", y);

    return 0;
}