Implement naive flow control mechanism using (a) Stop and Wait Protocol and (b) Selective and Repeat Protocol. Transfer files (Text, Image, Audio, Video) using UDP protocol. If during the connection suddenly connection is terminated then you have start ones again, it simply resume the process not start from beginning.
Write a socket program in C for Multimodal File Transmission using UDP with Half-Duplex Stop and Wait protocol. The program/protocol should support the following properties/mechanism
-
The protocol will send any type of files
-
Each packet should consist of the file name, sequence number / acknowledgement number
-
A log file should be generated with some information like,
List of uncommon files in server and client which are to be transferred, Start time, If the connection is broken then the
Implement a reliable file transfer system over the UDP protocol. Since UDP itself is unreliable (packets may be lost, duplicated, or arrive out of order), you must design a mechanism to ensure reliability using techniques such as segmentation, sequencing, acknowledgments, and retransmission.
-
File Segmentation
Divide the file into fixed-size segments (e.g.,
$1$ KB each). Each segment should contain metadata:- Sequence Number
- File Name / File Identifier
- Data Payload
-
Stop-and-Wait Protocol
Implement a Stop-and-Wait ARQ (Automatic Repeat Request) mechanism:
- Sender transmits one segment at a time.
- Sender waits for an acknowledgment (ACK) from the receiver.
- If the ACK is not received within a timeout, retransmit the segment.
- Receiver sends ACK for each correctly received segment (use sequence number to handle duplicates).
-
Acknowledgment Handling
Receiver must send back an ACK containing:
- Sequence Number of the successfully received segment
- File identifier (to handle multiple file transfers, if extended later)
-
Reassembly of File
Receiver collects all the received segments in order. Write them back into the original file format after successful transfer.
-
Go to the server directory and open the terminal.
-
Run the
server.cfile using the below command:cd server gcc server.c -o server -
Run the
serverfile using the below command:./server
-
Now go to the client directory and open another terminal and run the
client.cfile using the below command:gcc client.c -o client
-
Run the
clientfile using the below command:./client
-
Now give the folder names that you want to be compared.
-
The client is requested for the files.
-
The server will transfer the files.
-
clientafter transfer (added the files of folder2).
Open WireShark and click on
Loopback: loto capture the packets.Now go to the WireShark window and filter the packets by typing below command in the filter bar.
udp.port == 8080Go to the directory and open the terminal.
Open another terminal and build the
sender.candreceiver.cby running the below command:makeOpen the terminal and start the receiver (listen on all interfaces on
port 8080, no simulated loss)../receiver 127.0.0.1 8080 ./output 0Open another terminal and Run the sender (send
test.txtto receiver at127.0.0.1:8080; no simulated loss)../sender 127.0.0.1 8080 ./output/test.txt 0
- After completion, the receiver writes
received_test.txt.
Testing Retransmissions
Open a terminal and run the below command.
./sender 127.0.0.1 8080 ./data/test.txt 20Open another terminal and run below comman.
./receiver 0.0.0.0 8080 ./output 20







