The goal of this programming assignment is to simulate the sliding window
protocol discussed in the
class (Section 2.5.2 of the textbook). Similar to Project 1, you will implement
a server and a client programs
where the client program can be invoked to request a file from the server. The
key difference between Project
1 and this project is to use a sliding window protocol for communication between
the server and the client.
To test the sliding window protocol, you will also simulate packet losses.
Server:
The server program should start on a port specified as a command-line
argument and listen for
connections from clients. When a connection from a client is established, server
should read a string from
the client. This string will be the name of the file that the client is
interested in. Server should check in the
file directory, specified as a command line argument, to see if the requested
file exits. If a file exists, server
should respond to the client with a string “SUCCESS” followed by the contents of
the file. If no file exists
with the requested name, then the server should respond with the following
failure message string—“NO
SUCH FILE EXISTS”.
Server should use the sliding window protocol to send the file contents to the
client. Server should
fragment the contents into small frames of size, FrameSize. Server should use a
sliding window size specified
as command-line argument and use a loss probability specified on command-line to
simulate packet losses
on the outgoing packets.
Server should support the following arguments:
So, one should be able to start a server listening on port number 5678,
serving files in directory “./testDir”,
with frame sizes of 100, with sender window size of 10, and loss probability of
1 in every 10 packets as follows:
$> ./server -p 5678 -d ./testDir -F 100 -w 10 -l 0.1
Client:
The client program should take command-line arguments to denote a
server’s name and server’s
port number that it will connect to, and a string denoting the name of the file
it will request from the server.
If the client obtains the file successfully, it should create a file with name
specified above in the local directory
and write the contents into that file. Remember to remove “SUCCESS” string at
the start of the contents
received from the server. Also client program should accept command-line
arguments for specifying frame
size, receiving window size, and a loss probability. Similar to server, client
should use the loss probability
specified on the command-line to simulate packet losses only on the outgoing
packets.
The client program should support the following arguments:
• -s <servername>: Name of the machine where server is located. If you are
running server and client on a same host, you can specify “localhost” as the
server name.
• -p <serverport>: Port number where server is running
• -f <fileNameToRequest>: Name of the file to download
• -F <FrameSize>: Payload size in each frame
• -w <ReceiverWindowSize>: Sliding window size at the receiver
• -l <LossProbability>: A float value to denote the packet loss probability.
You should be able to start a client to connect to the server started in the example above, to request a file testFile while using frame size of 100 and a receiver window size of 10 and loss probability of 1 in every 20 packets as follows:
$> ./client -s localhost -p 5678 -f testFile -F 100 -w 10 -l 0.05
Important Notes: