A complete implementation of the FT-Echo protocol for TCP-based file transfer with support for LIST, GET, PUT, and RESUME operations. Includes a TCP server, client library, CLI client, FastAPI HTTP wrapper, and React frontend.
ft-echo-project/
├── README.md
├── transcript.txt # Test run transcript
├── server/
│ ├── tcp_server.py # Async TCP FT-Echo server
│ ├── tcp_client_lib.py # Synchronous client library
│ ├── cli_client.py # CLI for manual testing
│ ├── fastapi_app.py # FastAPI HTTP wrapper
│ ├── requirements.txt # Python dependencies
│ └── logs/ # Server logs
├── frontend/
│ ├── package.json
│ └── src/ # React application
├── demo_scripts/
│ ├── run_tests.sh # Automated test script
│ └── demo_commands.txt # Manual test commands
└── storage/ # Server file storage
Every message follows this structure:
- 4 bytes: Big-endian uint32 length (N)
- 1 byte: ASCII message type
- (N-1) bytes: Payload
- L (LIST): Request file listing
- G (GET): Download a file
- P (PUT): Upload a file
- R (RESUME): Resume interrupted transfer
- Q (QUIT): Disconnect
- O (OK): Success response
- E (ERROR): Error response
- F (FILE): File data chunk
- S (SHA256): Checksum (hex digest)
- Client sends:
L(no payload) - Server responds:
O+ newline-separated list (filename|size\n)
- Client sends:
G+ filename (UTF-8) - Server responds:
O+ metadata (JSON:{"size": N}) - Server sends: Multiple
Fchunks (file data) - Server sends:
S+ SHA256 hex digest
- Client sends:
P+ metadata (JSON:{"filename": "...", "size": N}) - Server responds:
O+ "Ready to receive" - Client sends: Multiple
Fchunks (file data) - Server responds:
O+ SHA256 hex digest
- Client sends:
R+filename|offset|direction - Server verifies partial file exists
- Transfer continues from offset
- Same flow as GET/PUT but starting from offset
- Python 3.10+
- Node.js 16+ and npm
- Bash (for test scripts on Unix-like systems)
cd server
pip install -r requirements.txtcd frontend
npm installLinux/macOS:
cd server
python3 tcp_server.py [port]Windows:
cd server
python tcp_server.py [port]Default port: 9000
The server will:
- Listen on all interfaces (0.0.0.0)
- Store files in
../storage/directory - Log to
logs/server.log
Linux/macOS:
cd server
python3 cli_client.pyWindows:
cd server
python cli_client.pyInteractive commands:
connect <host> <port>- Connect to serverlist- List files on serverget <filename> [dest_path]- Download a fileput <filepath>- Upload a fileresume <file> <offset> <direction>- Resume transfer (direction: get|put)quit- Disconnect and exit
Example:
ft-echo> connect localhost 9000
ft-echo> list
ft-echo> put ../demo_data/test.txt
ft-echo> get test.txt downloaded_test.txt
ft-echo> quitStart the HTTP server:
Linux/macOS:
cd server
python3 fastapi_app.pyWindows:
cd server
python fastapi_app.pyOr with uvicorn (all platforms):
uvicorn fastapi_app:app --host 0.0.0.0 --port 8000API Endpoints:
GET /api/list- List filesGET /api/get?file=<filename>- Download filePOST /api/put- Upload file (multipart/form-data)POST /api/resume- Resume transfer (JSON body:{file, offset, direction})
Start the React app:
cd frontend
npm startOpen http://localhost:3000 in your browser.
Features:
- View server file list
- Upload files with progress bar
- Download files with checksum verification
- Automatic refresh after operations
Linux/macOS:
cd demo_scripts
chmod +x run_tests.sh
./run_tests.shWindows:
cd demo_scripts
run_tests.batSimple Python Test:
Linux/macOS:
cd server
python3 test_simple.pyWindows:
cd server
python test_simple.pyThe test scripts will:
- Create test files
- Start the TCP server
- Test PUT, LIST, GET operations
- Test RESUME functionality
- Generate
transcript.txtwith results
-
PUT Operation
- Upload a file using CLI or frontend
- Verify SHA256 checksum matches
- Check file appears in server storage
-
GET Operation
- Download a file from server
- Verify SHA256 checksum matches original
- Compare file contents byte-by-byte
-
RESUME Operation
- Start uploading a large file
- Interrupt the transfer (Ctrl+C or kill process)
- Resume from the last offset
- Verify final file matches original checksum
See demo_scripts/demo_commands.txt for detailed manual testing instructions.
After running tests, you should see:
- Files successfully uploaded with SHA256 checksums
- Files successfully downloaded with matching checksums
- Resume operations completing partial transfers
- All operations logged in
server/logs/server.log
- Async I/O: Uses
asynciofor concurrent client handling - Safe Writes: Writes to
.parttemporary files, renames on success - Checksum Verification: SHA256 computed during streaming
- Error Handling: Graceful error messages via
Emessage type - Logging: All operations logged with timestamps
- Synchronous API: Easy to use in scripts and HTTP wrappers
- Automatic Reconnection: Each function manages its own connection
- Progress Tracking: Can be extended for progress callbacks
- Checksum Validation: Verifies server checksums match client
- ✅ 4-byte big-endian length prefix
- ✅ 1-byte message type
- ✅ All message types implemented (L, G, P, R, Q, O, E, F, S)
- ✅ SHA256 checksums for integrity
- ✅ Safe file writes (temp + rename)
- ✅ Resume support with byte offsets
- ✅ Configurable chunk size (default 4096)
FT_ECHO_HOST: TCP server host (default: localhost)FT_ECHO_PORT: TCP server port (default: 9000)
Edit server/tcp_server.py:
DEFAULT_PORT: Server listening portCHUNK_SIZE: Transfer chunk size (bytes)STORAGE_DIR: Directory for stored files
- Check if port is already in use:
lsof -i :9000(Unix) ornetstat -an | findstr 9000(Windows) - Check Python version:
python3 --version(needs 3.10+)
- Ensure TCP server is running
- Check firewall settings
- Verify host and port are correct
- Verify file wasn't corrupted during transfer
- Check network stability
- Ensure both client and server use same chunk size
- Verify partial file (
.part) exists in storage directory - Check offset matches actual file size
- Ensure same filename is used for resume
The following students contributed to this project:
- Penubothu Vaishnavi
- Velagapudi Jeshnav
- Ugrapalli Mukesh
- Mullapudi Mounika Sri Vijaya Lakshmi
- Bhanu Kiran Annavarapu
- Ravooru Sumanaswi
- Guntumadugu Manjeesh
- Sesank Chaluvadi
- Kavitha Sai Prasanth
- Kodavati Lakshmi Manikanta
- Paturi Bhavana