project assignment 1 ying zhang eecs 489 w07. clarification questions for each test expected output...

19
Project Assignment 1 Ying Zhang EECS 489 W07

Upload: posy-spencer

Post on 26-Dec-2015

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Project Assignment 1

Ying Zhang

EECS 489 W07

Page 2: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Clarification Questions for each test Expected output for each test

Page 3: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Project

a simple Web server that only serves files. two different I/O models:

select()-based I/O multiplexing (45 points) use select() to serve all clients in a single thread

thread-based blocking I/O. (45 points) pthreads serving each client with its own thread.

documentation (10 points) one to two pages documentation README file

Page 4: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Clarification HTTP file directory: chroot problem

The problem is because in many systems usually only the super-user can use it. Because most of you cannot use as super-user, you cannot use chroot. However, the spec requires: disallow clients from access files above the working directory where the server is run So, besides using chroot, you can parse the command line to check whether there are "../file" such character exists.

checksum issue First of all, the checksum is hard-coded in the python code. And the calcuation is platform dependent. I have modified the HttpTest.py to set the checksum based on platform. So, you don't need to worry about that. Please download the latest HttpTest.py from the web page.

File size In the HTTP spec, you can use "HTTP/1.%d 200 OK\r\nContent-Type: text/html\r\nContent-Length: 1000" to set the file size. However, the filesize is hard-coded in HttpTest.py. So, you don't need to consider how to set the file size for this project because it is not required.

connection for Test 3 The problem is because that there is an inconsistency between the HttpTest.py and the project specification. I have changed the connection value for Test3 to be 1000 to make it consistent with the spec.

Page 5: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Questions for each test

Page 6: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

select can use blocking socket select has three sets read_sets, write_sets, exception_sets

FD_ZERO(&rfds); FD_ZERO(&efds); FD_ZERO(&wfds); FD_SET(listen_Sockfd,&rfds); FD_SET(listen_Sockfd,&efds); if (socks[i].state==StateWaitingForRequest) FD_SET(socks[i].sock, &rfds); FD_SET(socks[i].sock, &efds);

if (socks[i].state==StateSendingFile) FD_SET(socks[i].sock, &wfds); FD_SET(socks[i].sock, &efds);select(MAX_FDSIZE, &rfds, &wfds, &efds, &to);

protect recv() and send() by using select if (FD_ISSET(socks[i].sock, &rfds))

recv() if (FD_ISSET(socks[i].sock, &wfds))

send()

Page 7: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Data ready

Number of bytes is greater than low-water mark for socket receive buffer

Read half of the connection is closed(FIN,EOF)

Listen socket, incoming connection; Socket error pending

Page 8: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Timeout Acutally, you need to implete the checking for inactive connectio

ns. To do that, you need to remember a time for the client's latest activity and use that to compare with your current time

Broken pipe When sending a file, our code will spontaneously stop, then displ

ay "Broken pipe". The python test (#1) ends up throwing a checksum error: signal(SIGPIPE, SIG_IGN);

Page 9: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 2 Resource temporally unavailable?

client sequentially send request for a small file, recv file, and close the socket (Phython code GetFile())

server finish sends need to check whether the connection is closed by the client

select(MAX_FDSIZE, &rfds, &wfds, &efds, &to); for (int i=0;i<ALL_CONNECTIONS;i++)

if (FD_ISSET(socks[i].sock, &rfds))– ready to read because of FIN_received

If(recv() == 0)close_connection()

socket number increased by 2, reaching max 1024 quickly?

limit the number of file descriptor used for opening file at a time

Page 10: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 3

Connect to the server until the server cannot handle more connections Set maximum number of connections

//check if can accept another connection if (nconn<MAX_CONNECTIONS) Or Select(MAX_CONNECTIONS, &rfds, &wfds, &efds, &to);

Keep persistent connections //get current time time(&curTime); If(curTime-socks[i].timestamp)>=TIMEOUT)

close_connection Rev request:

time(&socks[i].timestamp);

Page 11: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 3

avoid blocking in send() each time send a chunk of file for each connection select(FD_SETSIZE, &rfds, &wfds, &efds, &to); for (int i=0;i<CONNECTIONS_WAIT_SNED;i++)

if (FD_ISSET(socks[i].sock, &wfds)) Send size

if we are sending an error, file_pos=-1 file and are not done with the file send chuck size whatever remains in the buffer

Page 12: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 5

Maximum number of concurrent slow downloads

client send request without recv() In Python code, DownloadThread() function, c

heck __MAX_IDLE_SECONDS__ (10sec), close

Page 13: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Expected output for each test

Page 14: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 1 ############################################################### Test #1: Get a single file from the web server (Simple Correctness) Calculating checksum HttpTest.py:194: FutureWarning: %u/%o/%x/%X of negative int will return a signed str

ing in Python 2.4 and up print "Received file with checksum: %08X, elapsed time: %f seconds" % \ Received file with checksum: 83021ED8, elapsed time: 0.170263 seconds Checksum is correct (PASSED)

#Wed Feb 7 16:27:38 2007 0 Accepting new connection from client 141.212.110.75:43036.

##Wed Feb 7 16:27:39 2007 0 client 141.212.110.75:43036 prematurely disconnected.

Page 15: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 2

############################################################### Test #2: Get a small file 2000 times from the web server (Resource de-allocation and latency) Received 2000 files successfully, average request time: 1.936741 milliseconds

#Wed Feb 7 16:28:12 2007 0 Accepting new connection from client 141.212.110.75:43037.

##Wed Feb 7 16:28:12 2007 0 client 141.212.110.75:43037 prematurely disconnected.

…… ##Wed Feb 7 16:28:12 2007 0 Accepting new connection from client 141.2

12.110.75:43038. ##Wed Feb 7 16:28:12 2007 0 client 141.212.110.75:43038 prematurely di

sconnected.

Page 16: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 3 ############################################################### Test #3: Connect to the server until the server cannot handle more connections (Scal

ability) Server handled all 1000 connections without failing

##Wed Feb 7 16:29:08 2007 0 Accepting new connection from client 141.212.110.75:45037. ##Wed Feb 7 16:29:08 2007 0 Accepting new connection from client 141.212.110.75:45038. ##Wed Feb 7 16:29:08 2007 0 Accepting new connection from client 141.212.110.75:45039. ##Wed Feb 7 16:29:08 2007 0 Accepting new connection from client 141.212.110.75:45040. ##Wed Feb 7 16:29:08 2007 0 Accepting new connection from client 141.212.110.75:45041. ##Wed Feb 7 16:29:08 2007 0 Accepting new connection from client 141.212.110.75:45042. ##Wed Feb 7 16:29:08 2007 0 Accepting new connection from client 141.212.110.75:45043. ##Wed Feb 7 16:29:08 2007 0 Accepting new connection from client 141.212.110.75:45044.

….. ##Wed Feb 7 16:29:32 2007 104 client 141.212.110.75:45037 prematurely disconnected.

Page 17: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 4

############################################################### Test #4: Maximum bandwidth of 100 concurrent downloads (Throughput) Waiting for downloads to complet

e........................................................................................................................................................................................................

Test case #4 finished successfully -- Average bandwidth for ~50 MByte transfer: 39.0049286575 MBits/Second

Page 18: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 5

############################################################### Test #5: Maximum number of concurrent slow downloads (Fairness and scalability) Starting concurrent slow download

s......................................................................................................................... 1210 connections in progress when terminated, 0 finished

Page 19: Project Assignment 1 Ying Zhang EECS 489 W07. Clarification Questions for each test Expected output for each test

Test 6

############################################################### Test #6: Repeatedly connect, send request, then close connection (Resource de-allo

cation and error handling) Successfully handled 5000 subsequent failed connections (PASSED)