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)
18 views
5 pages
CN Lab
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 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
18 views
5 pages
CN Lab
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 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save CN LAB For Later
You are on page 1
/ 5
Search
Fullscreen
DIJKSTRA’S ALGORITHM printf(“20711A0595\n”);
#include<stdio.h> printf("Enter frame size ");
void main() scanf("%d",&n);
{ printf("Enter the frame in the form of 0
int path[5][5],i, j, min, a[5][5],p, and 1 :");
st=1,ed=5,stp,edp,t[5],index; for(i=0; i<n; i++)
printf(“20711A0595\n”); scanf("%d",&a[i]);
printf("Enter the cost matrix\n"); i=0;
for(i=1;i<=5;i++) count=1;
for(j=1;j<=5;j++) j=0;
scanf("%d", &a[i][j]); while(i<n)
printf("Enter the paths\n"); {
scanf("%d", &p); if(a[i]==1)
printf("Enter possible paths\n"); #include<stdio.h>
for(i=1;i<=p; i++) {
for(j=1;j<=5;j++) b[j]=a[i];
scanf("%d", &path[i][j]); for(k=i+1; a[k]==1 && k<n && count<5;
for(i=1;i<=p; i++) k++)
{ {
t[i]=0; j++;
stp=st; b[j]=a[k];
for(j=1;j<=5;j++) count++;
{ if(count==5)
edp=path[i][j+1]; {
t[i]=t[i]+a[stp][edp]; j++;
if(edp==ed) b[j]=0;
break; }
else i=k;
stp=edp; }
} }
} else
min=t[st];index=st; {
for(i=1;i<=p; i++) b[j]=a[i];
{ }
if(min>t[i]) i++;
{ j++;
min=t[i]; }
index=i; printf("After Bit Stuffing :");
} for(i=0; i<j; i++)
} printf("%d",b[i]);
printf("Minimum cost %d", min); return 0;
printf("\n Minimum cost path "); }
for(i=1;i<=5;i++) BYTE STUFFING
{ #include<stdio.h>
printf("--> %d", path[index][i]); #include<string.h>
if(path[index][i]==ed) main()
break; {
} char a[30], fs[50] = " ", t[3], sd, ed, x[3],
BIT STUFFING: s[3], d[3], y[3];
#include<string.h> int i, j, p = 0, q = 0;
int main() clrscr();
{ printf("Enter characters to be stuffed:");
int a[20],b[30],i,j,k,count,n; scanf("%s", a);
printf("\nEnter a character that printf("\ntransmitted Code Word:
represents starting delimiter:"); %s",temp);
scanf(" %c", &sd); printf("\n\nEnter the received code
printf("\nEnter a character that word:");
represents ending delimiter:"); scanf("%s",total);
scanf(" %c", &ed); check();
x[0] = s[0] = s[1] = sd; for(i=0;i<divlen-1;i++)
x[1] = s[2] = '\0'; if(data[i]=='1')
y[0] = d[0] = d[1] = ed; {
d[2] = y[1] = '\0'; flag=0;
strcat(fs, x); break;
for(i = 0; i < strlen(a); i++) }
{ if(flag==1)
t[0] = a[i]; printf("\nsuccessful!!");
t[1] = '\0'; else
if(t[0] == sd) printf("\nreceived code word contains
strcat(fs, s); errors...\n");
else if(t[0] == ed) }
strcat(fs, d); void check()
else {
strcat(fs, t); for(j=0;j<divlen;j++)
} data[j]=total[j];
strcat(fs, y); while(j<=len)
printf("\n After stuffing:%s", fs); {
getch(); if(data[0]=='1')
} for(i = 1;i <divlen ; i++)
CRC data[i] = (( data[i] == div[i])?'0':'1');
#include<stdio.h> for(i=0;i<divlen-1;i++)
char data[20],div[20],temp[4],total[100]; data[i]=data[i+1];
int i,j,datalen,divlen,len,flag=1; data[i]=total[j++];
void check(); }
int main() }
{
printf(“20711A0595\n”);
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];
}
LEAKY BUCKET ALGORITHM:
#include<stdio.h>
DISTANCE VECTOR ROUTING #include<conio.h>
#include<stdio.h> int main(){
struct node int incoming, outgoing, buck_size, n,
{ store = 0;
unsigned dist[20]; clrscr();
unsigned from[20]; printf("20711A0595\n");
}rt[10]; printf("Enter bucket size, outgoing rate
int main() and no of inputs: ");
{ scanf("%d %d %d", &buck_size,
int costmat[20][20]; &outgoing, &n);
int nodes,i,j,k,count=0; while (n != 0) {
printf(“20711A0595\n”); printf("Enter the incoming packet size :
printf("\nEnter the number of nodes : ");
"); scanf("%d", &incoming);
scanf("%d",&nodes); printf("Incoming packet size %d\n",
printf("\nEnter the cost matrix :\n"); incoming);
for(i=0;i<nodes;i++) if (incoming <= (buck_size - store)){
{ store += incoming;
for(j=0;j<nodes;j++) printf("Bucket buffer size %d out of
{ %d\n", store, buck_size);
scanf("%d",&costmat[i][j]); } else {
costmat[i][i]=0; printf("Dropped %d no of packets\n",
rt[i].dist[j]=costmat[i][j]; incoming - (buck_size - store));
rt[i].from[j]=j; printf("Bucket buffer size %d out of
} %d\n", store, buck_size);
} store = buck_size;
do }
{ store = store - outgoing;
count=0; printf("After outgoing %d packets left
for(i=0;i<nodes;i++) out of %d in buffer\n", store,
for(j=0;j<nodes;j++) buck_size);
for(k=0;k<nodes;k++) n--;
if(rt[i].dist[j]>costmat[i][k]+rt[k].dist[j]) }
{ }
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j]; Sliding Window Protocol
rt[i].from[j]=k; #include<stdio.h>
count++; #include<stdlib.h>
} void main()
}while(count!=0); {
for(i=0;i<nodes;i++) int i,j,k,n,s,r;
{ clrscr();
printf("\n\n For router %d\n",i+1); printf("Enter no of frames: ");
for(j=0;j<nodes;j++) scanf("%d",&n);
{ printf("Enter the window size: ");
printf("\t\nnode %d via %d Distance scanf("%d",&s);
%d ",j+1,rt[i].from[j]+1,rt[i].dist[j]); r=rand()%(n+1);
} printf("The random number is %d\n",r);
} i=1;
printf("\n\n"); while(i<=n)
getch(); {
j=i; {
for(k=1;k<=s;k++) int count,src_router,i,j,k,w,v,min;
{ int cost_matrix[100]
if(i<=n) [100],dist[100],last[100];
{ int flag[100];
printf("%d frame has transmitted\n",i); printf("\nEnter the no of routers: ");
} scanf("%d",&count);
i++; printf("\n Enter the cost matrix values:
} ");
printf("Window size completed\n"); for(i=0;i<count;i++)
for(k=1;k<=s;k++) {
{ for(j=0;j<count;j++)
if(j<=n && r!=j) {
{ printf("\n%d->%d:",i,j);
printf("%d frame has got ACK\n",j); scanf("%d",&cost_matrix[i][j]);
} if(cost_matrix[i][j]<0)cost_matrix[i]
j++; [j]=1000;
} } }
printf("\n"); printf("\n Enter the source router: ");
} scanf("%d",&src_router);
if(r>0 && r<=n) for(v=0;v<count;v++)
{ {
printf("%d frame ACK missed so the flag[v]=0;
packet has to be retransmitted \n\n",r); last[v]=src_router;
i=r; dist[v]=cost_matrix[src_router][v];
while(i<=n) }
{ flag[src_router]=1;
j=i; for(i=0;i<count;i++)
for(k=1;k<=s;k++) {
{ min=1000;
if(i<=n) for(w=0;w<count;w++)
{ {
printf("%d frame has transmitted \n",i); if(!flag[w])
} if(dist[w]<min)
i++; {
} v=w;
printf("Window size completed \n"); min=dist[w];
for(k=1;k<=s;k++) } }
{ flag[v]=1;
if(j<=n) for(w=0;w<count;w++)
{ {
printf("%d frame has got ACK\n",j); if(!flag[w])
} if(min+cost_matrix[v][w]<dist[w])
j++; {
} dist[w]=min+cost_matrix[v][w];
printf("\n"); last[w]=v;
} } } } } }
OPEN SHORTEST FIRST for(i=0;i<count;i++)
ALGORITHM {
PROGRAM: printf("\n%d==>%d:Path taken:
#include<stdio.h> %d",src_router,i,i);
#include<string.h> w=i;
int main() while(w!=src_router)
{
printf("\n<--%d",last[w]);w=last[w];
}
printf("\n Shortest path cost:
%d",dist[i]);
} }
You might also like
Assignment #2 Strings PDF
PDF
No ratings yet
Assignment #2 Strings PDF
3 pages
CN LAB Small
PDF
No ratings yet
CN LAB Small
3 pages
Badrichit
PDF
No ratings yet
Badrichit
6 pages
Computer Networks Lab
PDF
No ratings yet
Computer Networks Lab
15 pages
CN Lab
PDF
No ratings yet
CN Lab
26 pages
Exp 9-12
PDF
No ratings yet
Exp 9-12
10 pages
All Programs
PDF
No ratings yet
All Programs
6 pages
Computer Networks Labs Executable Progs: Prog 1 CRC
PDF
No ratings yet
Computer Networks Labs Executable Progs: Prog 1 CRC
15 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
Codes
PDF
No ratings yet
Codes
4 pages
Networklabstiya
PDF
No ratings yet
Networklabstiya
16 pages
CN Lab prog-BH
PDF
No ratings yet
CN Lab prog-BH
12 pages
Print First
PDF
No ratings yet
Print First
28 pages
1111
PDF
No ratings yet
1111
1 page
Computer Networking Lab Program
PDF
No ratings yet
Computer Networking Lab Program
25 pages
Computer Networks Record To Print
PDF
No ratings yet
Computer Networks Record To Print
47 pages
Cn&os Lab Executed Codes
PDF
No ratings yet
Cn&os Lab Executed Codes
24 pages
Compuner Network Programs
PDF
No ratings yet
Compuner Network Programs
8 pages
CN Lab
PDF
No ratings yet
CN Lab
33 pages
CN Lab
PDF
No ratings yet
CN Lab
13 pages
Alpha
PDF
No ratings yet
Alpha
2 pages
Int Int Printf
PDF
No ratings yet
Int Int Printf
26 pages
NC-Unique Byte Codes For System Configuration
PDF
No ratings yet
NC-Unique Byte Codes For System Configuration
36 pages
PART-B MANUALh
PDF
No ratings yet
PART-B MANUALh
14 pages
Implement On A Data Set of Characters The Three CRC Polynomials - CRC 12, CRC 16 and CRC
PDF
No ratings yet
Implement On A Data Set of Characters The Three CRC Polynomials - CRC 12, CRC 16 and CRC
5 pages
CN&NP LAB Manual R13 Regulation
PDF
No ratings yet
CN&NP LAB Manual R13 Regulation
82 pages
CN Lab CSE-CS! - Merged
PDF
No ratings yet
CN Lab CSE-CS! - Merged
3 pages
MCom (IS) - DCN LAB Programs
PDF
No ratings yet
MCom (IS) - DCN LAB Programs
16 pages
CN LAB Manual
PDF
No ratings yet
CN LAB Manual
14 pages
2,3 &4 CN Prgs
PDF
No ratings yet
2,3 &4 CN Prgs
7 pages
RR University Networking Practical Notes
PDF
No ratings yet
RR University Networking Practical Notes
12 pages
CN and WP Lab Manual
PDF
No ratings yet
CN and WP Lab Manual
101 pages
CN Lab Manual
PDF
No ratings yet
CN Lab Manual
109 pages
Ns Codes
PDF
No ratings yet
Ns Codes
19 pages
Implement On A Data Set of Characters The Three CRC Polynomials
PDF
No ratings yet
Implement On A Data Set of Characters The Three CRC Polynomials
26 pages
Program 7 To 12 CN Lab With Outputs
PDF
No ratings yet
Program 7 To 12 CN Lab With Outputs
21 pages
CN All Programs
PDF
No ratings yet
CN All Programs
25 pages
Network Communication - Embedded Lab Inlab Exam Lab Code: L41+L42 Name: Sannithi Sai Lokesh Reg No: 19bce2379
PDF
No ratings yet
Network Communication - Embedded Lab Inlab Exam Lab Code: L41+L42 Name: Sannithi Sai Lokesh Reg No: 19bce2379
8 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
Net Com Lab Assigment
PDF
No ratings yet
Net Com Lab Assigment
9 pages
Ada Lab Bcsl404 Manual Ise - Hkbkce - Corrected
PDF
No ratings yet
Ada Lab Bcsl404 Manual Ise - Hkbkce - Corrected
28 pages
20CSI42 - DAA Lab Manual
PDF
No ratings yet
20CSI42 - DAA Lab Manual
21 pages
CN LAB Exercise
PDF
No ratings yet
CN LAB Exercise
12 pages
Ada Lab Manual
PDF
No ratings yet
Ada Lab Manual
31 pages
Progs1 8
PDF
No ratings yet
Progs1 8
12 pages
Computer Networks Lab
PDF
No ratings yet
Computer Networks Lab
14 pages
Computer Networks
PDF
No ratings yet
Computer Networks
29 pages
CN Chatgpt Programs
PDF
No ratings yet
CN Chatgpt Programs
17 pages
Assignment 4 Solution
PDF
No ratings yet
Assignment 4 Solution
8 pages
CN Lab
PDF
No ratings yet
CN Lab
20 pages
CN Manual
PDF
No ratings yet
CN Manual
33 pages
DA Assignment7
PDF
No ratings yet
DA Assignment7
8 pages
Analysis and Design Algorithm Manual
PDF
No ratings yet
Analysis and Design Algorithm Manual
40 pages
CN Lab Manual
PDF
No ratings yet
CN Lab Manual
21 pages
Computer Networks Algorithms in C Language
PDF
63% (8)
Computer Networks Algorithms in C Language
20 pages
Ada Lab Programs
PDF
No ratings yet
Ada Lab Programs
21 pages
C Program / Source Code For The Distance Vector Routing Algorithm Using Bellman Ford's Algorithm
PDF
No ratings yet
C Program / Source Code For The Distance Vector Routing Algorithm Using Bellman Ford's Algorithm
4 pages
ADA LAB MANUAL 2022 Scheme
PDF
No ratings yet
ADA LAB MANUAL 2022 Scheme
24 pages
Practical Assignment 1 (A)
PDF
No ratings yet
Practical Assignment 1 (A)
25 pages
Pointers in C Pro
PDF
No ratings yet
Pointers in C Pro
54 pages
Lab Reports C Programming
PDF
No ratings yet
Lab Reports C Programming
56 pages
Data Structures Practfile by Zoraver Eee - 015 Zoraver Singh Eee
PDF
No ratings yet
Data Structures Practfile by Zoraver Eee - 015 Zoraver Singh Eee
63 pages
C Program To Implement Single Linked List
PDF
No ratings yet
C Program To Implement Single Linked List
12 pages
OS Lab Ex 7 To 15 - 240927 - 111402
PDF
No ratings yet
OS Lab Ex 7 To 15 - 240927 - 111402
42 pages
Viva Questions
PDF
No ratings yet
Viva Questions
4 pages
Discrete Structures and Logic Lab by Vishal Kushwaha
PDF
No ratings yet
Discrete Structures and Logic Lab by Vishal Kushwaha
32 pages
Print Century
PDF
No ratings yet
Print Century
4 pages
Computer 10
PDF
No ratings yet
Computer 10
25 pages
10 Practice Problems ICS (F)
PDF
No ratings yet
10 Practice Problems ICS (F)
4 pages
OSprint 1)
PDF
No ratings yet
OSprint 1)
71 pages
BERC 1313 Lab 2 SELECTION CONTROL TECHNIQUE IN C 2023 - 2024 - Sem2
PDF
No ratings yet
BERC 1313 Lab 2 SELECTION CONTROL TECHNIQUE IN C 2023 - 2024 - Sem2
23 pages
PSCP Notes Co3&Co4
PDF
No ratings yet
PSCP Notes Co3&Co4
58 pages
C Program Rcu
PDF
100% (1)
C Program Rcu
52 pages
BDS Record
PDF
No ratings yet
BDS Record
55 pages
Programming For Problem Solving (ICT 151) : Mukul Sharma
PDF
No ratings yet
Programming For Problem Solving (ICT 151) : Mukul Sharma
18 pages
Most Important Questions of PPS With Solutions For GTU Exam
PDF
No ratings yet
Most Important Questions of PPS With Solutions For GTU Exam
64 pages
BERC 1313 Lab 1 PROBLEM SOLVING IN C 2023 - 2024 - Sem2
PDF
No ratings yet
BERC 1313 Lab 1 PROBLEM SOLVING IN C 2023 - 2024 - Sem2
21 pages
C Program Record Completed
PDF
No ratings yet
C Program Record Completed
167 pages
22pop13 Important Q-Ans
PDF
No ratings yet
22pop13 Important Q-Ans
36 pages
SRM Institute of Science and Technology College of Engineering and Technology
PDF
No ratings yet
SRM Institute of Science and Technology College of Engineering and Technology
5 pages
Compiler Design Lab File
PDF
No ratings yet
Compiler Design Lab File
46 pages
PPS Material
PDF
No ratings yet
PPS Material
271 pages
OS Lab Manual Aditya
PDF
No ratings yet
OS Lab Manual Aditya
49 pages
PPS Notes Unit 1 & Unit 2 - Dr. Aditya Kumar
PDF
No ratings yet
PPS Notes Unit 1 & Unit 2 - Dr. Aditya Kumar
45 pages
Module1 Part 2 Notes
PDF
No ratings yet
Module1 Part 2 Notes
26 pages
Cs3271 C Lab Manual Ucetk
PDF
No ratings yet
Cs3271 C Lab Manual Ucetk
62 pages
C U1 Notes
PDF
No ratings yet
C U1 Notes
163 pages