Thursday, March 1, 2012

Write a Program of Uthopia Protocol

//Header.c

include
#include
char str[100];
void from_network_layer()
{
printf("Enter the data :");
scanf("%s",str);
}
void to_network_layer()
{
printf("Received data is : %s\n",str);
}
int from_physical_layer(int pid)
{
read(pid,str,100);
}
void to_physical_layer(int pid)
{
write(pid,str,100);
}


//Receiver.c
#include "header.c"
main()
{
int pid;
mkfifo("pipe_data",0666);
pid=open("pipe_data",O_RDONLY);
//printf("ok......\n");
while(from_physical_layer(pid))
{
to_network_layer();
}
close(pid);
unlink("pipe_data");
}

//Sender.c
#include "header.c"
#include "header.c"
main()
{
int pid,no,i;
pid=open("pipe_data",O_WRONLY);
printf("Enter the no of frames you want to enter :");
scanf("%d",&no);
for(i=0;i