Posts

Showing posts from September, 2024

Congestion control policies

Congestion control policies are essential for managing data flow in computer networks to prevent congestion, which can lead to delays and data loss. These policies can be broadly classified into two categories: Open Loop and Closed Loop congestion control. Open Loop Congestion Control These policies aim to prevent congestion before it happens. Some common techniques include: Retransmission Policy : Ensures packets are retransmitted only when necessary to avoid increasing congestion. Window Policy : Uses selective repeat windows to resend only specific lost packets, reducing unnecessary retransmissions. Discarding Policy : Routers discard less critical packets to maintain overall network quality. Acknowledgment Policy : Reduces the number of acknowledgments sent to minimize network load. Admission Policy : Checks resource requirements before establishing new connections to prevent congestion. Closed Loop Congestion Control These techniques address congestion after it has occurred. Som...

Shortest Path Routing

Shortest Path Routing is a crucial concept in the network layer of computer networks. It involves finding the most efficient path for data packets to travel from a source to a destination. Here are some key points: What is Shortest Path Routing? Shortest Path Routing refers to algorithms that determine the shortest path between two nodes in a network. This path is typically measured in terms of distance, cost, or time. The goal is to optimize the routing process, ensuring data packets reach their destination quickly and efficiently. Common Algorithms Dijkstra’s Algorithm : A greedy algorithm that finds the shortest path from a single source node to all other nodes in a weighted graph. It updates the shortest path estimates and finalizes the shortest path for each node one by one. Bellman-Ford Algorithm : This algorithm can handle graphs with negative edge weights. It iteratively relaxes the edges, updating the shortest path estimates until it converges to the shortest path. Floyd-Warsh...

Network layer Optimality Principle

The Optimality Principle is a fundamental concept in network routing. It states that if a router ( R ) is on the optimal path from source ( S ) to destination ( D ), then the path from ( R ) to ( D ) must also be optimal. This principle is crucial for designing efficient routing algorithms. Explanation Optimal Path : The shortest or most efficient path between two nodes in a network. Router ( R ) : An intermediary device that forwards data packets between networks. Implications Consistency : Ensures that once a part of the path is determined to be optimal, it remains optimal for the rest of the journey. Efficiency : Helps in reducing the complexity of routing decisions, as routers can rely on the optimality of sub-paths. Example Consider a network where the optimal path from ( S ) to ( D ) passes through routers ( R1 ) and ( R2 ). According to the Optimality Principle: The path from ( S ) to ( R1 ) is optimal. The path from ( R1 ) to ( R2 ) is optimal. The path from ( R2 ) to ( D ) is...

Network layer Routing Algorithms:

Routing algorithms are crucial for determining the best path for data packets to travel across a network. They can be broadly classified into two main categories: Adaptive (Dynamic) Algorithms and Non-Adaptive (Static) Algorithms . Adaptive (Dynamic) Algorithms These algorithms adjust their routing decisions based on changes in the network topology or traffic load. They use real-time data to optimize routing paths. Some common types include: Isolated Algorithms : Each node makes routing decisions independently using local information. Examples include Hot Potato Routing and Backward Learning. Centralized Algorithms : A central node has complete information about the network and makes all routing decisions. The Link State Algorithm is an example. Distributed Algorithms : Nodes share information with their neighbors and make routing decisions collaboratively. The Distance Vector Algorithm is an example. Non-Adaptive (Static) Algorithms These algorithms do not change their routing decisi...

Network Layer: Design Issues

The network layer, which is the third layer in the OSI model, is responsible for the delivery of data packets from the source to the destination across multiple hops or links. Here are some key design issues associated with the network layer: Store and Forward Packet Switching : In this mechanism, a packet is sent from the host to the nearest router, where it is stored until it has fully arrived and its checksum is verified. Once verified, the packet is forwarded to the next router until it reaches its destination . Services to the Transport Layer : The network layer provides services to the transport layer, which can be either connection-oriented or connectionless. Connection-Oriented Service : A path is established between the source and destination before data transmission begins. All packets follow this path, ensuring they arrive in order. Connectionless Service : Each packet is treated independently and routed separately, which means packets may arrive out of order. Routing : The ...

Data Link Layer in the Internet (SLIP, PPP)

 The Data Link Layer is crucial in the Internet’s architecture, handling the physical addressing and reliable transmission of data across a network. Two notable protocols at this layer are Serial Line Internet Protocol (SLIP) and Point-to-Point Protocol (PPP) . Serial Line Internet Protocol (SLIP) Purpose : SLIP is a simple protocol used to encapsulate IP packets for transmission over serial connections. Features : Simplicity : It lacks error detection, correction, and authentication mechanisms. Efficiency : Minimal overhead, making it suitable for low-bandwidth connections. Support : Compatible with many operating systems, including Windows and Linux. Limitations : No support for dynamic IP addressing or error handling, making it less reliable. Point-to-Point Protocol (PPP) Purpose : PPP is a more advanced protocol designed for reliable data transmission over serial links. Features : Authentication : Supports mechanisms like PAP and CHAP for secure communication. Error Handling :...

DSA Lab 16 Program

  Program for implementing Singly Linked list  # include < stdio.h > # include < stdlib.h >   struct Node {     int data;     struct Node * next; };   void linkedListTraversal ( struct Node * ptr ) {     while (ptr != NULL )     {         printf ( " Element: %d \n " , ptr -> data ) ;         ptr = ptr -> next ;     } }   int main () {     struct Node * head;     struct Node * second;     struct Node * third;     struct Node * fourth;       head = ( struct Node * ) malloc ( sizeof ( struct Node)) ;     second = ( struct Node * ) malloc ( sizeof ( struct Node)) ;     third = ( struct Node * ) malloc ( sizeof ( struct Node)) ;     fourth = ( struct Node * ) malloc ( sizeof ( struct Node)) ;         head -> data = 7 ;   ...

DSA Lab 15 Program

  Program for implementing dequeue. # include < stdio.h > # include < stdlib.h > # define MAX 5 // Define maximum size of the deque int deque [MAX]; int front = - 1 ; int rear = - 1 ; // Function to check if the deque is full int isFull () {     return ((front == 0 && rear == MAX - 1 ) || (front == rear + 1 )); } // Function to check if the deque is empty int isEmpty () {     return (front == - 1 ); } // Function to insert an element at the front of the deque void insertFront ( int key ) {     if ( isFull () ) {         printf ( " Overflow: Unable to insert element at the front. \n " ) ;         return ;     }     if (front == - 1 ) { // First element insertion         front = rear = 0 ;     } else if (front == 0 ) {         front = MAX - 1 ;     } else {     ...

DSA Lab 14 Program

  Program for implementing circular queue. # include < stdio.h > # define MAX_SIZE 5 int queue [MAX_SIZE]; int front = - 1 , rear = - 1 ; void enqueue ( int data ) {     if ((rear + 1 ) % MAX_SIZE == front) {         printf ( " Queue overflow \n " ) ;         return ;     }     if (front == - 1 ) {         front = 0 ;     }     rear = (rear + 1 ) % MAX_SIZE;     queue [rear] = data;     printf ( " Element %d inserted \n " , data) ; } int dequeue () {     if (front == - 1 ) {         printf ( " Queue underflow \n " ) ;         return - 1 ;     }     int data = queue [front];     if (front == rear) {         front = rear = - 1 ;     } else {         front = (front + 1 ) % MAX_SIZE;  ...

DSA Lab 13 Program

 Program for dynamic implementation of queue. # include < stdio.h > # include < stdlib.h > # define MAX_SIZE 10 struct Queue {     int queue [MAX_SIZE];     int front;     int rear; }; int isEmpty ( struct Queue * q ) {     return ( q -> front == - 1 ); } int isFull ( struct Queue * q ) {     return ( q -> rear == MAX_SIZE - 1 ); } void enqueue ( struct Queue * q , int data ) {     if ( isFull (q) ) {         printf ( " Queue is full \n " ) ;         return ;     }     if ( isEmpty (q) ) {         q -> front = 0 ;     }     q -> rear ++ ;     q -> queue [ q -> rear ] = data;     printf ( " Enqueued %d in queue \n " , data) ; } int dequeue ( struct Queue * q ) {     if ( isEmpty (q) ) {         printf ( " Queue is em...

DSA Lab 12 Progam

 Program for implementing merge sort # include < stdio.h > void merge ( int arr [] , int l , int m , int r ) {     int i, j, k;     int n1 = m - l + 1 ;     int n2 = r - m;     int L [n1], R [n2];     for (i = 0 ; i < n1; i ++ )         L [i] = arr [l + i];     for (j = 0 ; j < n2; j ++ )         R [j] = arr [m + 1 + j];     // Merge the temporary arrays back into arr[l..r]     i = 0 ; // Initial index of first subarray     j = 0 ; // Initial index of second subarray     k = l; // Initial index of merged subarray     while (i < n1 && j < n2) {         if ( L [i] <= R [j]) {             arr [k] = L [i];             i ++ ;         } else {       ...

DSA Lab 11 Program

  Program for implementing quick sort # include < stdio.h > # include < stdlib.h > void swap ( int * a , int * b ) {     int t = * a;     * a = * b;     * b = t; } int partition ( int arr [] , int low , int high ) {     int pivot = arr [high];     int i = low - 1 ;     for ( int j = low; j <= high - 1 ; j ++ ) {         if ( arr [j] < pivot) {             i ++ ;             swap ( & arr [i], & arr [j]) ;         }     }     swap ( & arr [i + 1 ], & arr [high]) ;     return i + 1 ; } void quickSort ( int arr [] , int low , int high ) {       if (low < high) {           int pi = partition (arr, low, high) ;         quickSort (arr, low, pi - 1 ) ;     ...

DSA Lab 10 Program

Program for implementing insertion sort. # include < stdio.h > void insertionSort ( int arr [] , int n ) {     for ( int i = 1 ; i < n; ++ i) {         int key = arr [i];         int j = i - 1 ;               while (j >= 0 && arr [j] > key) {             arr [j + 1 ] = arr [j];             j = j - 1 ;         }         arr [j + 1 ] = key;     } } void printArray ( int arr [] , int n ) {     for ( int i = 0 ; i < n; ++ i)         printf ( " %d " , arr [i]) ;     printf ( " \n " ) ; } int main () {     int arr [] = { 12 , 11 , 13 , 5 , 6 };     int n = sizeof (arr) / sizeof ( arr [ 0 ]);     insertionSort (arr, n) ;     printArray (arr, n) ;   ...

DSA Lab 9 Program

Program for implementing selection sort. # include < stdio.h > void swap ( int * xp , int * yp ) {     int temp = * xp;     * xp = * yp;     * yp = temp; } void selectionSort ( int arr [] , int n ) {     int i, j, min_idx;     // One by one move boundary of unsorted subarray     for (i = 0 ; i < n - 1 ; i ++ )     {         // Find the minimum element in unsorted array         min_idx = i;         for (j = i + 1 ; j < n; j ++ ){           if ( arr [j] < arr [min_idx])             min_idx = j;         }         // Swap the found minimum element with the first element             if (min_idx != i)             swap ( & arr [min_idx], & arr [i]) ;     }...