Bit Stuffing is one of the framing technique used in Data-Link Layer (layer 2) of OSI Reference Model.
In Bit-Stuffing technique, stuffing is done at the bit level. It was developed for the once very popular HDLC(High-Level Data Link Layer) protocol. Each frame begins and ends with a special bit pattern 01111110 or 0x7E in hexadecimal. This pattern is a flag byte.
For Example:
If the user data contain the flag pattern, 01111110, this flag is transmitted as 011111010 but stored in the receiver's memory as 01111110, as shown in fig below:
In Bit-Stuffing technique, stuffing is done at the bit level. It was developed for the once very popular HDLC(High-Level Data Link Layer) protocol. Each frame begins and ends with a special bit pattern 01111110 or 0x7E in hexadecimal. This pattern is a flag byte.
"Whenever the sender's data link layer encounters five consecutive 1s in the data, it automatically stuffs a 0 bit into the outgoing bit stream"
"Whenever the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically destuffs (i.e, deletes) the 0 bit."
"Whenever the receiver sees five consecutive incoming 1 bits, followed by a 0 bit, it automatically destuffs (i.e, deletes) the 0 bit."
For Example:
If the user data contain the flag pattern, 01111110, this flag is transmitted as 011111010 but stored in the receiver's memory as 01111110, as shown in fig below:
fig.a) Original Data. b) Stuffed Data. c) Received Data |
Source Code
import java.util.*;
public class SEFBS
{
public static
void main(String[] args)
{
System.out.print("Enter the Binary message: ");
Scanner
sn=new Scanner(System.in);
String
data = sn.nextLine();
String
res = new String();
String
out=new String();
int
counter = 0;
for(int
i=0;i<data.length();i++)
{
if
(data.charAt(i)!='1' && data.charAt(i)!='0')
{
System.out.println("Enter only Binary values!!!");
return;
}
if(data.charAt(i) == '1')
{
counter++;
res = res + data.charAt(i);
}
else
{
res = res + data.charAt(i);
counter = 0;
}
if(counter == 5)
{
res = res + '0';
counter = 0;
}
}
String
inc="01111110"+res+"01111110";
System.out.println("The Message to be transfered: " +inc);
System.out.println("Seding Message....");
counter=0;
for(int
i=0;i<res.length();i++)
{
if(res.charAt(i) == '1')
{
counter++;
out = out + res.charAt(i);
}
else
{
out = out + res.charAt(i);
counter = 0;
}
if(counter == 5)
{
if((i+2)!=res.length())
out = out + res.charAt(i+2);
else
out=out + '1';
i=i+2;
counter = 1;
}
}
System.out.println("Message Recevied...Successfully!!!");
System.out.println("The Destuffed Message is: "+out);
}
}
Output
ne yenkama rai program thapu ra program raka pothay musukoni undali paniki rani panlu chaiya kudadhu
ReplyDeleteYes, man you are telugu guy.
DeleteIf u dont understand what I say plz call me 893951948
ReplyDelete256026516
ReplyDelete24335734241
65401251469564e48
44206542
344638695
4425443453
535424985973455
645434355456478347
6743453324454324
76647853645434
4453354453543
3478468
757643645
83947538
7354756385
334563576
543587565456344
7669465
4345543654539
4750745365
5453454
355398745037
84536435332454
33545435483657938
64733455324453234
5458736458
374543433645364
87340834545375543
49384634543445632534487
7456193071567634512412534654435765
7048350688476860456446603465087
7884066440562456345046870609847
564435230434506544755047604608
35245304806467906004670645674
604043604545766034049
7876745065
064
7586047565r04657
65706654476506645
9866870456
5667804676045
74604557
8067645
45646557605407
6870745054589806
6440654305234765687897987
5049865046456
0ha654va4560
05460456
0-04250984641928564012
312-=1241240
Have a nice day dude
I am afraid that you have mistaken. Its bit stuffing. Bit may be either 0 or 1. The program is written in such a way. But i guess u are entering integers rather than binary.
Deletejust change the class name bro it works!!!
Delete:-s
Deleteplz give me algorithm of bit and character stuffing
ReplyDeleteThis comment has been removed by the author.
ReplyDeletepichha nakodaka aa code anti aa lokam anti? :-b chinnaga pettu mari antha pedda code lu anti
ReplyDeleteLearned a lot of new things from your post!Good creation
ReplyDeleteJava Online Training
After its use, use scanner close (), to avoid leakage of data and code efficeincy
ReplyDelete