A lightweight, UDP-based file transfer protocol with a sliding window mechanism to ensure reliable delivery of images over a network with simulated packet loss.
- Reliable Transmission: Implements a sliding window protocol with selective repeat to ensure reliable and ordered delivery of image packets.
- Packet Loss Simulation: Simulates packet loss with a configurable percentage.
- Multiple Image Transfer: Supports sequential transfer of multiple files from the sender to the receiver.
- Acknowledgment-Based: Uses acknowledgment packets to confirm receipt of individual data packets.
packet.py: Contains the definitions for data and acknowledgment packets, and functions to create data packets.sender.py: The sender side of the protocol that reads images from disk, breaks them into packets, and sends them to the receiver.receive.py: The receiver side of the protocol that listens for packets, acknowledges them, and reconstructs the image files.
.
├── images
│ ├── large.jpeg
│ ├── medium.jpeg
│ └── small.jpeg
├── packet.py
├── sender.py
└── receive.py
git clone https://github.com/yourusername/reliable-image-transfer.git
cd reliable-image-transferPlace your images in the images directory and ensure they are named according to the imgs list in sender.py.
Start the receiver to listen for incoming packets.
python receive.pyStart the sender to send images sequentially to the receiver.
python sender.py- Packet Loss Simulation: The sender simulates a 15% packet loss by default. You can adjust this by changing the probability condition in the
sendfunction ofsender.py.
if random.randint(1, 100) >= 15: # Adjust this value for different loss rates
sender.sendto(packets[i].packet, (receiver_ip, receiver_port))- Sliding Window Size: The window size is adjustable in
sender.pythrough thewindow_sizeparameter.
window_size = 4 # Adjust the size as neededThis project is licensed under the MIT License. See the LICENSE file for details.