0% found this document useful (0 votes)
17 views58 pages

CN Lab Manual R18 - Modified

Use better write ✍️ modified one to make

Uploaded by

Salomi Pamu
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
0% found this document useful (0 votes)
17 views58 pages

CN Lab Manual R18 - Modified

Use better write ✍️ modified one to make

Uploaded by

Salomi Pamu
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
You are on page 1/ 58

COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB MANUAL

CS506PC: COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB


III Year B.Tech. CSE I-Sem L T P C
3003
Course Objectives
1. To understand the working principle of various communication protocols.
2. To understand the network simulator environment and visualize a network topology and
observe its performance
3. To analyze the traffic flow and the contents of protocol frames
Course Outcomes
1. Implement data link layer farming methods
2. Analyze error detection and error correction codes.
3. Implement and analyze routing and congestion issues in network design.
4. Implement Encoding and Decoding techniques used in presentation layer
5. To be able to work with different network tools
List of Experiments
1. Implement the data link layer framing methods such as character, character-stuffing and bit
stuffing.
2. Write a program to compute CRC code for the polynomials CRC-12, CRC-16 and CRC CCIP
3. Develop a simple data link layer that performs the flow control using the sliding window protocol,
and loss recovery using the Go-Back-N mechanism.
4. Implement Dijsktra’s algorithm to compute the shortest path through a network
5. Take an example subnet of hosts and obtain a broadcast tree for the subnet.
6. Implement distance vector routing algorithm for obtaining routing tables at each node.
7. Implement data encryption and data decryption
8. Write a program for congestion control using Leaky bucket algorithm.
9. Write a program for frame sorting technique used in buffers.
10. Wireshark
1. Packet Capture Using Wire shark
2. Starting Wire shark
3. Viewing Captured Traffic
4. Analysis and Statistics & Filters.
11. How to run Nmap scan
12. Operating System Detection using Nmap
13. Do the following using NS2 Simulator
i. NS2 Simulator-Introduction
ii. Simulate to Find the Number of Packets Dropped
iii. Simulate to Find the Number of Packets Dropped by TCP/UDP
iv. Simulate to Find the Number of Packets Dropped due to Congestion
v. Simulate to Compare Data Rate& Throughput.
vi. Simulate to Plot Congestion for Different Source/Destination
vii. Simulate to Determine the Performance with respect to Transmission of Packets
Web Technologies Experiments
1. Write a PHP script to print prime numbers between 1-50.
2. PHP script to
a. Find the length of a string.
b. Count no of words in a string.
c. Reverse a string.
d. Search for a specific string.
3. Write a PHP script to merge two arrays and sort them as numbers, in descending order.
4. Write a PHP script that reads data from one file and write into another file.
5. Develop static pages (using Only HTML) of an online book store. The pages should resemble:
www.amazon.com. The website should consist the following pages.
a) Home page
b) Registration and user Login
c) User Profile Page
d) Books catalog
e) Shopping Cart
f) Payment By credit card
g) Order Conformation
6. Validate the Registration, user login, user profile and payment by credit card pages using
JavaScript.
7. Create and save an XML document on the server, which contains 10 users information. Write
a program, which takes User Id as an input and returns the user details by taking the user
information from the XML document.
8. Install TOMCAT web server. Convert the static web pages of assignments 2 into dynamic web
pages using servlets and cookies. Hint: Users information (user id, password, credit card
number) would be stored in web.xml. Each user should have a separate Shopping Cart.
9. Redo the previous task using JSP by converting the static web pages of assignments 2 into
dynamic web pages. Create a database with user information and books information. The
books catalogue should be dynamically loaded from the database. Follow the MVC architecture
while doing the website.
TEXT BOOKS:
1. WEB TECHNOLOGIES: A Computer Science Perspective, Jeffrey C. Jackson, Pearson
Education
REFERENCES:
1. Deitel H.M. and Deitel P.J., “Internet and World Wide Web How to program”, Pearson
International, 2012, 4th Edition.
2. J2EE: The complete Reference By James Keogh, McGraw-Hill
3. Bai and Ekedhi, The Web Warrior Guide to Web Programming, Thomson
4. Paul Dietel and Harvey Deitel,” Java How to Program”, Prentice Hall of India, 8th Edition
5. Web technologies, Black Book, Dreamtech press.
6. Gopalan N.P. and Akilandeswari J., “Web Technology”, Prentice Hall of India
1.Implement the datalink layer framing methods such as Character-stuffing and Bit -Stuffing.

AIM: Implement the data link layer framing methods such as and bit stuffing.

THEORY:
The new technique allows data frames to contain an arbitrary number if bits and allows character
codes with an arbitrary no of bits per character. Each frame begins and ends with special bit pattern,
01111110, called a flag byte. When ever the senders data link layer encounters five consecutive
one’s in the data, it automatically stuffs a 0 bit into the out going bit stream. This bit stuffing is
analogous to character stuffing, in which a DLE is stuffed into the out going character stream before
DLE in the data

ALGORITHM:

Begin
Step 1: Read frame length n
Step 2: Repeat step (3 to 4) until i<n(: Read values in to the input frame (0’s and 1’s) i.e.
Step 3: initialize I i=0;
Step 4: read a[i] and increment i
Step 5: Initialize i=0, j=0,count =0
Step 6: repeat step (7 to 22) until i<n
Step 7: If a[i] == 1 then
Step 8: b[j] = a[i]
Step 9: Repeat step (10 to 18) until (a[k] =1 and k<n and count <5)
Step 10: Initialize k=i+1;
Step 11: Increment j and b[j]= a[k];
Step 12: Increment count ;
Step 13: if count =5 then
Step 14: increment j,
Step 15: b[j] =0
Step 16: end if
Step 17: i=k;
Step 18: increment k
Step 19: else
Step 20: b[j] = a[i]
Step 21: end if
Step 22: increment I and j
Step 23: print the frame after bit stuffing
Step 24: repeat step (25 to 26) until i< j
Step 25: print b[i]
Step 26: increment i
End
SOURCE CODE:

// BIT Stuffing program

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int a[20],b[30],i,j,k,count,n;
clrscr();
printf("Enter frame length:");
scanf("%d",&n);
printf("Enter input frame (0's & 1's only):");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0; count=1; j=0;
while(i<n)
{
if(a[i]==1)
{
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 stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]);
getch();
}
OUTPUT:

EXPERIMENT NO: 1. (b)

NAME OF THE EXPERIMENT: Character Stuffing.

AIM: Implement the data link layer framing methods such as character, character stuffing.
THEORY:
The framing method gets around the problem of resynchronization after an error by having each
frame start with the ASCII character sequence DLE STX and the sequence DLE ETX. If the
destination ever losses the track of the frame boundaries all it has to do is look for DLE STX or DLE
ETX characters to figure out. The data link layer on the receiving end removes the DLE before the
data are given to the network layer. This technique is called character stuffing

ALGORITHM:
Begin
Step 1: Initialize I and j as 0
Step 2: Declare n and pos as integer and a[20],b[50],ch as character
Step 3: read the string a
Step 4: find the length of the string n, i.e n-strlen(a)
Step 5: read the position, pos
Step 6: if pos > n then
Step 7: print invalid position and read again the position, pos
Step 8: end if
Step 9: read the character, ch
Step 10: Initialize the array b , b[0…5] as ’d’, ’l’, ’e’, ’s’ ,’t’ ,’x’
respectively
Step 11: j=6;
Step 12: Repeat step[(13to22) until i<n
Step 13: if i==pos-1 then
Step 14: initialize b array,b[j],b[j+1]…b[j+6] as‘d’, ‘l’, ‘e’ ,’ch, ’d’, ‘l’,‘e’
respectively
Step 15: increment j by 7, i.e j=j+7
Step 16: end if
Step 17: if a[i]==’d’ and a[i+1]==’l’ and a[i+2]==’e’ then
Step 18: initialize array b, b[13…15]=’d’, ‘l’, ‘e’ respectively
Step 19: increment j by 3, i.e j=j+3
Step 20: end if
Step 21: b[j]=a[i]
Step 22: increment I and j;
Step 23: initialize b array,b[j],b[j+1]…b[j+6] as‘d’, ‘l’,‘e’ ,’e’,‘t’, ‘x’,‘\0’
respectively
Step 24: print frame after stiuffing
Step 25: print b
End

SOURCE CODE:
//PROGRAM FOR CHARACTER STUFFING
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;
char a[20],b[50],ch;
clrscr();
printf("enter string\n");
scanf("%s",&a);
n=strlen(a);
printf("enter position\n");
scanf("%d",&pos);
if(pos>n)
{
printf("invalid position, Enter again :");
scanf("%d",&pos);
}
printf("enter the character\n");
ch=getche();

b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';
b[5]='x';
j=6;
while(i<n)
{
if(i==pos-1)
{

b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]=ch;
b[j+4]='d';
b[j+5]='l';
b[j+6]='e';
j=j+7;
}
if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e')
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
j=j+3;
}

b[j]=a[i];
i++;
j++;
}
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("\nframe after stuffing:\n");
printf("%s",b);
getch();
}

OUTPUT:

EXPERIMENT NO: 2.

AIM: Write a program to computeCRC code for the polynomials – CRC 12, CRC 16 and CRC
CCIP.

THEORY:
CRC method can detect a single burst of length n, since only one bit per column will be changed, a
burst of length n+1 will pass undetected, if the first bit is inverted, the last bit is inverted and all
other bits are correct. If the block is badly garbled by a long burst or by multiple shorter burst, the
probability that any of the n columns will have the correct parity that is 0.5. so the probability of a
bad block being expected when it should not be 2 power(-n). This scheme some times known as
Cyclic Redundancy Code

ALGORITHM/FLOWCHART:
Begin
Step 1: Declare I,j,fr[8],dupfr[11],recfr[11],tlen,flag,gen[4],genl,frl,
rem[4] as integer
Step 2: initialize frl=8 and genl=4
Step 3: initialize i=0
Step 4: Repeat step(5to7) until i<frl
Step 5: read fr[i]
Step 6: dupfr[i]=fr[i]
Step 7: increment i
Step 8: initialize i=0
Step 9: repeat step(10to11) until i<genl
Step 10: read gen[i]
Step 11: increment i
Step 12: tlen=frl+genl-1
Step 13: initialize i=frl
Step 14: Repeat step(15to16) until i<tlen
Step 15: dupfr[i]=0
Step 16: increment i
Step 17: call the function remainder(dupfr)
Step 18: initialize i=0
Step 19: repeat step(20 to 21) until j<genl
Step 20: recfr[i]=rem[j]
Step 21: increment I and j
Step 22: call the function remainder(dupfr)
Step 23: initialize flag=0 and i=0
Step 24: Repeat step(25to28) until i<4
Step 25: if rem[i]!=0 then
Step 26: increment flag
Step 27: end if
Step 28: increment i
Step 29: if flag=0 then
Step 25: print frame received correctly
Step 25: else
Step 25: print the received frame is wrong
End
Function: Remainder(int fr[])
Begin
Step 1: Declare k,k1,I,j as integer
Step 2: initialize k=0;
Step 3: repeat step(4 to 14) until k< frl
Step 4: if ((fr[k] == 1) then
Step 5: k1=k
Step 6: initialize i=0, j=k
Step 7: repeat step(8 to 9) until i< genl
Step 8: rem[i] =fr[j] exponential gen[i]
Step 9: increment I and j
Step 10: initialize I = 0
Step 11: repeat step(12to13) until I <genl
Step 12: fr[k1] = rem[i]
Step 13: increment k1 and i
Step 14: end if
End

SOURCE CODE:
//PROGRAM FOR CYCLIC REDUNDENCY CHECK
#include<stdio.h>
#include<conio.h>
int gen[4],genl,frl,rem[4];
void main()
{
int i,j,fr[8],dupfr[11],recfr[11],tlen,flag;
clrscr();
frl=8; genl=4;
printf("enter frame:");
for(i=0;i<frl;i++)
{
scanf("%d",&fr[i]);
dupfr[i]=fr[i];
}
printf("enter generator:");
for(i=0;i<genl;i++)
scanf("%d",&gen[i]);

tlen=frl+genl-1;
for(i=frl;i<tlen;i++)
{
dupfr[i]=0;
}
remainder(dupfr);

for(i=0;i<frl;i++)
{
recfr[i]=fr[i];
}
for(i=frl,j=1;j<genl;i++,j++)
{
recfr[i]=rem[j];
}
remainder(recfr);
flag=0;
for(i=0;i<4;i++)
{
if(rem[i]!=0)
flag++;
}
if(flag==0)
{
printf("frame received correctly");
}
else
{
printf("the received frame is wrong");
}

getch();
}

remainder(int fr[])
{
int k,k1,i,j;
for(k=0;k<frl;k++)
{
if(fr[k]==1)
{
k1=k;
for(i=0,j=k;i<genl;i++,j++)
{
rem[i]=fr[j]^gen[i];
}

for(i=0;i<genl;i++)
{
fr[k1]=rem[i];
k1++;
}
}
}
}
OUTPUT:
1. Here you will get sliding window protocol program in C.
2. In computer networks sliding window protocol is a method to transmit data on a network.
Sliding window protocol is applied on the Data Link Layer of OSI model. At data link layer
data is in the form of frames. In Networking, Window simply means a buffer which has data
frames that needs to be transmitted.
3. Both sender and receiver agrees on some window size. If window size=w then after sending
w frames sender waits for the acknowledgement (ack) of the first frame.
4. As soon as sender receives the acknowledgement of a frame it is replaced by the next frames
to be transmitted by the sender. If receiver sends a collective or cumulative
acknowledgement to sender then it understands that more than one frames are properly
received, for eg:- if ack of frame 3 is received it understands that frame 1 and frame 2 are
received properly.

5.
6. Image Source
7. In sliding window protocol the receiver has to have some memory to compensate any loss in
transmission or if the frames are received unordered.
8. Efficiency of Sliding Window Protocol
9. η = (W*tx)/(tx+2tp)
10. W = Window Size
11. tx = Transmission time
12. tp = Propagation delay
13. Sliding window works in full duplex mode
14. It is of two types:-
15. 1. Selective Repeat: Sender transmits only that frame which is erroneous or is lost.
16. 2. Go back n: Sender transmits all frames present in the window that occurs after the error
bit including error bit also.

17. Sliding Window Protocol Program in C

18. Below is the simulation of sliding window protocol in C.

19.
1 #include<stdio.h>
2
3 int main()
4 {
5 int w,i,f,frames[50];
6
7 printf("Enter window size: ");
8 scanf("%d",&w);
9
10 printf("\nEnter number of frames to transmit: ");
11 scanf("%d",&f);
12
13 printf("\nEnter %d frames: ",f);
14
15 for(i=1;i<=f;i++)
16 scanf("%d",&frames[i]);
17
printf("\nWith sliding window protocol the frames will be sent in the following manner (assuming
18
no corruption of frames)\n\n");
19
printf("After sending %d frames at each stage sender waits for acknowledgement sent by the
20
receiver\n\n",w);
21
22 for(i=1;i<=f;i++)
23 {
24 if(i%w==0)
25 {
26 printf("%d\n",frames[i]);
27 printf("Acknowledgement of above frames sent is received by sender\n\n");
28 }
29 else
30 printf("%d ",frames[i]);
31 }
32
if(f%w!=0)
33
printf("\nAcknowledgement of above frames sent is received by sender\n");
34
35 return 0;
36 }
20. Output
21. Enter window size: 3
22. Enter number of frames to transmit: 5
23. Enter 5 frames: 12 5 89 4 6
24. With sliding window protocol the frames will be sent in the following manner (assuming no
corruption of frames)
25. After sending 3 frames at each stage sender waits for acknowledgement sent by the receiver
26. 12 5 89
Acknowledgement of above frames sent is received by sender
27. 4 6
Acknowledgement of above frames sent is received by sender
28.
29.

EXPERIMENT NO: 3

NAME OF THE EXPERIMENT: Shortest Path.

AIM: Implement Dijkstra‘s algorithm to compute the Shortest path thru a given graph.

ALGORITHM/FLOWCHART:
Begin
Step1: Declare array path [5] [5], min, a [5][5], index, t[5];
Step2: Declare and initialize st=1,ed=5
Step 3: Declare variables i, j, stp, p, edp
Step 4: print “enter the cost “
Step 5: i=1
Step 6: Repeat step (7 to 11) until (i<=5)
Step 7: j=1
Step 8: repeat step (9 to 10) until (j<=5)
Step 9: Read a[i] [j]
Step 10: increment j
Step 11: increment i
Step 12: print “Enter the path”
Step 13: read p
Step 14: print “Enter possible paths”
Step 15: i=1
Step 16: repeat step(17 to 21) until (i<=p)
Step 17: j=1
Step 18: repeat step(19 to 20) until (i<=5)
Step 19: read path[i][j]
Step 20: increment j
Step 21: increment i
Step 22: j=1
Step 23: repeat step(24 to 34) until(i<=p)
Step 24: t[i]=0
Step 25: stp=st
Step 26: j=1
Step 27: repeat step(26 to 34) until(j<=5)
Step 28: edp=path[i][j+1]
Step 29: t[i]= [ti]+a[stp][edp]
Step 30: if (edp==ed) then
Step 31: break;
Step 32: else
Step 33: stp=edp
Step 34: end if
Step 35: min=t[st]
Step 36: index=st
Step 37: repeat step( 38 to 41) until (i<=p)
Step 38: min>t[i]
Step 39: min=t[i]
Step 40: index=i
Step 41: end if
Step 42: print” minimum cost” min
Step 43: print” minimum cost pth”
Step 44: repeat step(45 to 48) until (i<=5)
Step 45: print path[index][i]
Step 46: if(path[idex][i]==ed) then
Step 47: break
Step 48: end if
End

SOURCE CODE:
//*********************************
//5 .PROGRAM FOR FINDING SHORTEST //PATH FOR A GIVEN GRAPH
//*********************************

#include<stdio.h>
#include<conio.h>
void main()
{
int path[5][5],i,j,min,a[5][5],p,st=1,ed=5,stp,edp,t[5],index;
clrscr();
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;
}
getch();
}
9. OUTPUT:

EXPERIMENT NO:
THEORY:
This technique is widely used because it is simple and easy to understand. The idea of this algorithm
is to build a graph of the subnet with each node of the graph representing a router and each arc of the
graph representing a communication line. To choose a route between a given pair of routers the
algorithm just finds the broadcast between them on the graph.

ALGORITHM/FLOWCHART:

step 1: declare variable as int p,q,u,v,n;


step 2: Initialize min=99,mincost=0;
step 3: declare variable as int t[50][2],i,j;
step 4: declare variable as int parent[50],edge[50][50];
step 5: Begin
step 6: write "Enter the number of nodes"
step 7: read "n"
step 8: Initialize i=0
step 9: repeat step(10-12) until i<n
step10: increment i
step11: write"65+i"
step12: Initialize parent[i]=-1
step13:wite "\n"
step14: Initialize i=0
step15: repeat step(15-21) until i<n
step16: increment i
step17: write"65+i"
step18: Initialize j=0
step19: repeat until j<n
step20: increment j
step21: read edge[i][j]
step22: Initialize i=0
step23: repeat step(23-43) until i<n
step24: increment i
step25: Initialize j=0
step26: repeat until j<n
step27: increment j
step28: if'edge[i]j]!=99
step29: if'min>edge[i][j] repeat step (29-32)
step30: intialize min=edge[i][j]
step31: intialize u=i
step32: intialize v=j
step33: calling function p=find(u);
step34: calling function q=find(v);
step35: if'P!=q repeat steps(35-39)
step36: intialize t[i][0]=u
step37: intialize t[i][1]=v
step38: initialize mincost=mincost+edge[u][v]
step39: call function sunion(p,q)
step40: else repeat steps(40-42)
step41: Intialize t[i][0]=-1;
step42: Intialize t[i][1]=-1;
step43: intialize min=99;
step44; write"Minimum cost is %d\n Minimum spanning tree is",mincost
step45: Initialize i=0
step46: repeat until i<n
step47: increment i
step48: if't[i][0]!=-1 && t[i][1]!=-1'repeat step(48-50)
step49: write "%c %c %d", 65+t[i][0], 65+t[i][1], edge[t[i][0]][t[i][1]]
step50: write"\n"
step51: end
step52: called function sunion(int l,int m) repeat step(51-52)
step53: intialize parent[l]=m
step54: called function find(int l) repeat step(53-56)
step55: if parent([l]>0)
step56: initialize l=parent
step57: return l

SOURCE CODE:

// Write a ‘c’ program for Broadcast tree from subnet of host

#include<stdio.h>
int p,q,u,v,n;
int min=99,mincost=0;
int t[50][2],i,j;
int parent[50],edge[50][50];
main()
{
clrscr();
printf("\n Enter the number of nodes");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("%c\t",65+i);
parent[i]=-1;
}
printf("\n");
for(i=0;i<n;i++)
{
printf("%c",65+i);
for(j=0;j<n;j++)
scanf("%d",&edge[i][j]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
if(edge[i][j]!=99)
if(min>edge[i][j])
{
min=edge[i][j];
u=i;
v=j;
}
p=find(u);
q=find(v);
if(p!=q)
{
t[i][0]=u;
t[i][1]=v;
mincost=mincost+edge[u][v];
sunion(p,q);
}
else
{
t[i][0]=-1;
t[i][1]=-1;
}
min=99;
}
printf("Minimum cost is %d\n Minimum spanning tree is\n" ,mincost);
for(i=0;i<n;i++)
if(t[i][0]!=-1 && t[i][1]!=-1)
{
printf("%c %c %d", 65+t[i][0], 65+t[i][1],
edge[t[i][0]][t[i][1]]);
printf("\n");
}
getch();
}
sunion(int l,int m)
{
parent[l]=m;
}
find(int l)
{
if(parent[l]>0)
l=parent[l];
return l;
}
OUTPUT:

EXPERIMENT NO: 4

NAME OF THE EXPERIMENT: Distance Vector routing.

AIM: Obtain Routing table at each node using distance vector routing algorithm for a given subnet.
THEORY:
Distance Vector Routing Algorithms calculate a best route to reach a destination based solely on
distance. E.g. RIP. RIP calculates the reach ability based on hop count. It’s different from link state
algorithms which consider some other factors like bandwidth and other metrics to reach a
destination. Distance vector routing algorithms are not preferable for complex networks and take
longer to converge.

ALGORITHM/FLOWCHART:
Begin
Step1: Create struct node unsigned dist[20],unsigned from[20],rt[10]
Step2: initialize int dmat[20][20], n,i,j,k,count=0,
Step3: write "the number of nodes "
Step4: read the number of nodes "n"
Step5: write" the cost matrix :"
Step6: intialize i=0
Step7: repeat until i<n
Step8: increment i
Step9: initialize j=0
Step10: repeat Step(10-16)until j<n
Step11: increment j
Step12:read dmat[i][j]
Step13:intialize dmat[i][j]=0
Step14:intialize rt[i].dist[j]=dmat[i][j]
Step15:intialize rt[i].from[j]=j
Step16:end
Step17:start do loop Step (17-33)until
Step18:intilialize count =0
Step19:initialize i=0
Step20:repeat until i<n
Step21:increment i
Step22:initialize j=0
Step23:repeat until j<n
Step24:increment j
Step25:initialize k=0
Step26:repeat until k<n
Step27:increment k
Step28:if repeat Step(28-32) until rt[i].dist[j]>dmat[i][k]+rt[k].dist[j]
Step29:intialize rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j]
Step30:intialize rt[i].from[j]=k;
Step31:increment count
Step32:end if
Step33:end do stmt
Step34:while (count!=0)
Step35:initialize i=0
Step36:repeat Steps(36-44)until i<n
Step37:increment i
Step38:write ' state values for router',i+1
Step39:initialize j=0
Step40:repeat Steps ( 40-43)until j<n
Step41:increment j
Step42:write 'node %d via %d distance % ',j+1,rt[i].from[j]+1,rt[i].dist[j]
Step43:end
Step44:end
end

SOURCE CODE:
#include<stdio.h>
#include<conio.h>

struct node
{
unsigned dist[20];
unsigned from[20];
}rt[10];

int main()
{
int dmat[20][20];
int n,i,j,k,count=0;
clrscr();
printf("\nEnter the number of nodes : ");
scanf("%d",&n);
printf("Enter the cost matrix :\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("\nState value for router %d is \n",i+1);
for(j=0;j<n;j++)
{
printf("\nnode %d via %d Distance%d",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n");
}
OUTPUT:

EXPERIMENT NO: 8

NAME OF THE EXPERIMENT: RSA.

AIM: Implement data encryption and data decryption.

HARDWARE REQUIREMENTS: Intel based Desktop PC:-RAM of 512 MB

SOFTWARE REQUIREMENTS: Turbo C / Borland C.


THEORY:
RSA method is based on some principles from number theory. In encryption process divide the plain
text into blocks, so that each plain text message p falls in the interval 0<p<n this can be done by
grouping the plain text into blocks of k bits. Where k is the largest integer for which 2 power k <n is
true. The security of this method is based on the difficulty of factoring large numbers. The
encryption and decryption functions are inverses

ALGORITHM/FLOWCHART:

Step1: Start
Step2: Initialize variables as int a,b,i,j,t,x,n,k=0,flag=0,prime[100]
Step3: Initialize variables as char m[20],pp[20]
Step4: Initialize variables as float p[20],c[20]
Step5: Initialize variables as double e,d;
Step6: Initialize i=0
Step7: Repeat step(7-16) until i<50
Step8: Increment i
Step9: Initialize flag=0
Step10: Initialize j=2
Step11: Repeat until j<i/2
Step12: if ‘ i%j == 0 ’ repeat until(12-14)
Step13: Initialize flag=1
Step14: break
Step15: if ’ (flag==0) ‘
Step16: Initialize prime[k++]=i
Step17: Initialize a=prime[k-1]
Step18: Initialize b=prime[k-2]
Step19: Initialize n=a*b
Step20: Initialize t=(a-1)*(b-1)
Step21: Initialize e=(double)prime[2]
Step22: Initialize d=1/(float)e
Step23: write "\nKey of encryption is:%lf\n",d
Step24: write"\nEnter plain the text:"
Step25: read m
Step26: Intialize x=strlen(m)
Step27: write"\nDecryption status From Source to Destination:\n"
Step28: write"\nSource\t->----------------------------------<-destination\n"
Step29: write"\nChar\tnumeric\tcipher\t\tnumeric\t\tchar \n"
Step30: write"\n***********************************************************\n"
Step31: write"\n"
Step32: Intialize i=0
Step33: repeat steps(33-46) until i<x
Step34: Increment i
Step35: write "%c",m[i]
Step36: write"\t%d",m[i]-97
Step37; Intialize c[i]=pow(m[i]-97,(float)e)
Step38: Initialize c[i]=fmod(c[i],(float)n)
Step39: write "\t%f",c[i]
Step40: Intialize p[i]=pow(c[i],(float)d);
Step41: Intialize p[i]=fmod(p[i],(float)n);
Step42: write "\t%f",p[i]
Step43: Intialize pp[i]=p[i]+97
Step44: write "\t%c\n",pp[i]
Step45: write "\n***********************************************************\n"
Step46: write "\n"
Step 47 end

SOURCE CODE:
/*Using RSA algorithm encrypt a text data and Decrypt the same*/
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<math.h>
#include<string.h>
void main()
{
int a,b,i,j,t,x,n,k=0,flag=0,prime[100];
char m[20],pp[20];
float p[20],c[20];
double e,d;
clrscr();
for(i=0;i<50;i++)
{
flag=0;
for(j=2;j<i/2;j++)
if(i%j==0)
{
flag=1;
break;
}
if(flag==0)
prime[k++]=i;
}
a=prime[k-1];
b=prime[k-2];
n=a*b;
t=(a-1)*(b-1);
e=(double)prime[2];
d=1/(float)e;
printf("\nKey of encryption is:%lf\n",d);
printf("\nEnter plain the text:");
scanf("%s",&m);
x=strlen(m);
printf("\nDecryption status From Source to Destination:\n");
printf("\nSource\t->----------------------------------<-destination\n");
printf("\nChar\tnumeric\tcipher\t\tnumeric\t\tchar \n");
printf("\n***********************************************************\n");

printf("\n");
for(i=0;i<x;i++)
{
printf("%c",m[i]);
printf("\t%d",m[i]-97);
c[i]=pow(m[i]-97,(float)e);
c[i]=fmod(c[i],(float)n);
printf("\t%f",c[i]);
p[i]=pow(c[i],(float)d);
p[i]=fmod(p[i],(float)n);
printf("\t%f",p[i]);
pp[i]=p[i]+97;
printf("\t%c\n",pp[i]);
printf("\n***********************************************************\n");
printf("\n");
}
getch();
}

OUTPUT:
AIM:
Write a program for congestion control using Leaky bucket algorithm.

Theory
The congesting control algorithms are basically divided into two groups: open loop and closed
loop. Open loop solutions attempt to solve the problem by good design, in essence, to make sure
it does not occur in the first place. Once the system is up and running, midcourse corrections are
not made. Open loop algorithms are further divided into ones that act at source versus ones that
act at the destination.

In contrast, closed loop solutions are based on the concept of a feedback loop if there is any
congestion. Closed loop algorithms are also divided into two sub categories: explicit feedback
and implicit feedback. In explicit feedback algorithms, packets are sent back from the point of
congestion to warn the source. In implicit algorithm, the source deduces the existence of
congestion by making local observation, such as the time needed for acknowledgment to come
back.

The presence of congestion means that the load is (temporarily) greater than the resources (in
part of the system) can handle. For subnets that use virtual circuits internally, these methods can
be used at the network layer.
Another open loop method to help manage congestion is forcing the packet to be transmitted
at a more predictable rate. This approach to congestion management is widely used in ATM
networks and is called traffic shaping.

The other method is the leaky bucket algorithm. Each host is connected to the network by an
interface containing a leaky bucket, that is, a finite internal queue. If a packet arrives at the queue
when it is full, the packet is discarded. In other words, if one or more process are already queued,
the new packet is unceremoniously discarded. This arrangement can be built into the hardware
interface or simulate d by the host operating system. In fact it is nothing other than a single
server queuing system with constant service time.

The host is allowed to put one packet per clock tick onto the network. This mechanism turns
an uneven flow of packet from the user process inside the host into an even flow of packet onto
the network, smoothing out bursts and greatly reducing the chances of congestion.
Program

#include<iostream.h>
#include<dos.h>
#include<stdlib.h> #define
bucketSize 512

void bktInput(int a,int b) {


if(a>bucketSize)
cout<<"\n\t\tBucket overflow"; else {
delay(500);
while(a>b){
cout<<"\n\t\t"<<b<<" bytes outputted."; a-=b;
delay(500);
}
if (a>0) cout<<"\n\t\tLast "<<a<<" bytes sent\t"; cout<<"\n\t\
tBucket output successful";
}
}

void main() {
int op, pktSize;
randomize();
cout<<"Enter output rate : "; cin>>op; for(int
i=1;i<=5;i++){
delay(random(1000)); pktSize=random(1000);
cout<<"\nPacket no "<<i<<"\tPacket size = "<<pktSize;
bktInput(pktSize,op);
}
}

Sample Output

Enter output rate : 100

Packet no 0 Packet size = 3


Bucket output successful Last
3 bytes sent
Packet no 1 Packet size = 33
Bucket output successful Last
33 bytes sent
Packet no 2 Packet size = 117
Bucket output successful
100 bytes outputted.
Last 17 bytes sent
Packet no 3 Packet size = 95
Bucket output successful Last
95 bytes sent
Packet no 4 Packet size = 949
Bucket overflow

How to write a C Program to Frame sorting technique used in buffers in C Programming


Language ?

Solution:

1. #include<stdio.h>
2. #include<string.h>
3. #define FRAM_TXT_SIZ 3
4. #define MAX_NOF_FRAM 127
5. char str[FRAM_TXT_SIZ*MAX_NOF_FRAM];
6. struct frame // structure maintained to hold frames
7. { char text[FRAM_TXT_SIZ];
8. int seq_no;
9. }fr[MAX_NOF_FRAM], shuf_ary[MAX_NOF_FRAM];
10. int assign_seq_no() //function which splits message
11. { int k=0,i,j; //into frames and assigns sequence no
12. for(i=0; i < strlen(str); k++)
13. { fr[k].seq_no = k;
14. for(j=0; j < FRAM_TXT_SIZ && str[i]!='\0'; j++)
15. fr[k].text[j] = str[i++];
16. }
17. printf("\nAfter assigning sequence numbers:\n");
18. for(i=0; i < k; i++)
19. printf("%d:%s ",i,fr[i].text);
20. return k; //k gives no of frames
21. }
22. void generate(int *random_ary, const int limit) //generate array of random nos
23. { int r, i=0, j;
24. while(i < limit)
25. { r = random() % limit;
26. for(j=0; j < i; j++)
27. if( random_ary[j] == r )
28. break;
29. if( i==j ) random_ary[i++] = r;
30. } }
31. void shuffle( const int no_frames ) // function shuffles the frames
32. {
33. int i, k=0, random_ary[no_frames];
34. generate(random_ary, no_frames);
35. for(i=0; i < no_frames; i++)
36. shuf_ary[i] = fr[random_ary[i]];
37. printf("\n\nAFTER SHUFFLING:\n");
38. for(i=0; i < no_frames; i++)
39. printf("%d:%s ",shuf_ary[i].seq_no,shuf_ary[i].text);
40. }
41. void sort(const int no_frames) // sorts the frames
42. {
43. int i,j,flag=1;
44. struct frame hold;
45. for(i=0; i < no_frames-1 && flag==1; i++) // search for frames in sequence
46. {
47. flag=0;
48. for(j=0; j < no_frames-1-i; j++) //(based on seq no.) and display
49. if(shuf_ary[j].seq_no > shuf_ary[j+1].seq_no)
50. {
51. hold = shuf_ary[j];
52. shuf_ary[j] = shuf_ary[j+1];
53. shuf_ary[j+1] = hold;
54. flag=1;
55. }
56. }
57. }
58. int main()
59. {
60. int no_frames,i;
61. printf("Enter the message: ");
62. gets(str);
63. no_frames = assign_seq_no();
64. shuffle(no_frames);
65. sort(no_frames);
66. printf("\n\nAFTER SORTING\n");
67. for(i=0;i<no_frames;i++)
68. printf("%s",shuf_ary[i].text);
69. printf("\n\n");
70. }

OUTPUT C Program to Frame sorting technique used in buffers.:


[root@localhost nwcn]# ./a.out
Enter the message:Swarna Bharathi Institute of Science & Technology .
After assigning sequence numbers:
0:Wel 1:com 2:e T 3:o A 4:swarna 5:bharathi 6:col 7of 8:sci 9:and 10tec T 11:of 12:eng 13:inee
14:ringAFTER SHUFFLING:
AFTER SORTING

Welcome To Swana Bharathi Institute of Science and technology

SIMULATION-INTRODUCTION

Network simulation is an important tool in developing, testing and evaluating


network protocols. Simulation can be used without the target physical hardware, making it
economical and practical for almost any scale of network topology and setup. It is possible to
simulate a link of any bandwidth and delay, even if such a link is currently impossible in
the real world. With simulation, it is possible to set each simulated node to use any desired
software. This means that meaning deploying software is not an issue. Results are also easier
to obtain and analyze, because extracting information from important points in the simulated
network is as done by simply parsing the generated trace files.
Simulation is only of use if the results are accurate, an inaccurate simulator is not
useful at all. Most network simulators use abstractions of network protocols, rather than the
real thing, making their results less convincing. S.Y. Wang reports that the simulator OPNET
uses a simplified finite state machine to model complex TCP protocol processing. [19] NS-2
uses a model based on BSD TCP, it is implemented as a set of classes using inheritance.
Neither uses protocol code that is used in real world networking.

Setting up the environment

A user using the NCTUns in single machine mode, needs to do the following steps
before he/she starts the GUI program:

1. Set up environment variables:


Before the user can run up the dispatcher, coordinator, or NCTUns GUI
program he/she must set up the NCTUNSHOME environment variable.

2. Start up the dispatcher on terminal 1.

3. Start up the coordinator on terminal 2.


4. Start up the nctuns client on terminal 3.
After the above steps are followed, the starting screen of NCTUns disappears and the user is
presented with the working window as shown below:

Drawing A Network Topology

To draw a new network topology, a user can perform the following steps:

Choose Menu->File->Operating Mode-> and make sure that the “Draw Topology” mode is
checked. This is the default mode of NCTUns when it is launched. It is only in this mode
that a user can draw a new network topology or change an existing simulation topology.
When a user switches the mode to the next mode “Edit Property”, the simulation network
topology can no longer be changed.

1. Move the cursor to the toolbar.


2. Left-Click the router icon on the toolbar.

3. Left-Click anywhere in the blank working area to add a router to the current network
topology. In the same way we can add switch, hub,WLAN access point,WLAN mobile
node , wall (wireless signal obstacle) etc.

4. Left-Click the host icon on the toolbar. Like in step 4, add the required number of hosts
to the current topology.
5. To add links between the hosts and the router, left-click the link icon on the toolbar to
select it.

6. Left-Click a host and hold the mouse button. Drag this link to the router and then
release the mouse left button on top of the router. Now a link between the selected host and
the router has been created.

7. Add the other, required number of links in the same way. This completes the creation of a
simple network topology.

8. Save this network topology by choosing Menu->File->Save. It is saved with a .tpl


extension.

9. Take the snapshot of the above topology.

Editing Node's Properties

1. A network node (device) may have many parameters to set. For example, we may have to
set the maximum bandwidth, maximum queue size etc to be used in a network interface.
For another example, we may want to specify that some application programs (traffic
generators) should be run on some hosts or routers to generate network traffic.

2. Before a user can start editing the properties of a node, he/she should switch the mode from
the “Draw Topology” to “Edit Property” mode. In this mode, topology changes can no
longer be made. That is, a user cannot add or delete nodes or links at this time.

3. The GUI automatically finds subnets in a network and generates and assigns IP and MAC
addresses to layer 3 network interfaces.

4. A user should be aware that if he/she switches the mode back to the “Draw Topology”
mode when he/she again switches the mode back to the “Edit Topology” mode, node's IP
and MAC addresses will be regenerated and assigned to layer 3 interfaces.
Therefore the application programs now may use wrong IP addresses to
communicate with their partners.

Running the Simulation

When a user finishes editing the properties of network nodes and specifying application
programs to be executed during a simulation, he/she can start running the simulation.

1. In order to do so, the user must switch mode explicitly from “Edit Property” to “Run
Simulation”. Entering this mode indicates that no more changes can (should) be made to
the simulation case, which is reasonable. This simulation is about to be started at this
moment; of course, any of its settings should be fixed.

2. Whenever the mode is switched to the “ Run Simulation” mode, the many simulation files
that collectively describe the simulation case will be exported. These simulation files will
be transferred to the (either remote or local) simulation server for it to execute the
simulation. These files are stored in the “ main File Name.sim” directory, where main
Filename is the name of the simulation case chosen in the “Draw Topology” mode.
Playing Back the Packet Animation Trace

After the simulation is finished, the simulation server will send back the simulation result
files to the GUI program after receiving these files, the GUI program will store these files in
the “results directory” .It will then automatically switch to “play back mode”.

1. These files include a packet animation trace file and all performance log files that the user
specifies to generate. Outputting these performance log files can be specified by checking
some output options in some protocol modules in the node editor. In addition to this,
application programs can generate their own data files.

2. The packet animation trace file can be replayed later by the packet animation player.
The performance curve of these log files can be plotted by the performance monitor.

Post Analysis

1. When the user wants to review the simulation results of a simulation case that has been
finished before, he /she can run up the GUI program again and then open the case's
topology file.

2. The user can switch the mode directly to the “Play Back” mode. The GUI program will then
automatically reload the results (including the packet animation trace file and performance
log file.

3. After the loading process is finished, the user can use the control buttons located at the
bottom of the screen to view the animation.

Simulation Commands

 Run: Start to run simulation.


 Pause: Pause the currently -running simulation.
 Continue: Continue the simulation that was just paused.
 Stop: Stop the currently -running simulation
 Abort: Abort the currently running simulation. The difference between
“stop” and “abort” is that a stopped simulation job's partial results will be
transferred back to GUI files.
 Reconnect: The Reconnect command can be executed to reconnect to a simulation job
that was previously disconnected. All disconnected jobs that have not finished their
simulations or have finished their simulations but the results have not been retrieved
back to be a GUI program by the user will appear in a session table next to the
“Reconnect” command. When executing the reconnect command, a user can choose a
disconnected job to reconnect from this session table.
 Disconnect: Disconnect the GUI from the currently running simulation job. The GUI
now can be used to service another simulation job. A disconnected simulation will be
given a session name and stored in a session table.
PART A Programs
Exp.No:1
Simulate to Find the Number of Packets
Dropped

AIM:
Simulate a three-node point-to-point network with a duplex link between them. Set the queue
size and vary the bandwidth and find the number of packets dropped.

Sender:-
stcp –p 2000 –l 1024 1.0.1.2

Receiver:-
rtcp –p 2000 –l 1024

Parameters:-
Drop Packets and Collision Packets.

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place a HOST1 on the editor.
Repeat the above procedure and place another host “HOST2” on the editor.

2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor,
to place HUB1 on the editor.

3. Click on the LINK icon on the toolbar and connect HOST1 to HUB1 and HUB1 to
HOST2
4. Click on the “E” icon on the toolbar to save the current topology
e.g: file1.tpl
(Look for the ******.tpl extension.)

NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.

2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stg –u 1024 100 1.0.1.2

3. Click OK button on the command window to exit and once again click on the OK
button on the HOST window to exit.

4. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.

5. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtg –u –w log1

6. Click OK button on the command window to exit.

7. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

8. Select LOG STATISTICS and select checkboxes for Number of Drop Packet and
Number of Collisions in the MAC window

9. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

Note: To set QUEUE size


1. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.

2. Click NODE EDITOR Button on the HOST window and select the FIFO tab from the
modal window that pops up.

3. Change Queue size (Default 50).


4. Click OK button on the FIFO window to exit and once again click on the OK button
on the HOST window to exit.

Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the
dropdown list to execute the simulation.
iii. venTo start playback select “►” icon located at the bottom right corner of
the editor.
iv. To view results, Open up new TERMINAL window, move to file1.results
folder and open collision and drop log files in separate TERMINAL window.
Caution: file1 is the hypothetical name given to this simulation.
(Refer Step 1.4)

Changing configurations
Change 1
1. Open the above file,
2. Do not change the topology or any other configuration,
3. Select E icon on the toolbar
4. Reduce the bandwidth at link2 by double clicking the left mouse button while cursor
is on link2 .(Change bandwidth on both tabs Uplink/Downlink)
5. Repeat Step3 (Simulate)

Change 2
1. Open the above file,
2. Remove HUB and replace it with SWITCH.
3. Do not change anything in the
configuration Repeat Step3(Simulate)
Exp.No:2
Simulate to Find the Number of Packets Dropped by
TCP/UDP

AIM:
Simulate a four-node point-to-point network and connect the link as follows: Apply a TCP
agent between n0 to n3 and apply a UDP agent between n1 and n3. Apply relevant
applications over TCP and UDP agents changing the parameters and determine the number
of packets sent by two agents.

Topology:-

Sender:-
stcp –p 3000 –l 1024 1.0.1.3
stg –u 1024 1.0.1.3

Receiver:-
rtcp –p 3000 –l 1024
rtg –u 3000

Parameters:-
Throughput of incoming and outgoing Packets

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place a host on the editor.
Repeat the above procedure and place two other hosts “HOST2” and “HOST3”
on the editor.

2. Select/click the HUB (or SWITCH) icon on the toolbar and click the left mouse
button on the editor, to place a HUB (or SWITCH) on the editor.
3. Click on the LINK icon on the toolbar and connect HOST1 to HUB, HOST2 to HUB and
HUB to HOST3

4. Click on the “E” icon on the toolbar to save the current topology e.g: file2.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.

2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stcp –p 21 –l 1024 1.0.1.3

3. Click OK button on the command window to exit

4. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

5. Select LOG STATISTICS and select checkbox for output throughput in the MAC
window

6. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

7. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.

8. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stg –u 1024 100 1.0.1.3

9. Click OK button on the command window to exit

10. Click NODE EDITOR Button on the HOST window and select the MAC tab from
the modal window that pops up.

11. Select LOG STATISTICS and select checkbox for output throughput in the MAC
window

12. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

13. Double click the left mouse button while cursor is on HOST3 to open the HOST
window.

14. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtcp –p 21 –l 1024

15. Click OK button on the command window to exit.

16. Also add the following command on HOST3


rtg –u –w log1

17. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

18. Select LOG STATISTICS and select checkbox for input and output
throughput in the MAC window

19. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the
dropdown list to execute the simulation.
iii. To start playback select “►” icon located at the bottom right corner of the editor.
iv. To view results, Open up new TERMINAL window, move to file2.results
folder and open input and output throughput log files in separate TERMINAL
window.
Caution: file2 is the hypothetical name given to this simulation.
(Refer Step 1.4)
Exp.No:3
Simulate to Find the Number of Packets Dropped due to
Congestion

AIM:
Simulate the transmission of ping messages over a network topology consisting of 6 nodes
and find the number of packets dropped due to congestion.

Topology:-

Sender:-
stcp –p 2000 –l 1024 1.0.1.4

Receiver:-
rtcp –p 2000 –l 1024

Command Console:-
Goto tools-> simulation time and change Simulation time to 100. During run mode,
double click host 2 and then click command console. And execute the following
command.
ping 1.0.1.4
Parameters:-
Drop Packets and Collision Packets.
Step1: Drawing topology
1. Select/click the SUBNET icon on the toolbar and click the left mouse button on the
editor, to place a SUBNET on the editor.

2. A pop up window appears requesting the number of nodes and radius for the subnet
Set number of nodes=6;
Set radius of subnet >150

3. Click on the “E” icon on the toolbar to save the current topology e.g: file4.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting

Step2: Configuration
4. Double click the left mouse button while cursor is on a HOST to open the HOST
window.

5. Click NODE EDITOR Button on the HOST window and select the
INTERFACE tab (1st tab) from the modal window that pops up.

6. Determine the IP address of the selected host.

7. Click OK button on the INTERFACE window to exit and once again click on the OK
button on the HOST window to exit.

8. Repeat the above step for 2 other HOSTS

9. Also click NODE EDITOR Button on the HOST window and select the MAC tab
from the modal window that pops up.

10. Select LOG STATISTICS and select checkbox for drop and collision log statistics
in the MAC window

11. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

12. Repeat steps 6 to 9 for the other hosts selected at step 5.

13. Select G_Setting from the menu bar and select Simulation from the drop down list
Set simulation time>600sec

Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the dropdown list to
execute the simulation.
iii. During simulation, open a new terminal window.
iv. Type ping IP address of a host in the subnet at the command prompt.
v. To view results, Open up new TERMINAL window, move to file4.results folder
and open drop and collision log files in separate TERMINAL window.
Caution: file4 is the hypothetical name given to this simulation.
(Refer Step 1.3)
Exp.No:4
Simulate to Compare Data Rate & Throughput

AIM:
Simulate an Ethernet LAN using N nodes (6-10), change error rate and data rate and compare
throughput.

Topology:-

Sender:-
stcp –p 2000 –l 1024 1.0.1.4

Receiver:-
rtcp –p 2000 –l 1024
Double click on receiver link and change BER to 0.000001, Run Again.
Parameters:-
Throughput of outgoing Packets

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place HOST1 on the editor.
Repeat the above procedure and place 5 other hosts “HOST2”, “HOST3”,
“HOST4”, “HOST5”, and “HOST6”on the editor.

2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor,
to place HUB1 on the editor.
Repeat the above procedure and place another host “HUB2” on the editor

3. Click on the LINK icon on the toolbar and connect HOST1, HOST2 and HOST3 to
HUB1, HOST4, HOST5 and HOST6 to HUB2.

4. Select/click the SWITCH icon on the toolbar and click the left mouse button on the
editor, to place SWITCH1 on the editor.

5. Click on the LINK icon on the toolbar and connect HUB1 to SWITCH1 and HUB2 to
SWITCH1.

6. Click on the “E” icon on the toolbar to save the current topology e.g: file5.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.

2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stcp –p 21 –l 1024 1.0.1.4

3. Click OK button on the command window to exit and once again click on the OK
button on the HOST window to exit.

4. Repeat this step at HOST 2 and HOST3, but use different commands
stcp –p 21 –l 1024 1.0.1.5 at HOST2
stcp –p 21 –l 1024 1.0.1.6 at HOST3

5. Double click the left mouse button while cursor is on HOST4 to open the HOST
window.

6. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtcp –p 21 –l 1024

7. Click OK button on the command window to exit.

8. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

9. Select LOG STATISTICS and select checkbox for output throughput in the MAC
window

10. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.
11. Repeat this step at HOST 5 and HOST6, but use different commands
rtcp –p 21 –l 1024 at HOST5
rtcp –p 21 –l 1024 at HOST6

12. Double click the left mouse button while cursor is on HOST5 to open the HOST
window.

13. Click NODE EDITOR Button on the HOST5 window and select the
PHYSICAL tab from the modal window that pops up.

14. Change Bit Error Rate

15. Click OK button on the PHYSICAL window to exit and once again click on the OK
button to return to the HOST window

16. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

17. Select LOG STATISTICS and select checkbox for output throughput in the MAC
window

18. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

19. Repeat this step HOST6, Change Bandwidth this time while undoing the change
in Bit Error Rate, also select the output throughput at HOST6.

Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the dropdown list to
execute the simulation.
iii. To start playback select “►” icon located at the bottom right
iv. To view results, Open up new TERMINAL window, move to file5.results folder
and open output throughput log files in separate TERMINAL window.

Caution: file5 is the hypothetical name we gave to this simulation


(Refer Step 1.7)
Exp.No:5
Simulate to Plot Congestion for Different Source/Destination

AIM:
Simulate an Ethernet LAN using N nodes and set multiple traffic nodes and plot congestion
window for different source/destination.

Topology:-

Sender:-
stcp –p 2000 –l 1024 1.0.1.4

Receiver:-
rtcp –p 2000 –l 1024

Parameters:-
Receiver side Collision Packets and Drop Packets

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place HOST1 on the editor.
Repeat the above procedure and place 3 other hosts “HOST2”, “HOST3”, “HOST4”,
“HOST5”, and “HOST6”on the editor.

2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor,
to place HUB1 on the editor.
Repeat the above procedure and place another host “HUB2” on the editor

3. Click on the LINK icon on the toolbar and connect HOST1, HOST2 and HOST3 to
HUB1, HOST4, HOST5 and HOST6 to HUB2.

4. Select/click the SWITCH icon on the toolbar and click the left mouse button on the
editor, to place SWITCH1 the editor.

5. Click on the LINK icon on the toolbar and connect HUB1 to SWITCH1 and HUB2 to
SWITCH1.

6. Click on the “E” icon on the toolbar to save the current topology e.g: file7.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.

2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stcp –p 21 –l 1024 1.0.1.4

3. Click OK button on the command window to exit and once again click on the OK
button on the HOST window to exit.
4. Repeat this step at HOST 2 and HOST3, but use different commands
stcp –p 23 –l 1024 1.0.1.5 at HOST2
stcp –p 25 –l 1024 1.0.1.6 at HOST3

5. Double click the left mouse button while cursor is on HOST4 to open the HOST
window.

6. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtcp –p 21 –l 1024

7. Click OK button on the command window to exit.

8. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.

9. Select LOG STATISTICS and select checkbox for Number of drop and collisions
packets in the MAC window

10. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.
11. Repeat this step at HOST 5 and HOST6, but use different commands
rtcp –p 23 –l 1024 at HOST5
rtcp –p 25 –l 1024 at HOST6
12. Double click the left mouse button while cursor is on HOST5 to open the HOST
window.

13. Click NODE EDITOR Button on the HOST5 window and select the MAC tab
from the modal window that pops up.
14. Select LOG STATISTICS and select checkbox for Number of drop and
collisions packets in the MAC window

15. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

16. Also select the drop and collisions at HOST6.


Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the dropdown list
to execute the simulation.
iii. To start playback select “►” icon located at the bottom right corner of the editor.
iv. To plot congestion window select Tools in the menu bar and select PLOT GRAPH
in the drop down list.
v. In the Graph window, select File->OPEN, move to file7.results folder and the drop and
collision log file.
vi. To open another Graph window, Select File->New tab on the drop down list to open
up to a maximum of 6 windows
vii. To view results, Open up new TERMINAL window, move to file7.results folder and
open input and output throughput log files in separate TERMINAL window.

Caution: file7 is the hypothetical name given to this simulation.


Exp.No:6
Simulate to Determine the Performance with respect to Transmission of Packets

AIM:
Simulate simple ESS and with transmitting nodes in wireless LAN by simulation and
determine the performance with respect to transmission of packets.

Topology:-

Click on “access point”. Goto wireless interface and tick on “show transmission range and
then click OK.

Double click on Router -> Node Editor and then


Left stack -> throughput of Incoming packets
Right stack -> throughput of Outgoing packets

Select mobile hosts and access points then click on.


Tools -> WLAN mobile nodes-> WLAN Generate infrastructure.
Subnet ID: Port number of router (2)
Gateway ID: IP address of router

Mobile Host 1
ttcp –t –u –s –p 3000 1.0.1.1

Mobile Host 1
ttcp –t –u –s –p 3001 1.0.1.1
Host(Receiver)
ttcp –r –u –s –p 3000
ttcp –r –u –s –p 3001

Run and then play to plot the graph.

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place HOST1 on the editor.

2. Select/click the ROUTER icon on the toolbar and click the left mouse button on the
editor, to place ROUTER1 on the editor.

3. Select/click the WIRELESS ACCESS POINT(802.11b) icon on the toolbar and click the
left mouse button on the editor, to place ACCESS POINT 1 on the editor.
Repeat this procedure and place ACCESS POINT 2 on the editor.

4. Select/click the MOBILE NODE (infrastructure mode) icon on the toolbar and click
the left mouse button on the editor, to place MOBILE NODE 1 on the editor.
Repeat this procedure and place MOBILE NODE 2, MOBILE NODE3 and MOBILE
NODE 4 on the editor.

5. Click on the LINK icon on the toolbar and connect ACCESS POINT1 to ROUTER1
and ACCESS POINT2 to ROUTER1

6. Click on the “Create a moving path” icon on the toolbar and draw moving path across
MOBILE NODE 1 and 2, Repeat for MOBILE NODE 3and 4 (Accept the default
speed value 10 and close the window, Click the right mouse button to terminate the
path).

To create Subnet
7. Select wireless subnet icon in the toolbar now select MOBILE NODE1, MOBILE
NODE2 and ACCESS POINT1 by clicking on left mouse button, and clicking
right mouse button will create a subnet.

8. Repeat the above step for MOBILE NODE3, MOBILE NODE4 and ACCESS
POINT2.

9. Click on the “E” icon on the toolbar to save the current topology e.g: file8.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.
2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
ttcp –r –u –s –p 8001

3. Click OK button on the command window to exit

4. Repeat this step and add the following commands at HOST1


ttcp –r –u –s –p 8002
ttcp –r –u –s –p 8003
ttcp –r –u –s –p 8004

5. Click NODE EDITOR Button on the HOST1 window and select the MAC tab from
the modal window that pops up.

6. Select LOG STATISTICS and select checkbox for Input throughput in the MAC
window

7. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.

8. Double click the left mouse button while cursor is on MOBILE NODE 1 to open the
MOBILE NODE window.

9. Select Application tab and select Add button to invoke the command window
and provide the following command in the command textbox.
ttcp –t –u –s –p 80011.0.2.2 (host’s ip address)

10. Click NODE EDITOR Button on the MOBILE NODE1 window and select the MAC
tab from the nodal window that pops up.

11. Select LOG STATISTICS and select checkbox for Output throughput in the
MAC window

12. Click OK button on the MAC window to exit and once again click on the OK button
on the MOBILE NODE1 window to exit.

13. Repeat the above steps (step 8 to step12) for the MOBILE NODE2,3 and 4 and add the
following commands at
MOBILE NODE2:- ttcp –t –u –s –p 8002 1.0.2.2
MOBILE NODE3:- ttcp –t –u –s –p 8003 1.0.2.2
MOBILE NODE4:- ttcp –t –u –s –p 8004 1.0.2.2

14. Double click the left mouse button while cursor is on ROTER1 to open the ROUTER
window.
15. Click NODE EDITOR Button on the ROUTER1 window and you can see three
stacks. two stacks for two ACCESS POINTS and another stack for HOST1
which is connected to the ROUTER1.

16. Select the MAC tab of ACCESS POINT1 and Select LOG STATISTICS and
select checkbox for Input throughput in the MAC window. Click OK button on
the MAC window to exit.

17. Select the MAC tab of ACCESS POINT2 and Select LOG STATISTICS and
select checkbox for Input throughput in the MAC window. Click OK button on
the MAC window to exit.

18. Select the MAC tab of HOST1 and Select LOG STATISTICS and select checkbox
for Output throughput in the MAC window. Click OK button on the MAC window
to exit.

Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/select RUN in the dropdown list to
execute the simulation.
iii. To start playback select “►” icon located at the bottom right corner of the editor.
iv. MOBILE NODE’s start moving across the paths already drawn.
Caution: file8 is the hypothetical name given to this simulation,

You might also like