Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
10 views
3 pages
CN LAB Small
Uploaded by
Saalif Rahman
AI-enhanced title
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
Download
Save
Save CN LAB small For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
10 views
3 pages
CN LAB Small
Uploaded by
Saalif Rahman
AI-enhanced title
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
Carousel Previous
Carousel Next
Download
Save
Save CN LAB small For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save CN LAB small For Later
You are on page 1
/ 3
Search
Fullscreen
DIJKSTRA’S ALGORITHM
#include<stdio.h>----void main() ----{ ----int path[5][5],i, j, min, a[5][5],p,
st=1,ed=5,stp,edp,t[5],index; ----printf("Enter the cost matrix\n"); ----
for(i=1;i<=5;i++) ----for(j=1;j<=5;j++) ----scanf("%d", &a[i][j]); ----
printf("Enter the paths\n"); ----scanf("%d", &p); ----printf("Enter possible
paths\n"); ----for(i=1;i<=p; i++) ----for(j=1;j<=5;j++) ----scanf("%d", &path[i]
[j]); ----for(i=1;i<=p; i++) ----{ ----t[i]=0; ----stp=st; ----for(j=1;j<=5;j++) ----
{ ----edp=path[i][j+1]; ----t[i]=t[i]+a[stp][edp]; ----if(edp==ed) ----break; ----
else ----stp=edp; ----} ----} ----min=t[st];index=st; ----for(i=1;i<=p; i++) ----
{ ----if(min>t[i]) ----{ ----min=t[i]; ----index=i; ----} ----} ----printf("Minimum
cost %d", min); ----printf("\n Minimum cost path "); ----for(i=1;i<=5;i++)----
{----printf("--> %d", path[index][i]); ----if(path[index][i]==ed) ----break;
----}----OUTPUT----INPUT: ----5 10 5 8 2 0 9 8 3 7 3 3 5 2 7 0 0 12 14 5 0 16 4 0 2 1 0 ----
OUTPUT: ----Enter no. of vertices: ----Enter the adjacency matrix: ----Enter the starting node:----
Distance of node1=5 Path=1<-0 ---Distance of node2=8 Path=2<-0 ----Distance of node3=2 Path=3<-0
----Distance of node4=8 Path=4<-1<-0
BIT STUFFING:
#include<string.h> ----int main() ----{ ----int a[20],b[30],i,j,k,count,n; ---
printf("Enter frame size "); ----scanf("%d",&n); ----printf("Enter the frame in
the form of 0 and 1 :"); ----for(i=0; i<n; i++) ----scanf("%d",&a[i]); ----i=0; ----
count=1; ----j=0; ----while(i<n) ----{ ----if(a[i]==1) ----#include<stdio.h> ----
{ ----b[j]=a[i]; ----for(k=i+1; a[k]==1 && k<n && count<5; k++) ----{ ----j++;
----b[j]=a[k]; ----count++; ----if(count==5) ----{ ---j++; ----b[j]=0; ----} ----i=k;
----} ----} ----else ----{ ----b[j]=a[i]; ----} ----i++;----j++; ----} ----printf("After Bit
Stuffing :");----for(i=0; i<j; i++) ----printf("%d",b[i]); ----return 0; ----}
OUTPUT----Enter frame size :12 ----Enter the frame in the form of 0 and 1 :0 1 0 1 1 1 1 1 1 0 0 1 ----After Bit
Stuffing :0 1 0 1 1 1 1 1 0 1 0 0 1
BYTE STUFFING
#include<stdio.h> ----#include<string.h> ----main() ----{ ----char a[30], fs[50]
= " ", t[3], sd, ed, x[3], s[3], d[3], y[3]; ----int i, j, p = 0, q = 0; ----clrscr(); ----
printf("Enter characters to be stuffed:"); ----scanf("%s", a); ----printf("\
nEnter a character that represents starting delimiter:"); ----scanf(" %c",
&sd); ----printf("\nEnter a character that represents ending delimiter:"); ----
scanf(" %c", &ed); ----x[0] = s[0] = s[1] = sd;
x[1] = s[2] = '\0'; ----y[0] = d[0] = d[1] = ed; ----d[2] = y[1] = '\0'; ----strcat(fs,
x); ----for(i = 0; i < strlen(a); i++) ----{ ----t[0] = a[i]; ----t[1] = '\0'; ----if(t[0] ==
sd) ----strcat(fs, s); ---else if(t[0] == ed) ----strcat(fs, d); ----else ----strcat(fs,
t); ----} ----strcat(fs, y); ----printf("\n After stuffing:%s", fs); ----getch();
----}----OUTPUT-Enter string ----OnlineSmartTrainer Enter position Enter the character ----k ----Frames after
character stuffing: DlestxOnlined lekd leSmartTrainerd leetx
CRC
#include<stdio.h> ----char data[20],div[20],temp[4],total[100]; ----int
i,j,datalen,divlen,len,flag=1; ----void check(); ----int main() ----{ ----
printf("Enter the total bit of data:"); ----scanf("%d",&datalen); ----printf("\
nEnter the total bit of divisor"); ----scanf("%d",&divlen); ----
len=datalen+divlen-1; ----printf("\nEnter the data:"); ----scanf("%s",&data);
----printf("\nEnter the divisor"); ----scanf("%s",div);
for(i=0;i<datalen;i++) ----{ ----total[i]=data[i]; ----temp[i]=data[i]; ----} ----
for(i=datalen;i<len;i ----total[i]='0'; ----check(); ----for(i=0;i<divlen;i++) ----
temp[i+datalen]=data[i]; ----printf("\ntransmitted Code Word:%s",temp);
printf("\n\nEnter the received code word:"); ----scanf("%s",total); ----
check(); ----for(i=0;i<divlen-1;i++) ----if(data[i]=='1') ----{ ----flag=0; ----
break; ----} ----if(flag==1)----printf("\nsuccessful!!"); ----else----printf("\
nreceived code word contains errors...\n"); ----} ----void check() ----{ ----
for(j=0;j<divlen;j++) ----data[j]=total[j]; ----while(j<=len) ----{
if(data[0]=='1') ----for(i = 1;i <divlen ; i++) ----data[i] = (( data[i] ==
div[i])?'0':'1'); ----for(i=0;i<divlen-1;i++) ----data[i]=data[i+1]; ----
data[i]=total[j++]; ----} ----} OUTPUT- ----Enterdata: 1001010 ----Enter key: 1011 ----
Quotient is 1010101 ----Reminder is 111 ----Final data is 10010110111
DISTANCE VECTOR ROUTING
#include<stdio.h> ----struct node ----{ ----unsigned dist[20]; ----unsigned
from[20]; ----}----rt[10]; ----int main() ----{ ----int costmat[20][20]; ----int
nodes,i,j,k,count=0; ----printf("\nEnter the number of nodes : "); ----
scanf("%d",&nodes);----printf("\nEnter the cost matrix :\n"); ----
for(i=0;i<nodes;i++) ----{ ----for(j=0;j<nodes;j++) ----{ ----
scanf("%d",&costmat[i][j]); ----costmat[i][i]=0; ----rt[i].dist[j]=costmat[i][j];----
rt[i].from[j]=j; ----} ----} ----do ----{ ----count=0; ----for(i=0;i<nodes;i++) ----
for(j=0;j<nodes;j++) ----for(k=0;k<nodes;k++) ---if(rt[i].dist[j]>costmat[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<nodes;i++)----{ ----printf("\
n\n For router %d\n",i+1); ----for(j=0;j<nodes;j++) ----{ ----printf("\t\nnode
%d via %d Distance %d ",j+1,rt[i].from[j]+1,rt[i].dist[j]); ----} ----} ----printf("\
n\n"); ----getch(); ----}
LEAKY BUCKET ALGORITHM:
#include<stdio.h> ----#include<conio.h> ----int main(){ ----int incoming,
outgoing, buck_size, n, store = 0; ----clrscr(); ----printf("Enter bucket size,
outgoing rate and no of inputs: "); ----scanf("%d %d %d", &buck_size,
&outgoing, &n); ----while (n != 0) { ----printf("Enter the incoming packet size
: "); ----scanf("%d", &incoming); ----printf("Incoming packet size %d\n",
incoming); ---if (incoming <= (buck_size - store)){ ----store += incoming; ----
printf("Bucket buffer size %d out of %d\n", store, buck_size); ----} else { ----
printf("Dropped %d no of packets\n", incoming - (buck_size - store)); ----
printf("Bucket buffer size %d out of %d\n", store, buck_size); ----store =
buck_size; ----} ----store = store - outgoing; ----printf("After outgoing %d
packets left out of %d in buffer\n", store, buck_size); ----n--; ----}----}
Sliding Window Protocol
#include<stdio.h> ----#include<stdlib.h> ----void main() ----{ ----int i,j,k,n,s,r;
----clrscr(); ----printf("Enter no of frames: "); ----scanf("%d",&n); ----
printf("Enter the window size: "); ----scanf("%d",&s); ----r=rand()%(n+1); ----
printf("The random number is %d\n",r); ----i=1; ----while(i<=n) ----{ ----j=i;
----for(k=1;k<=s;k++) ----{ ----if(i<=n) ----{ ----printf("%d frame has
transmitted\n",i); ----} ----i++; ----} ----printf("Window size completed\n"); ----
for(k=1;k<=s;k++) ----{ ----if(j<=n && r!=j) ----{ ----printf("%d frame has got
ACK\n",j); ----} ----j++; ----} ----printf("\n"); ----} ----if(r>0 && r<=n) ----{ ----
printf("%d frame ACK missed so the packet has to be retransmitted \n\
n",r); ----i=r; ----while(i<=n) ----{ ----j=i; ----for(k=1;k<=s;k++) ----{ ----if(i<=n)
----{ ----printf("%d frame has transmitted \n",i); ----} ----i++; ----} ----
printf("Window size completed \n"); ----for(k=1;k<=s;k++) ----{ ----if(j<=n)
----{ ----printf("%d frame has got ACK\n",j); ----} ----j++; ----} ----printf("\n");
----}----}----}
Open shortest first algorithm
#include<stdio.h> ----#include<string.h> ----int main() ----{ ----int count,src_router,i,j,k,w,v,min; ----int
cost_matrix[100][100],dist[100],last[100]; ----int flag[100]; ----printf("\nEnter the no of routers: "); ----
scanf("%d",&count); ----printf("\n Enter the cost matrix values: "); ----for(i=0;i<count;i++) ----{ ----
for(j=0;j<count;j++) ----{ ----printf("\n%d->%d:",i,j); ----scanf("%d",&cost_matrix[i][j]); ----
if(cost_matrix[i][j]<0)cost_matrix[i][j]=1000; ----} ----} ----printf("\n Enter the source router: ");----
scanf("%d",&src_router); ----for(v=0;v<count;v++) ----{ ----flag[v]=0; ----last[v]=src_router; ----
dist[v]=cost_matrix[src_router][v]; ----} ----flag[src_router]=1; ----for(i=0;i<count;i++) ----{ ----
min=1000; ----for(w=0;w<count;w++) ----{ ----if(!flag[w]) ----if(dist[w]<min) ----{ ----v=w; ----
min=dist[w]; ----} ----} ----flag[v]=1; ----for(w=0;w<count;w++) ----{ ----if(!flag[w]) ----
if(min+cost_matrix[v][w]<dist[w]) ----{ ----dist[w]=min+cost_matrix[v][w];----last[w]=v; ----} ----} ----}
----for(i=0;i<count;i++) ----{ ----printf("\n%d==>%d:Path taken:%d",src_router,i,i); ----w=i; ----while(w!
=src_router) ----{ ----printf("\n<--%d",last[w]);w=last[w]; ----} ----printf("\n Shortest path cost:
%d",dist[i]); ----} ----}
You might also like
CN Lab
PDF
No ratings yet
CN Lab
5 pages
CN Lab prog-BH
PDF
No ratings yet
CN Lab prog-BH
12 pages
CN Lab
PDF
No ratings yet
CN Lab
26 pages
Computer Networks Lab
PDF
No ratings yet
Computer Networks Lab
15 pages
Cn&os Lab Executed Codes
PDF
No ratings yet
Cn&os Lab Executed Codes
24 pages
Badrichit
PDF
No ratings yet
Badrichit
6 pages
CN Lab
PDF
No ratings yet
CN Lab
13 pages
NC-Unique Byte Codes For System Configuration
PDF
No ratings yet
NC-Unique Byte Codes For System Configuration
36 pages
Codes
PDF
No ratings yet
Codes
4 pages
1111
PDF
No ratings yet
1111
1 page
All Programs
PDF
No ratings yet
All Programs
6 pages
RR University Networking Practical Notes
PDF
No ratings yet
RR University Networking Practical Notes
12 pages
CN Lab
PDF
No ratings yet
CN Lab
33 pages
CN Lab
PDF
No ratings yet
CN Lab
20 pages
CN and WP Lab Manual
PDF
No ratings yet
CN and WP Lab Manual
101 pages
AIM:-Implement The Data Link Layer Framing Bit Stuffing Method. Program
PDF
No ratings yet
AIM:-Implement The Data Link Layer Framing Bit Stuffing Method. Program
17 pages
Write A C Program To Simulate Bit Stuffing and De-Stuffing
PDF
No ratings yet
Write A C Program To Simulate Bit Stuffing and De-Stuffing
23 pages
Computer Networks
PDF
No ratings yet
Computer Networks
29 pages
CN&NP LAB Manual R13 Regulation
PDF
No ratings yet
CN&NP LAB Manual R13 Regulation
82 pages
CN All Programs
PDF
No ratings yet
CN All Programs
25 pages
CN LAB Manual
PDF
No ratings yet
CN LAB Manual
14 pages
CN - PART B
PDF
No ratings yet
CN - PART B
17 pages
CN Lab Manual
PDF
No ratings yet
CN Lab Manual
21 pages
CN Record
PDF
No ratings yet
CN Record
25 pages
CN Lab Manual
PDF
No ratings yet
CN Lab Manual
109 pages
1a) Implement The Data Link Layer Framing Bit Stuffing Method
PDF
No ratings yet
1a) Implement The Data Link Layer Framing Bit Stuffing Method
19 pages
Ns Codes
PDF
No ratings yet
Ns Codes
19 pages
Computer Networks Algorithms in C Language
PDF
63% (8)
Computer Networks Algorithms in C Language
20 pages
PART-B MANUALh
PDF
No ratings yet
PART-B MANUALh
14 pages
MCom (IS) - DCN LAB Programs
PDF
No ratings yet
MCom (IS) - DCN LAB Programs
16 pages
Computer Networks Labs Executable Progs: Prog 1 CRC
PDF
No ratings yet
Computer Networks Labs Executable Progs: Prog 1 CRC
15 pages
Computer Networks Record To Print
PDF
No ratings yet
Computer Networks Record To Print
47 pages
Azdocuments
PDF
No ratings yet
Azdocuments
23 pages
Computer Networks Record: Pojit
PDF
No ratings yet
Computer Networks Record: Pojit
10 pages
Computer Networks Lab
PDF
No ratings yet
Computer Networks Lab
14 pages
CN Lab Part B Exp 1 and 2
PDF
No ratings yet
CN Lab Part B Exp 1 and 2
11 pages
B. Prashanth - CN Lab Manual (R22)
PDF
No ratings yet
B. Prashanth - CN Lab Manual (R22)
43 pages
CN Internals
PDF
No ratings yet
CN Internals
13 pages
CN Manual
PDF
No ratings yet
CN Manual
33 pages
CN Chatgpt Programs
PDF
No ratings yet
CN Chatgpt Programs
17 pages
Laboratory Manual: Data Communication and Computer Networks
PDF
No ratings yet
Laboratory Manual: Data Communication and Computer Networks
33 pages
CN Programs
PDF
No ratings yet
CN Programs
21 pages
CN Practical File
PDF
No ratings yet
CN Practical File
16 pages
CN Manual
PDF
No ratings yet
CN Manual
21 pages
CN LAB Manual
PDF
No ratings yet
CN LAB Manual
14 pages
Program 7 To 12 CN Lab With Outputs
PDF
No ratings yet
Program 7 To 12 CN Lab With Outputs
21 pages
Compuner Network Programs
PDF
No ratings yet
Compuner Network Programs
8 pages
Int Int Printf
PDF
No ratings yet
Int Int Printf
26 pages
Network Lab Programs For 7th Sem Vtu
PDF
No ratings yet
Network Lab Programs For 7th Sem Vtu
40 pages
CN Lab Manual
PDF
No ratings yet
CN Lab Manual
41 pages
Computer Network Lab Manual 2024
PDF
No ratings yet
Computer Network Lab Manual 2024
11 pages
CNS Lab Manual For End Sem Exam
PDF
No ratings yet
CNS Lab Manual For End Sem Exam
28 pages
Part-A: 1. Write A Program To Implement RSA Algorithm
PDF
No ratings yet
Part-A: 1. Write A Program To Implement RSA Algorithm
49 pages
Computer Networks Lab
PDF
No ratings yet
Computer Networks Lab
70 pages
CCN - Part-B Programs
PDF
No ratings yet
CCN - Part-B Programs
11 pages
CN Lab Internal
PDF
No ratings yet
CN Lab Internal
17 pages
4 To 13 CN
PDF
No ratings yet
4 To 13 CN
33 pages
ALG RECORD Printing
PDF
No ratings yet
ALG RECORD Printing
52 pages
Computer Engineering Laboratory Solution Primer
From Everand
Computer Engineering Laboratory Solution Primer
Karan Bhandari
No ratings yet
150+ C Pattern Programs
From Everand
150+ C Pattern Programs
Hernando Abella
No ratings yet
Unit-Iii: Deadlocks & Memory Management
PDF
No ratings yet
Unit-Iii: Deadlocks & Memory Management
43 pages
Case Sensitive Vlookup in Excel Finding The 1st, 2nd, NTH or Last Occurrence of The Lookup Value
PDF
No ratings yet
Case Sensitive Vlookup in Excel Finding The 1st, 2nd, NTH or Last Occurrence of The Lookup Value
8 pages
Data Structures Algorithms and Applications in C by Sartraj Sahani
PDF
100% (1)
Data Structures Algorithms and Applications in C by Sartraj Sahani
826 pages
12 Apsp
PDF
No ratings yet
12 Apsp
6 pages
Data Structure & Algorithm: Fundamental of DSA
PDF
No ratings yet
Data Structure & Algorithm: Fundamental of DSA
30 pages
Lab Assignment 1 - Sequential Control Structure - ANSWER SCHEME
PDF
No ratings yet
Lab Assignment 1 - Sequential Control Structure - ANSWER SCHEME
3 pages
Lno 2017 Syllabus
PDF
No ratings yet
Lno 2017 Syllabus
1 page
Data Structures and Algorithms MCQ Questions Set 02
PDF
100% (1)
Data Structures and Algorithms MCQ Questions Set 02
41 pages
Chapter 2 Problem Solving
PDF
No ratings yet
Chapter 2 Problem Solving
205 pages
Midterm Exam Review
PDF
No ratings yet
Midterm Exam Review
25 pages
Algorithms and Flowcharts
PDF
No ratings yet
Algorithms and Flowcharts
12 pages
Topic - 3 (Solving Problems by Searching) (31.01.17)
PDF
No ratings yet
Topic - 3 (Solving Problems by Searching) (31.01.17)
70 pages
Mount Zion College of Engineering & Technology: 100 Marks (Answer All The Questions) PART A - 2 Mark Qs (10x2 20)
PDF
100% (1)
Mount Zion College of Engineering & Technology: 100 Marks (Answer All The Questions) PART A - 2 Mark Qs (10x2 20)
1 page
ABET Syllabus-Numerical Methods (Spring 2024-2025)
PDF
No ratings yet
ABET Syllabus-Numerical Methods (Spring 2024-2025)
2 pages
Frontmatter
PDF
No ratings yet
Frontmatter
24 pages
B.Sc-Computer Science Syllabus Under CBCS Pattern With Effect From 2021-2022 Onwards
PDF
No ratings yet
B.Sc-Computer Science Syllabus Under CBCS Pattern With Effect From 2021-2022 Onwards
1 page
Collection
PDF
No ratings yet
Collection
25 pages
Spreadsheet Modeling & Decision Analysis: A Practical Introduction To Management Science
PDF
100% (1)
Spreadsheet Modeling & Decision Analysis: A Practical Introduction To Management Science
56 pages
Comp Science 2
PDF
No ratings yet
Comp Science 2
5 pages
Simplexmethod-Lec.-2 (1) (2) (Original)
PDF
No ratings yet
Simplexmethod-Lec.-2 (1) (2) (Original)
21 pages
Cs I PR II MQP
PDF
No ratings yet
Cs I PR II MQP
2 pages
ADD Find Unsorted Array Sorted Array Linked List
PDF
No ratings yet
ADD Find Unsorted Array Sorted Array Linked List
27 pages
Constraint Satisfaction Problem in AI
PDF
No ratings yet
Constraint Satisfaction Problem in AI
5 pages
Data Structures and Algorithms Question Bank Unit - I Part - A
PDF
No ratings yet
Data Structures and Algorithms Question Bank Unit - I Part - A
22 pages
27 Computer Programming CS100 Syllabus
PDF
No ratings yet
27 Computer Programming CS100 Syllabus
2 pages
STAT 451: Introduction To Machine Learning Lecture Notes
PDF
No ratings yet
STAT 451: Introduction To Machine Learning Lecture Notes
22 pages
(Jignesh Joshi) 3 Greedy 2
PDF
No ratings yet
(Jignesh Joshi) 3 Greedy 2
85 pages
Simulated Annealing
PDF
No ratings yet
Simulated Annealing
11 pages
Module 1 - DAA
PDF
No ratings yet
Module 1 - DAA
116 pages
Ads Course File 2019-20
PDF
No ratings yet
Ads Course File 2019-20
293 pages