CN Lab - Manual (2023-24) Odd Sem
CN Lab - Manual (2023-24) Odd Sem
CN Lab - Manual (2023-24) Odd Sem
2023-24
1
COMPUTER NETWORKS LABORATORY 2023-24
Lab Instructor
Mrs. Divyashree H S
2
COMPUTER NETWORKS LABORATORY 2023-24
OBJECTIVES
OUTCOMES
On the completion of this laboratory course, the students will be able to:
3
COMPUTER NETWORKS LABORATORY 2023-24
LIST OF EXPERIMENTS
1. Implement a point to point network with four nodes and duplex links
between them. Analyze the network performance by setting the queue size and
varying the bandwidth.
2. Implement a four node point to point network with links n0-n2, n1-n2 and
n2-n3. Apply TCP agent between n0-n3 and UDP between n1-n3. Apply
relevant applications over TCP and UDP agents changing the parameter and
determine the number of packets sent by TCP/UDP.
4. Implement Ethernet LAN using n nodes and assign multiple traffic to the
nodes and obtain congestion window for different sources/ destinations.
5. Implement ESS with transmission nodes in Wireless LAN and obtain the
performance parameters.
4
COMPUTER NETWORKS LABORATORY 2023-24
i) Bit stuffing
ii) Character stuffing.
2. Write a program for distance vector algorithm to find suitable path for
transmission.
4. For the given data, use CRC-CCITT polynomial to obtain CRC code. Verify
the program for the cases
a. Without error
b. With error
5
COMPUTER NETWORKS LABORATORY 2023-24
INTRODUCTION
6
COMPUTER NETWORKS LABORATORY 2023-24
The Network Simulator can design and simulate a network with SNMP, TL1,
TFTF, FTP, Telnet and IOS devices, in four simple steps:
1. Add devices to the Device tree: Add devices with the required configuration
to the device tree in the Network Designer. Preconfigured devices are also
bundled with the toolkit.
2. Create the Network: Create and add bulk devices to the network, at one shot.
4. Start the Network: Start the network or start individual agents in the network.
The MIB Browser and TL1 Craft Interface test tools, can be used as the
manager tools for testing.
and ARP, and layer 4 protocols such as TCP and UDP. Routing protocols can
also be traced. Packet Tracer is a supplement to and not a replacement for
experience with real equipment. Students are encouraged to compare the results
obtained from Packet Tracer network models with the behavior of real
equipment.
Cisco® Packet Tracer is a powerful network simulation program that
allows students to experiment with network behavior and ask “what if”
questions. As an integral part of the Networking Academy comprehensive
learning experience, Packet Tracer provides simulation, visualization,
authoring, assessment, and collaboration capabilities to facilitate the teaching
and learning of complex technology concepts.
Key Features
9
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT -1
Aim: Implement a point to point network with four nodes and duplex links
between them. Analyze the network performance by setting the queue size and
varying the bandwidth.
Procedure:
10
COMPUTER NETWORKS LABORATORY 2023-24
11
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT -2
Aim: Implement a four node point to point network with links n0-n2, n1-n2 and
n2-n3. Apply TCP agent between n0-n3 and UDP between n1-n3. Apply
relevant applications over TCP and UDP agents changing the parameter and
determine the number of packets sent by TCP/UDP.
Procedure:
12
COMPUTER NETWORKS LABORATORY 2023-24
13
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT - 3
Aim: Implement Ethernet LAN using n (6-10) nodes. Compare the throughput
by changing the error rate and data rate.
Procedure:
1. Develop a topology shown in the figure given below
2. Configure all the workstations
3. Configure the switch & Router
4. Verify the continuity using ping command
5. Compare the throughput by changing the error rate and data rate
14
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT - 4
Aim: Implement Ethernet LAN using n nodes and assign multiple traffic to the
nodes and obtain congestion window for different sources/ destinations.
Procedure:
1. Develop a topology shown in the figure given below
2. Configure all the nodes
3. Configure the switch & Router
4. Verify the continuity using ping command
5. Verify congestion window for different sources / destinations
15
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT - 5
Aim: Implement ESS with transmission nodes in Wireless LAN and obtain the
performance parameters.
Procedure:
16
COMPUTER NETWORKS LABORATORY 2023-24
17
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT - 6
Procedure:
18
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT NO-01
i) Bit stuffing and De-stuffing
Algorithm:
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max 1000
#if 0
void main()
{
int si=0, di=0,count=0;
char src[max],des[max];
char flag[max]="01111110";
clrscr();
printf("enter the msg bits:\n");
scanf("%s",&src);
di = strlen(flag) ;
strcpy(des,flag);
di=strlen(flag);
while(src[si]!='\0')
{
if(src[si]=='1')
count ++;
else
count = 0;
des[di++]=src[si++];
if (count == 5)
19
COMPUTER NETWORKS LABORATORY 2023-24
{
count = 0;
des[di++]='0';
}
}
des[di++]='\0';
printf("stuffed message is %s ", strcat(des,flag));
si = strlen(flag);
for(di=0;si<strlen(des)-2*si-1;si++,di++)
src[di]=des[si];
count = 0;
si = 0; di =0;
while (src[si]!='\0')
{
if(src[si]=='1')
count++;
else
count = 0;
des[di++]=src[si++];
if(count==5)
{
count = 0;
des[di++]=src[si++];
}
}
des[di]='\0';
printf("destuffed data is %s" , des);
getch();
}
#else
void main()
{
int si=0, di=0,count=0,StuffedLen;
char src[max],des[max];
char flag[max]="01111110";
clrscr();
printf("enter the msg bits:\n");
scanf("%s",&src);
di = strlen(flag) ;
strcpy(des,flag);
di=strlen(flag);
while(src[si]!='\0')
{
if(src[si]=='1')
count ++;
else
count = 0;
des[di++]=src[si++];
20
COMPUTER NETWORKS LABORATORY 2023-24
if (count == 5)
{
count = 0;
des[di++]='0';
}
}
des[di++]='\0';
printf("stuffed message is %s ", strcat(des,flag));
si = strlen(flag);
StuffedLen = strlen(des)-2*si;
for(di=0;di<StuffedLen;si++,di++)
src[di]=des[si];
src[di] = '\0';
count = 0;
si = 0; di =0;
while (src[si]!='\0')
{
if(src[si]=='1')
count++;
else
count = 0;
des[di++]=src[si++];
if(count==5)
{
count = 0;
si++;
//des[di++]=src[si++];
}
}
des[di]='\0';
printf("The destuffed data is %s" , des);
getch();
}
Output
21
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT NO-01
ii) Character Stuffing And De-Stuffing
Theory:
Bit stuffing seems to be a foolproof plan but sometimes the communication
systems cannot handled bits but only manipulate bytes(8 bits). In these case we assume an
ASCII set. The main control signals are ETX (End text), STX (Start text), and DLE (data link
escape). Other control signals are also present like SOH (Start of header), EOT (End of
transmission), etc but we will restrict the the discussion to ETX STX DLE .The principle
remains the same STX (ASCII 02) denots start of data and ETX (ASCII 03) the end of text
.incase ETX or the byte 03 happens to be present in data and not end of the text.
Similar is the case for STX. to making sure this happens we use another ASCII
value called DLE (ASCII 16). Each time we see the STX in data we make it DLE STX and
an ETX is made into DLE ETX. So if we receive an ETX or a STX and the previous ASCII
value is not DLE we know it is a frame start/end. Consider the case when DLE was the last
data byte. Then end of the text will now become as data as the receiver will get DLE ETX.
So now even DLE is stuffed. So each time transmitter sees DLE it makes it DLE DLE.
ALGORITHM:
// character stuffing
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max 100
void main()
{
clrscr();
int si=0, di =0;
char flag1[max]="DLESTX", flag2[max]="DLEETX", des[max], src[max];
/*stuffing process*/
strcpy(des,flag1);
di=strlen(flag1);
while(src[si]!='\0')
{
if(src[si]=='D'&& src[si+1]=='L'&& src[si+2]=='E')
{
des[di+0]='D', des[di+1]='L', des[di+2]='E',
des[di+3]='D', des[di+4]='L', des[di+5]='E';
di+=6;
si+=3;
}
else
des[di++]=src[si++];
}
des[di]='\0';
strcat(des,flag2);
printf("\nthe stuffed string is %s\n",des);
/*destuffing process*/
di = strlen(des)-strlen(flag2);
des[di]='\0';
di=strlen(flag1);
for(si=0;des[di]!='\0';si++,di++)
src[si]=des[di];
si=di=0;
while(src[si]!='\0')
{
if(src[si]=='D'&&src[si+1]=='L'&&src[si+2]=='E'&&
src[si+3]=='D'&&src[si+4]=='L'&&src[si+5]=='E')
{
des[di]='D',des[di+1]='L',des[di+2]='E';
di+=3;
si+=6;
}
else
des[di++]=src[si++];
}
des[di]='\0';
printf("the destuffed string is %s",des);
getch();
}
23
COMPUTER NETWORKS LABORATORY 2023-24
OUTPUT:
24
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT NO-02
DISTANCE VECTOR ALGORITHM
Aim: Write a program for distance vector algorithm to find suitable path for
transmission.
Theory:
One of the most popular & dynamic routing algorithms, the distance
vector routing algorithms operate by using the concept of each router having to
maintain a table( ie., a vector ), that lets the router know the best or shortest
distance to each destination and the next hop to get to there. Also known as
Bellman Ford(1957) and Ford Fulkerson (1962). It was the original ARPANET
algorithm.
Algorithm Overview:
Each router maintains a table containing entries for and indexed by each
other router in the subnet. Table contains two parts:
The metric used here is the transmission delay to each destination. This metric
maybe number of hops, queue length, etc.
The router is assumed to know the distance metric to each of its neighbors.
Across the network the delay is calculated by sending echo packets to each of
neighbors.
PROGRAM :
#include<stdio.h>
#include<string.h>
#include<conio.h>
struct rtable
{
int dist[20],nextnode[20];
}table[20];
25
COMPUTER NETWORKS LABORATORY 2023-24
int cost[10][10],n;
void distvector()
{
int i,j,k,count=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
table[i].dist[j]=cost[i][j];
table[i].nextnode[j]=j;
}
}
do
{
count=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
for(k=0;k<n;k++)
{
if(table[i].dist[j]>cost[i][k]+table[k].dist[j])
{
table[i].dist[j]=table[i].dist[k]+table[k].dist[j];
table[i].nextnode[j]=k;
count++;
}
}
}
}
}while(count!=0);
}
void main()
{
int i,j;
printf("\nenter the no of vertices:\t");
scanf("%d",&n);
printf("\nenter the cost matrix\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&cost[i][j]);
distvector();
for(i=0;i<n;i++)
{
printf("\nstate value for router %c \n",i+65);
printf("\ndestnode\tnextnode\tdistance\n");
for(j=0;j<n;j++)
26
COMPUTER NETWORKS LABORATORY 2023-24
{
if(table[i].dist[j]==99)
printf("%c\t\t-\t\tinfinite\n",j+65);
else
printf("%c\t\t%c\t\t%d\n",j+65,table[i].nextnode[j]+65,table[i].dist[j]);
}
%%return 0;
getch(),
}
}
OUTPUT :
0 2 1 99 99 1
2 0 99 2 1 99
1 99 0 99 2 2
99 2 99 0 1 5
99 1 2 1 0 99
1 99 2 5 99 0
A A 1
B A 3
C C 0
D E 3
E E 2
F F 2
28
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT NO-03
Shortest Path Algorithm
Theory:
All packet need to be routed from the source to the destination and in
most cases multiple hopes are required. Routing Algorithms are required to
decide on which output line and incoming pocket should be forwarded into.
Two types Routing Algorithms now come in-one where the decision
is fixed and One where the route is constantly recalculated for the best route in
other words static and dynamic routing algorithms or non-adaptive and adaptive
algorithms. Routing algorithms can be made to adapt to average
traffic/loss/distance queue length etc.
29
COMPUTER NETWORKS LABORATORY 2023-24
ALGORITHM:
#include <stdio.h>
#include <conio.h>
int p[10][10];
void main()
{
int i,j,k,n,t; int m[10][10], w[10][10];
void path(int a,int b);
clrscr();
printf("enter the number of nodes");
scanf ("%d",&n);
printf("\n Enter the nodes connection matrix");
printf("\n To indicate no connection between two nodes, enter weight as 100\n\n");
/* prints the outline of the matrix */
for(i=1;i<=n;i++)
printf("\t %d",i);
for(i=1;i<=n;i++)
{
printf("\n %d \t",i);
/* Takes the entered values as input */
for( j=1;j<=n;j++)
{
scanf("%d",&w[i][j]);
m[i][j]=w[i][j];
p[i][j]=0;
}
}
for(k=1;k<=n;k++)
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
30
COMPUTER NETWORKS LABORATORY 2023-24
if(m[i][k]+m[k][j]<m[i][j])
{
m[i][j] =m[i][k] + m[k][j];
p[i][j] = k;
}
do
{
printf("\n enter the source & Destination nodes\n");
scanf("%d %d",&i,&j);
printf("\n the weight is %d", m[i][j]);
printf("\n the path is");
printf( "%d-->",i);
path(i,j);
printf("%d", j);
printf("\n to repeat press R");
}
while(getch()=='R');
}
void path(int i,int j)
{
int k;
k=p[i][j];
if(k!=0)
{
path(i,k);
printf("%d-->",k);
path(k,j);
} }
OUTPUT:
Enter no of nodes 7
31
COMPUTER NETWORKS LABORATORY 2023-24
32
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT NO-04
Cyclic Redundancy Check
THEORY:
The polynomial code (also known as a Cyclic Redundancy code or CRC code)
is widely used. polynomial codes are based upon treating bit string as representations of
polynomials with coefficients of 0 and 1 only. A k-bit frame is regarded as the coefficient list
for a polynomial with k terms, ranging from x k-1 to x0. Such a polynomial is said to be of a
degree k-1. The high order (left most) bit is the coefficient of x k-1; the next bit is the
coefficient of x k-2 and so on. For example 110001 has 6 bits and thus represents a six-term
polynomial with coefficients.1,1,0,0,0 and 1: x5+x4+x0.
When the polynomial code method is employed, the centre and receiver must agree upon a
generator polynomial, G(x) in advanced, both the high and low order bits of the generator
must be one. To compute the checksum for some frame with m bits, corresponding to the
polynomial M(x) the frame must be longer than the generator polynomial. the idea is so to
append a checksum to the end of the frame in such a way that the polynomial represented by
the check summed frame is divisible by G(x).When the receiver gets the check summed
frame, it tries dividing it by G(x).If there is a remember there has been a transmission error.
ALGORITHM:
➢ Let r be the degree of G(x). Append r zero bits to the low order end of the frame, so it now
contains m+r bits and corresponds to the polynomial xr M(x).
➢ Divide the bits string corresponding to G(x) into the bit string corresponding to xr M(x)
using modulo-2 division.
➢ Subtract the remainder(which is always r or fewer bits) from the bit string corresponding to
xr M(x) using modulo-2 subtraction. The result is the checksummed frame to be transmitted.
Call its polynomial T(x).
➢ The CRC- CCITT polynomial is X3+ X1 + 1
#include<stdio.h>
#include<conio.h>
#include<string.h>
#define degree 3
int res[30];
int getnext(int array[],int);
void crc(int len)
{
int cp[]={1,0,1,1};
int i=0,pos=0,newpos;
33
COMPUTER NETWORKS LABORATORY 2023-24
while(pos<len-degree)
{
for(i= pos;i<pos+degree+1;++i)
res[i]=res[i]^cp[i-pos];
newpos=getnext(res,pos);
if(newpos>pos+1)
pos= newpos-1;
++pos;
}
}
int getnext(int array[], int pos)
{
int i = pos;
while( array[i] ==0)
++i;
return i;
}
void main()
{
int array[30];
char ch;
int len,i=0;
clrscr();
puts("enter the data stream:");
while((ch =getche())!='\r')
array[i++] = ch-'0';
len=i;
for(i=0;i<degree; ++i)
array[i+len]=0;
len+= degree;
for(i=0;i<len;i++)
res[i]=array[i];
crc(len);
printf("\n the transmitted frame is: ");
for(i=0; i<len-degree; ++i)
printf("%d", array[i]);
for(i=len-degree; i<len;++i)
printf("%d", res[i]);
printf("\nEnter the stream for which crc to be checked");
i=0;
while((ch=getche())!='\r')
array[i++]= ch-'0';
len=i;
for(i=0;i<len;i++)
res[i]=array[i];
crc(len);
printf("\n checksum: ");
for(i=len-degree; i<len;i++)
printf("%d", res[i]);
getch();
}
OUTPUT:
34
COMPUTER NETWORKS LABORATORY 2023-24
(Without error)
Enter data stream 10011
Transmitted frame is 10011100
Enter the stream for which CRC to be checked 10011100
Checksum: 000
(With error)
Enter data stream 10011
Transmitted frame is 10011100
Enter the stream for which crc to be checked 10011101
Checksum: 001
35
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT NO – 5
AIM: Implementation of Stop and Wait Protocol and Sliding Window Protocol
THEORY:
Flow Control
Consider a situation in which the sender transmits frames faster than the receiver can accept
them. If the sender keeps pumping out frames at high rate, at some point the receiver will be
completely swamped and will start losing some frames. This problem may be solved by
introducing flow control. Most flow control protocols contain a feedback mechanism to
inform the sender when it should transmit the next frame.
• Stop and Wait Protocol: This is the simplest file control protocol in which the
sender transmits a frame and then waits for an acknowledgement, either positive or
negative, from the receiver before proceeding. If a positive acknowledgement is
received, the sender transmits the next packet; else it retransmits the same frame.
However, this protocol has one major flaw in it. If a packet or an acknowledgement is
completely destroyed in transit due to a noise burst, a deadlock will occur because the
sender cannot proceed until it receives an acknowledgement. This problem may be
solved using timers on the sender's side. When the frame is transmitted, the timer is
set. If there is no response from the receiver within a certain time interval, the timer
goes off and the frame may be retransmitted.
36
COMPUTER NETWORKS LABORATORY 2023-24
37
COMPUTER NETWORKS LABORATORY 2023-24
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
Void main()
{
int i,j,noframes,x,x1=10,x2;
clrscr();
for(i=0;i<200;i++)
rand();
noframes=rand()/200;
i=1;j=1;
noframes=noframes/8;
printf(“\n Number of frames is %d”,noframes);
getch();
while(noframes>0)
38
COMPUTER NETWORKS LABORATORY 2023-24
{
printf(“\n Sending frames %d”,i);
strand(x1++);
x=rand()%10;
if(x%2==0)
{
for(x2=1;x2<2;x2++)
{
Printf(“Waiting for %d seconds \n”,x2);
sleep(x2);
}
printf(“\n sending frame %d”,i);
strand(x1++);
x=rand()%10;
}
printf(“\n ack for frame %d”.j);
noframes-=1;
i++;j++;
}
printf(“\n end of stop and wait protocol”);
getch();
}
• Sliding Window Protocols: In spite of the use of timers, the stop and wait protocol
still suffers from a few drawbacks. Firstly, if the receiver had the capacity to accept
more than one frame, its resources are being underutilized. Secondly, if the receiver
was busy and did not wish to receive any more packets, it may delay the
acknowledgement. However, the timer on the sender's side may go off and cause an
unnecessary retransmission. These drawbacks are overcome by the sliding window
protocols.
In sliding window protocols the sender's data link layer maintains a 'sending window'
which consists of a set of sequence numbers corresponding to the frames it is
permitted to send. Similarly, the receiver maintains a 'receiving window'
corresponding to the set of frames it is permitted to accept. The window size is
dependent on the retransmission policy and it may differ in values for the receiver's
and the sender's window. The sequence numbers within the sender's window
represent the frames sent but as yet not acknowledged. Whenever a new packet
arrives from the network layer, the upper edge of the window is advanced by one.
When an acknowledgement arrives from the receiver the lower edge is advanced by
one. The receiver's window corresponds to the frames that the receiver's data link
layer may accept. When a frame with sequence number equal to the lower edge of the
window is received, it is passed to the network layer, an acknowledgement is
generated and the window is rotated by one. If however, a frame falling outside the
window is received, the receiver's data link layer has two options. It may either
discard this frame and all subsequent frames until the desired frame is received or it
39
COMPUTER NETWORKS LABORATORY 2023-24
may accept these frames or buffer them until the appropriate frame is received and
then pass the frames to the network layer in sequence.
It is of two types:-
1. Selective Repeat: Sender transmits only that frame which is erroneous or is lost.
2. Go back n: Sender transmits all frames present in the window that occurs after the error
bit including error bit also.
#include<stdio.h>
int main()
{
int w,i,f,frames[50];
40
COMPUTER NETWORKS LABORATORY 2023-24
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]);
}
if(f%w!=0)
printf("\nAcknowledgement of above frames sent is received by sender\n");
return 0;
}
Output
Enter 5 frames: 12 5 89 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 5 89
Acknowledgement of above frames sent is received by sender
41
COMPUTER NETWORKS LABORATORY 2023-24
46
Acknowledgement of above frames sent is received by sender
42
COMPUTER NETWORKS LABORATORY 2023-24
EXPERIMENT NO – 6
6. Write a program for Congestion control using the leaky bucket algorithm.
The leaky-bucket implementation is used to control the rate at which traffic is sent to
the network. A leaky bucket provides a mechanism by which bursty traffic can be shaped to
present a steady stream of traffic to the network, as opposed to traffic with erratic bursts of
low-volume and high-volume flows.
Traffic analogy An appropriate analogy for the leaky bucket is a scenario in which
four lanes of automobile traffic converge into a single lane. A regulated admission interval
into the single lane of traffic flow helps the traffic move. The benefit of this approach is that
traffic flow into the major arteries (the network) is predictable and controlled. The major
liability is that when the volume of traffic is vastly greater than the bucket size, in
conjunction with the drainage-time interval, traffic backs up in the bucket beyond bucket
capacity and is discarded.
43
COMPUTER NETWORKS LABORATORY 2023-24
PROGRAM :
#include<stdio.h>
#include<stdlib.h>
int trand(int a)
{
int rn;
rn=random()%10;
rn=rn%a;
if(rn==0)
rn=1;
return(rn);
}
int main()
{
int i,packet[5],psz,bsz,pszrn=0,clk,ptime,premain,orate,flag=0;
for(i=0;i<5;i++)
packet[i]=trand(6)*10;
printf("\nenter the o/p rate");
scanf("%d",&orate);
printf("\nenter the bucket size");
scanf("%d",&bsz);
for(i=0;i<5;i++)
{
if((packet[i]+pszrn)>bsz)
printf("\n incoming packet size %d is greater than bucket
size_reject",packet[i]);
else
{
for(;;)
{
premain=4-i;
psz=packet[i];
pszrn+=psz;
printf("\nincoming packet size is %d",psz);
printf("\n no.of packets waiting for transmission= %d",pszrn);
ptime=trand(4)*10;
printf("\nnext packet will come at %d",ptime);
for(clk=0;clk<=ptime;clk++)
{
printf("\ntime left =%d",ptime-clk);
sleep(1);
if(pszrn)
{
if(pszrn==0)
printf("\nbucket is empty");
else
{
44
COMPUTER NETWORKS LABORATORY 2023-24
if(pszrn>=orate)
printf("%d bytes are tranmited",orate);
else
printf("\n %d bytes are
transmitted",pszrn);
}
if(pszrn<=orate)
pszrn=0;
else
pszrn-=orate;
printf("\nbytes remaining %d ",pszrn);
}
else
printf("\nbytes remaing %d ",pszrn);
}
if(pszrn!=0)
flag=1;
break;
}
}
}
printf("\n\n");
return 0;
}
OUTPUT : RUN 1:
RUN 2:
time left =7
bytes remaing 0
time left =6
bytes remaing 0
time left =5
bytes remaing 0
time left =4
bytes remaing 0
time left =3
bytes remaing 0
time left =2
bytes remaing 0
time left =1
bytes remaing 0
time left =0
bytes remaing 0
incoming packet size 50 is greater than bucket size_reject
incoming packet size 30 is greater than bucket size_reject
47
COMPUTER NETWORKS LABORATORY 2023-24
Viva Questions
1.What do you mean by data communication?
Ans: It is the exchange of data between two devices via some form of transmission medium
such as wire cable. The communicating system must be part of a communication system
made up of a combination of hardware and software. The effectiveness of a data
communication system depends on three fundamental characteristics: delivery, accuracy and
timeliness.
2.What is simplex?
Ans: It is the mode of communication between two devices in which flow of data is
unidirectional. i.e. one can transmit and other can receive. E.g. keyboard and monitor.
3.What is half-duplex?
Ans: It is the mode of communication between two devices in which flow of data is bi-
directional but not at the same time. ie each station can transmit and receive but not at the
same time. E.g walkie-talkies are half-duplex system.
5.What is a network?
Ans: It is a set of devices connected by communication links. A node can be a computer or
any other device capable of sending and/or receiving data generated by other nodes on the
network.
9.What is a topology?
Ans: Topology of a network is defined as the geometric representation of the relationship of
all the links and linking devices (node) to one another.Four basic topologies are star, bus,
ring and mesh. Star – Here each device has a dedicated point to point link only to a central
controller called hub.Bus -It is multipoint. One long cable acts as a backbone to link all the
devices in the network. Ring -Here each device has a dedicated point to point connection
only with the two devices on either side of it. Mesh -Here every device has a dedicated point
to point link to every other device.
48
COMPUTER NETWORKS LABORATORY 2023-24
11.Define internet?
Ans: It is a network of networks.
12.What is a protocol?
Ans: It is a set of rules that governs data communication. A protocol defines what is
communicated, how it is communicated, and when it is communicated. The key elements of
protocol are syntax, semantics and timing.
17.What is switching?
Ans: Switching in data communication is of three types Circuit switching Packet switching
Message switching
49
COMPUTER NETWORKS LABORATORY 2023-24
19. Compare analog and digital signals? Ans: Analog signals can have an infinite number
of values in a range but digital signal can have only a limited number of values.
20.Define bandwidth?
Ans: The range of frequencies that a medium can pass is called bandwidth. It is the
difference between the highest and lowest frequencies that the medium can satisfactorily
pass.
and stop bit and without gaps between bytes. Regrouping the bits into meaningful bytes is the
responsibility of the receiver.
32.What are the different types of multiplexing? Ans: Multiplexing is of three types.
Frequency division multiplexing and wave division multiplexing is for analog signals and
time division multiplexing is for digital signals.
33.What is FDM? Ans: In frequency division multiplexing each signal modulates a different
carrier frequency. The modulated carrier combines to form a new signal that is then sent
across the link. Here multiplexers modulate and combine the signal while demultiplexers
decompose and demodulate. Guard bands keep the modulating signal from overlapping and
interfering with one another.
34.What is TDM ? Ans: In TDM digital signals from n devices are interleaved with one
another, forming a frame of data. Framing bits allow the TDM multiplexer to synchronize
properly.
35.What are the different transmission media? Ans: The transmission media is broadly
categorized into two types i)Guided media(wired) i)Unguided media(wireless)
36.What are the different Guided Media? Ans: The media which provides a conduct from
one device to another is called a guided media. These include twisted pair cable, coaxial
cable, and fiber-optic cable.
37.Describe about the different Guided Medias. Ans: Twisted pair cable consists of two
insulated cupper wires twisted together. It is used in telephone line for voice and data
communications. Coaxial cable has the following layers: a metallic rod-shaped inner
conductor, an insulator covering the rod, a metallic outer conductor (shield), an insulator
covering the shield, and a plastic cover.Coaxial cable can carry signals of higher frequency
ranges than twisted-pair cable. Coaxial cable is used in cable TV networks and Ethernet
LANs.Fiber-optic cables are composed of a glass or plastic inner core surrounded by
cladding, all encased in an outer jacket.Fiber-optic cables carry data signals in the form of
light. The signal is propagated along the inner core by reflection. Its features are noise
resistance, low attenuation, and high bandwidth capabilities. It is used in backbone networks,
cable TV nerworks, and fast Ethernet networks.
38.What do you mean by wireless communication? Ans: Unguided media transport
electromagnetic waves without using a physical conductor. This type of communication is
referred as wireless communication. Here signals are broadcaster through air and thus
available to anyone who has a device to receive it. are connected to one another efficiently. A
switch is intermediary hardware or software that links devices together temporarily.
39.What are the switching methods? Ans: There are three fundamental switching methods:
circuit switching, packet switching, And message switching.In circuit switching, a direct
physical connection between two devices is created by space division switches, time division
switches or both. In packet switching data is transmitted using a packet switched network.
Packet switched network is a network in which data are transmitted in independent units
called packets.
40.What are the duties of data link layer? Ans: Data link layer is responsible for carrying
packets from one hop (computer or router) to the next. The duties of data link layer include
packetizing, adderssing, error control, flow control, medium access control.
41.What are the types of errors? Ans: Errors can be categorized as a single-bit error or
burst error. A single bit error has one bit error per data unit. A burst error has two or more
bits errors per data unit.
42.What do you mean by redundancy? Ans: Redundancy is the concept of sending extra
bits for use in error detection. Three common redundancy methods are parity check, cyclic
redundancy check (CRC), and checksum.
51
COMPUTER NETWORKS LABORATORY 2023-24
43.Define parity check. Ans: In parity check, a parity bit is added to every data unit so that
the total number of 1s is even (or odd for odd parity).Simple parity check can detect all single
bit errors. It can detect burst errors only if the total number of errors in each data unit is
odd.In two dimensional parity checks, a block of bits is divided into rows and a redundant
row of bits is added to the whole block.
44. Define cyclic redundancy check (CRC). Ans: C RC appends a sequence of redundant
bits derived from binary division to the data unit. The divisor in the CRC generator is often
represented as an algebraic polynomial.
45. What is hamming code? Ans: The hamming code is an error correction method using
redundant bits. The number of bits is a function of the length of the data bits. In hamming
code for a data unit of m bits, we use the formula 2r >= m+r+1 to determine the number of
redundant bits needed. By rearranging the order of bit transmission of the data units, the
hamming code can correct burst errors.
46.What do you mean by flow control? Ans: It is the regulation of sender’s data rate so
that the receiver buffer doesn’t become overwhelmed.i.e. flow control refers to a set of
procedures used to restrict the amount of data that the sender can send before waiting for
acknowledgement.
47.What do you mean by error control? Ans: Error control refers primarily to methods of
error detection and retransmission. Anytime an error is detected in an exchange, specified
frames are retransmitted. This process is called automatic repeat request (ARQ).
48.Define stop and wait ARQ. Ans: In stop and wait ARQ, the sender sends a frame and
waits for an acknowledgement from the receiver before sending the next frame.
49.Define Go-Back-N ARQ? Ans: In Go-Back-N ARQ, multiple frames can be in transit at
the same time. If there is an error, retransmission begins with the last Unacknowledged frame
even if subsequent frames arrived correctly. Duplicate frames are discarded.
50.Define Selective Repeat ARQ? Ans: In Selective Repeat ARQ, multiple frames can be
in transit at the same time. If there is an error, only unacknowledged frame is retransmitted.
50.What do you mean by pipelining, is there any pipelining in error control? Ans: The
process in which a task is often begun before the previous task has ended is called pipelining.
There is no pipelining in stop and wait ARQ however it does apply in Go-Back-N ARQ and
Selective Repeat ARQ.
51.What is HDLC? Ans: It is a bit oriented data link protocol designed to support both half
duplex and full duplex communication over point to point and multi point links.HDLC is
characterized by their station type,configuration and their response modes.
52.What do you mean by point to point protocol? Ans: The point to point protocol was
designed to provide a dedicated line for users who need internet access via a telephone line or
a cable TV connection. Its connection goes through three phases: idle, establishing,
authenticating, networking and terminating. At data link layer it employs a version of HDLC.
53. What do you mean by point to point protocol stack? Ans: Point to point protocol uses
a stack of other protocol to use the link, to authenticate the parties involved, and to carry the
network layer data. Three sets of protocols are defined: link control protocol, Authentication
protocol, and network control protocol.
54.What do you mean by line control protocol? Ans: It is responsible for establishing,
maintaining, configuring, and terminating links.
55.What do you mean by Authentication protocol? Ans: Authentication means validating
the identity of a user who needs to access a set of resources. It is of two types i)Password
Authentication Protocol(PAP) ii)Challenge Handshake Authentication Protocol(CHAP) PAP
is a two step process. The user sends a authentication identification and a password. The
system determines the validity of the Information sent.CHAP is a three step process. The
52
COMPUTER NETWORKS LABORATORY 2023-24
system sends a value to the user. The user manipulates the value and sends the result. The
system Verifies the result.
56.What do you mean by network control protocol? Ans: Network control protocol is a
set of protocols to allow the encapsulation of data coming from network layer protocol that
requires the services of PPP.
57. What do you mean by CSMA? Ans: To reduce the possibility of collision CSMA
method was developed. In CSMA each station first listen to the medium (Or check the state
of the medium) before sending. It can’t eliminate collision.
58.What do you mean by Bluetooth? Ans: It is a wireless LAN technology designed to
connect devices of different functions such as telephones, notebooks, computers, cameras,
printers and so on. Bluetooth LAN Is an adhoc network that is the network is formed
spontaneously? It is the implementation of protocol defined by the IEEE 802.15 standard.
59.What is IP address? Ans: The internet address (IP address) is 32bits that uniquely and
universally defines a host or router on the internet. The portion of the IP address that
identifies the network is called netid. The portion of the IP address that identifies the host or
router on the network is called hostid.
60.What do you mean by subnetting? Ans: Subnetting divides one large network into
several smaller ones. It adds an intermediate level of hierarchy in IP addressing.
61.What are the advantages of fiber optics cable ? Ans: The advantages of fiber optics
cable over twisted pair cable are Noise resistance-As they use light so external noise is not a
factor. Less signal attenuation-fiber optics transmission distance is significantly greater than
that of other guided media.Higher bandwidth-It can support higher bandwidth.
62.What are the disadvantages of fiber optics cable? Ans: The disadvantages of fiber
optics cable over twisted pair cable are Cost-It is expensive Installation/maintenance-Any
roughness or cracking defuses light and alters the signal Fragility-It is more fragile.
63.What are the propagation type of radio wave ? Ans: Radio wave propagation is
dependent upon frequency.There are five propagation type. i)surface propagation
ii)Tropospheric propagation iii)Ionospheric propagation iv)Line of sight propagation v)space
propagation
64.What do you mean by Geosynchronous Satellites ? Ans: Satellite communication uses
a satellite in geosynchronous orbit to relay signals.The Satellite must move at the same speed
as the earth so that it seems to remain fixed above a certain spot..Only one orbit can be
geosynchronous.This orbit occurs at the equatorial plane and is approximately 22,000 miles
from the surface of earth.
65.What are the factors for evaluating the suitability of the media ? Ans: The factors are
cost,throughput,attenuation,Electromagneric interference(EMI),securtty.
66.What do you mean by medium access control(MAC) sublayer. Ans: The protocols
used to determine who goes next on a multi-access channel belong to a sublayer of the data
link layer is called the multi-access channel(MAC) sublayer.It is the buttom part of data link
layer.
67.What do you mean by ALOHA ? Ans: It is the method used to solve the channel
allocation problem .It is used for: i)ground based radio broadcasting ii)In a network in which
uncoordinated users are competing for the use of single channel. It is of two types: 1.Pure
aloha 2.Slotted aloha
68.What is pure ALOHA? Ans: It lets users transmit whenever they have data to
sent.Collision may occur but due to feedback property sender can know the status of
message.conflict occur when at one time more bits are transmitted.The assumptions are : i)all
frame size is same for all user. ii)collision occur when frames are transmitted simultaneously
53
COMPUTER NETWORKS LABORATORY 2023-24
54
COMPUTER NETWORKS LABORATORY 2023-24
81.What do you mean by protocol stack ? Ans: The list of protocols used by certain
system ,one protocol per layer is called protocol stack.
82.What do you mean by peer ? Ans: Entities comprising the corresponding layers on
different machines are called peers.It may be • hardware device. • processes • human being
peers communicate by using protocol.
83.What do you mean by broadcasting ? Ans: Broadcast system allow addressing a packet
to all destination by using a special code in address field.when packet is transmitted it is
received and processed by every machine on the network.
84.What are the advantages of broadcast network. Ans: • a single communication
channel is shared by all computers. • packets are transmitted and received by all the
computer. • address field is attached to whom it is intended. • multicasting is used in network.
85.What do you mean by point to point network? Ans: Point to point network consist of
many connections between individual pair of machines.large networks are point to
point.Routing algorithm plays an important in point to point network.It uses stored ad
forword technique.It is a packet switching network.
86.What are the design issue of layers ? Ans: The design issue of layer are • Addressing
technique.ie source and destination address • Types of communication • Error control • Order
of message. • Speed matching • Multiplexing and demultiplexing.
87.What are the protocols in application layer ? Ans: The protocols defined in application
layer are • TELNET • FTP • SMTP • DNS
88.What are the protocols in transport layer ? Ans: The protocols defined in transport
layer are • TCP • UDP
89.Define TCP ? Ans: It is connection oriented protocol.It consist byte streams oeiginating
on one machine to be delivered without error on any other machine in the network.while
transmitting it fragments the stream to discrete messages and passes to interner layer.At the
destination it reassembles the messages into output stream.
90.Define UDP ? Ans: It is unreliable connectionless protocol.It is used for one-shot,client-
server type,requesr-reply queries and applications in which prompt delivery is required than
accuracy.
91.Define IP ? Ans: Internetwork protocol (IP) is the transmission mechanism used by
TCP/IP protocol.It is an unreliable and connectionless datagram protocol.It provides no error
checking and tracking.
92.What do you mean by client server model ? Ans: In client server model ,the client runs
a program to request a service and the server runs a program to provide the service.These two
programs communicate with each other. One server program can provide services to many
client programs.
93.What are the information that a computer attached to a TCP/IP internet must
possesses ? Ans: Each computer attached to TCP/IP must possesses the following
information • Its IP addesss • Its subnet mask • The IP addesss of the router. • The Ip address
of the name server.
94.What is domain name system(DNS)? Ans: Domain Name System (DNS )is a client
server application that identifies each host on the internet with a unique user friendly name.
95.What is TELNET ? Ans: TELNET is a client –server application that allows a user to
log on to a remote machine,giving the user access to the remote system. TELNET is an
abbreviation of terminal Network.
96.What do you mean by local login and remote login ? Ans: When a user logs into a
local time-sharing system ,it is called local login. When a user wants to access an application
program or utility located on a remote machine,he or she performs remote login.
55
COMPUTER NETWORKS LABORATORY 2023-24
56
COMPUTER NETWORKS LABORATORY 2023-24
57
COMPUTER NETWORKS LABORATORY 2023-24
58