Simple Character Stuffing Program in C

Character Stuffing Program in C

Here, you will know about character stuffing, and get the source code of Character Stuffing Program in C programming language.

What is Character Stuffing?

Character Stuffing is also known as Byte Stuffing and Character Oriented Framing. It is equivalent to bit stuffing, where as operates on bytes whereas bit stuffing operates on bits.
 
A byte (usually the escape character, ESC) that has a pre-defined pattern is appended to the data section of the frame when any data contains the same pattern as the character in the flag. Whenever the receiver sees an ESC character, it removes it from the data section and treats the next character as data (not as a flag). 
 
But the problem arises when a text contains one or more escape characters and is followed by a flag. To solve this problem, the escape character that is part of the text is marked with another escape character. That is to say, if the ESCAPE character is a part of text, then an extra 1 is added to make it appear that the second 1 is part of the text itself. 
 
 character stuffing program in c chart
 
* Point to Point Protocol is the byte based protocol.

 

Algorithm of Character Stuffing (Byte Stuffing)

  • Start
  • Add DLE STX at the beginning of string
  • Check the data to see whether a character is present and to see if the character DLE is contained in the string (for example, DOODLE) Add more DLEs to the string (for example, DOODLEDLE).
  • In the string’s last position, send DLE ETX.
  • print string
  • End

Character Stuffing Program in Computer Networks

Output

Enter a String:   abc[de]fgh

String after Byte Stuffing is performed:  [abc[[de]]fgh]

String after Destuffing is performed:   abc[de]fgh

 

 

 

 

 

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top