Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zimka1/udp-transfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

████████████████████████████████████████████████████████
████████████████████████████████████████████████████████
██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░███████╗░██████╗░░░██████╗░░░░░░░░░░░░░██
██░░░░░░░░░░░░░██╔════╝░██╔══██╗░░██╔══██╗░░░░░░░░░░░░██
██░░░░░░░░░░░░░█████╗░░░██████╔╝░░██████╔╝░░░░░░░░░░░░██
██░░░░░░░░░░░░░██╔══╝░░░██╔══██╗░░██╔═══╝░░░░░░░░░░░░░██
██░░░░░░░░░░░░░██║░░░░░░██║░░░██╗░██║░░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░╚═╝░░░░░░╚═╝░░░╚═╝░╚═╝░░░░░░░░░░░░░░░░░██
██░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██
████████████████████████████████████████████████████████
████████████████████████████████████████████████████████

FRP – Ferris Reliable Protocol

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.

Installation & Running

1. Clone the repository:

git clone https://github.com/zimka1/udp_transfer
cd udp_transfer

2. Build:

cargo build --release

3. Run:

cargo 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 6000

On the other side:

cargo run -- 6000 127.0.0.1 5000

CLI Commands

  • help — 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.

Project Structure

  • 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.

Protocol Features

  • 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.

About

Reliable custom protocol built on top of UDP in Rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages