A modern TFTP (Trivial File Transfer Protocol) server written in C++20. Implements RFC 1350.
- RFC 1350 compliant: Full support for TFTP protocol (RRQ, WRQ, DATA, ACK, ERROR)
- Transfer modes: NETASCII, OCTET, and MAIL modes
- Dual-stack networking: IPv6 with IPv4 compatibility
- Concurrent sessions: Handles multiple file transfers simultaneously using async I/O
- Adaptive timeouts: RTT-based timeout adjustment for reliable transfers
- Modern C++20: Leverages coroutines, concepts, and stdexec for async operations
# Debug build with tests
cmake --preset debug
cmake --build build/debug
# Release build (optimized)
cmake --preset release
cmake --build build/releaseInstall the server to your system (default prefix: /usr/local):
# Build the release version first
cmake --preset release
cmake --build build/release
# Install (may require sudo)
sudo cmake --install build/releaseThis installs the tftpd executable to /usr/local/bin/ by default.
To install to a custom location, set the CMAKE_INSTALL_PREFIX:
# Configure with custom prefix
cmake --preset release -DCMAKE_INSTALL_PREFIX=/opt/tftp
cmake --build build/release
# Install to custom location
sudo cmake --install build/releaseTo remove the installed files:
# From your build directory
cat build/release/install_manifest.txt | sudo xargs rmAlternatively, if you no longer have the build directory:
# Manual removal (adjust paths if using custom prefix)
sudo rm /usr/local/bin/tftpd# Run on default port 69 (requires root/sudo)
sudo ./build/release/bin/tftpd
# Run on custom port
./build/release/bin/tftpd -p 6969
# Set log level
./build/release/bin/tftpd -l debug -p 6969
# Set mail directory prefix
./build/release/bin/tftpd -m /var/mail -p 6969-h, --help- Display help message-p, --port=<PORT>- Port to listen on (default: 69)-l, --log-level=<LEVEL>- Log level: critical, error, warn, info, debug (default: info)-m, --mail-prefix=<PATH>- Mail directory prefix for MAIL mode transfers
# Run all tests
cmake --preset debug
cmake --build build/debug
ctest --test-dir build/debug
# Run a single test executable
./build/debug/bin/test_tftp_server
# Run specific test by name pattern
./build/debug/bin/test_tftp_server --gtest_filter=TftpServer.HandleRRQ
# Generate code coverage report
cmake --build build/debug --target coverage
# View: build/debug/coverage/index.html- stdexec - NVIDIA's sender/receiver async framework
- AsyncBerkeley - Async Berkeley sockets interface
- cppnet (cloudbus-net) v0.7.5 - Networking utilities
- spdlog v1.16.0 - Fast C++ logging library
- GoogleTest v1.17.0 - Testing framework (testing only)
All dependencies are automatically fetched via CPM.cmake during build.
Built on stdexec's sender/receiver async model:
- UDP demultiplexing: Each client connection becomes an independent session
- Session management: Sessions tracked in multimap keyed by client address
- Async file I/O: Non-blocking file operations using stdexec senders
- Adaptive retransmission: Timeout adjusts based on measured round-trip time
Clients can download files from the server. Files are read in 512-byte blocks and transmitted sequentially.
Clients can upload files to the server. Data is written to a temporary file first, then atomically renamed on successful completion.
Comprehensive error reporting with standard TFTP error codes:
- File not found (1)
- Access violation (2)
- Disk full (3)
- Illegal operation (4)
- Unknown transfer ID (5)
- File already exists (6)
- No such user (7)
- C++20 compiler (GCC 11+, Clang 14+)
- CMake 3.28+
- Ninja build system (recommended)
GPL-3.0 - See source files for full license text.
This project uses:
- clang-format for code formatting
- clang-tidy for static analysis
- GoogleTest for unit testing
- gcov/gcovr for code coverage