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:

  1. client connects to server
  2. client receives string packet with the string “BEGIN’
  3. client sends a four-byte integer in big endian indicating how many random strings to receive
  4. client receives the requested number of random string packets
  5. client closes its write end of the socket
  6. client receives string packet with the string “END’
  7. client closes its socket completely

Server:

  1. server accepts a connection
  2. server sends a string packet with the string “BEGIN”
  3. server receives a four-byte integer in big endian indicating the number of random string packets to send
  4. server sends the requested number of random string packets
  5. server waits for the client to close its write end of the socket
  6. server sends a string packet with the string “END”
  7. server closes the accepted socket

Specifications

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

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.