#include <stdio.h>
#include <string.h>
int main() {
char inp[50], stuffed[100];
int len, i, count = 0, j = 0;
printf("Enter the data: ");
scanf("%s", inp);
len = strlen(inp);
for (i = 0; i < len; i++) {
stuffed[j++] = inp[i];
if (inp[i] == '1') {
count++;
} else {
count = 0;
}
if (count == 5) {
stuffed[j++] = '0';
count = 0;
}
}
stuffed[j] = '\0';
printf("Data after Bit Stuffing: %s\n", stuffed);
return 0;
}
Enter the data: 11011111
Data after Bit Stuffing: 110111110
This program demonstrates the Bit Stuffing Framing Method, which is used to avoid ambiguity in communication systems when certain patterns, such as consecutive 1
s, may be mistaken for frame delimiters.
0
after five consecutive 1
s.1
s, which could be interpreted as a frame delimiter.0
s to break up sequences of five consecutive 1
s.Bit stuffing is commonly used in protocols like HDLC to ensure that control characters (like 011111
or 111111
) do not appear in the data portion of the transmission, maintaining the integrity of the communication.