Protocol 1 utopia
header file
/*
Protocol 1 (utopia)
provides for data transmission in one direction only, from sender to receiver.
The communication channel is assumed to be error free,
and the receiver is assumed to be able to process all the input infinitely fast.
Consequently, the sender just sits in a loop pumping data out onto the line as
fast as it can.
*/
#include<stdio.h>
#include<fcntl.h>
#include<string.h>
//define the frame structure
typedef struct
{
int seqno;
int ackno;
char data[100];
}frame;
//services used @ sender side
void from_network_layer(char buffer[],int sno)
{
printf("Enter Frame [%d] : ",sno);
scanf("%s",buffer);
}
void to_physical_layer(int pid,frame *f)
{
write(pid,f,sizeof(frame));
}
//services used @ reciving side
void from_physical_layer(int pid,frame *f)
{
read(pid,f,sizeof(frame));
}
void to_network_layer(char buffer[],int sno)
{
printf("\nFrame [%d] : %s",sno,buffer);
}
Sender
#include "header.h"
void main()
{
int pid,i,no;
char buffer[100];
frame f;
system(">pipe");
pid=open("pipe",O_WRONLY);
printf("How many Frame you want to send? : ");
scanf("%d",&no);
write(pid,&no,sizeof(no));
for(i=0;i<no;i++)
{
from_network_layer(buffer,i); /* get some data from network layer to send next layer */
strcpy(f.data,buffer); /* copy received data into frame's pay load for transmission */
f.seqno=i;
to_physical_layer(pid,&f); /* send our frame on physical layer */
}
close(pid);
}
Receiver
#include "header.h"
void main()
{
int pid,no,i;
char buffer[100];
frame f;
pid=open("pipe",O_RDONLY);
read(pid,&no,sizeof(no));
printf("Total Frame Recived : %d",no);
for(i=0;i<no;i++)
{
from_physical_layer(pid,&f); /* get some data from physical layer to send network layer */
strcpy(buffer,f.data); /* copy received data into buffer */
to_network_layer(buffer,f.seqno); /* send our received data to network layer */
}
close(pid);
unlink("pipe");
}
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