Skip to content

CopperFlame14/stop-waitARQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Stop-and-Wait ARQ Protocol using UDP Sockets

Overview

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.

Features

  • 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

Project Structure

.
├── client.c
├── server.c
└── README.md

How It Works

Sender (Client)

  1. Sends a packet with a sequence number.
  2. Waits for an acknowledgment.
  3. Retransmits if ACK is not received within 2 seconds.
  4. Sends the next packet after receiving the correct ACK.

Receiver (Server)

  1. Receives packets from the sender.
  2. Simulates packet loss with a 10% probability.
  3. Sends ACK for correctly received packets.
  4. Detects duplicate packets and resends the previous ACK.

Packet Format

Data Packet

<sequence_number>|<message>

Example:

0|Hello

ACK Packet

ACK<sequence_number>

Example:

ACK0

Compilation

Compile the programs using GCC:

gcc server.c -o server
gcc client.c -o client

Execution

Start the Server

./server

Start the Client

Open a new terminal and run:

./client

Sample Output

Server

Stop-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

Client

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

Concepts Demonstrated

  • UDP Socket Programming
  • Reliable Data Transfer
  • Stop-and-Wait ARQ
  • Sequence Numbers
  • Acknowledgments
  • Timeout Handling
  • Packet Loss Recovery

Applications

  • Data Link Layer Protocols
  • Reliable Communication Systems
  • Networking Simulations
  • Educational Networking Projects

Author

M R Krishni

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages