Byte Stuffing - Framing Technics
Sender
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
#define FLAG '#'
#define ESC '*'
void main()
{
int j=1,i,pid;
char Frame_Data[50],Targeted_Frame[50];
system("clear");
system(">pipe");
pid=open("pipe",O_WRONLY);
printf("Enter the Frame Data : ");
scanf("%s",Frame_Data);
Targeted_Frame[0]=FLAG; //set header FLAG
for(i=0;i<strlen(Frame_Data);i++)
{
if (Frame_Data[i]==FLAG || Frame_Data[i]==ESC) //check FLAG or ESCAPE charechter is in frame data
{
Targeted_Frame[j++]=ESC; // if FLAG / ESCAPE Char found add one more ESCAPE char
}
Targeted_Frame[j++]=Frame_Data[i]; //copy other data
}
Targeted_Frame[j++]=FLAG; //set tailer FLAG
Targeted_Frame[j]='\0';
printf("\nFrame to be send : %s",Targeted_Frame);
write(pid,&Targeted_Frame,sizeof(Targeted_Frame));
close(pid);
}
Receiver
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
#define FLAG '#'
#define ESC '*'
void main()
{
int j=0,i=1,pid;
char str[50],targeted_frame[50],frame_data[50];
pid=open("pipe",O_RDONLY);
read(pid,&targeted_frame,sizeof(targeted_frame));
printf("\ndata received is %s",targeted_frame);
while(targeted_frame[i+1]!='\0')
{
if (targeted_frame[i]==ESC) //check ESCAPE char is in DATA?
{
i++; //remove ESCAPE charecter
}
frame_data[j]=targeted_frame[i];
i++;
j++;
}
frame_data[j]='\0';
printf("\nframe received : %s\n",frame_data);
close(pid);
}
Subscribe to:
Post Comments (Atom)
Subjects
- WordPress
- Mobile Computing-4649303 Practical Solution
- Android Programming New Syllabus Theory
- PHP LAMP Question Bank
- PHP LAMP Theory
- Step by Step Android Example
- Android Practical
- Android Theory
- Android Question Bank
- Networking FON Practical
- Networking FON Theory
- OS Practical
- OS Theory
- HTML
- JavaScript
- J2EE WTAD Theory
- J2EE WTAD Question Bank
- J2EE WTAD Quick Guide
- J2EE WTAD GTU Papers
- J2EE WTAD Practical
- Python
- JAVA Theory
- JAVA Practical
- MIS
Categories
- Android (55)
- c (11)
- Configure Tomcat7 (2)
- CSS (3)
- Decryption (16)
- Difference (1)
- Encryption (16)
- Error Detection and Correction Techniques (3)
- FON (27)
- Framing Technic (2)
- install Tomcat (2)
- J2EE (29)
- JAVA (13)
- JavaScript (19)
- linux (8)
- OS (17)
- PHP (11)
- Protocol (3)
- SERVER SOCKET PROGRAMING (7)
- Servlet (13)
- shell script (33)
- unix (22)
- WTAD (34)
Total Pageviews
© BipinRupadiya.com. Powered by Blogger.
0 comments:
Post a Comment