CY350

On this page

  • Overview
    • Generative AI Use Policy
    • Learning Objectives
    • Submission Instructions
    • Points Breakdown
  • Part 1: HTTP Server
    • Key Tasks
    • Testing
    • Hints
  • Part 2: Go-Back-N Protocol
    • SABRE Protocol Packet Structure
    • Key Features
    • Getting Started
    • Key Tasks
    • Hints
    • Testing
  • Part 3: Explain your work

Other Links

  • HTTP Messages
  • Gradescope

Code Links

  • Starter Files ZIP
  • Starter Files GitHub

Project 1 - Web Server and Reliable Data Transfer

Implement a basic Web Server and Go-Back-N protocols over UDP
Published

March 4, 2026

Overview

In this project, you will tackle two layers of the network stack-

  • At the application layer, you will implement a simple HTTP server.
  • At the transport layer, you will implement a reliable data transfer protocol over UDP using the Go-Back-N protocols.

Generative AI Use Policy

The use of generative AI tools is prohibited for the written portion of this assignment.

The use of generative AI tools such as ChatGPT or Claude is authorized for the programming portion of this assignment subject to the following restrictions:

  • You may only use a generative AI tool that has **study mode*- or the equivelant concept enabled.
    • ChatGPT calls it Study and learn mode.
    • Gemini calls it Guided Learning mode.
    • VS Code Copilot does not meet this requirement and must be disabled within VSCode before you start writing any code for this project. Features > Chat > Disable AI Features
  • You must provide a link to your chat in your DAAW and properly inline cite provided assistance.
    • Recommend that you open your link in an incognito window to verify that it is publicly accessible. If you cannot reach it from an incognito window, your instructor will not be able to access it either.
  • You must copy and paste the following prompt as the very first message in any chat on any tool you use:
Following are the authorized Human-AI teaming (HAT) levels

- HAT Level 1: Support learning of concepts - Focus on explaining concepts, theories, or background knowledge without giving direct solutions.
- HAT Level 2: Collaborate in thinking/reasoning/design - Brainstorm, evaluate, or suggest ideas and options, but do not provide a fully formed solution.

This conversation is for an assignment where you serve as a tutor for me and all responses should be limited to HAT level 1 and HAT level 2.

Failure to follow any of the above restrictions will be considered unauthorized collaboration will result in a significant deduction of points.

Learning Objectives

  • Implement a functioning HTTP server that can parse HTTP requests, generate appropriate responses, and handle conditional GET requests.
  • Explain why UDP is unreliable and describe strategies to achieve reliable data transfer over UDP.
  • Design and implement a custom transport header with TCP-like flags and fields.
  • Implement 3-way handshake over UDP and a graceful connection teardown.
  • Implement sliding window protocols such as Go-Back-N.
    • Use a single base timer, cumulative ACKs, and bulk retransmissions.
  • Analyze and understand protocol behavior using Wireshark.
  • Reflect on trade-offs between protocol complexity and performance.

Submission Instructions

  1. Part 1 (HTTP Server): Submit your code to Gradescope. Autograder will give you feedback on the correctness of your implementation.

  2. Part 2 (Go-Back-N Protocol): Run your code on the WREN. Your sender program (client) will reach out to the receiver (server) and attempt to transmit data. The server logs your activity and will track successful transmissions. When completed, submit your code to Gradescope. Autograder will ensure that your code is free of compilation errors but will not attempt to run it for you.

  3. Part 3: Once you have completed the programming portion, you will answer several questions on Canvas that explain your thought process. Majority of your grade will be based on your understanding and explanation of your implementation, which requires you to have a working implementation. These must be answered in your own words without any assistance from generative AI tools. You may discuss these questions with your instructor and verbally assist others to develop understanding of the material, but you may not share your written responses with anyone else.

Tip

If you are unable to get your code working, explain your testing strategy, what you did to debug your code, and what your steps would have been to get it working. Consider what prevented you from actually taking those steps.

Points Breakdown

  • Part 1: Basic HTTP Server - 30 points
  • Part 2: Go-Back-N Protocol - 30 points
    • Submit a working implementation free of compilation errors - 5 points
    • connect() - 10 points
    • send() - 10 points
    • close() - 5 points
  • Part 3: Explanation of your work - 40 points

Bonus Points: 5 extra points if you submit the project in its entirety 5 days before the deadline.

Part 1: HTTP Server

This part introduces you to the client-server programming paradigm and the basics of HTTP. Using your code from Lab 3, implement a HTTP server that supports GET method of the HTTP/1.1 protocol. You are only expected to handle one request per connection.

  • Correctly initialize a TCP listening socket.
  • Accept incoming connections from clients.
  • Receive and reassemble a segmented GET or POST request from a client.
  • Handle GET request and parse the method, resource, and headers.
  • Look up the requested resource, check the cache, and determine the correct response.
  • Generate the HTTP response, properly segment it, and send it back to the client.
  • Close the TCP connection after each response and start over.

Key Tasks

  • Implement segmentation and reassembly of messages. This means you will need to handle cases where a single HTTP request or response is split across multiple TCP segments.
  • Parse HTTP requests to extract the method, resource, and headers. See HTTP Message Format for exactly how HTTP messages are structured.
  • Handle GET requests. Parse the If-None-Match header and conditionally return 304 Not Modified if the content cache entry is valid.
  • Generate appropriate HTTP responses with correct status codes, headers, and body content.

Testing

Gradescope will give you a score with minimal feedback. You must develop your own testing strategy. Here are some ideas:

curl

curl -v localhost:8090
curl -v localhost:8090/

firefox (or any web browser)

  • Open Developer Tools and go to the Network Monitor. Use Ctrl-Shift-ECtrl-Shift-E to bring it up.
  • Navigate to http://localhost:8090
  • Observe the request and response details
    • request method, URL, headers
    • response status code, headers, body

Hints

  • Most autograder test results are hidden. Come up with your own test cases and test your code locally.
  • Test your work incrementally. Don’t try to implement everything at once. Test each piece as you go.
  • Use Wireshark to analyze the packets being sent and received by your server.
  • Add lots of print statements to your code to understand the flow of execution and produce useful debug information. You can comment out these print statements as you progress.
  • Check CRLF termination \r\n\r\n carefully.
  • Ensure Content-Length matches body length.
  • Use your browser’s Network Monitor to analyze If-None-Match header and expected 304 Not Modified response.

Part 2: Go-Back-N Protocol

Army needs robust communication protocols that works over unreliable networks especially in contested environments. You propose a new protocol called SABRE (Simple And Basic Reliable Exchange) that provides reliable data transfer over UDP. USMA’s CIO is very interested in your protocol and wants you to implement it as a proof of concept. You are very excited to show off your recently acquired CY3350 knowledge and skills, and cannot wait to demonstrate the power of your protocol. You will implement the client side of the SABRE protocol, and I will host the server side for you to test against.

Objective: Implement Go-Back-N protocol for reliable data transfer over UDP to transfer a file from the client (sender) to the server (receiver).

SABRE Protocol Packet Structure

packet
title SABRE Packet
+8: "PACKET TYPE"
+4: "PADDING"
+1: "RST"
+1: "FIN"
+1: "SYN"
+1: "ACK"
+16: "LENGTH"
+16: "SEQUENCE NUMBER"
+16: "ACKNOWLEDGEMENT"
+32: "CADET ID"

Key Features

  • Establish a connection with the receiver using a 3-way handshake with the SYN flag.
  • Use a sliding window mechanism to manage the flow of packets.
  • Implement a single timer for the base of the window to detect timeouts.
  • Implement cumulative acknowledgements to acknowledge all packets up to a certain sequence number.
  • Implement bulk retransmissions of all unacknowledged packets when a timeout occurs.
  • Handle connection teardown using a FIN sequence.
  • Read the payload in the final FIN packet from the server.

Getting Started

Grab the starter code from the github repository or download the ZIP file directly and then implement sender.py. You will be sending packets to a server that I have hosted on the WREN. The server runs the same SABRE protocol. Once you successfully capture a flag from the server, your instructor will be notified.

Type python main.py --help to get started.

Project Files

  • main.py: Main entry point for your sender. You will run this to start your sender and connect to the server.
  • sender.py: This is where you will implement the SABRE protocol.
  • packet.py: This file contains the Packet class that defines the structure of a SABRE packet and provides methods for serialization and deserialization.
  • simpletimer.py: This file contains a simple timer class that you can use for implementing timeouts in your Go-Back-N protocol.
  • corpus.py: This file downloads the sample text files that you will send to the server as payload. It downloads severals e-books from Project Gutenberg to gutenberg.zip file and extracts them to the gutenberg directory.

Key Tasks

In sender.py, implement the following functions:

  • connect(): Establish a connection with the server using a 3-way handshake.
  • send(): Send data to the server using the Go-Back-N protocol.
  • close(): Gracefully close the connection with the server using a FIN sequence.

Upon successful connection and data transfer, inspect the final FIN packet sent by the server.

Hints

  • Try the Go-Back-N Protocol animation from the textbook authors.
  • Use print statements extensively to trace the flow of your program and understand the state of your sender.
  • Since we are using Go-Back-N, you only need a single timer that is provided to you. Use it.
  • Sequence numbers start at 0 and increment by 1 for each packet sent. In Go-Back-N, we do not count the number of bytes but just the number of packets.
  • The ACK number on outgoing packets will remain zero since the sender does not receive any data from the server. The ACK number on incoming packets from the server will be used to determine which packets have been acknowledged.
Warning

⚠ Each time you send out multiple packets in a window, you should expect multiple ACK packets back. Make sure to receive multiple packets for each iteration until you receive None implying no more packets to receive. Otherwise your receive buffer will fill up and your sender will not function correctly.

To receive multiple packets, you can use a loop while True with a break or for _ in range(self.WINDOW_SIZE).

Testing

  • Run your sender on the WREN. You should see some server responses subject to approximately ~20% packet loss.
  • Use tcpdump or tshark to capture and analyze the packets.
sudo tshark -i any -f 'udp port 5050' -x --print -w sabre.pcap # writing to file fails on WSL 🤷
sudo tcpdump -i any udp port 5050

Part 3: Explain your work

See the questions on Canvas. You must answer these questions in your own words without any Generative AI assistance. You may discuss these questions with your instructor and verbally assist others to develop understanding of the material, but you may not share your written responses with anyone else.

Reuse

CC BY-NC-SA 4.0
 

© 2026 United States Military Academy