Skip to main content

Posts

ARQ Protocols

ARQ (Automatic Repeat reQuest) is an error-control protocol used in data communication to ensure reliable transmission. It allows the receiver to detect errors in received data and request the sender to resend the corrupted or lost packets. How ARQ Works Data Transmission : The sender transmits packets to the receiver. Error Detection : The receiver checks for errors using techniques like checksums or CRC (Cyclic Redundancy Check). Acknowledgment (ACK/NACK) : If the data is correct, the receiver sends an ACK (Acknowledgment) . If the data is incorrect or missing, the receiver sends a NACK (Negative Acknowledgment) . Retransmission : Upon receiving a NACK or after a timeout (no response), the sender retransmits the packet. Types of ARQ Protocols Stop-and-Wait ARQ : The sender transmits one packet at a time and waits for an acknowledgment before sending the next one. Pros : Simple and easy to implement. Cons : Inefficient for long-distance or high-latency networks (slow due to waiting)....

Go-Back-N ARQ

Here's a simple Go-Back-N ARQ implementation using C socket programming to simulate communication between a client (sender) and a server (receiver). Overview: Go-Back-N ARQ allows the sender to send multiple packets (window size) without waiting for individual ACKs. If a packet is lost or an ACK is not received, all packets starting from the lost packet are retransmitted. The server randomly simulates ACK loss or successful reception. Program Structure: Server : Simulates ACK reception with a chance of ACK loss, acknowledging packets up to the first lost packet. Client : Sends packets in a sliding window fashion, retransmitting the entire window if an ACK is lost. Server - Receiver #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> #include <time.h> #define PORT 8080 #define BUFFER_SIZE 1024 #define LOSS_PROBABILITY 30  // 30% chance of ACK loss int main() {     int server_fd, new_soc...

Stop and Wait ARQ

Here's a simple C program that demonstrates the Stop-and-Wait ARQ protocol. This basic implementation simulates the sender transmitting packets one at a time and waiting for an acknowledgment from the receiver. If the acknowledgment is not received, the sender retransmits the packet. Key Points: The sender sends one packet at a time. If the receiver acknowledges it (ACK), the sender sends the next packet. If the acknowledgment is lost, the sender retransmits after a timeout. C Program: Stop-and-Wait ARQ Simulation #include <stdio.h> #include <stdlib.h> #include <time.h> #include <unistd.h>  // for sleep() #define TIMEOUT 3  // Timeout duration in seconds #define TOTAL_PACKETS 5  // Number of packets to send int simulate_acknowledgment() {     // Simulate a 70% chance of successful acknowledgment     return rand() % 10 < 7; } int main() {     srand(time(0));  // Seed for random number generation     i...

Sliding Window Protocol

What is Sliding Window Flow Control? Sliding Window Flow Control is a mechanism that controls the flow of data between a sender and a receiver. It prevents the sender from overwhelming the receiver with too much data at once and ensures that data is transmitted efficiently. Key Concepts Window Size : The "window" represents the amount of data (in bytes or packets) that the sender can send before requiring an acknowledgment (ACK) from the receiver. Both the sender and receiver agree on the window size beforehand. Acknowledgments (ACKs) : The receiver sends an acknowledgment to confirm the successful receipt of data. The sender uses these acknowledgments to decide how much more data to send. Sliding Mechanism : As the receiver acknowledges packets, the sender’s window "slides" forward, allowing it to send additional packets. How It Works Initial Transmission : The sender transmits packets up to the window size limit. For example, if the window size is 4 packets, the s...

Selective Repeat ARQ

Selective Repeat ARQ Protocol - Simple Steps Initialization Set up a window size (N) to control how many frames can be sent before receiving acknowledgments. Initialize counters for sent frames and received acknowledgments. Send Frames Transmit frames within the current sliding window. Each frame is assigned a sequence number. Simulate Frame Loss (Optional) Frames may be randomly lost during transmission (simulated by probability). Receive Acknowledgments The receiver acknowledges individual frames as they arrive. Out-of-order frames are buffered until missing frames are received. Retransmit Lost Frames If an acknowledgment for a frame is not received, only that specific frame is retransmitted. Slide the Window Once the lowest-numbered frame (base) is acknowledged, the window slides forward. The sender can now transmit new frames. Repeat Until Completion The process continues until all frames are sent and acknowledged. Key Points Efficient Use of Bandwidth: Only lost frames are retrans...

Routing Protocols- Distance Vector and Link State

Routing Protocols: Distance Vector vs. Link-State Routing protocols are essential for determining the best path for data packets in a network. Two primary types of routing protocols are Distance Vector and Link-State . These protocols differ in how they calculate routes, share information, and react to changes in the network. 1. Distance Vector Routing Protocols Overview: Concept : The router determines the best path by counting hops (distance) to the destination. Routing Table Exchange : Routers periodically exchange their entire routing tables with their directly connected neighbors. Algorithm : Bellman-Ford algorithm. Metric : Hop count (number of routers to reach the destination). Network View : Routers have a limited view — they only know the distance and direction to a destination, not the full network topology. How It Works: Each router starts with knowledge of its directly connected networks. Periodically, routers share their routing tables with neighbors. If a neighbor advert...

Simulation of Link State Routing Algorithm

Link-State Routing Algorithm The Link-State Routing Algorithm is a dynamic routing protocol that ensures all routers in a network have a consistent and complete view of the network's topology. Each router uses this information to compute the shortest path to every other router using Dijkstra's Algorithm . Key Steps in Link-State Routing Neighbor Discovery : Each router identifies its directly connected neighbors and the cost (link metrics) to reach them. This is done using a protocol such as Hello packets. Link-State Advertisement (LSA) Flooding : Each router creates a Link-State Packet (LSP) containing: Its ID. List of neighbors and their respective link costs. The LSP is flooded across the entire network, ensuring all routers receive the same topology information. Topology Database Creation : Each router constructs a Link-State Database (LSDB) , which represents the entire network topology. This database is built using the received LSAs from all routers. Shortest Path Calcu...