Professional Documents
Culture Documents
“CSMA/CA”
Submitted in the partial fulfilment of the requirements
for the award of the degree of
BACHELOR OF ENGINEERING
IN
ELECTRONICS AND COMMUNICATION
ENGINEERING
For the Academic Year 2023-2024
Submitted by
SUBMIT
TED TO MS
GUNASAG
ARI G S
Q.Implement and analyze CSMA/CA using simulation tool.
• PROGRAM:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define CHANNEL_IDLE 0
#define CHANNEL_BUSY 1
#define TRANSMISSION_PROBABILITY 0.5
// CSMA/CA algorithm
void csma_ca(int nodeID) {
printf("Node %d wants to transmit.\n", nodeID);
while (1)
{
if (isChannelIdle() == CHANNEL_IDLE)
{
printf("Channel is idle. Transmitting...\n");
break;
}
else
{
printf("Channel is busy. Waiting...\n");
}
}
int main()
{
// Seed for random number generation
srand(time(NULL));
return 0;
}
Output :
C program for CSMA/CA that addresses the hidden station problem
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#define NUM_STATIONS 3
if (!channel_busy) {
printf("Station %d senses idle channel, starts transmission...\n", station_id);
return true;
} else {
printf("Station %d senses busy channel, defers transmission...\n", station_id);
return false;
}
}
int main() {
srand(time(NULL));
return 0;
}
Output: