Professional Documents
Culture Documents
CN Practical 4
CN Practical 4
Experiment-4
Date: 01/02/2022
Aim: Write a program to implement bit stuffing & Destuffing
Apparatus (Software): Turbo C, C++.
Code:
#include <stdio.h>
#include <string.h>
190170111090_Mihir Patel
Computer Networks(3161007)
}
}
// Print Result
printf("\nStuffed output:");
for (i = 0; i < j; i++)
printf("%d", brr[i]);
}
190170111090_Mihir Patel
Computer Networks(3161007)
// If 5 consecutive set bits are found skip the next bit in crr[]
if (count == 5)
{
k++;
}
i = k;
}
}
// Otherwise insert crr[i] into brr[]
else
{
brr[j] = crr[i];
}
i++;
j++;
}
// Print Result
printf("\nDestuffed output:");
for (i = 0; i < j; i++)
printf("%d", brr[i]);
}
// Driver Code
int main()
{
int N = 10;
int i;
int arr[] = { 1, 0, 1, 0, 1, 1, 1, 1, 1, 1 };
int crr[] = { 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1};
bitStuffing(N, arr);
bitDestuffing(N, crr);
return 0;
}
Output:
190170111090_Mihir Patel