Straight up kms for this shit
This project implements a reliable file transfer system over UDP using the Selective Repeat protocol. It consists of a server (server.c) that serves files to clients, and a client program (rcopy.c) that requests and receives files from the server.
- Reliable file transfer over unreliable UDP
- Selective Repeat protocol with configurable window size
- Error detection and handling with checksums
- Packet drop simulation for testing
- Support for transferring text and binary files
Server implementation that handles file transfer requests from clients.
Key Functions:
main(): Entry point that initializes server and starts FSMrunServerFSM(): Main server state machinetransferData(): Handles file data transmission using sliding windowprocessClient(): Processes client requestslookupFilename(): Verifies if a requested file existssend_data_packet(): Sends data packets to clientsretransmit_packets(): Handles packet retransmission on timeout
Client implementation that requests and receives files from the server.
Key Functions:
main(): Entry point that parses arguments and starts client FSMrcopyFSM(): Main client state machinestateHandshake(): Establishes connection with serverstateFileReceive(): Receives and writes file datasendFilename(): Constructs and sends filename request packetsendRR(),sendSREJ(): Send acknowledgment and selective reject packets
Implements the sliding window buffer for the Selective Repeat protocol.
Key Structures:
pane: Holds packet data and sequence numberWindowBuffer: Manages the sliding window
Key Functions:
init_window(): Initializes the window bufferslide_window(): Moves the window forwardfree_window(): Cleans up allocated memory
Helper utilities for packet handling and network operations.
Key Structures:
pdu_header: Packet header structure with sequence number, checksum, and flag
Key Functions:
sendPdu(): Sends a packet with proper checksumsendAck(): Convenience function for sending acknowledgmentsprintHexDump(): Debugging utility for packet inspection
./server <error-rate> [port-number]
error-rate: Probability of packet errors (0.0-1.0)port-number: Optional port number (defaults to OS-assigned)
./rcopy <from-filename> <to-filename> <window-size> <buffer-size> <error-rate> <remote-machine> <remote-port>
from-filename: File to request from serverto-filename: Local filename to save received datawindow-size: Number of packets in the sliding windowbuffer-size: Size of each packet buffererror-rate: Probability of packet errors (0.0-1.0)remote-machine: Server hostname or IPremote-port: Server port number
- Client sends filename request to server
- Server responds with "Ok" if file exists, "Not Ok" otherwise
- Server sends file data using Selective Repeat protocol
- Client acknowledges received packets with RR (Ready to Receive)
- Client requests missing packets with SREJ (Selective Reject)
- Server sends EOF packet when file transfer is complete
- Client acknowledges EOF and closes connection
- Flag 8: Filename Request
- Flag 9: Filename ACK
- Flag 5: RR (Ready to Receive)
- Flag 6: SREJ (Selective Reject)
- Flag 10: EOF/EOF ACK
- Flag 16: Data Packet