This project implements the Stop-and-Wait Automatic Repeat Request (ARQ) protocol using UDP socket programming in C. The protocol ensures reliable data transmission by using acknowledgments (ACKs), sequence numbers, timeouts, and retransmissions.
- UDP-based client-server communication
- Stop-and-Wait ARQ implementation
- Sequence numbers (0 and 1)
- ACK-based reliability
- Timeout handling
- Packet retransmission
- Simulated packet loss (10%)
- Duplicate packet detection
.
├── client.c
├── server.c
└── README.md
- Sends a packet with a sequence number.
- Waits for an acknowledgment.
- Retransmits if ACK is not received within 2 seconds.
- Sends the next packet after receiving the correct ACK.
- Receives packets from the sender.
- Simulates packet loss with a 10% probability.
- Sends ACK for correctly received packets.
- Detects duplicate packets and resends the previous ACK.
<sequence_number>|<message>
Example:
0|Hello
ACK<sequence_number>
Example:
ACK0
Compile the programs using GCC:
gcc server.c -o server
gcc client.c -o client./serverOpen a new terminal and run:
./clientStop-and-Wait Receiver started...
Received packet seq 0: Hello
Received packet seq 1: from
Packet lost (simulated).
Received packet seq 0: Stop-and-Wait
Received packet seq 1: ARQ
Sent packet seq 0: Hello
Received ACK0
Sent packet seq 1: from
Received ACK1
Sent packet seq 0: Stop-and-Wait
Timeout or error, resending...
Sent packet seq 0: Stop-and-Wait
Received ACK0
Sent packet seq 1: ARQ
Received ACK1
- UDP Socket Programming
- Reliable Data Transfer
- Stop-and-Wait ARQ
- Sequence Numbers
- Acknowledgments
- Timeout Handling
- Packet Loss Recovery
- Data Link Layer Protocols
- Reliable Communication Systems
- Networking Simulations
- Educational Networking Projects
M R Krishni