The Bit-Map Protocol is a contention-free MAC (Medium Access Control) layer protocol used to coordinate which stations are allowed to transmit on a shared channel. Before any data frame is sent, each station broadcasts a single bit during its reserved slot in a contention slot period: a 1 signals that the station has a frame ready to send, while a 0 means the station has nothing to transmit. Once every station has announced its status, transmissions occur in station order, eliminating collisions entirely.
This C++ program simulates the Bit-Map Protocol. The user specifies the number of stations and their ready/not-ready status. The program reads each station’s status, then announces which stations are ready to transmit in station-number order.
C++ Program: Bit-Map Protocol
#include <iostream.h>
#include <stdio.h>
#include <conio.h>
void main()
{
int stationCount; // Total number of stations on the shared channel
int stationStatus[20]; // stationStatus[i] = 1 means station i+1 is ready to transmit
cout << "\n How many stations: ";
cin >> stationCount;
char repeatChoice; // Holds user's choice to repeat the simulation
do
{
// --- Contention slot period: read each station's status ---
cout << "\n Enter status of stations (1 = ready, 0 = not ready):";
for (int stationIndex = 0; stationIndex < stationCount; stationIndex++)
{
cout << "\n Enter status of station " << stationIndex + 1 << " : ";
cin >> stationStatus[stationIndex];
}
// --- Announcement phase: print ready stations in order ---
for (int stationIndex = 0; stationIndex < stationCount; stationIndex++)
{
if (stationStatus[stationIndex] == 1)
{
cout << "\n Station " << stationIndex + 1 << " is ready to transmit";
}
}
cout << "\n Repeat? Press Y : ";
cin >> repeatChoice;
}
while (repeatChoice == 'y' || repeatChoice == 'Y');
getch();
}
How the Code Works
Step 1 — Input: The user enters the total number of stations. This simulates the size of the broadcast network segment.
Step 2 — Contention Slots: Inside the do-while loop, each station’s status is collected in order from station 1 to station N. A status of 1 means the station has data to send; 0 means it is idle. In a real network, each station broadcasts this bit during its dedicated contention slot.
Step 3 — Transmission Order: After all statuses are collected, the program iterates through the stations in sequence and announces those with status 1. Because this scan is strictly sequential, transmissions happen in ascending station-number order with no collisions.
Step 4 — Repeat: The simulation can be run again with a new set of statuses (press Y) or terminated (press any other key).
Sample Output
How many stations: 8
Enter status of stations (1 = ready, 0 = not ready):
Enter status of station 1 : 0
Enter status of station 2 : 1
Enter status of station 3 : 0
Enter status of station 4 : 1
Enter status of station 5 : 1
Enter status of station 6 : 1
Enter status of station 7 : 0
Enter status of station 8 : 0
Station 2 is ready to transmit
Station 4 is ready to transmit
Station 5 is ready to transmit
Station 6 is ready to transmit
Repeat? Press Y : Y
Enter status of stations (1 = ready, 0 = not ready):
Enter status of station 1 : 1
Enter status of station 2 : 0
Enter status of station 3 : 0
Enter status of station 4 : 1
Enter status of station 5 : 0
Enter status of station 6 : 0
Enter status of station 7 : 0
Enter status of station 8 : 0
Station 1 is ready to transmit
Station 4 is ready to transmit
Repeat? Press Y : N
Output Explanation
In the first round, stations 2, 4, 5, and 6 report status 1. The protocol announces them in ascending order, meaning station 2 transmits first, followed by 4, 5, and 6. Stations 1, 3, 7, and 8 are silent this round. In the second round, only stations 1 and 4 are ready, so only they are permitted to transmit. Pressing N ends the simulation.
See Also
- Implementation of Hamming Code in C++ — error correction in transmitted frames
- Implementation of CRC Algorithm in C++ — error detection using polynomial division
- Implementation of Dijkstra Algorithm in C++ — shortest path routing
- Implementation of Distance Vector Routing (DVR) Algorithm in C++ — distributed routing protocol
- Implementing Socket Programming in Java — TCP client-server communication
Conclusion
The Bit-Map Protocol demonstrates how a simple reservation mechanism completely eliminates collisions on a shared channel. By dedicating one bit per station in the contention period, the protocol scales predictably: N stations require exactly N contention slots per transmission cycle. While this overhead makes it less efficient than CSMA/CD for lightly loaded networks, its collision-free guarantee makes it valuable in time-critical or high-load scenarios. Understanding it builds a strong foundation for studying more sophisticated MAC protocols like token ring and IEEE 802.11 EDCA.