SlideShare a Scribd company logo
ECE 477 Bitstuffing
Created Fall 2010 Revised: Fall 2010
Objectives
Understand the bitstuffing technique in-depth.
Write two C-language programs. One that performs bit stuffing on a sequence of ASCII
represented zeros and ones and the other that unstuffs the ASCII formatted frame.
Become more proficient in C-programming.
Discussion
Consider the bit stuffing technique described in class and in the textbook. In this technique, we use
the special bit pattern, 01111110, as a flag to delimit the start and end of frames. Bit stuffing allows
arbitrary data patterns to be used in a frame and still allow a receiver to determine where a frame
begins and ends. In summary, after every 5 consecutive 1's in the data, an extra 0 is inserted by the
sender. This process is reversed at the receiver. If there are two consecutive back-to-back frames,
then assume that there is a separate flag for the end of the first and a separate flag for the start of
the second. Any frames that do not start or end with a valid flag are discarded. One of the most
common applications that uses bit stuffing is USB interfaces.
The bit stuffing/unstuffing procedure can be efficiently implemented using a finite-state machine.
The state diagram for a bit unstuffing finite-state machine is shown below:
ECE 477 Bitstuffing
Created Fall 2010 Revised: Fall 2010
Implementation
Since the objective of this assignment is to understand the bitstuffing technique, I have some
simplifications that will make the assignment easier. We will represent the data bits in a frame as the
ASCII characters ‘0’ (hex 0x30) and ‘1’ (hex 0x31). This will allows us to process and view the input and
output data using a terminal or text editor rather than going through the steps of manipulating the
individual bits themselves, which is somewhat complicated in software. Your sending program will read
the data from an input text file that contains the ASCII represented bits that will be framed and
“stuffed” by your sending program and its output saved to an output text file. Likewise your receiving
program will read an input text file, detect the start-of-frame and end-of-frame delimiters, and “unstuff”
the stuffed bits as necessary. To further simplify things, we can use an input/output method called
standard-I/O (stdio) redirection what will eliminate the need for you to learn and use file I/O operations.
To jump-start you on this task, I have made a sample program available that illustrates the
implementation of a finite-state machine, the processing of ASCII data, and the usage of I/O redirection.
All files necessary for this assignment can be found at:
http://www.ee.siue.edu/~bnoble/classes/ece477/lab/bitstuff/files/
At this URL, there are two directories of interest. The directory named sample contains a C-program that
detects a simple ASCII sequence by use of a finite-state machine implemented in C. To use and learn
from it, save the source file, seqdetect.c, to your account on your lab computer and open it with a text
editor. Contained in the comments are the instructions for both compiling it as well as examples of using
it with I/O redirection. For this task you will need to open a terminal program. The terminal gives you
access to the UNIX shell where you can execute commands on your operating system. You need to
become familiar with the shell since later labs will require you to modify the behavior of your lab system
using commands executed within the shell.
ECE 477 Bitstuffing
Created Fall 2010 Revised: Fall 2010
Assignment
Write two C-programs.
Sender: Reads ASCII 0's and 1's from a file and frames them with the 01111110 sequence
appropriately. A file can contain multiple frames with each frame corresponding to a single line
of ASCII 0’s and 1’s. A carriage-return or new-line means the end of that data to be framed. Each
subsequent line represents a new set of data to be framed. The output of the sender program
should not place any carriage-returns or new-lines between the frames; the output should only
be one long line of zeros and ones terminated by a single carriage-return/new-line at the end.
Receiver: Reads a bitstuffed ASCII string of 0’s and 1’s from a file, in the format described in the
sender program description, and breaks it up into the data contained in each of the frames. Your
output should be a sequence of frames (1 per line) with all start/end sequences and stuffed bits
removed. If an error is detected, it should print "Error Detected" and exit immediately.
Both programs should be thoroughly commented in such a way that its logic and flow can be
followed by reading the comments and the source code alone.
Demonstration and Report
On the due date you need to schedule a demonstration time with the TA. During the demonstration, you
will be expected to show your programs operation and may be asked to run it on a frame supplied by
the TA. You will also be expected to answer questions about its operation. Credit for this assignment will
only be earned if you can demonstrate complete knowledge of your programs implementation and
operation, even if the program works correctly.
You must include the output of your sender program when it is given the files named sinput and the
output of your receiver program when it is given the files named rinput, both of which are located in the
directory named data at the URL given above.
Your report should describe the logic you used in implementing the program as well as its operation.
You should also describe how you determined that it was functioning correctly and how you verified
that all states within your program were tested for correct operation. You must include a state diagram
for your sender program.

More Related Content

PPTX
أجهزة الارتباط الشبكي ومهامها
PDF
historyofcomputer-170621232538.pdf
PDF
ใบงานที่ 1.1
PDF
Basic of computer
PDF
ภาษาซี
PDF
แนวข้อสอบบรรจุครูผู้ช่วย วิชาเอกคอมพิวเตอร์ ชุดที่ 4
PDF
Ky thuat-chuyen-mach -ky-thuat-chuyen-mach-1
PDF
ชั้นประถมศึกษาปีที่ 4
أجهزة الارتباط الشبكي ومهامها
historyofcomputer-170621232538.pdf
ใบงานที่ 1.1
Basic of computer
ภาษาซี
แนวข้อสอบบรรจุครูผู้ช่วย วิชาเอกคอมพิวเตอร์ ชุดที่ 4
Ky thuat-chuyen-mach -ky-thuat-chuyen-mach-1
ชั้นประถมศึกษาปีที่ 4

What's hot (20)

DOCX
ผลการดำเนินงานเศรษฐกิจพอเพียง
PDF
Buku pintar mgr
PPTX
Computer (ประวัติความเป็นมาของคอมพิวเตอร์)
PPTX
Workflow ykhoanet
PPTX
INTRODUCTION TO MOBILE COMPUTING.pptx
PDF
CSS L13 STRUCTURED CABLING SYSTEM
PDF
พระราชบัญญัติระเบียบบริหารราชการกรุงเทพมหานคร พ.ศ.๒๕๒๘
PDF
แผนการเรียนรู้การใช้งานโปรแกรม Microsoft Office Excel
PDF
IRJET- IoT based Smart Ambulance System
PDF
3.5 อารยธรรมโรมัน
PDF
แนวข้อสอบครูผู้ช่วยวิชาเอกคอมพิวเตอร์ 2
DOCX
แบบทดสอบวิชาคอมพิวเตอร์เบื้องต้น
PDF
Luận văn: Nghiên cứu hệ thống rút tiền tự động ATM, HOT
PPTX
DOCX
แบบสอบถามความพึงพอใจของผู้ใช้บริการห้องสมุด
DOCX
โครงงานเรื่อง กล้วยฉาบ
PDF
สรุปความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์
PDF
BẢO MẬT VÀ AN TOÀN THÔNG TIN TRONG THƯƠNG MẠI ĐIỆN TỬ
DOC
ĐỒ ÁN - Ứng dụng Openvpn trong bảo mật hệ thống mạng cho doanh nghiệp.doc
PPTX
Fundamental of computers by Neeraj Bhandari ( Surkhet.Nepal )
ผลการดำเนินงานเศรษฐกิจพอเพียง
Buku pintar mgr
Computer (ประวัติความเป็นมาของคอมพิวเตอร์)
Workflow ykhoanet
INTRODUCTION TO MOBILE COMPUTING.pptx
CSS L13 STRUCTURED CABLING SYSTEM
พระราชบัญญัติระเบียบบริหารราชการกรุงเทพมหานคร พ.ศ.๒๕๒๘
แผนการเรียนรู้การใช้งานโปรแกรม Microsoft Office Excel
IRJET- IoT based Smart Ambulance System
3.5 อารยธรรมโรมัน
แนวข้อสอบครูผู้ช่วยวิชาเอกคอมพิวเตอร์ 2
แบบทดสอบวิชาคอมพิวเตอร์เบื้องต้น
Luận văn: Nghiên cứu hệ thống rút tiền tự động ATM, HOT
แบบสอบถามความพึงพอใจของผู้ใช้บริการห้องสมุด
โครงงานเรื่อง กล้วยฉาบ
สรุปความรู้เบื้องต้นเกี่ยวกับคอมพิวเตอร์
BẢO MẬT VÀ AN TOÀN THÔNG TIN TRONG THƯƠNG MẠI ĐIỆN TỬ
ĐỒ ÁN - Ứng dụng Openvpn trong bảo mật hệ thống mạng cho doanh nghiệp.doc
Fundamental of computers by Neeraj Bhandari ( Surkhet.Nepal )
Ad

Viewers also liked (16)

PDF
Обучающий комикс Приключения льва Лявона: «Платёжная карточка»
DOCX
Rospau entrevistabona
PPTX
Rospau esquemes tema 4
PPTX
Pau rosbouesquemestema1 i 2
DOCX
El planeta terra(activitats)
PPT
Halloween
PDF
Обучающий комикс Приключения льва Лявона «Обмен валют»
PDF
Piràmides pau ros3erd
PPTX
Esquemes tema 8
PPTX
Rospau esquemes tema 4
PPTX
ทีม
DOCX
Activitats tema3 pauros3er_d
PPTX
PDF
Planol urba mallorca_pau_ros3erd
PPTX
Classroom engagement
Обучающий комикс Приключения льва Лявона: «Платёжная карточка»
Rospau entrevistabona
Rospau esquemes tema 4
Pau rosbouesquemestema1 i 2
El planeta terra(activitats)
Halloween
Обучающий комикс Приключения льва Лявона «Обмен валют»
Piràmides pau ros3erd
Esquemes tema 8
Rospau esquemes tema 4
ทีม
Activitats tema3 pauros3er_d
Planol urba mallorca_pau_ros3erd
Classroom engagement
Ad

Similar to Bitstuffing (20)

DOCX
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
PDF
Mp lab manual
PDF
ARM Embeded_Firmware.pdf
PDF
Project 2 Assigned Tuesday February 21tst2023 Due Tuesd.pdf
PDF
This project explores usage of the IPC in the form of shared.pdf
PPTX
Input-output
DOCX
PDF
C question
PPTX
What is algorithm
PDF
Input and output in c++
PDF
Alp 05
PDF
Porting is a Delicate Matter: Checking Far Manager under Linux
PDF
Introduction To Programming With C 1st Edition Nhce
PDF
Embedded concepts
PDF
Mp &mc programs
PDF
A Project Based Lab Report On AMUZING JOKE
PPT
Assembly language programming(unit 4)
DOCX
Program 1 – CS 344This assignment asks you to write a bash.docx
PDF
2600 v08 n1 (spring 1991)
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
Mp lab manual
ARM Embeded_Firmware.pdf
Project 2 Assigned Tuesday February 21tst2023 Due Tuesd.pdf
This project explores usage of the IPC in the form of shared.pdf
Input-output
C question
What is algorithm
Input and output in c++
Alp 05
Porting is a Delicate Matter: Checking Far Manager under Linux
Introduction To Programming With C 1st Edition Nhce
Embedded concepts
Mp &mc programs
A Project Based Lab Report On AMUZING JOKE
Assembly language programming(unit 4)
Program 1 – CS 344This assignment asks you to write a bash.docx
2600 v08 n1 (spring 1991)

Recently uploaded (20)

PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
Basic Mud Logging Guide for educational purpose
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Cell Structure & Organelles in detailed.
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Complications of Minimal Access Surgery at WLH
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Insiders guide to clinical Medicine.pdf
PPTX
master seminar digital applications in india
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Business Ethics Teaching Materials for college
PDF
Microbial disease of the cardiovascular and lymphatic systems
O5-L3 Freight Transport Ops (International) V1.pdf
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Basic Mud Logging Guide for educational purpose
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Microbial diseases, their pathogenesis and prophylaxis
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Cell Structure & Organelles in detailed.
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Supply Chain Operations Speaking Notes -ICLT Program
Complications of Minimal Access Surgery at WLH
VCE English Exam - Section C Student Revision Booklet
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
TR - Agricultural Crops Production NC III.pdf
Final Presentation General Medicine 03-08-2024.pptx
Insiders guide to clinical Medicine.pdf
master seminar digital applications in india
Module 4: Burden of Disease Tutorial Slides S2 2025
human mycosis Human fungal infections are called human mycosis..pptx
Business Ethics Teaching Materials for college
Microbial disease of the cardiovascular and lymphatic systems

Bitstuffing

  • 1. ECE 477 Bitstuffing Created Fall 2010 Revised: Fall 2010 Objectives Understand the bitstuffing technique in-depth. Write two C-language programs. One that performs bit stuffing on a sequence of ASCII represented zeros and ones and the other that unstuffs the ASCII formatted frame. Become more proficient in C-programming. Discussion Consider the bit stuffing technique described in class and in the textbook. In this technique, we use the special bit pattern, 01111110, as a flag to delimit the start and end of frames. Bit stuffing allows arbitrary data patterns to be used in a frame and still allow a receiver to determine where a frame begins and ends. In summary, after every 5 consecutive 1's in the data, an extra 0 is inserted by the sender. This process is reversed at the receiver. If there are two consecutive back-to-back frames, then assume that there is a separate flag for the end of the first and a separate flag for the start of the second. Any frames that do not start or end with a valid flag are discarded. One of the most common applications that uses bit stuffing is USB interfaces. The bit stuffing/unstuffing procedure can be efficiently implemented using a finite-state machine. The state diagram for a bit unstuffing finite-state machine is shown below:
  • 2. ECE 477 Bitstuffing Created Fall 2010 Revised: Fall 2010 Implementation Since the objective of this assignment is to understand the bitstuffing technique, I have some simplifications that will make the assignment easier. We will represent the data bits in a frame as the ASCII characters ‘0’ (hex 0x30) and ‘1’ (hex 0x31). This will allows us to process and view the input and output data using a terminal or text editor rather than going through the steps of manipulating the individual bits themselves, which is somewhat complicated in software. Your sending program will read the data from an input text file that contains the ASCII represented bits that will be framed and “stuffed” by your sending program and its output saved to an output text file. Likewise your receiving program will read an input text file, detect the start-of-frame and end-of-frame delimiters, and “unstuff” the stuffed bits as necessary. To further simplify things, we can use an input/output method called standard-I/O (stdio) redirection what will eliminate the need for you to learn and use file I/O operations. To jump-start you on this task, I have made a sample program available that illustrates the implementation of a finite-state machine, the processing of ASCII data, and the usage of I/O redirection. All files necessary for this assignment can be found at: http://www.ee.siue.edu/~bnoble/classes/ece477/lab/bitstuff/files/ At this URL, there are two directories of interest. The directory named sample contains a C-program that detects a simple ASCII sequence by use of a finite-state machine implemented in C. To use and learn from it, save the source file, seqdetect.c, to your account on your lab computer and open it with a text editor. Contained in the comments are the instructions for both compiling it as well as examples of using it with I/O redirection. For this task you will need to open a terminal program. The terminal gives you access to the UNIX shell where you can execute commands on your operating system. You need to become familiar with the shell since later labs will require you to modify the behavior of your lab system using commands executed within the shell.
  • 3. ECE 477 Bitstuffing Created Fall 2010 Revised: Fall 2010 Assignment Write two C-programs. Sender: Reads ASCII 0's and 1's from a file and frames them with the 01111110 sequence appropriately. A file can contain multiple frames with each frame corresponding to a single line of ASCII 0’s and 1’s. A carriage-return or new-line means the end of that data to be framed. Each subsequent line represents a new set of data to be framed. The output of the sender program should not place any carriage-returns or new-lines between the frames; the output should only be one long line of zeros and ones terminated by a single carriage-return/new-line at the end. Receiver: Reads a bitstuffed ASCII string of 0’s and 1’s from a file, in the format described in the sender program description, and breaks it up into the data contained in each of the frames. Your output should be a sequence of frames (1 per line) with all start/end sequences and stuffed bits removed. If an error is detected, it should print "Error Detected" and exit immediately. Both programs should be thoroughly commented in such a way that its logic and flow can be followed by reading the comments and the source code alone. Demonstration and Report On the due date you need to schedule a demonstration time with the TA. During the demonstration, you will be expected to show your programs operation and may be asked to run it on a frame supplied by the TA. You will also be expected to answer questions about its operation. Credit for this assignment will only be earned if you can demonstrate complete knowledge of your programs implementation and operation, even if the program works correctly. You must include the output of your sender program when it is given the files named sinput and the output of your receiver program when it is given the files named rinput, both of which are located in the directory named data at the URL given above. Your report should describe the logic you used in implementing the program as well as its operation. You should also describe how you determined that it was functioning correctly and how you verified that all states within your program were tested for correct operation. You must include a state diagram for your sender program.