In: Computer Science
I have this projegt I will use asp.net wHAT PART CAN USE TO COMPLETE THE PROGET
For this project in the (Advanced Computer Networks) course, you may pick a system/language you like, design the project, implement it, and write a project report about it.
This project is related with the Readers and writers. Two types of users, Readers and Writers, can access a shared file. The file is allowed to be read by many readers simultaneously, but to be written by a single writer at a time when no reader is reading.
In this project, you are asked to solve the readers and writers problem by using the clientserver model and a kind of communication facility. Your program consists of several clients (readers and writers), a file access authorization server, and a shared file bank server. Clients may read/write different files or share a single file.
Before a client being able to access a file from the shared file bank server, it must first communicate with the authorization server to get a ticket (an encrypted permission which can be decrypted only by the shared file bank server). The file access authorization server receives requests from clients and manipulates up to N different files. The request message involves the following fields: the ID of the client, the type of the request (R/W), and the name of the file that the client wants to access. A transaction of accessing a file from a client is as follows:
• send REQ Message: request to the authorization server
• block_receive: waiting for a ticket
• send read/write (data) and ticket: request to the file bank server
• block_receive: waiting for data or ACK
• send REL Message: release to authorization server
• loop for certain times
You should test your program by different cases. For example, suppose your system manipulate five files A, B, C, D and E. One possible test case is to start with 30 clients that randomly access (with 30 percent of writers) a randomly selected file. Each client repeat 100 times. You should design at least 5 different test cases and you should use at least 3 computers to run your project.
Project Report: the report is a short report (2-4 pages) for what your project will be. It should contain a problem description and motivation, a description of the design of your solution, a description of your implementation, and an evaluation of how well your system solved the original problem.
/* I have written code for Reader Writer client server in C
programming */
/* server */
#include<stdio.h>
#include<string.h>
#include<netinet/ip.h>
#include<netinet/in.h>
#include<sys/socket.h>
#include<unistd.h>
main()
{
struct sockaddr_in
v,v1;
int
sfd,nsfd,len,i;
char a[100];
sfd=socket(AF_INET,SOCK_STREAM,0);
perror("sfd");
v.sin_family=AF_INET;
v.sin_port=htons(3000);
v.sin_addr.s_addr=inet_addr("0.0.0.0");
len=sizeof(v);
bind(sfd,(struct sockaddr *)&v,len);
listen(sfd,5);
perror("listen");
nsfd=accept(sfd,(struct sockaddr *)&v1,&len);
perror("accept");
while(1)
{
read(nsfd,a,sizeof(a));
printf("%s\n",a);
for(i=0;a[i];i++)
if(a[i]>='a' && a[i]<='z')
a[i]=a[i]-32;
/*scanf("\t\t%s",a);*/
gets(a);
write(nsfd,a,strlen(a)+1);
}
}
/ * client */
#include<stdio.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<string.h>
#include<stdlib.h>
int main(int argc ,char* argv[])
{
int sfd, nsfd;
char a[256];
struct sockaddr_in
var;
socklen_t l;
if((sfd =
socket(AF_INET, SOCK_STREAM, 0))==-1)
perror("socket");
var.sin_family =
AF_INET;
var.sin_port =
htons(atoi(argv[1]));
var.sin_addr.s_addr =
INADDR_ANY ;//net_addr("0.0.0.0");
l = sizeof(var);
connect(sfd, (struct
sockaddr *)&var, l);
perror("connect");
printf("message
:");
while(1){
scanf("%s", a);
write(sfd, a, strlen(a)+1);
sleep(1);
read(sfd, a, sizeof(a));
printf("%s\n", a);
}
}
