CCN Manual
CCN Manual
Education Trust’s
Prepared by Approved by
Prof. Anita .P Asst. Professor Dr. Jayashri M.Rudagi
Prof. Vinayak.H Asst. Professor Head of the Department
Institute Mission
• Strive to encourage ideas, talents and value systems.
• Guide students to be successful in the endeavor with moral and
ethical values.
• Build relation with Industries and National Laboratories to support
in the field of Engineering and Technology.
• Inculcate a thirst for knowledge in students and help them to
achieve Academic Excellence and Placement.
• Train and develop the faculty to achieve Professional,
Organizational Objectives, and excel in Research and
Development.
Department Vision
To be the department of Electronics and Communication Engineering striving hard
to develop responsive teaching–learning methodology, research and employable
skills in allied fields by empowering students to become globally competent and
socially responsible citizens.
Department Mission
M1: To develop an active learning environment that ensures participation of
students in both curricular as well as co-curricular activities.
M2: To foster research, innovation and creativity amongst students.
M3: To encourage development of entrepreneurial skills.
M4: To inculcate, amongst students, team-spirit, leadership qualities, positive
attitude and effective communication skills to solve societal needs.
Program Educational Objectives (PEOs)
Mapping of CO-PO-PSO
PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
PO1
C318.1 1 1 2 - - 1 2 1 - - 1 -
C318.2 1 1 1 1 - - 1 2 1 - - 1 2
C318.3 1 2 2 2 2 - - 1 2 1 - - 1 -
C318.4 1 1 2 - - 1 2 1 - - 1 2
Set Value 1 1.50 1.50 1.33 1.75 - 1.0 2.0 1.0 - - 1.0 2.0
Do’s and Don’ts in the Laboratory
DO’S
ExamHours03 Laboratory=03(01HrTutorial(Instructions)+02Hrs)
Laboratory Experiments
PART-A:
Simulation experiments using NS2/ NS3/ OPNET/ NCTUNS/ NetSim/ QualNet/ Packet
Tracer or any other equivalent tool
1. Implement a point to point network with four nodes and duplex links between them.
Analyze thenetworkperformancebysettingthequeuesizeandvaryingthe
bandwidth.
2. Implement a four nodepoint to pointnetwork with linksn0-n2, n1-n2 and n2-n3.
Apply TCP agent between n0-n3 and UDP between n1-n3. Apply relevant applications
over TCP and UDP agentschangingtheparameteranddeterminethenumberof
packetssentbyTCP/UDP.
3. Implement Ethernet LAN using n (6-10) nodes. Compare the throughput by changing
the error rate and datarate.
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.
6. Implementation of Link state routing algorithm.
PART-B:
2 Implement a four node point to point networkwith links (n0-n2, n1-n2 and n2-n3) 3
Apply TCP agent between n0-n3 and UDP between n1-n3. Apply relevant
applications over TCP and UDP agentschangingtheparameteranddeterminethe
numberofpacketssentbyTCP/UDP.
4 Implement Ethernet LAN using n nodes and assign multiple traffic to the nodes 7
and obtain congestion window for different sources/ destinations.
5 Implement ESS with transmission nodes in Wireless LAN and obtain the performance 9
parameters
6 Implementation of Link state routing algorithm 11
PART B
Experiments to be conducted using C code
1 Write a programfor a HLDC frame toperform the following. 14
1.Bit stuffing
2. Character stuffing.
2 Writeaprogramfordistancevectoralgorithmtofindsuitablepathfortransmission. 18
3 Implement Dijkstra’s algorithm tocompute the shortestrouting path. 20
7 Viva Questions 29
Tools Used
OS Ubuntu [ Linux ]
C Compiler GCC
(18ECL38) Computer Networks Laboratory
1. Implement a point to pint network with four nodes and duplex links between
them. Analyze the network performance by setting the queue size and varying
the bandwidth.
proc finish {} {
global f nf ns
$ns flush-trace
close $f
close $nf
exec nam lab1.nam &
exit 0
}
$ns duplex-link $n0 $n1 0.3Mb 10ms DropTail #vary bandwidth 0.3, 0.4, 0.5 0.7
$ns duplex-link $n1 $n2 0.3Mb 20ms DropTail #vary bandwidth 0.3, 0.4, 0.5 0.7
$ns duplex-link $n2 $n3 0.3Mb 20ms DropTail #vary bandwidth 0.3, 0.4, 0.5 0.7
$ns queue-limit $n0 $n1 20
$ns queue-limit $n1 $n2 20
$ns queue-limit $n2 $n3 20
➢
Plot a graph with x- axis with bandwidth and y-axis with network performance of UDP protocol.
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.
proc finish {} {
global ns f nf
$ns flush-trace
close $f
close $nf
exec nam lab2.nam &
exit 0
}
proc finish { } {
global nf ns tf
exec nam lab3.nam &
close $naf
close $trf
exit 0
}
$ns make-lan "$n0 $n1 $n2 $n3" 10Mb 10ms LL Queue/DropTail Mac/802_3
$ns make-lan "$n4 $n5 $n6" 10Mb 10ms LL Queue/DropTail Mac/802_3
$err set rat e_ 0.7 #vary error rate 0.1, 0.4, 0.5 and 0.7
➢
Plot a graph with x- axis with Error rate and y-axis with Throughput.
4. Implement Ethernet LAN using n nodes and assign multiple traffic to the
nodes and obtain congestion window for different sources/ destinations.
proc finish {} {
global ns tf nf outFile1 outFile2
$ns flush-trace
close $tf
close $nf
exec nam lab4.nam &
exec xgraph Congestion1.xg Congestion2.xg -geometry 400x400
& exit 0
}
$ns make-lan "$n0 $n1 $n2 $n3 $n4 $n5 " 10Mb 30ms LL Queue/DropTail Mac/802_3
5. Implement ESS with transmission nodes in Wireless LAN and obtain the
performance parameters.
create-god 3
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
$n0 label "ESS"
$n1 label "mob1"
$n2 label "mob2"
$n0 set X_ 10
$n0 set Y_ 600
$n0 set Z_ 0
$n1 set X_ 80
$n1 set Y_ 600
$n1 set Z_ 0
$n2 set X_ 1200
$n2 set Y_ 600
$n2 set Z_ 0
$ns at 0.1 "$n0 setdest 10 600 15"
$ns at 0.1 "$n1 setdest 80 600 25"
$ns at 0.1 "$n2 setdest 1200 600 25"
proc finish { } {
global ns nf tf
$ns flush-trace
exec nam lab5.nam &
close $tf
exit 0
}
$ns at 20 "finish"
$ns run
$ns rtproto LS
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam lab6.nam &
exit 0
}
$ns run
PART-B:
Implement the following in C/C++
2. Write a program for distance vector algorithm to find suitable path for transmission.
Bit stuffing is a process of inserting an extra bit as 0, once the frame sequence encountered 5 consecutive 1's.
Program
#include<stdio.h>
int main()
{
int a[15];
int i,j,k,n,c=0,pos=0;
printf("\n Enter the number of bits");
scanf("%d",&n);
printf("\n Enter the bits");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
if(a[i]==1)
{
c++;
if(c==5)
{
pos=i+1;
c=0;
for(j=n;j>=pos;j--)
{
k=j+1;
a[k]=a[j];
}
a[pos]=0;
n=n+1;
}
}
else
c=0;
}
for(i=0;i<n;i++) {
printf("%d",a[i]);
}
Execution:
[root@localhost code]# gcc 1a.c
[root@localhost code]# ./a.out
Character Stuffing is process in which DLESTX and DLEETX are used to denote start and end of character data with
some constraints imposed on repetition of characters.
Program:
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
char c[50],d[50],t[50];
int i,m,j;
printf("enter the number of characters\n");
scanf("%d",&m);
printf("\n enter the characters\n");
for(i=0;i<m+1;i++)
{
scanf("%c",&c[i]);
}
printf("\n original data\n");
for(i=0;i<m+1;i++)
printf("%c",c[i]);
d[0]='d';
d[1]='l';
d[2]='e';
d[3]='s';
d[4]='t';
d[5]='x';
for(i=0,j=6;i<m+1;i++,j++)
{
if((c[i]=='d'&&c[i+1]=='l'&& c[i+2]=='e'))
{
d[j]='d';
j++;
d[j]='l';
j++;
d[j]='e';
j++;
m=m+3;
}
d[j]=c[i];
}
m=m+6;
m++;
d[m]='d';
m++;
d[m]='l';
m++;
d[m]='e';
m++;
d[m]='e';
m++;
d[m]='t';
m++;
d[m]='x';
m++;
printf("\n\n transmitted data: \n");
for(i=0;i<m;i++)
{
printf("%c",d[i]);
}
for(i=6,j=0;i <m-6;i++,j++)
{
if(d[i]=='d'&&d[i+1]=='l'&&d[i+2]=='e'&&d[i+3]=='d'&&d[i+4]=='l'&&d[i+5]=='e')
i=i+3;
t[j]=d[i];
}
printf("\n\nreceived data:");
for(i=0;i<j;i++)
{printf("%c",t[i]);
}
}
Execution:
[root@localhost code]# gcc 1b.c
[root@localhost code]# ./a.out
enter the number of characters
9
original data
abcdabcde
transmitted data:
dlestx
abcdabcdedleetx
received data:
abcdabcde
2. Write a program for distance vector algorithm to find suitable path for transmission.
Distance vector routing algorithms operate by having each router maintain a table (i.e., vector) giving the best
known distance to each destination and which line to get there. These tables are updated by exchanging
information with the neighbors.
Program:
#include<stdio.h>
struct node
{
unsigned dist[20];
unsigned from[20];
}rt[10];
int main()
{
int dmat[20][20];
int n,i,j,k,count=0;
printf("\nEnter the number of nodes : ");
scanf("%d",&n);
printf("\nEnter the cost matrix (999 for no link):\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&dmat[i][j]);
dmat[i][i]=0;
rt[i].dist[j]=dmat[i][j];
rt[i].from[j]=j;
}
do
{
count=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
for(k=0;k<n;k++)
if(rt[i].dist[j]>dmat[i][k]+rt[k].dist[j])
{
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;
}
}while(count!=0);
for(i=0;i<n;i++)
{
printf("\n\nState value for router %d is
\n",i+1); for(j=0;j<n;j++)
{
printf("\t\nnode %d via %d Distance%d",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n\n");
}
Execution:
[root@localhost code]# gcc 2.c
[root@localhost code]# ./a.out
0 2 999 1
2 0 5 2
999 5 0 6
1 2 6 0
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;
}
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);
}while(j!=startnode);
}
}
Execution:
Distance of node1=10
Path=1<-0
Distance of node2=50
Path=2<-3<-0
Distance of node3=30
Path=3<-0
Distance of node4=60
Path=4<-2<-3<-0
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
Cylic Redundency Check is error checking technique it does error checking via polynomial division.
Progtam:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N strlen(g)
char t[128],cs[128],g[]="1000100000010001";
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);
}
int main(){
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);
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 postion where error is to be inserted:");
scanf("%d",&e);
t[e]=(t[e]=='0')?'1':'0';
printf("Erroneous Data: %s\n",t);
22
(18ECL38) Computer Networks Laboratory
}
crc();
for(e=0;(e<N-1)&&(cs[e]!='1');e++);
if(e<N-1)
printf("Error Detected");
else printf("No Error Detected");
return 0;
}
Execution:
[root@localhost code]# gcc 4.c
[root@localhost code]# ./a.out
Program:
#include<stdio.h>
#define w 1
int main()
{
int i,f,frames[50];
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 stop and wait 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);
printf("if error occur negative acknowledge is detected same frame is resend
back\n");
for(i=1;i<=f;i++)
{
if((random()%2)==1)
{
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]);
}
else
{
sleep(3);
printf("negative acknowledge resend %d frame\n",i);
i=i-1;
sleep(1);
}
}
return 0;
}
Execution:
Enter 6 frames: 1
4
5
7
8
9
With stop and wait protocol the frames will be sent in the following
manner (assuming no corruption of frames)
After sending 1 frames at each stage sender waits for acknowledgement sent by the
receiver
5
Acknowledgement of above frames sent is received by sender
7
Acknowledgement of above frames sent is received by sender
8
Acknowledgement of above frames sent is received by sender
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]);
}
if(f%w!=0)
printf("\nAcknowledgement of above frames sent is received by sender\n");
return 0;
}
Execution:
Enter 5 frames: 12 20 87 65 4
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 20 87
Acknowledgement of above frames sent is received by sender
65 4
Acknowledgement of above frames sent is received by sender
Program:
#include<stdio.h>
#include<stdlib.h>
int bucket_size;
void bucket_input ( int pkt_sz, int op_rt )
{
if( pkt_sz > bucket_size )
printf(" \n\nBucket overflow\n ");
else
{
sleep(1);
while ( pkt_sz > op_rt )
{
printf(" \n %d bytes outputted ", op_rt );
pkt_sz-= op_rt;
sleep(1);
}
if ( pkt_sz > 0 )
printf(" \nLast %d bytes sent\n", pkt_sz );
printf(" \n Bucket output successful \n" );
}
}
int main()
{
int i, op_rate, packet_size;
printf("\n Enter Bucket Size: " );
scanf( "%d", &bucket_size );
printf(" \n Enter output rate: " );
scanf( "%d", &op_rate );
for( i=1; i<=5; i++ )
{
sleep(1);
packet_size = random()%1000;
printf(" \n Packet number [%d] \t Packet size = %d ", i, packet_size );
bucket_input( packet_size, op_rate ); }
return 0;
}
Execution:
[root@localhost code]# gcc 6.c
[root@localhost code]# ./a.out
Bucket overflow
Bucket overflow
Bucket overflow
Bucket overflow
Viva Questions
1. Explain What is Network?
A network is a set of devices connected by physical media links. A network is recursively is a connection of two or more nodes by a physical link or two or
more networks connected by one or more nodes.
2. What is a Link?
At the lowest level, a network can consist of two or more computers directly connected by some physical medium such as coaxial cable or optical fiber. Such a
physical medium is called as Link.
3. What is a node?
A network can consist of two or more computers directly connected by some physical medium such as coaxial cable or optical fiber. Such a physical medium
is called as Links and the computer it connects is called as Nodes.
8. What are the criteria necessary for an effective and efficient network?
a. Performance
It can be measured in many ways, including transmit time and response time. b. Reliability
It is measured by frequency of failure, the time it takes a link to recover from a failure, and the networks robustness.
c. Security
Security issues includes protecting data from unauthorized access and virues.
10. Name the factors that affect the reliability of the network?
a. Frequency of failure
b. Recovery time of a network after a failure
11. Name the factors that affect the security of the network?
a. Unauthorized Access
b. Viruses
If the message is sent from a source to a single destination node, it is called Unicasting.
If the message is sent to some subset of other nodes, it is called Multicasting.
If the message is sent to all the m nodes in the network it is called Broadcasting.
22. What is Multiplexing?
Multiplexing is the set of techniques that allows the simultaneous transmission of multiple signals across a single data link.
31. Which layer links the network support layers and user support layers?
The Transport layer links the network support layers and user support layers.