Skip to main content

NETWORK TECHNOLOGY MANNUAL

PRACTICAL SET  1>>


AIM-->. TO  STUDY DIFFERENT TYPES OF  TOPOLOGIES AND IMPLEMENT IN CISCO PACKET TRACER:

ANS--->  


1>> BUS TOPOLOGY



 











2>>  STAR TOPOLOGY 













3>> RING TOPOLOGY 
















4>> MESH TOPOLOGY 















5>> TREE TOPOLOGY 













6>> HYBRID TOPOLOGY 














PRACTICAL SET 2 >>.  NO NEED TO WRITE

PRACTICAL SET 3 >>.  NO NEED TO WRITE

PRACTICAL SET 4 >>.  NO NEED TO WRITE



PRACTICAL SET 5>>

AIM--> WRITE A PROGRAM TO IMPLEMENT HAMMING CODE 


C- PRACTICAL CODE :


#include <stdio.h>

// Encoding Function for (7,4) Hamming Code

void hamming_encode(int data, int *codeword) {

    // Ensure the input data is a 4-bit value (0-15)

    if (data < 0 || data > 15) {

        printf("Input data must be a 4-bit value between 0 and 15.\n");

        return;

    }

    // Initialize the parity bits

    int p1 = (data & 1) ^ ((data >> 1) & 1) ^ ((data >> 3) & 1);

    int p2 = (data & 1) ^ ((data >> 2) & 1) ^ ((data >> 3) & 1);

    int p4 = ((data >> 1) & 1) ^ ((data >> 2) & 1) ^ ((data >> 3) & 1);

    

    // Create the 7-bit Hamming codeword

    *codeword = (p1 << 6) | (p2 << 5) | (data << 1) | p4;

}


// Decoding Function for (7,4) Hamming Code

int hamming_decode(int codeword) {

    // Calculate syndrome bits

    int s1 = ((codeword >> 6) & 1) ^ ((codeword >> 4) & 1) ^ ((codeword >> 2) & 1) ^ (codeword & 1);

    int s2 = ((codeword >> 5) & 1) ^ ((codeword >> 4) & 1) ^ ((codeword >> 1) & 1) ^ (codeword & 1);

    int s4 = ((codeword >> 3) & 1) ^ ((codeword >> 2) & 1) ^ ((codeword >> 1) & 1) ^ (codeword & 1);

    

    // Calculate the error position

    int error_position = s1 + 2 * s2 + 4 * s4;

    

    // Correct the error if one is detected

    if (error_position != 0) {

        printf("Error detected at position %d. Correcting...\n", error_position);

        codeword ^= (1 << (7 - error_position)); // Flip the bit at the error position

    }

    

    // Remove the parity bits to obtain the original data

    int decoded_data = ((codeword >> 1) & 1) | ((codeword >> 2) & 2) | ((codeword >> 3) & 4) | ((codeword >> 5) & 8);

    

    return decoded_data;

}


int main() {

    int data = 5;  // Four-bit data word (e.g., 0101 in binary)

    int codeword;

    

    printf("Original Data: %d (Binary: %04b)\n", data, data);

    

    // Encoding

    hamming_encode(data, &codeword);

    printf("Encoded Codeword: %d (Binary: %07b)\n", codeword, codeword);

    

    // Simulate errors in the received codeword (for testing)

    int received_codeword = codeword ^ (1 << 2);  // Flip a bit for demonstration

    

    // Decoding

    int decoded_data = hamming_decode(received_codeword);

    printf("Decoded Data: %d (Binary: %04b)\n", decoded_data, decoded_data);

    

    return 0;

}



OUTPUT : 

Original Data: 5 (Binary: 0101)

Encoded Codeword: 75 (Binary: 1001011)

Error detected at position 1. Correcting...

Decoded Data: 3 (Binary: 0011)


PRACTICAL SET 6 >>

AIM--> WRITE A PROGRAM TO IMPLEMENT BIT STUFFING


PRACTICAL CODE :


#include <stdio.h>


// Function to perform bit stuffing

void bit_stuffing(char* input, char* stuffed_output) {

    char flag_sequence[] = "01111110"; // Flag or delimiter sequence

    int flag_len = 8; // Length of the flag sequence


    int i, j = 0;

    int consecutive_ones = 0;


    for (i = 0; input[i] != '\0'; i++) {

        stuffed_output[j++] = input[i];


        if (input[i] == '1') {

            consecutive_ones++;

        } else {

            consecutive_ones = 0;

        }


        if (consecutive_ones == 5) {

            // If five consecutive ones are encountered, insert a '0'

            stuffed_output[j++] = '0';

            consecutive_ones = 0; // Reset counter

        }

    }


    // Append the flag sequence to the stuffed output

    for (i = 0; i < flag_len; i++) {

        stuffed_output[j++] = flag_sequence[i];

    }


    stuffed_output[j] = '\0'; // Null-terminate the stuffed output

}


int main() {

    char input[] = "011111010110110";

    char stuffed_output[100];

    

    printf("Original Data: %s\n", input);


    bit_stuffing(input, stuffed_output);


    printf("Stuffed Data: %s\n", stuffed_output);


    return 0;

}


OUTPUT:

Original Data: 011111010110110

Stuffed Data: 011111001011011001111110


PRACTICAL SET 7 >>

AIM--> WRITE A PROGRAM TO IMPLEMENT CRC


PRACTICAL CODE:

#include <stdio.h>

#include <string.h>


// CRC-32 Polynomial (used in Ethernet and many other protocols)

#define CRC32_POLYNOMIAL 0xEDB88320L


// Function to generate a CRC checksum

unsigned int generate_crc32(const char* message) {

    unsigned int crc = 0xFFFFFFFF; // Initial CRC value

    int i, j;


    for (i = 0; message[i] != '\0'; i++) {

        crc ^= (unsigned char)message[i];


        for (j = 0; j < 8; j++) {

            if (crc & 1) {

                crc = (crc >> 1) ^ CRC32_POLYNOMIAL;

            } else {

                crc >>= 1;

            }

        }

    }


    return ~crc; // Invert the bits

}


// Function to verify the CRC checksum

int verify_crc32(const char* message, unsigned int checksum) {

    return generate_crc32(message) == checksum;

}


int main() {

    const char* message = "Hello, CRC!";

    unsigned int crc_checksum;


    // Generate CRC checksum

    crc_checksum = generate_crc32(message);

    printf("CRC-32 Checksum: 0x%X\n", crc_checksum);


    // Verify the CRC checksum

    int is_valid = verify_crc32(message, crc_checksum);

    if (is_valid) {

        printf("CRC-32 Checksum is valid.\n");

    } else {

        printf("CRC-32 Checksum is NOT valid.\n");

    }


    return 0;

}


OUTPUT:

CRC-32 Checksum: 0xB02496E6

CRC-32 Checksum is valid




PRACTICAL SET 8>>.  NO NEED TO WRITE

PRACTICAL SET 9 >>.  NO NEED TO WRITE

PRACTICAL SET 10 >>.  NO NEED TO WRITE
























Comments

Popular posts from this blog

Question bank solution of CAMP

     1>> Explain basic computer organization and enlist various design components. ANS----> .   Computer organization refers to the way in which a computer's various components work together to execute instructions and perform tasks. The basic computer organization includes various design components, which are as follows: Central Processing Unit (CPU): It is the brain of the computer that performs all the arithmetic and logical operations. The CPU consists of an arithmetic logic unit (ALU) that performs arithmetic and logical operations, a control unit (CU) that fetches instructions from memory and decodes them, and registers that store data. Memory Unit: It is the component of the computer that stores instructions and data. The memory unit consists of two types of memory: primary memory and secondary memory. Primary memory, also known as main memory, includes Random Access Memory (RAM) and Read-Only Memory (ROM), while secondary memory

PYTHON ASSIGNMENT 5 AND 6 SOLVED

  PYTHON  ASSIGNMENT – 5 1>What is string concatenation? Explain different ways to concatenate strings. ANS>> String concatenation is the process of combining two or more strings into a single string. In programming, it is a commonly used operation for manipulating text data. There are different ways to concatenate strings depending on the programming language or framework being used. Here are some examples: Using the plus (+) operator: In many programming languages, the simplest way to concatenate strings is by using the plus (+) operator. This is also known as the concatenation operator. Here's an example in Python: string1 = "Hello" string2 = "World" result = string1 + " " + string2 print(result) OUTPUT: Hello World 2.Using the join() method: Another way to concatenate strings is by using the join() method. This method takes an iterable (such as a list or tuple) of strings as an argument and concatenates them with a separator string. Here&#
  PYTHON PROGRAMMING QUESTION BANK SOLUTION:                               UNIT: 1 1>> Explain features of python. ANS---->.   Python is a popular high-level programming language that is known for its simplicity, readability, and versatility. Some of the key features of Python are: Easy to Learn: Python has a clean and simple syntax that is easy to understand and learn, even for beginners. Interpreted Language: Python code is executed line by line by the interpreter, which means that you don't have to compile your code before running it. Cross-platform: Python is a portable language that can be used on a variety of operating systems, including Windows, Linux, and Mac OS. Object-Oriented Programming (OOP) support: Python supports object-oriented programming, which allows developers to write reusable and modular code. Large Standard Library: Python has a large and comprehensive standard library, which includes modules for many common tasks such as file I/O, regular expressio