████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████ ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██ ██░░░░░░░░░░░░░███████╗░██████╗░░░██████╗░░░░░░░░░░░░░██ ██░░░░░░░░░░░░░██╔════╝░██╔══██╗░░██╔══██╗░░░░░░░░░░░░██ ██░░░░░░░░░░░░░█████╗░░░██████╔╝░░██████╔╝░░░░░░░░░░░░██ ██░░░░░░░░░░░░░██╔══╝░░░██╔══██╗░░██╔═══╝░░░░░░░░░░░░░██ ██░░░░░░░░░░░░░██║░░░░░░██║░░░██╗░██║░░░░░░░░░░░░░░░░░██ ██░░░░░░░░░░░░░╚═╝░░░░░░╚═╝░░░╚═╝░╚═╝░░░░░░░░░░░░░░░░░██ ██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██ ████████████████████████████████████████████████████████ ████████████████████████████████████████████████████████
FRP is a reliable custom protocol built on top of UDP in Rust. It uses Selective Repeat ARQ (SR) to ensure data reliability and supports:
- Custom connection handshake (SYN / SYN-ACK / ACK) and graceful disconnect (FIN / FIN-ACK).
- Message and file transfer with fragmentation and reassembly.
- Data integrity check using CRC32.
- Positive (ACK) and negative (NACK) acknowledgements for lost/corrupted packet recovery.
- Sliding window for efficient transmission.
- Packet loss simulation for testing the protocol.
- Heartbeat packets for connection state monitoring.
- CLI interface with user commands.
git clone https://github.com/zimka1/udp_transfer
cd udp_transfercargo build --releasecargo run -- <local_port> <peer_ip> <peer_port><local_port>— port for the local instance to listen on.<peer_ip>— peer IP address.<peer_port>— peer port.
Example:
cargo run -- 5000 127.0.0.1 6000On the other side:
cargo run -- 6000 127.0.0.1 5000help— show available commands.connect— initiate connection.disconnect— gracefully disconnect.change mode— toggle packet loss simulation.change repo (<path>)— change the directory for saving received files.send message (<text>, <fragment_size>)— send a message split into fragments.send message (<text>)— send a message without fragmentation.send file (<file_name>, <fragment_size>)— send a file split into fragments.send file (<file_name>)— send a file without fragmentation.
main.rs— application entry point, CLI, and state machine.send.rs— message/file sending logic, sliding window, CRC32.receiver.rs— packet receiving, ACK/NACK handling, reassembly.reassembler.rs— assembling fragmented messages and files.packet.rs— packet structure and serialization.state.rs— connection state machine.commands.rs— CLI command parsing.change.rs— handling repository/mode change commands.
- Reliable UDP: Selective Repeat ARQ with ACK/NACK and retransmissions.
- Sliding Window: Increases transfer speed without waiting for each packet acknowledgment.
- CRC32: Ensures packet integrity.
- Heartbeat: Detects connection loss.