Please work out the pre-lab problems before your next lab section. The GSI/IAs will go over all problems during the lab section.
You will use sockets in Project 4 to facilitate communication between a client and the network file server you will write. This exercise will serve to give you practice using the various socket functions for both the client and the server.
[pre-lab] A. Read the socket programming tutorial on the course webpage.
[pre-lab] B. Write a simple client and server, where the client sends a string to the server, the server outputs the string using cout, and then sends some acknowledgement response back to the client.
Use TCP by specifying options AF_INET and SOCK_STREAM when calling socket(). Use send() in the client to send data, and recv() in the server to receive it.
[in-lab] C. Run your client and server on a CAEN machine (the client and server programs need to run on the same CAEN machine, since the CAEN firewall won't let you communicate between machines). Then try communicating with another student in your section.
Use the fs_inode and fs_direntry data structures from Project 4 (from fs_server.h) Note: Blocks are 512 bytes, and inodes are block-sized.
A. What is the minimum and maximum number of disk blocks that must be brought into memory in order to read the first block of the file /etc/passwd?
B. A big file /bigfile that is 4 blocks in size is stored in the file system.
B1. Draw out how /bigfile is laid out on disk. Include all inodes and data blocks required to store the file. Assume there are no other files.
B2. A user program makes a read request from offset 1 from /bigfile. How many disk accesses are required to process the request?
B3. i) How many disk accesses are required to process a read request on offset 2 of /bigfile? ii) How many accesses would it be if we had cached the blocks from part b?
B4. If we wanted to add a new directory, /foo, how many new disk blocks do we need to allocate? Update your diagram from part a with the new disk blocks.
B5. A request for a new file, /foo/bar, has been made. How many new disk blocks do we need to allocate? Update your diagram from part a with the new disk blocks.