Protocol with Endianness
Due: 5:00am, Friday, November 8, 2024
Get the Assignment Code
Login to your university Unix account and copy the assignment code to a location under your home directory. The starter code for this assignment is on the Linux server here:
/export/home/public/schwesin/cpsc328/assignments/project5
Description
For this project you will write a client program to read string data from a server. The assignment directory contains a directory named ‘reference’ which contains a reference implementation of the client and server for testing.
Part of the protocol for this project entails string packets. A string packet has two parts: the length of a string and the ASCII characters of the string. The length is encoded in the first two bytes of the packet as an unsigned two-byte integer (an unsigned short in C) in big endian (network) byte order.
Here is an example string packet in hex:
h e l l o
00 05 68 65 6C 6C 6F
Here is an outline of the protocol:
Client:
- client connects to server
- client receives string packet with the string “BEGIN’
- client sends a four-byte integer in big endian indicating how many random strings to receive
- client receives the requested number of random string packets
- client closes its write end of the socket
- client receives string packet with the string “END’
- client closes its socket completely
Server:
- server accepts a connection
- server sends a string packet with the string “BEGIN”
- server receives a four-byte integer in big endian indicating the number of random string packets to send
- server sends the requested number of random string packets
- server waits for the client to close its write end of the socket
- server sends a string packet with the string “END”
- server closes the accepted socket
Specifications
The name of the compiled program must be
client
.The input to the program must be in the form of command line arguments as follows:
-h <string>
(required) host-p <string>
(required) port-n <string>
number of strings requested (default 1)
The following rules must be added to the provided Makefile:
- Add a rule to build an executable named
client
. This must be the default action of the Makefile. - Add a rule called
clean
to remove any temporary files and theclient
executable.
- Add a rule to build an executable named
Turning in the Assignment
To turn in the assignment, execute the submit script by running the command
make submit
from within the project5
directory.
Grading Criteria
- Consistent coding style
- Modular design
- Correct implementation of the specification
- Correct error checking of library calls
Note: If the submission includes material that was not covered in class and the material is not properly cited, then you will receive a failing grade for this assignment.