0% found this document useful (0 votes)
15 views18 pages

CN File

The document outlines various experiments related to network commands and programming, including IP configuration, pinging, traceroute, and checksum implementation. It also covers cyclic redundancy check (CRC), Hamming code, IP address classification, and sliding window control protocols. Each experiment includes code snippets, purposes, and sample outputs demonstrating their functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views18 pages

CN File

The document outlines various experiments related to network commands and programming, including IP configuration, pinging, traceroute, and checksum implementation. It also covers cyclic redundancy check (CRC), Hamming code, IP address classification, and sliding window control protocols. Each experiment includes code snippets, purposes, and sample outputs demonstrating their functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

EXPERIEMENT- 01

AIM: To implement various commands.


CODE:
1)IP CONFIG

Purpose: Displays the IP


Configuration of computer. Cmd used:
ipconfig

C:\Users\

Hp>ipconfig

Windows IP

Configuration
Wireless LAN adapter Local Area Connection* 1:

Media State...............Media disconnected


Connection-specific DNS Suffix . :

Wireless LAN adapter Local Area


Connection* 10:

Media State...............Media
disconnected
Connection-specific DNS Suffix . :

Wireless LAN adapter Wi-Fi:

AVINASH KUMAR THAKUR 2200910100040 VI-CS1(A2)


Connection-specific DNS Suffix . :
mshome.net
Link-local IPv6 Address : fe80::e4b4:febb:890c:9ae1%5
IPv4 Address............: 192.168.137.231
Subnet Mask.............: 255.255.255.0
Default Gateway.........: 192.168.137.1

Ethernet adapter Bluetooth Network


Connection: Media State
...................................Media
disconnected

ConnectionspecificDNSSuff

2}PING

Purpose: Send packet to a Network Host and measure the response time to

check the connectivity. CMD USED: ping google.com

OUTPUT:

C:\Users\Hp>ping google.com
Pinging google.com [142.250.194.238] with 32

bytes of data: Reply from 142.250.194.238:

bytes=32 time=11ms TTL=117 Reply from

142.250.194.238: bytes=32 time=15ms

TTL=117 Reply from 142.250.194.238:

bytes=32 time=15ms TTL=117 Reply from

142.250.194.238: bytes=32 time=20ms

AVINASH KUMAR THAKUR 2200910100040 VI-CS1(A2)


TTL=117 Ping statistics for 142.250.194.238:

Packets: Sent = 4, Received = 4,


Lost = 0 (0% loss), Approximate
round trip times in milli-seconds:
Minimum = 11ms, Maximum = 20ms, Average = 15ms

3}TRACERT {TRACEROUTE}

Purpose: Tracks the route packets take to reach a destination


CMD : tracert google.com

OUTPUT:

C:\Users\Hp>tracert google.com

Tracing route to google.com

[142.250.194.238] over a maximum

of 30 hops:

1 2854 ms 12 ms * DESKTOP-51H74CE.mshome.net
[192.168.137.1]
2 DESKTOP-51H74CE.mshome.net [192.168.137.1] reports:

Destination net unreachable. Trace complete.

4} GETMAC
Purpose: Displays the MAC address of network interfaces.

CMD USED: getmac

AVINASH KUMAR THAKUR 2200910100040 VI-CS1(A2)


OUTPUT:

C:\Users\Hp>getmac
Physical Address Transport Name
===================

====================================================

====== 38-D5-7A-BB-68-53 \Device\Tcpip_{2DECC9D7-29B7-46D5-

BB24-FADC9F3FEBDE}

38-D5-7A-BB-68-54 Media disconnected

AVINASH KUMAR THAKUR 2200910100040 VI-CS1(A2)


EXPERIEMENT – 02
AIM: Write a program to implement Check Sum.
CODE:
#include<stdio.h>

#include<math.h>

int sender(int arr[10],int n)

int checksum,sum=0,i;

printf("\n****SENDER SIDE****\n");

for(i=0;i<n;i++)

sum+=arr[i];

printf("SUM IS: %d",sum);

checksum=~sum;

printf("\nCHECKSUM IS:%d",checksum);

return checksum;

void receiver(int arr[10],int n,int sch)

int checksum,sum=0,i;

printf("\n\n****RECEIVER SIDE****\n");

for(i=0;i<n;i++)

sum+=arr[i];

printf("SUM IS:%d",sum);

sum=sum+sch;

checksum=~sum;

printf("\nCHECKSUM IS:%d",checksum);

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


void main()

int n,sch,rch;

printf("\nENTER SIZE OF THE STRING:");

scanf("%d",&n);

int arr[n];

printf("ENTER THE ELEMENTS OF THE ARRAY TO CALCULATE CHECKSUM:\n");

for(int i=0;i<n;i++)

scanf("%d",&arr[i]);

sch=sender(arr,n);

receiver(arr,n,sch);

OUTPUT:
ENTER SIZE OF THE STRING:2

ENTER THE ELEMENTS OF THE ARRAY TO CALCULATE CHECKSUM:

1011

1101

****SENDER SIDE****

SUM IS: 2112

CHECKSUM IS:-2113

****RECEIVER SIDE****

SUM IS:2112

CHECKSUM IS:0

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


EXPERIEMENT – 03
AIM: Write a program to implement Cyclic Redundancy Check (CRC).
CODE:
#include<stdio.h>

#include<string.h>

#define N strlen(gen_poly)

char data[28];

char check_value[28];

char gen_poly[10];

int data_length,i,j;

void XOR(){

for(j = 1;j < N; j++)

check_value[j] = (( check_value[j] == gen_poly[j])?'0':'1');

void receiver(){

printf("Enter the received data: ");

scanf("%s", data);

printf("\n-----------------------------\n");

printf("Data received: %s", data);

crc();

for(i=0;(i<N-1) && (check_value[i]!='1');i++);

if(i<N-1)

printf("\nError detected\n\n");

else

printf("\nNo error detected\n\n");

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


void crc(){

for(i=0;i<N;i++)

check_value[i]=data[i];

do{

if(check_value[0]=='1')

XOR();

for(j=0;j<N-1;j++)

check_value[j]=check_value[j+1];

check_value[j]=data[i++];

}while(i<=data_length+N-1);

int main()

printf("\nEnter data to be transmitted: ");

scanf("%s",data);

printf("\n Enter the Generating polynomial: ");

scanf("%s",gen_poly);

data_length=strlen(data);

for(i=data_length;i<data_length+N-1;i++)

data[i]='0';

printf("\n----------------------------------------");

printf("\n Data padded with n-1 zeros : %s",data);

printf("\n----------------------------------------");

crc();

printf("\nCRC or Check value is : %s",check_value);

for(i=data_length;i<data_length+N-1;i++)

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


data[i]=check_value[i-data_length];

printf("\n----------------------------------------");

printf("\n Final data to be sent : %s",data);

printf("\n----------------------------------------\n");

receiver();

return 0;

OUTPUT:
Enter data to be transmitted: 1001101

Enter the Generating polynomial: 1011

----------------------------------------

Data padded with n-1 zeros : 1001101000

----------------------------------------

CRC or Check value is : 101

----------------------------------------

Final data to be sent : 1001101101

----------------------------------------

Enter the received data: 1001101101

-----------------------------

Data received: 1001101101

No error detected

In the case of error,

Enter the received data: 1001001101

-----------------------------

Data received: 1001001101

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


Error detected

EXPERIEMENT – 04
AIM: Write a program to implement Hamming code.
CODE:
#include<stdio.h>

void main()

int data[10];

int dataatrec[10],c,c1,c2,c3,i;

printf("Enter 4 bits of data one by one\n");

scanf("%d",&data[0]);

scanf("%d",&data[1]);

scanf("%d",&data[2]);

scanf("%d",&data[4]);

data[6]=data[0]^data[2]^data[4];

data[5]=data[0]^data[1]^data[4];

data[3]=data[0]^data[1]^data[2];

printf("\nEncoded data is\n");

for(i=0;i<7;i++)

printf("%d",data[i]);

printf("\n\nEnter received data bits one by one\n");

for(i=0;i<7;i++)

scanf("%d",&dataatrec[i]);

c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


c2=dataatrec[5]^dataatrec[4]^dataatrec[1]^dataatrec[0];

c3=dataatrec[3]^dataatrec[2]^dataatrec[1]^dataatrec[0];

c=c3*4+c2*2+c1 ;

if(c==0) {

printf("\nNo error while transmission of data\n");

else {

printf("\nError on position %d",c);

printf("\nData sent : ");


for(i=0;i<7;i++)

printf("%d",data[i]);

printf("\nData received : ");

for(i=0;i<7;i++)

printf("%d",dataatrec[i]);

printf("\nCorrect message is\n");

if(dataatrec[7-c]==0)

dataatrec[7-c]=1;

else

dataatrec[7-c]=0;

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

printf("%d",dataatrec[i]);

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


}

OUTPUT:
Enter 4 bits of data one by one
1
0
1
0

Encoded data is
1010010

Enter received data bits one by one


1
0
1
0
0
1
0

No error while transmission of data

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


EXPERIEMENT – 05
AIM: Write a program to classify an IP address into classes.
CODE:
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

void classify_ip_address(char *ip)

int octet;

char *token = strtok(ip, ".");

if (token == NULL)

printf("Invalid IP address format\n");

return;

octet = atoi(token);

if (octet >= 0 && octet <= 127)

printf("Class A\n");

else if (octet >= 128 && octet <= 191)

printf("Class B\n");

else if (octet >= 192 && octet <= 223)

printf("Class C\n");

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


}

else if (octet >= 224 && octet <= 239)

printf("Class D (Multicast)\n");

else if (octet >= 240 && octet <= 255)

printf("Class E (Reserved for experimental use)\n");

else

printf("Invalid IP address\n");

int main()

char ip[16];

printf("Enter an IP address: ");

scanf("%15s", ip);

int dot_count = 0, num_count = 0;

for (int i = 0; ip[i] != '\0'; i++)

if (ip[i] == '.')

dot_count++;

else if (ip[i] >= '0' && ip[i] <= '9')

num_count++;

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


}

else

printf("Invalid character detected in IP address.\n");

return 1;

if (dot_count != 3 || num_count == 0)

printf("Invalid IP address format.\n");

return 1;

classify_ip_address(ip);

return 0;

OUTPUT :
Enter an IP address: 147.255.123.0
Class B

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


EXPERIEMENT- 06
AIM: Write a code to implement Sliding Wait Control.
CODE:
#include<stdio.h>

int main()

int w,i,f,frames[50];

printf("Enter window size: ");

scanf("%d",&w);

printf("\nEnter number of frames to transmit: ");

scanf("%d",&f);

printf("\nEnter %d frames: ",f);

for(i=1;i<=f;i++)

scanf("%d",&frames[i]);

printf("\nWith sliding window protocol the frames will be sent in the following manner
(assuming no corruption of frames)\n\n");

printf("After sending %d frames at each stage sender waits for acknowledgement sent by
the receiver\n\n",w);

for(i=1;i<=f;i++)

if(i%w==0)

printf("%d\n",frames[i]);

printf("Acknowledgement of above frames sent is received by sender\n\n");

else

printf("%d ",frames[i]);

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


if(f%w!=0)

printf("\nAcknowledgement of above frames sent is received by sender\n");

return 0;

OUTPUT:

Enter window size: 3

Enter number of frames to transmit: 5

Enter 5 frames: 12 89 5 4 6

With sliding window protocol the frames will be sent in the following manner
(assuming no corruption of frames)

After sending 3 frames at each stage sender waits for acknowledgement sent by
the receiver

12 89 5
Acknowledgement of above frames sent is received by sender

46
Acknowledgement of above frames sent is received by sender

DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)


DEEPANSHU KUMAR 2200910100053 VI-CS1(A2)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy