Lab Manual of CN
Lab Manual of CN
Lab Manual of CN
S.No Contents
Lab Plan
Teacher: Name: LP-KCS653-JT.doc
Subject Code: RCS651 SubjectName: Computer Network Lab
Session: 2020-21 Group: 3CSA/3CSB/IT
Course Objectives:
1. To expose student to implement various computer networks program using C language
2. To develop ability of using computer network to solve simple engineering problems.
Learning Outcome:
After completion of this course the students will be able to:
1. Implement various Algorithms using in C programming language.
2. Understanding of uses of various networking issues for networking field.
A. LIST OF EXPERIMENTS:
3 Connection of Computer in LAN & Configuration of router, hub, switch etc using simulators.
4 Running and using services/commands like ping, trace route, telnet,ftp etc.
6 Configure a Network using Distance Vector and Link State Routing protocol
11 To write a program for simple RSA algorithm to encrypt and decrypt the data.
15 To write a program to find Class of IP address and Network Address for Given IP address.
Subject Code:
Teacher: KCS -651
Subject Name: Computer Networks lab NBA Code:
Group: III YEAR
Session: 2020-21 CSE
[Course
Coordinator] [Module Coordinator]
Hardware Requirements
RJ45 connector
Clamping tool
COURSE :B.Tech(CSE) Subject: Lab - CN (RCS-651)
Experiment No. 1
The cable can be categorized as Cat 5, Cat 5e, Cat 6 UTP cable. Cat 5 UTP cable can support 10/100 Mbps
Ethernet network, whereas Cat 5e and Cat 6 UTP cable can support Ethernet network running at 10/100/1000
Mbps. You might heard about Cat 3 UTP cable, it's not popular anymore since it can only support 10 Mbps
Ethernet network.
Straight and crossover cable can be Cat3, Cat 5, Cat 5e or Cat 6 UTP cable, the only difference is each type
will have different wire arrangement in the cable for serving different purposes.
Straight Cable
You usually use straight cable to connect different type of devices. This type of cable will be used most of the
time and can be used to:
If you need to check how straight cable looks like, it's easy. Both sides (side A and side B) of cable have
wire arrangement with same color. Check out different types of straight cable that are available in the
market here.
Crossover Cable
Sometimes you will use crossover cable, it's usually used to connect same type of devices. A crossover cable
can be used to:
In you need to check how crossover cable looks like, both side (side A and side B) of cable have wire
arrangement with following different color . Have a look on these crossover cables if you plan to buy one.
You can also find more network cable choices and information from Comtrad Cables.
In case you need to make a crossover cable yourself! You can use this crimper to do it.
Lastly, if you still not sure which type of cable to be used sometimes, try both cables and see which works.
Note: If there is auto MDI/MDI-X feature support on the switch, hub, network card or other network devices,
you don't have to use crossover cable in the situation which I mentioned above. This is because crossover
function would be enabled automatically when it's needed.
1. Step 1: Strip the cable jacket about 1.5 inch down from the end.
2. Step 2: Spread the four pairs of twisted wire apart. ...
3. Step 3: Untwist the wire pairs and neatly align them in the T568B orientation. ...
4. Step 4: Cut the wires as straight as possible, about 0.5 inch above the end of the jacket.
1. Using a cable stripping tool, strip about 1/3"of the out jacket of the cat-5 cable. ...
2. Assemble the pairs of wires in the following order for network cables (EAI standard / TIA-568B).
3. Insert the wires into the RJ45 jack
COURSE: B.Tech (CSE) Subject: Lab - CN (KCS-653)
Experiment No. 2
NETWORK IP AND SUB NETTING.
Apparatus (Software): NA
Subnetting is a process of dividing large network into the smaller networks based on layer 3 IP address. Every
computer on network has an IP address that represent its location on network. Two version of IP addresses are
available IPv4 and IPv6. In this article we will perform subnetting on IPv4.
IPv4
IP addresses are displayed in dotted decimal notation, and appear as four numbers separated by dots. Each
number of an IP address is made from eight individual bits known as octet. Each octet can create number value
from 0 to 255. An IP address would be 32 bits long in binary divided into the two components, network
component and host component. Network component is used to identify the network that the packet is intend
for, and host component is used to identify the individual host on network.
IP addresses are broken into the two components:
This tutorial is the first part of this article. In this introductory part I explained how computers
find each other in network with basic terminology of network addressing.
This tutorial is the last part of this article. In this part I will explain VLSM in detail with
examples. Later I will provide a unique six steps method of VLSM that will help you in
learning VLSM rapidly.
Subnet mask
Subnet mask is a 32 bits long address used to distinguish between network address and host
address in IP address. Subnet mask is always used with IP address. Subnet mask has only one
purpose, to identify which part of an IP address is network address and which part is host
address.
For example how will we figure out network partition and host partition from IP address
192.168.1.10 ? Here we need subnet mask to get details about network address and host
address.
In decimal notation subnet mask value 1 to 255 represent network address and value 0 [Zero]
represent host address.
In binary notation subnet mask ON bit [ 1] represent network address
while OFF bit[0] represent host address.
In decimal notation
IP address 192.168.1.10
Subnet mask 255.255.255.0
IP Class Default Subnet Network bits Host bits Total hosts Valid hosts
A 255.0.0.0 First 8 bits Last 24 bits 16, 777, 216 16, 777, 214
Network ID
First address of subnet is called network ID. This address is used to identify one segment or
broadcast domain from all the other segments in the network.
Block Size
Block size is the size of subnet including network address, hosts addresses and broadcast
address.
Broadcast ID
There are two types of broadcast, direct broadcast and full broadcast.
Direct broadcast or local broadcast is the last address of subnet and can be hear by all hosts in
subnet.
Full broadcast is the last address of IP classes and can be hear by all IP hosts in network. Full
broadcast address is 255.255.255.255
The main difference between direct broadcast and full broadcast is that routers will not
propagate local broadcasts between segments, but they will propagate directed broadcasts.
Host Addresses
All address between the network address and the directed broadcast address is called host
address for the subnet. You can assign host addresses to any IP devices such as PCs, servers,
routers, and switches.
COURSE: B.Tech (CSE) Subject: Lab - CN (KCS-653)
Experiment No. 3
CONNECTION OF COMPUTER IN LAN
On the host computer, follow these steps to share the Internet connection:
To connect to the Internet by using the shared connection, you must confirm the LAN adapter
IP configuration, and then configure the client computer. To confirm the LAN adapter IP
configuration, follow these steps:
1. Log on to the client computer as Administrator or as Owner.
2. Click Start, and then click Control Panel.
3. Click Network and Internet Connections.
4. Click Network Connections.
5. Right-click Local Area Connection and then click Properties.
6. Click the General tab, click Internet Protocol (TCP/IP) in the connection uses the following
items list, and then click Properties.
7. In the Internet Protocol (TCP/IP) Properties dialog box, click Obtain an IP address
automatically (if it is not already selected), and then click OK.
Note: You can also assign a unique static IP address in the range of 192.168.0.2 to
192.168.0.254. For example, you can assign the following static IP address, subnet mask, and
default gateway:
8. IP Address 192.168.31.202
9. Subnet mask 255.255.255.0
10. Default gateway 192.168.31.1
11. In the Local Area Connection Properties dialog box, click OK.
12. Quit Control Panel.
COURSE: B.Tech (CSE) Subject: Lab - CN (KCS-653)
Experiment No. 4
Running and using services/commands like ping, trace route, telnet, ftp etc.
PING:
It's instances like these that make ping a very useful day-to-day command. It provides
a very quick way to see if a machine is up and connected to the network. The basic
syntax is:
% ping www.slackware.com
TRACEROUTE:
% traceroute www.slackware.com
NSLOOKUP:
nslookup is a tried and true program that has weathered the ages. nslookup has been
deprecated and may be removed from future releases. There is not even a man page for this
program.
% nslookup 64.57.102.34
Note: nslookup is deprecated and may be removed from future releases.
Consider using the `dig' or `host' programs instead. Run nslookup with
the `-sil[ent]' option to prevent this message from appearing.
Server: 192.168.1.254
Address: 192.168 1.254#53
Non-authoritative answer:
www.slackware.com canonical name =
slackware.com. Name: slackware.com
Address: 64.57.102.34
TELNET:
Telnet allows you to log in to a computer, just as if you were sitting at the terminal. Once
your username and password are verified, you are given a shell prompt. From here, you can
do anything requiring a text console. Compose email, read newsgroups, move files around,
and so on. If you are running X and you telnet to another machine, you can run X programs
on the remote computer and display them on yours.
% telnet <hostname>
COURSE: B.Tech (CSE) Subject: Lab - CN (KCS-653)
Experiment No. 4
Experiment No. 6
Procedure:
• OSPF
Procedure:
Experiment No. 7
To write a program to Calculate Checksum
Theory:
A checksum is a error detection method in Data Communication. It is used for errors which
may have been introduced during transmission or storage. It is usually applied to an
installation file after it is received from the download server.
Checksum method can only detect errors but is unable to correct the error.
In this method a checksum is calculated based on the given binary strings which is sent with
the data as redundant bits. This data + checksum is received at receiver end and checksum is
calculated again, if checksum is 0 it means no error in data received, else there exists some
error in the received data.
Program:
#include<stdio.h>
1. #include<conio.h>
2. #include<math.h>
3.
4. intsender(int b[10],int k)
5. {
6. intchecksum,sum=0,i;
7. printf("\n****SENDER****\n");
8.
9. for(i=0;i<k;i++)
10. sum+=b[i];
12.
13. checksum=~sum;
16. }
22
17.
19. {
20. intchecksum,sum=0,i;
21. printf("\n\n****RECEIVER****\n");
22. for(i=0;i<k;i++)
23. sum+=c[i];
25. sum=sum+scheck;
26. checksum=~sum;
29. }
30. main()
31. {
32. inta[10],i,m,scheck,rcheck;
33. clrscr();
35. scanf("%d",&m);
37. for(i=0;i<m;i++)
38. scanf("%d",&a[i]);
39. scheck=sender(a,m);
40. rcheck=receiver(a,m,scheck);
41. if(rcheck==0)
23
42. printf("\n\nNO ERROR IN TRANSMISSION\n\n");
43. else
45. getch();
46. }
Output:
Experiment No. 8
Program:
void
main()
{ int
a[10];
int
b[10];
int c=0;
int i,n;
clrscr();
printf("enter the length of data code\n");
scanf("%d",&n);
printf("enter the sender side data code\n");
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
printf("enter the reciver side datacode\n");
for(i=0;i<n;i++)
{
scanf("%d",&b[i]);
}
for(i=0;i<n;i++)
{ if(a[i]!
=b[i])
{ c+
+; } }
printf("hamming distance is %d",c);
getch();
OUTPUT:
enter the length of data code 6
0
0
25
1 1 enter the receiver side
data code
Hamming distance is 2
Experiment No. 9
Theory-
26
It does error checking via polynomial division. In general, a bit
string bn-1bn-2bn-3…b2b1b0 As bn-1Xn-1+ bn-2 Xn-2+ bn-3
Xn-3+ …b2 X2+ b1 X1+ b0
Algorithm:-
1- Given a bit string, append 0S to the end of it (the number of 0s is the same as
the degree of the generator polynomial) let B(x) be the polynomial corresponding to B.
2- Divide B(x) by some agreed on polynomial G(x) (generator polynomial) and
determine the remainder R(x). This division is to be done using Modulo 2
Division.
3- Define T(x) = B(x) –R(x)
(T(x)/G(x) => remainder 0)
4- Transmit T, the bit string corresponding to T(x).
5- Let T’ represent the bit stream the receiver gets and T’(x) the associated
polynomial. The receiver divides T1(x) by G(x). If there is a 0 remainder, the
receiver concludes T = T’ and no error occurred otherwise, the receiver concludes
an error occurred and requires a retransmission.
Program :
#include<stdio.h>
#include<string.h>
#include<conio.h>
#define N strlen(g)
char t[128], cs[128],
g[]="10001000000100001"; int a, e, c; void
xor()
{
for(c=1;c<N;c++) cs[c]=((cs[c]==g[c])?'0':'1');
} void
crc()
{
for(e=0;e<N;e++)
cs[e]=t[e]; do {
if(cs[0]=='1') xor();
for(c=0;c<N-1;c++) cs[c]=cs[c+1];
cs[c]=t[e++];
}while(e<=a+N-1);
}
void main() { clrscr(); printf("\nEnter
poly : "); scanf("%s",t); printf("\
nGenerating Polynomial is : %s",g);
a=strlen(t); for(e=a;e<a+N-
1;e++)
t[e]='0';
printf("\nModified t[u] is : %s",t);
27
crc();
printf("\nChecksum is : %s",cs);
for(e=a;e<a+N-1;e++) t[e]=cs[e-a]; printf("\
nFinal Codeword is : %s",t); printf("\nTest
Error detection 0(yes) 1(no) ? : ");
scanf("%d",
&e);
if(e==0) {
printf("Enter position where error is to inserted : ");
scanf("%d",&e);
t[e]=(t[e]=='0')?'1':'0';
printf("Errorneous data : %s\n",t);
}
crc();
for (e=0;(e<N-1)&&(cs[e]!
='1');e++); if(e<N-1)
printf("Error detected."); else
printf("No Error Detected.");
getch(); }
OUTPUT :
Enter poly : 1011101
Generating Polynomial is : 10001000000100001
Modified t[u] is : 10111010000000000000000
Checksum is : 1000101101011000
Final Codeword is : 10111011000101101011000
Test Error detection 0(yes) 1(no) ? : 0
Enter position where you want to insert error : 3
Errorneous data : 10101011000101101011000
Error detected.
Enter poly : 1011101
Generating Polynomial is : 10001000000100001
Modified t[u] is : 10111010000000000000000
Checksum is : 1000101101011000
Final Codeword is :
10111011000101101011000 Test Error
detection 0(yes) 1(no) ? : 1 No Error
Detected.
28
Experiment No. 10
To write a program to Implement HammingCode
Theory:
Hamming code is a popular error detection and error correction method in data communication. Hamming
code can only detect 2 bit error and correct a single bit error which means it is unable to correct burst errors if
may occur while transmission of data.
Program:
#include<stdio.h>
voidmain(){
intdata[10];
intdataatrec[10],c,c1,c2,c3,i;
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];
for(i=0;i<7;i++)
printf("%d",data[i]);
for(i=0;i<7;i++)
29
scanf("%d",&dataatrec[i]);
c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];
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){
else{
for(i=0;i<7;i++)
printf("%d",data[i]);
for(i=0;i<7;i++)
printf("%d",dataatrec[i]);
if(dataatrec[7-c]==0)
dataatrec[7-c]=1;
else
30
dataatrec[7-c]=0;
for(i=0;i<7;i++){
printf("%d",dataatrec[i]);
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
Experiment No. 11
31
Write a program for simple RSA algorithm to encrypt and decrypt the data.
Theory-
Cryptography has a long and colorful history. The message to be encrypted, known as the plaintext, are
transformed by a function that is parameterized by a key. The output of the encryption process, known as the
ciphertext, is then transmitted, often by messenger or radio. The enemy, or intruder, hears and accurately
copies down the complete ciphertext. However, unlike the intended recipient, he does not know the decryption
key and so cannot decrypt the ciphertext easily. The art of breaking ciphers is called cryptanalysis the art of
devising ciphers
(cryptography) and breaking them
(cryptanalysis) is collectively known as cryptology.
There are several ways of classifying cryptographic algorithms. They are generally categorized based on the
number of keys that are employed for encryption and decryption, and further defined by their application and
use. The three types of algorithms are as follows:
1- Secret Key Cryptography (SKC): Uses a single key for both encryption and decryption. It is also
known as symmetric cryptography.
2- Public Key Cryptography (PKC): Uses one key for encryption and another for decryption. It is
also known as asymmetric cryptography.
3- Hash Functions: Uses a mathematical transformation to irreversibly "encrypt" Information.
Public-key cryptography has been said to be the most significant new development in cryptography. Modern
PKC was first described publicly by Stanford University professor Martin Hellman and graduate student
Whitfield Diffie in 1976. Their paper described a two-key crypto system in which two parties could engage in
a secure communication over a non-secure communications channel without having to share a secret key.
Generic PKC employs two keys that are mathematically related although knowledge of one key does not allow
someone to easily determine the other key. One key is used to encrypt the plaintext and the other key is used to
decrypt the ciphertext. The important point here is that it does not matter which key is applied first, but that
both keys are required for the process to work. Because pair of keys is required, this approach is also called
asymmetric cryptography.
In PKC, one of the keys is designated the public key and may be advertised as widely as the owner wants. The
other key is designated the private key and is never revealed to another party. It is straight forward to send
messages under this scheme.
Algorithm
1- Generate two large random primes, P and Q, of approximately equal size. 2- Compute N
=PxQ
3- Compute Z = (P-1) x (Q-1).
4- Choose an integer E, 1 <E <Z, such that GCD (E, Z) = 1
5- Compute the secret exponent D, 1 <D <Z, such that E x D ≡ 1 (mod Z)
6- The public key is (N, E) and the private key is (N, D).
Program :
#include <stdio.h>
#include <string.h>
#include <conio.h> #include <math.h>
int mult(unsigned int x, unsigned int y, unsigned int n)
{
unsigned long int k=1;
int j;
for (j=1; j<=y; j++) k = (k * x) % n; return (unsigned
int) k;
}
void main ()
{ char msg[100];
unsigned int pt[100], ct[100], n, d, e, p, q, i; printf("Enter message : ");
gets(msg);
//strcpy(pt, msg);
for(i=0;i<strlen(msg);i++) pt[i]=msg[i]; n = 253; d = 17; e =
13; printf("\nCT = "); for(i=0; i<strlen(msg); i++) ct[i] =
mult(pt[i], e,n); for(i=0; i<strlen(msg); i++) printf("%d ", ct[i]);
printf("\nPT = ");
for(i=0; i<strlen(msg); i++) printf("%c", pt[i]); for(i=0;
i<strlen(msg); i++) pt[i] = mult(ct[i], d,n) ;
}
Output :
Enter message : alpha
CT = 113 3 129 213 113
PT = alpha
33
34
Experiment No. 12
WAP Program to Calculate the Link Utilization for Stop and Wait ARQ Protocol
Theory:
Link utilization is simply the average traffic over a particular link expressed. as a percentage of the
total link capacity. Link efficiency is a less. commonly used term that is defined as the ratio of the time taken
to. transmit a frame (or frames) of data to the total time it takes to transmit.
Program:
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>
#define v 2.0e8
void main(void)
{
char instring[80];
double d,r,pr,p,a,u,u1;
long int l;
clrscr();
printf("....................");
printf("\n Program to Compute Utiliation of Stop and Wait Protocol\n");
printf("\n.....................\n");
printf("\n Length of the link in m:");
scanf("%s",instring);
d=atof(instring);
printf("\n Data rate of the link in bits per sec");
scanf("%s",instring);
r=atof(instring);
printf("\n Size of frame in byte:");
scanf("%s",instring);
l=8*atoi(instring);
printf("\n pr[biterror](0.0to1.0):");
scanf("%s",instring);
pr=atof(instring);
p=1-pow((1-pr),(double)l);
a=((double)r*d)/((double)v*l);
u=(1-p)/(1+(2*a));
u1=(1)/(1+(2*a));
printf("\n...................\n");
printf("\n.....Protocol is Stop and Wait....\n");
printf("......a=%f.........\n",a);
printf("......pr[frameloss]=%f....\n",p);
printf(".....Utilisation Factor with Error=%f....\n",100.0*u);
printf(".....Utilisation Factor without Error=%f....\n",100.0*u1);
printf("................\n");
getch();
}
35
OUTPUT:
36
Experiment No. 13
Write a c program for bit stuffing used in HDLC.
Theory
Bit stuffing is the insertion of one or more bits into a transmission unit as a way to provide signaling
information to a receiver. The receiver knows how to detect and remove or disregard the stuffed bits.
In another example of bit stuffing, a standard HDLC packet begins and ends with 01111110. To make sure this
sequence doesn't appear again before the end of the packet, a 0 is inserted after every five consecutive 1s.
Bit stuffing is defined by some to include bit padding, which is the addition of bits to a tranmission to make
the transmission unit conform to a standard size, but is distinct from bit robbing, a type of in-band signaling.
Program
#include<stdio.h>
#include<conio.h>
#include<string.h>
Void main()
{ intip[20];op[30];i=j=0;count=0; Printf(“enter
the i/p bit”); get(ip);
for(i=0;i<strlen(ip);i++) op[0]=ip[0];
op[j++]=ip[i];
if(ip[i]==’1’) count++;
else count=0; if(count==5)
{
Op[j++]=’0’;
Count=0;
}
}
Op[j++]=’\0’;
Printf(“bits stuffed is %s”,op); getch();
}
37
38
Experiment No. 14
Dijkstra's algorithm to find the shortest path between a and b. It picks the unvisited vertex with the lowest
distance, calculates the distance through it to each unvisited neighbor, and updates the neighbor's distance if
smaller. Mark visited (set to red) when done with neighbors.
Program:
#include<stdio.h>
#include<conio.h>
#define MAX 10
int main()
int G[MAX][MAX],i,j,n,u;
scanf("%d",&n);
39
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&G[i][j]);
scanf("%d",&u);
dijkstra(G,n,u);
return 0;
int cost[MAX][MAX],distance[MAX],pred[MAX];
int visited[MAX],count,mindistance,nextnode,i,j;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(G[i][j]==0)
cost[i][j]=INFINITY;
else
40
cost[i][j]=G[i][j];
for(i=0;i<n;i++)
distance[i]=cost[startnode][i];
pred[i]=startnode;
visited[i]=0;
distance[startnode]=0;
visited[startnode]=1;
count=1;
while(count<n-1)
mindistance=INFINITY;
for(i=0;i<n;i++)
if(distance[i]<mindistance&&!visited[i])
mindistance=distance[i];
nextnode=i;
41
//check if a better path exists through nextnode
visited[nextnode]=1;
for(i=0;i<n;i++)
if(!visited[i])
if(mindistance+cost[nextnode][i]<distance[i])
distance[i]=mindistance+cost[nextnode][i];
pred[i]=nextnode;
count++;
for(i=0;i<n;i++)
if(i!=startnode)
printf("\nDistance of node%d=%d",i,distance[i]);
printf("\nPath=%d",i);
j=i;
do
j=pred[j];
printf("<-%d",j);
42
}while(j!=startnode);
Output
43
Experiment No. 15
Write A Program to find Class of IP Address and Network Address for Given
IP Address
Theory:
TCP/IP defines five classes of IP addresses: class A, B, C, D, and E. Each class has a range of valid IP
addresses. The value of the first octet determines the class. IP addresses from the first three classes (A, B and
C) can be used for host addresses. The other two classes are used for other purposes (class D for multicast and
class E for experimental purposes).
The system of IP address classes was developed for the purpose of Internet IP addresses assignment. The
classes created were based on the network size. For example, for the small number of networks with a very
large number of hosts, the Class A was created. The Class C was created for the numerous networks with the
small number of hosts.
For the IP addresses from Class A, the first 8 bits (the first decimal number) represent the network part, while
the remaining 24 bits represent the host part. For Class B, the first 16 bits (the first two numbers) represent the
network part, while the remaining 16 bits represent the host part. For Class C, the first 24 bits represent the
network part, while the remaining 8 bits represent the host part.
Program:
void main()
{ inta,b,c,d; clrscr();
printf("enter the first octet");
scanf("%d",&a); printf("\n");
printf("enter the second octet");
scanf("%d",&b); printf("\n");
printf("enter the third octet");
scanf("%d",&c); printf("\n");
printf("enter the fourth octet");
scanf("%d",&d); printf("\n");
if((a<=127))
{
printf("enterdip address belong to class A\n");
printf("network address of given ip address is %d.0.0.0",a);
}
else if((a>127)&&(a<=191))
44
{
printf("entered ip address belong to class B\n");
printf("network address of given ip address is %d.%d.0.0",a,b);
}
else if((a>191)&&(a<=223))
{
printf("entered ipadress belong to class C\n");
printf("network address of given ip address is %d.%d.%d.0",a,b,c);
}
else if((a>223)&&(a<=241))
{
printf("entered ip address belong to class D\n");
} else {
printf("please enter the valid ip address\n");
}
getch(); }
Output:
enter the first octet 123 enter the second octet 233 enter the
123.0.0.0
45