Objective:

Simulate sending of a text file using a UDP segment over a UDP socket.

Requirements:

1. Create a C based client-server architecture using UDP socket

2. The server should run on cse02.cse.unt.edu machine and the client should run on cse03.cse.unt.edu machine

3. Create a UDP segment at the client side and populate the fields (source port, destination port, length, and payload) of the segment. The payload (data) should have the contents of the input text file ( 256 bytes)

4. The client should compute the checksum of the UDP segment and transmit the segment to the server

5. The server should receive the UDP segment and verify the checksum. If the checksum is right, then write the payload to an output text file and if the checksum is wrong discard the segment

6. Print on the console and write to log files (server.log and client.log) the UDP segment fields that are transmitted by the client and received by the server.

Procedure:

1. Create a C-based server that can run on cse02.cse.unt.edu and accepts single client's request using UDP socket

2. Create a C-based client that runs on cse03.cse.unt.edu and connects to the server

3. On the client side, create a UDP segment (as shown in Figure 1) using C structure that has the following fields:

  • 16-bit source port [Type: unsigned short int]
  • 16-bit destination port [Type: unsigned short int]
  • 16-bit length [Type: unsigned short int]
  • 16-bit checksum [Type: unsigned short int, computed after the header and payload is populated]
  • 256-byte payload (data) [Type: char]

4. Find the source port, destination port, and length and populate the corresponding fields of the UDP segment

5. Read the input (input.txt) text file ( 256 bytes) and populate the contents of the text file as the payload of the UDP segment

6. Compute the 16-bit checksum for the entire UDP segment and populate the checksum field and transmit the segment

7. Print on the client console and write to a client.log file the values of source port, destination port, length, checksum, and payload of the segment that is transmitted

8. The server will receive the UDP segment from the client and compute the checksum of the received UDP segment.

9. If the segment does not have any errors, then the payload is stored as an output text file (output.txt)

10. Print on the server console and write to a server.log file the values of source port, destination port, length, checksum, and payload of the segment that is received

11. If the segment has errors after checksum calculation, discard the segment. Print on the server console and write to a server.log file the error message saying the segment has errors

12. Make sure the server port number and the input text file are sourced as arguments to the client as shown below

./uclient < port_number> < filename>

11. Run the server as

./userver < port_number>

12. Write to a file (server.log and client.log) and print to the console the UDP segment fields that are transmitted by the client and received by the server

13. An example UDP server code and UDP client code is given on Canvas.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.