Download as pdf or txt
Download as pdf or txt
You are on page 1of 55

COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

1.Implement the data link layer framing methods such as character,


character-stuffing and bit stuffing

Bit Stuffing.
AIM: Write a C program to implement the data link layer framing
methods such as bit stuffing.
Description:

Bit stuffing is the mechanism of inserting one or more non-information bits into
a message to be transmitted, to break up the message sequence, for
synchronization purpose.
A pattern of bits of arbitrary length is stuffed in the message to differentiate
from the delimiter. This is also called bit - oriented framing.

Source Code:
#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);
pritf("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++)
Department of Computer Science and Engineering Page 1
COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

{
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();
}
printf("After stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]); getch();
}

Department of Computer Science and Engineering Page 2


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

Output:

Enter the
number of bits:
10
1
0
1
0
1
1
1
1
1
1
Data after stuffing: 10101111101
OUTPUT:

Department of Computer Science and Engineering Page 3


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

Character Stuffing:
AIM: Write a C program to Implement the data link layer framing method such
as character stuffing.

Description: In character – oriented protocol, the mechanism adopted is


byte stuffing. In byte stuffing, a special byte called the escape character (ESC) is
stuffed before every byte in the message with the same pattern as the flag byte.
If the ESC sequence is found in the message byte, then another ESC byte is
stuffed before it.

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)
{
Department of Computer Science and Engineering Page 4
COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

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("\n frame after stuffing: \n");
printf("%s",b);
getch();
}

Department of Computer Science and Engineering Page 5


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

OUTPUT:
Enter String:
haiarchana
Enter
position:
4
Enter the
Character K
Frame after stuffing:
dlestxhaidlekdlearchanadleetx

OUTPUT :

Department of Computer Science and Engineering Page 6


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

Character Count:
AIM: Write a C program to implement data link layer framing method character count.

Description: This method uses a field in the header to specify the number of characters in
the frame. When the data link layer at the destination sees the character count,it knows
how many characters follow, and hence where the end of the frame is. The disadvantage is
that if the count is garbled by a transmission error, the destination will lose
synchronization and will be unable to locate the start of the next frame. So, this method is
rarely used.

Source Code:
#include<stdio.h>
#include<conio.h
>
#include<string.h
> char
data[20][20]; int
n;
void main()
{
int i,ch,j;
char
tmp[20][20];
clrscr();
printf("Enter the number of
frames:"); scanf("%d",&n);
for(i=0;i<=n;i++)
{
if(i!=0)
{
printf("frame%d:",i);
fflush(stdin);
gets(data[i]);
}
}
/*saving frame with count and
data*/ for(i=0;i<=n;i++)
{
tmp[i][0]=49+strlen(data[i]);
tmp[i][1]='\0';

Department of Computer Science and Engineering Page 7


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

strcat(tmp[i],data[i]);
}
printf("\n\t\tAT THE SENDER:\n");

printf("Data as
frames:\n");
for(i=1;i<=n;i++)
{
printf("Frame%d:",i);
puts(tmp[i]);
}
printf("Data
transmitted:");
for(i=1;i<=n;i++)
printf("%s",tmp[i]);
printf("\n\t\tAT THE
RECEIVER\n"); printf("The data
received:"); for(i=1;i<=n;i++)
{
ch=(int)(tmp[i][0]-49);
for(j=1;j<=ch;j++)
data[i][j-1]=tmp[i][j];
data[i][j-1]='\0';
}
printf("\n The data after removing count char:");
for(i=1;i<=n;i++)
printf("%s",data[i]);
printf("\n The data in frame
form:\n"); for(i=1;i<=n;i++)
{
printf("Frame%d:",i);
puts(data[i]);
}
getch();
}

Department of Computer Science and Engineering Page 8


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

OUTPUT:
Enter the no. Of
frames: 2 Frame1:
computer Frame2:
networks
AT THE SENDER
Data as frames:
Frame1:9comput
er
Frame2:9networ
ks
Data transmitted
:9computer9networks AT THE
RECEIVER
The data received.
The data after removing count char: computer
networks The data in frame form:
Frame1:
computer
Frame2:
networks

OUTPUT

Department of Computer Science and Engineering Page 9


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

2.Write a program to compute CRC code for the polynomials CRC-12, CRC-16
and CRC CCIP

AIM: Write a C program to implement on a data set characters the three CRC polynomials
– CRC 12, CRC 16, and CRC CCIP.

Description:CRC or Cyclic Redundancy Check is a method of detecting accidental


changes/errors in the communication channel. CRC uses Generator Polynomial which is
available on both sender and receiver side.
This generator polynomial represents key 1011. Another example is x2 + 1 that represents
key 101.

Source Code:
// program for Cyclic Redundancy Check

#include<stdio.h
>#include<conio.
h> int main(void)
{
int
data[50],div[16],rem[16];
int datalen, divlen, i,j,k;
int ch;
clrscr()
;
printf("Enter the data:
"); i = 0;
while((ch = fgetc(stdin)) != '\n')
{
if(ch == '1')
data[i] =
1; else
data[i] =
0; i++;
}
datalen = i;
printf("\nEnter the
divisor: "); i = 0;
while((ch = fgetc(stdin)) != '\n')
{
if(ch == '1')
div[i] = 1;
else

Department of Computer Science and Engineering Page 10


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

div[i] = 0;

i++;
}
divlen = i;
for(i = datalen ; i<datalen + divlen - 1 ;
i++) data[i] = 0;
datalen = datalen + divlen
- 1; for(i = 0 ; i<divlen ;
i++) rem[i] = data[i];
k = divlen-1;
while(k <datalen)
if(rem[0] == 1)
{
for(i = 0 ; i<divlen ; i++)
rem[i] = rem[i] ^ div[i];
}
else
{
if(k == datalen-
1) break;
for(i = 0 ; i< divlen-1 ; i++)
{
rem[i] = rem[i+1];
printf("%d",rem[i]);
}
rem[i] = data[++k];
printf("%d\n",rem[i]);
}
j=1;
for(i = datalen - divlen + 1 ; i<datalen ; i++)
{
data[i] = rem[j++];
}
printf("\nThe data to be sent
is\n"); for(i = 0 ; i<datalen ;
i++) printf("%d",data[i]);
getch();
return
0;
Department of Computer Science and Engineering Page 11
COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

OUTPUT:
Enter the data:
10101111 Enter the
divisor: 1011 0011
0111
1111
1001
0100
1000
0110
The data to be sent is
10101111110
OUTPUT :

Department of Computer Science and Engineering Page 12


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

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.

AIM: 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.
Description: 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.

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.

As soon as sender receives the acknowledgement of a frame it is replaced by the next


frames to be transmitted by the sender.

 Go back n: Sender transmits all frames present in the window that occurs after the
error bit including error bit also.

SOURCE CODE:
#include<stdio.h>

int main ()
{
int w,i,f,frames[50];
printf("Enter window size: ");
scanf("%d",&w);
printf("\nEnter number of frames to transmit: ");
scanf("%d",&f);
printf("\nEnter %d frames: ",f);
for(i=1;i<=f;i++)
scanf("%d",&frames[i]);
printf("\nWith sliding window protocol the frames will be sent in the following manner
(assuming no corruption of frames)\n\n");
printf("After sending %d frames at each stage sender waits for acknowledgement sent by the
receiver\n\n",w);

Department of Computer Science and Engineering Page 13


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

for(i=1;i<=f;i++)
{
if(i%w==0)
{
printf("%d\n",frames[i]);
printf("Acknowledgement of above frames sent is received by sender\n\n");
}
else
printf("%d ",frames[i]);
}

if(f%w!=0)
printf("\nAcknowledgement of above frames sent is received by sender\n");

return 0;
}

OUTPUT:
Enter window size: 3

Enter number of frames to transmit: 5

Enter 5 frames: 12 5 89 4 6

With sliding window protocol the frames will be sent in the following manner (assuming no
corruption of frames)

After sending 3 frames at each stage sender waits for acknowledgement sent by the receiver

12 5 89
Acknowledgement of above frames sent is received by sender

Department of Computer Science and Engineering Page 14


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

46
Acknowledgement of above frames sent is received by sender

Department of Computer Science and Engineering Page 15


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

4. Implement Dijsktra’s algorithm to compute the shortest path


through a network

AIM: Write a C program to Implement Dijkstra’s Algorithm to compute the


shortest path through a given path.

DESCRIPTION:Dijkstra's algorithm is an algorithm that is used to solve the


shortest distance problem. That is, we use it to find the shortest distance
between two vertices on a graph. Depending on what the graph represents, we
can find shortest routes, minimum costs, etc. all using this algorithm

SOURCE CODE:

#include<stdio.h>
#include<conio.h>
#define INFINITY
9999
#define MAX 10
void dijkstra(int G[MAX][MAX],int
n,intstartnode); int main()
{
int G[MAX][MAX],i,j,n,u;
printf("Enter no. of vertices:");
scanf("%d",&n);
printf("\nEnter the adjacency matrix:\n");
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&G[i][j]);
printf("\nEnter the starting
node:"); scanf("%d",&u);
dijkstra(G,n,u);
return 0;
}
void dijkstra(int G[MAX][MAX],int n,intstartnode)
{
int cost[MAX][MAX],distance[MAX],pred[MAX];
int

Department of Computer Science and Engineering Page 16


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

visited[MAX],count,mindistance,nextnode,i,j;
//pred[] stores the predecessor of each node
//count gives the number of nodes seen so far
//create the cost matrix
for(i=0;i<n;i++)
for(j=0;j<n;j++)
if(G[i][j]==0)
cost[i][j]=INFINITY;
else
cost[i][j]=G[i][j];
//initialize pred[],distance[] and visited[]
for(i=0;i<n;i++)
{
distance[i]=cost[startnode][
i]; pred[i]=startnode;
visited[i]=0;
}
distance[startnode]
=0;
visited[startnode]=1
; count=1;
while(count<n-1)
{
mindistance=INFINITY;
//nextnode gives the node at minimum
distance for(i=0;i<n;i++)
if(distance[i]<mindistance&&!visited[i])
{
mindistance=distance[i];
nextnode=i;
}
//check if a better path exists through
nextnode visited[nextnode]=1;
for(i=0;i<n;i++)
if(!visited[i])
if(mindistance+cost[nextnode][i]<distance[i])
{
distance[i]=mindistance+cost[nextnode][i];
pred[i]=nextnode;
}
count++;
}
//print the path and distance of each node

Department of Computer Science and Engineering Page 17


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

for(i=0;i<n;i++)
if(i!=startnode)
{
printf("\nDistance of
node%d=%d",i,distance[i]);
printf("\nPath=%d",i);
j=i;
do
{
j=pred[j];
printf("<-
%d",j);
}while(j!=startnode);
}
}

OUTPUT

Department of Computer Science and Engineering Page 18


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

5.Take an example subnet of hosts and obtain a broadcast tree for the subnet

AIM: To write a C program on to obtain a broadcast tree for the subnet with an example
subnet of hosts.

DESCRIPTION: broadcast message is destined to all network devices. Broadcast


routing can be done in two ways (algorithm): A router creates a data packet and then
sends it to each host one by one. In this case, the router creates multiple copies of single
data packet with different destination addresses.

AIM: Write a C program Implement Broadcast Tree for a given subnet hosts.

SOURCE CODE:

#include<stdio.h>
int a[10][10],n;
main()
{

int
i,j,root;
clrscr();
printf("Enter no.of
nodes:"); scanf("%d",&n);
printf("Enter adjacent
matrix\n"); for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{

printf("Enter connecting of %d>%d::",i,j);


scanf("%d",&a[i][j]);
}

printf("Enter root
node:");
scanf("%d",&root);
adj(root);
}

adj(intk)

Department of Computer Science and Engineering Page 19


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

int i,j;
printf("Adjacent node of root
node::\n"); printf("%d\n",k);
for(j=1;j<=n;j++)

if(a[k][j]==1 ||
a[j][k]==1)
printf("%d\t",j);
}

printf("\n");
for(i=1;i<=n;i++)
{

if((a[k][j]==0) && (a[i][k]==0) && (i!=k)) printf("%d",i);


}}

OUTPUT:
Enter no.of
nodes:5 Enter
adjacentmatrix
Enter connecting of1–
>1::0 Enter connecting
of1–>2::1 Enter
connecting of1–>3::1
Enter connecting of1–
>4::0 Enter connecting
of1–>5::0 Enter
connecting of2–>1::1
Enter connecting of2–
>2::0 Enter connecting
of2–>3::1 Enter
connecting of2–>4::1
Enter connecting of2–
>5::0 Enter connecting
of3–>1::1 Enter
connecting of3–>2::1
Enter connecting of3–
>3::0 Enter connecting
of3–>4::0 Enter
connecting of3–>5::0
Enter connecting of4–
>1::0 Enter connecting

Department of Computer Science and Engineering Page 20


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

of4–>2::1 Enter
connecting of4–>3::0
Enter connecting of4–
>4::0 Enter connecting
of4–>5::1 Enter
connecting of5–>1::0
Enter connecting of5–
>2::0

Enter connecting of5–


>3::0 Enter connecting
of5–>4::1 Enter
connecting of5–>5::0
Enter rootnode:2
Adjacent node of root
node:: 2
134
5

OUTPUT :

Department of Computer Science and Engineering Page 21


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

6. Implement distance vector routing algorithm for obtaining routing tables at each
node.

AIM: Write a C program to take an example subnet graph with weights


indicating delay between nodes. Now obtain Routing table art each node using
distance vector routing algorithm.

DESCRIPTION: A distance-vector routing (DVR) protocol requires that a router inform its
neighbors of topology changes periodically. Historically known as the old
ARPANET routing algorithm (or known as Bellman-Ford algorithm).Distances,based on a
chosen metric, are computed using information from the neighbors' distance vectors.

SOURCE CODE:
#include<stdio.h>
structnode
{
unsigned dist[20];
unsigned from[20];
}rt[10];

int main()

{
int dmat[20][20];
int
n,i,j,k,count=0;
printf("\nEnter the number of nodes : ");
scanf("%d",&n);
printf("\nEnter the cost matrix
:\n"); for(i=0;i<n;i++)
for(j=0;j<n;j++)

{
scanf("%d",&dmat[i][j]);
dmat[i][i]=0;

Department of Computer Science and Engineering Page 22


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

rt[i].dist[j]=dmat[i][j];
rt[i].from[j]=j;
}

do

count=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
for(k=0;k<n;k++)
if(rt[i].dist[j]>dmat[i][k]+rt[k].dist[j])

{
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;

}while(count!=0);
for(i=0;i<n;i++)
{

printf("\n\nState value for router %d is


\n",i+1); for(j=0;j<n;j++)
{

printf("\t\nnode %d via %d
Distance%d",j+1,rt[i].from[j]+1,rt[i].dist[j]);

printf("\n\n");

Department of Computer Science and Engineering Page 23


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

OUTPUT :

Department of Computer Science and Engineering Page 24


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

Output (2):

Enter the number of nodes: 3

Department of Computer Science and Engineering Page 25


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

7. Implement data encryption and data decryption

AIM: Write a C program to implement that to Take a 64 bitplaying text and


encrypt the same using DESalgorithm.

DESCRIPTION:Given a string S, the task is to encrypt the string and decrypt


the string again to the original form.

Encryption Technique: If L is the length of the string, then take two values,
one the ceil of √L (say b), and the other floor of √L (say a), and make a two -
dimensional matrix having rows = a, and columns = b.
If rows*columns < L, then increase the value of a or b, whichever is minimum.
Fill the matrix with the characters of the original string sequentially. After
obtaining the matrix, read the matrix column-wise and print the obtained
string.

SOURCECODE:
#include<stdio.h
>
#include<conio.
h>#include<stri
ng.h>
int p10[]={3,5,2,7,4,10,1,9,8,6},
p8[]={6,3,7,4,8,5,10,9},
p4[]={2,4,3,1};
intip[]={2,6,3,1,4,8,5,7},
ipinv[]={4,1,3,5,7,2,8,6},
ep[]={4,1,2,3,2,3,4,1};
int s0[][4]={{1,0,3,2,},{3,2,1,0},{0,2,1,3,},{3,1,3,2}};
int s1[][4]={{0,1,2,3},{2,0,1,3},{3,0,1,0},{2,1,0,3}};
void permute(char op[],char ip[],int p[], int
n){ int i;
for(i=0;i<n;i++
) op[i]=ip[p[i]-
1]; op[i]='\0';
}
void circularls(char pr[],int
n){ int i;
char ch=pr[0];
Department of Computer Science and Engineering Page 26
COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

for(i=0;i<n-
1;i++)
pr[i]=pr[i+1];
pr[i]=ch;
}
void keygen(char k1[],char k2[],char
key[]){ char keytemp[11];
permute(keytemp,key,p10,10);
circularls(keytemp,5);
circularls(keytemp+5,5);
permute(k1,keytemp,p8,8);
circularls(keytemp,5);
circularls(keytemp,5);
circularls(keytemp+5,5);
circularls(keytemp+5,5);
permute(k2,keytemp,p8,8);
}
void xor(char op[],char ip[]){
int i;
for(i=0;i<strlen(op)&&i<strlen(ip);i+
+) op[i]=(op[i]-'0')^(ip[i]-'0')+'0';
}
void sbox(char op[],char ip[],int
s[][4]) { int value;
value=s[(ip[0]-'0')*2+(ip[3]-'0')][(ip[1]-'0')*2+(ip[2]-'0')];
op[0]=value/2+'0';
op[1]=value%2+'0';
op[2]='\0';
}
void fk(char op[],char ip[],char k[])
{
char
l[5],r[5],tmp[9],tmp1[9],tmp2[9];
strncpy(l,ip,4);
l[4]='\0';
strncpy(r,ip+4,4);
r[4]='\0';
permute(tmp,r,ep,
8); xor(tmp,k);
sbox(tmp1,tmp,s0);
sbox(tmp2,tmp+4,s1);
strcat(tmp1,tmp2);
permute(tmp,tmp1,p4,

Department of Computer Science and Engineering Page 27


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

4); xor(tmp,l);
strcat(tmp,r);
strcpy(op,tmp);
}
void sw(char pr[]) {
char tmp[9];
strncpy(tmp,pr+4,
4);
strncpy(tmp+4,pr,
4); tmp[8]='\0';
strcpy(pr,tmp);
}
void main()
{
char key[11],k1[9],k2[9],plain[9],cipher[9],tmp[9];
clrscr();
printf("enter 10 bit key:");
gets(key);
if(strlen(key)!=10) printf("invalid key length
!!"); else
{
keygen(k1,k2,key);
printf("sub key
k1::"); puts(k1);
printf("subkey
k2::"); puts(k2);
printf("enter 8 bit plain
text:"); gets(plain);
if(strlen(plain)!=8) printf("invalid length plain text
!!"); permute(tmp,plain,ip,8);
fk(cipher,tmp,k1);
sw(cipher);
fk(tmp,cipher,k2);
permute(cipher,tmp,ipinv,
8); printf("cipher teaxt
is::"); puts(cipher);
/* decryption process*/
permute(tmp,cipher,ip,8
); fk(plain,tmp,k2);
sw(plain);
fk(tmp,plain,k1);
permute(plain,tmp,ipinv
,8); printf("decrypted
textis::"); puts(plain);
}

Department of Computer Science and Engineering Page 28


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

getch();
}

OUTPUT:

Enter 10
bitkey:1456987203
Sub key k1::17062538
Sub keyk2::25893401
Enter 8 bit plain text:
computer Cipher text
is::epfnmrct
Decrypted text is::computer

OUTPUT CONSOLE:

Department of Computer Science and Engineering Page 29


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

AIM: Write a c program to implement to break the above DES coding.

SOURCE CODE:

#include<stdio.h
>#include<conio.
h>
#include<string.
h>
int p10[]={3,5,2,7,4,10,1,9,8,6},
p8[]={6,3,7,4,8,5,10,9},
p4[]={2,4,3,1};
intip[]={2,6,3,1,4,8,5,7},
ipinv[]={4,1,3,5,7,2,8,6},
ep[]={4,1,2,3,2,3,4,1};
int s0[][4]={{1,0,3,2,},{3,2,1,0},{0,2,1,3,},{3,1,3,2}};
int s1[][4]={{0,1,2,3},{2,0,1,3},{3,0,1,0},{2,1,0,3}};
void permute(char op[],char ip[],int p[], int n)
{
int i;
for(i=0;i<n;i++
) op[i]=ip[p[i]-
1]; op[i]='\0';
}
void circularls(char pr[],int n)
{
int i;
char ch=pr[0];
for(i=0;i<n-
1;i++)
pr[i]=pr[i+1];
pr[i]=ch;
}
void keygen(char k1[],char k2[],char key[])
{

char keytemp[11];
permute(keytemp,key,p10,10);
circularls(keytemp,5);
circularls(keytemp+5,5);

Department of Computer Science and Engineering Page 30


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

permute(k1,keytemp,p8,8);
circularls(keytemp,5);
circularls(keytemp,5);
circularls(keytemp+5,5);
circularls(keytemp+5,5);
permute(k2,keytemp,p8,8);
}
void xor(char op[],char ip[])
{
int i;
for(i=0;i<strlen(op)&&i<strlen(ip);i+
+) op[i]=(op[i]-'0')^(ip[i]-'0')+'0';
}
void sbox(char op[],char ip[],int s[][4])
{
int value;
value=s[(ip[0]-'0')*2+(ip[3]-'0')][(ip[1]-'0')*2+(ip[2]-'0')];
op[0]=value/2+'0';
op[1]=value%2+'0';
op[2]='\0';
}
void fk(char op[],char ip[],char k[])
{
char l[5],r[5],tmp[9],tmp1[9],tmp2[9];
strncpy(l,ip,4);
l[4]='\0';
strncpy(r,ip+4,4);
r[4]='\0';
permute(tmp,r,ep,8);
xor(tmp,k);
sbox(tmp1,tmp,s0);
sbox(tmp2,tmp+4,s1);
strcat(tmp1,tmp2);
permute(tmp,tmp1,p4,
4); xor(tmp,l);
strcat(tmp,r);
strcpy(op,tmp);
}
void sw(char pr[])
{
Department of Computer Science and Engineering Page 31
COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

char tmp[9];
strncpy(tmp,pr+4,
4);
strncpy(tmp+4,pr,
4); tmp[8]='\0';
strcpy(pr,tmp);
}
void main()
{
char key[11],k1[9],k2[9],plain[9],cipher[9],tmp[9];
clrscr();
printf("enter 10 bit key:");
gets(key);
if(strlen(key)!=10) printf("invalid key length
!!"); else
{
keygen(k1,k2,key);
printf("sub key
k1::"); puts(k1);
printf("subkey
k2::"); puts(k2);
printf("enter 8 bit plain
text:"); gets(plain);
if(strlen(plain)!=8) printf("invalid length plain text
!!"); permute(tmp,plain,ip,8);
fk(cipher,tmp,k1);
sw(cipher);
fk(tmp,cipher,k2);
permute(cipher,tmp,ipinv,
8); printf("cipher teaxt
is::"); puts(cipher);
/* decryption process*/
permute(tmp,cipher,ip,8
); fk(plain,tmp,k2);
sw(plain);
fk(tmp,plain,k1);
permute(plain,tmp,ipinv
,8); printf("decrypted
textis::"); puts(plain);
}
getch();
}

Department of Computer Science and Engineering Page 32


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

OUTPUT:
Enter 10 bit key:
1234567892 Sub
keyk1::17948326
Sub keyk2::83652291
Enter 8 bit plain text: computer
Cipher text is::epuomict
Decrypted text is :: computer

OUTPUT:

Department of Computer Science and Engineering Page 33


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

AIM: Using RSA algorithm encrypts a text data and Decrypt the same.

DESCRIPTION:Given a string S, the task is to encrypt the string and decrypt the string
again to the original form.
Decryption Technique: If L is the length of the encrypted string, then again find the
two values a and b, where a is the ceil value of the √L and b is the floor value of the √L.
Similarly create a 2D Matrix in which store the string column wise and read the matrix
row-wise to get the string in the original form

SOUECE CODE:

#include<stdio.
h>#include<stri
ng.h>#include<c
onio.h>
#include<math.
h>
int mult(unsigned int x,unsigned int y,unsigned int n)
{
unsigned long int
k=1; int j;
for(j=1;j<=y;j++)
k=(k*x)%n;
return(unsigned int)
k;
}
void main()
{
char msg[100];
unsigned int
pt[100],ct[100],n,d,e,p,q,i;
printf("enter the plain text:");
gets(msg);
//strcpy(pt,msg);
for(i=0;i<strlen(msg);i++)
pt[i]=msg[i];
n=253;d=17;e=13;
printf("\nCT=");
for(i=0;i<strlen(msg);i++)
ct[i]=mult(pt[i],e,n);
for(i=0;i<strlen(msg);i++)
printf("%d",ct[i]);
printf("\nPT=");
for(i=0;i<strlen(msg);i++)
printf("%c",pt[i]);
for(i=0;i<strlen(msg);i++)

Department of Computer Science and Engineering Page 34


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

pt[i]=mult(ct[i],d,n);
}
OUTPUT:
Enter the plain text: computer
CT=66 119 10 129211 139 173
229
PT=computer

OUTPUT:

Department of Computer Science and Engineering Page 35


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

8. Write a program for congestion control using Leaky bucket


algorithm.

AIM: To write a C program for congestion control using Leaky bucket


algorithm.

DESCRIPTION: The leaky bucket algorithm is a method of temporarily


storing a variable number of requests and organizing them into a set-rate
output of packets in an asynchronous transfer mode (ATM) network.
The leaky bucket is used to implement traffic policing and traffic shaping in
Ethernet and cellular data networks.

SOURCE CODE:
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>

#define NOF_PACKETS 10

int rand(int a)
{
intrn = (random() % 10) % a;
returnrn == 0 ? 1 :rn;
}

int main()
{
intpacket_sz[NOF_PACKETS], i, clk, b_size, o_rate, p_sz_rm=0, p_sz,
p_time, op;
for(i = 0; i<NOF_PACKETS; ++i)
packet_sz[i] = rand(6) * 10;
for(i = 0; i<NOF_PACKETS; ++i)
printf("\npacket[%d]:%d bytes\t", i, packet_sz[i]);
printf("\nEnter the Output rate:");
scanf("%d", &o_rate);

Department of Computer Science and Engineering Page 36


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

printf("Enter the Bucket Size:");


scanf("%d", &b_size);
for(i = 0; i<NOF_PACKETS; ++i)
{
if( (packet_sz[i] + p_sz_rm) >b_size)
if(packet_sz[i] >b_size)/*compare the packet siz with bucket size*/
printf("\n\nIncoming packet size (%dbytes) is Greater than
bucket capacity (%dbytes)-PACKET REJECTED", packet_sz[i],
b_size);
else
printf("\n\nBucket capacity exceeded-PACKETS REJECTED!!");
else
{
p_sz_rm += packet_sz[i];
printf("\n\nIncoming Packet size: %d", packet_sz[i]);
printf("\nBytes remaining to Transmit: %d", p_sz_rm);
p_time = rand(4) * 10;
printf("\nTime left for transmission: %d units", p_time);
for(clk = 10; clk<= p_time; clk += 10)
{
sleep(1);
if(p_sz_rm)
{
if(p_sz_rm<= o_rate)/*packet size remaining comparing with
output rate*/
op = p_sz_rm, p_sz_rm = 0;
else
op = o_rate, p_sz_rm -= o_rate;
printf("\nPacket of size %d Transmitted", op);
printf("----Bytes Remaining to Transmit: %d", p_sz_rm);
}
else
{

Department of Computer Science and Engineering Page 37


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

printf("\nTime left for transmission: %d units", p_time-


clk);
printf("\nNo packets to transmit!!");
}
}
}
}
}

OUTPUT:

Department of Computer Science and Engineering Page 38


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

9. Write a program for frame sorting technique used in buffers

AIM: To write a C program for frame sorting technique used in buffers.


DESCRIPTION:A frame is a digital data transmission unit in computer
networking and telecommunication. A frame typically includes frame
synchronization features consisting of a sequence of bits or symbols that
indicate to the receiver the beginning and end of the payload data within the
stream of symbols or bits it receives. If a receiver is connected to the system
in the middle of a frame transmission, it ignores the data until it detects a
new frame synchronization sequence.

SOURCE CODE:
#include<stdio.h>
#include<string.h>
#define FRAM_TXT_SIZ 3
#define MAX_NOF_FRAM 127
char str[FRAM_TXT_SIZ*MAX_NOF_FRAM];
struct frame // structure maintained to hold frames
{ char text[FRAM_TXT_SIZ];
int seq_no;
}fr[MAX_NOF_FRAM], shuf_ary[MAX_NOF_FRAM];
int assign_seq_no() //function which splits message
{ int k=0,i,j; //into frames and assigns sequence no
for(i=0; i < strlen(str); k++)
{ fr[k].seq_no = k;
for(j=0; j < FRAM_TXT_SIZ && str[i]!='\0'; j++)
fr[k].text[j] = str[i++];
}
printf("\nAfter assigning sequence numbers:\n");
for(i=0; i < k; i++)
printf("%d:%s ",i,fr[i].text);
return k; //k gives no of frames
}
void generate(int *random_ary, const int limit) //generate array of
random nos
{ int r, i=0, j;
while(i < limit)
{ r = random() % limit;
for(j=0; j < i; j++)
if( random_ary[j] == r )
break;
if( i==j ) random_ary[i++] = r;
}}
void shuffle( const int no_frames ) // function shuffles the frames
{
int i, k=0, random_ary[no_frames];

Department of Computer Science and Engineering Page 39


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

generate(random_ary, no_frames);
for(i=0; i < no_frames; i++)
shuf_ary[i] = fr[random_ary[i]];
printf("\n\nAFTER SHUFFLING:\n");
for(i=0; i < no_frames; i++)
printf("%d:%s ",shuf_ary[i].seq_no,shuf_ary[i].text);
}
void sort(const int no_frames) // sorts the frames
{
int i,j,flag=1;
struct frame hold;
for(i=0; i < no_frames-1 && flag==1; i++) // search for frames in
sequence
{
flag=0;
for(j=0; j < no_frames-1-i; j++) //(based on seq no.) and display
if(shuf_ary[j].seq_no > shuf_ary[j+1].seq_no)
{
hold = shuf_ary[j];
shuf_ary[j] = shuf_ary[j+1];
shuf_ary[j+1] = hold;
flag=1;
}
}
}
int main()
{
int no_frames,i;
printf("Enter the message: ");
gets(str);
no_frames = assign_seq_no();
shuffle(no_frames);
sort(no_frames);
printf("\n\nAFTER SORTING\n");
for(i=0;i<no_frames;i++)
printf("%s",shuf_ary[i].text);
printf("\n\n");
}

OUTPUT:
Enter the message:Welcomto Nalla Narasimha Reddy

After assigning sequence numbers:

0:Wel 1:com 2:e T 3:o 4:nal 5:la 6: na 7:ras 8:im 9:ha 10:R 11:ed 12:dy

Department of Computer Science and Engineering Page 40


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

AFTER SHUFFLING:

1:com 4:nal 9:ha 5:la 3:o 10:R 2:e T 6: na 11:ed 0:Wel 8:im 12:dy 7:ras

AFTER SORTING

Welcome ToNalla Narasimha Reddy

Department of Computer Science and Engineering Page 41


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

10. Wireshark

i. Packet Capture Using Wire shark

ii. Starting Wire shark

iii. Viewing Captured Traffic

iv. Analysis and Statistics & Filters.

1. Click View > Wireless Toolbar. The Wireless Toolbar will appear just below
the Main toolbar.

2. Use the Wireless Toolbar to configure the desired channel and channel
width.

3. Under Capture, click on AirPcap USB wireless capture adapter to select the
capture interface.

Note: If the AirPcap isn't listed, press F5 to refresh the list of available packet
capture interfaces.

Note: The AirPcap has been discontinued by RiverBed and is 802.11n only.

Department of Computer Science and Engineering Page 42


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

4. Click the Start Capture button to begin the capture.

5. When you are finished capturing, click the Stop button.

Saving the Capture

Department of Computer Science and Engineering Page 43


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

1. To save the capture, click File > Save.

2. Name the file, and click Save.

Note: .Pcap and .Pcap-ng are good filetypes to use for the capture if you plan to use
Eye P.A. to open the capture.

3. Eye P.A. can now open the capture file.

Department of Computer Science and Engineering Page 44


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

11. How to run Nmap scan


Nmap: Nmap is a free, open source and multi-platform network
security scanner used for network discovery and security auditing. Amongst
other things, it allows you to create a network inventory, managing service
upgrade schedules, monitor host or service uptime and scan for open ports and
services on a host.
This post will focus on how to use Nmap to scan for open ports. Nmap can be
extremely useful for helping you get to the root of the problem you are
investigating, verify firewall rules or validate your routing tables are configured
correctly.

To get started, download and install Nmap from the nmap.org website and then
launch a command prompt.

Typing nmap [hostname] or nmap [ip_address] will initiate a default scan. A


default scan uses 1000 common TCP ports and has Host Discovery enabled.

Host Discovery performs a check to see if the host is online. In a large IP range,
this is useful for identifying only active or interesting hosts, rather than scanning
every single port on every single IP in the range (a lot of which may not even be
there).

Department of Computer Science and Engineering Page 45


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

12. Operating System Detection using Nmap

Operating System Detection using Nmap: NMAP has a database which is


installed when you install NMAP. The database is used when doing OS detection,
but it is not automatically updated.

The database is located at ‘/usr/share/nmap/nmap-os-db’. The easiest way to


manage an update is first to look at the database version number. Open the file in
a text editor and the version number is usually listed on the second line
Before we get into the actual command and performing an OS Detection we should
cover some details about what is happening during this scan.

There are five separate probes being performed. Each probe may consist of one or
more packets. The response to each packet by the target system helps to determine
the OS type.

The five different probes are:

1. Sequence Generation
2. ICMP Echo
3. TCP Explicit Congestion Notification
4. TCP
5. UDP

Now we can look at these individually to see what they are doing.

Sequence Generation

The Sequence Generation Probe consists of six packets. The six packets are sent
100 ms apart and are all TCP SYN packets.

The result of each TCP SYN packet will help NMAP determine the OS type.

ICMP Echo

Two ICMP Request packets are sent to the target system with varying settings in
the packet.

The resulting responses will help verify the OS type by NMAP.

TCP Explicit Congestion Notification

When a lot of packets are being generated and passing through a router causing it
to be burdened is known as congestion. The result is that systems slow down to
reduce congestion so the router is not dropping packets.

The packet being sent is only to get a response from the target system. Specific
values returned are used to determine the specific OS since each OS handles the
packets in different ways.

Department of Computer Science and Engineering Page 46


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

TCP

Six packets are sent during this probe.

Some packets are sent to open or closed ports with specific packet settings. Again,
the results will vary depending on the target OS.

The TCP Packets are all sent with varying flags as follows:

1. no flags
2. SYN, FIN, URG and PSH
3. ACK
4. SYN
5. ACK
6. FIN, PSH, and URG

UDP

This probe consists of a single packet sent to a closed port.

If the port used on the target system is closed and an ICMP Port Unreachable
message is returned then there is no Firewall.

NMAP OS Detection Command

Now we need to run the actual command to perform an OS Detection. If you have
read any of the other of my NMAP articles then it is best not to perform a PING. To
skip the PING we use the parameter ‘-Pn’. To see the extra information we may
require you should use the ‘-v’ parameter for adding verbosity. Specifically to get
the OS Detection the parameter ‘-O’ is needed.

For the command to complete properly and perform the TCP SYN Scan you need
to perform the command as ROOT. In my case, I will perform the scan on one
system only and not the whole network so the command would be:

sudonmap -v -Pn -O 192.168.0.63

The results of the scan are shown in Figure 2. The scan shows that there are
seven open ports using a SYN Stealth Scan.

Department of Computer Science and Engineering Page 47


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

Department of Computer Science and Engineering Page 48


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

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
1. Name of the Program: NS 2 Simulator Introduction

NS2 stands for Network Simulator Version 2. It is an open-source event-driven


simulator designed specifically for research in computer communication
networks.

Features of NS2
1. It is a discrete event simulator for networking research.

2. It provides substantial support to simulate bunch of protocols like TCP, FTP,


UDP, https and DSR.

3. It simulates wired and wireless network.

4. It is primarily Unix based.

5. Uses TCL as its scripting language.

6. Otcl: Object oriented support

7. Tclcl: C++ and otcl linkage

8. Discrete event scheduler

Basic Architecture
NS2 consists of two key languages: C++ and Object-oriented Tool Command
Language (OTcl). While the C++ defines the internal mechanism (i.e., a backend) of
the simulation objects, the OTcl sets up simulation by assembling and configuring
the objects as well as scheduling discrete events. The C++ and the OTcl are linked
together using TclCL

Department of Computer Science and Engineering Page 49


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

2. Name of the Program: Simulate to find the number of packets Dropped

Column 1 represents event type (s: send, r: receive, d: drop, f: forward)

Columns 2 and 3 provide time of the event.

Columns 4 to 7 provide next-hop information.

Columns 8 to 21 are called node property tags.

Column 11 gives the reason for a packet drop and the various reasons possible for
a packet drop are as follows.

END drop due to end of simulation

COL drop due to collision at MAC layer

DUP drop due to duplicate packet

ERR drop due to MAC packet error

RET drop due to exceeding retry count

STA drop due to MAC invalid state

BSY drop due to MAC busy

NRTE drop due to no route available

LOOP drop due to routing loop

TTL drop due to TTL=0

Department of Computer Science and Engineering Page 50


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

TOUT drop due to packet expired

IFQ drop due to no buffer space in IFQ

ARP dropped ARP

OUT dropped by base stations

3. Name of the Program: Simulate to Find the Number of Packets Dropped


byTCP/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”

Department of Computer Science and Engineering Page 51


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

on theeditor.

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 forthe
******.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
HOSTwindow.

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

3. Click OK button on the command window toexit

4. Click NODE EDITOR Button on the HOST window and select


the MAC tab from themodal window that popsup.

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

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
HOSTwindow.

8. Select Add button on the HOST window to invoke the command


window and provide the following command in the commandtextbox.

stg –u 1024 100 1.0.1.3

9. Click OK button on the command window toexit

10. Click NODE EDITOR Button on the HOST window and select
the MAC tab from themodal window that popsup.

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

Department of Computer Science and Engineering Page 52


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

MACwindow

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
HOSTwindow.

14. Select Add button on the HOST window to invoke the


command window and providethe following command in the
commandtextbox.
rtcp –p 21 –l 1024

15. Click OK button on the command window toexit.

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 themodal window that popsup.

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

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

Step3: Simulate
i. Click “R” icon on the toolbar

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
theeditor.

iv. To view results, Open up new TERMINAL window, move to


file2.results folder and openinput and output throughput log files
in separate TERMINALwindow.

Caution: file2 is the hypothetical name


given to this simulation. (Refer Step 1.4)

Name of the Program: Simulate to Find the Number of Packets Dropped due
toCongestion.

Department of Computer Science and Engineering Page 53


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

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.
Drop Packets and Collision Packets.
Step1: Drawing topology
2. Select/click the SUBNET icon on the toolbar and click the left
mouse button on the editor, to place a SUBNET on theeditor.
3. A pop up window appears requesting the number of
nodes and radius for the subnet Set number ofnodes=6;
Set radius of subnet >150

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

Step2 : Configuration

5. Double click the left mouse button while cursor is on a HOST to open the
HOSTwindow.

Department of Computer Science and Engineering Page 54


COMPUTER NETWORKS AND WEB TECHNOLOGIES LAB

6. Click NODE EDITOR Button on the HOST window and select


the INTERFACE tab (1st tab) from the modal window that popsup.

7. Determine the IP address of the selectedhost.

8. Click OK button on the INTERFACE window to exit and once


again click on the OK button on the HOST window toexit.

9. Repeat the above step for 2 otherHOSTS

10. Also click NODE EDITOR Button on the HOST window and select
the MAC tab from themodal window that popsup.

11. Select LOG STATISTICS and select checkbox for drop and
collision log statistics in theMAC window

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

13. Repeat steps 6 to 9 for the other hosts selected at step5.

14. Select G_Setting from the menu bar and select


Simulation from the drop downlist Set simulation
time>600sec

Step3: Simulate
i. Click “R” icon on the toolbar

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 terminalwindow.

iv. Type ping IP address of a host in the subnet at the commandprompt.

v. To view results, Open up new TERMINAL window, move to


file4.results folder and opendrop and collision log files in separate
TERMINALwindow.
Caution: file4 is the hypothetical name
given to this simulation. (Refer Step 1.3)

Department of Computer Science and Engineering Page 55

You might also like