CN Lab Manual

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

lOMoARcPSD|28209439

EXPERIMENT-2
AIM:- A Program to implement the data link layer framing methods
i) Character stuffing
ii) bit stuffing.

DESCRIPTION:-
Introduction to character stuffing for Data Link Layer: 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.
PROGRAM:-
#include<stdio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;
char a[20],b[50],ch;
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';

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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);
}

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Program Output:
Enter string
MIRACLE
Enter position
2
Enter the character
frame after stuffing:
dlestxMdldleIRACLEdleetx
------------------
(program exited with code: 0) Press return to continue

ii) bit stuffing.


Bit Stuffing is a process of inserting an extra bit as 0, once the frame
sequence encountered 5 consecutive 1’s. Given an array, arr[] of size N consisting
of 0’s and 1’s, the task is to return an array after the bit stuffing.
PROGRAM:-
#include <stdio.h>
#include <string.h>
void bitStuffing(int N, int arr[])
{
int brr[30];
int i, j, k;
i = 0;
j = 0;

int count = 1;
while (i < N) {
if (arr[i] == 1) {
brr[j] = arr[i];
for (k = i + 1;
arr[k] == 1
&& k < N
&& count < 5;
k++) {
j++;

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

brr[j] = arr[k];
count++;

if (count == 5) {
j++;
brr[j] = 0;
}
i = k;
}
}
else {
brr[j] = arr[i];
}
i++;
j++;
}

for (i = 0; i < j; i++)


printf("%d", brr[i]);
}

int main()
{
int N = 6;
int arr[] = { 1, 1, 1, 1, 1, 1 };

bitStuffing(N, arr);

return 0;
}

Output:-
1111101

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

EXPERIMENT-3
AIM:- A Program to implement data link layer framing method checksum.
DESCRIPTION:-
Checksum is an error detection mechanism that detects the error in
the data/message in a data communication from sender to receiver. It is only an error
detection mechanism and hence cannot correct the errors in the message bits. It
uses Checksum generator on the sender side and Checksum checker on the receiver side to
check the errors.

PROGRAM:-

#include<stdio.h>
#include<math.h>
int sender(int arr[10],int n)
{
int checksum,sum=0,i;
printf("\n****SENDER SIDE****\n");
for(i=0;i<n;i++)
sum+=arr[i];
printf("SUM IS: %d",sum);
checksum=~sum; //1's complement of sum
printf("\nCHECKSUM IS:%d",checksum);
return checksum;
}

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

void receiver(int arr[10],int n,int sch)


{
int checksum,sum=0,i;
printf("\n\n****RECEIVER SIDE****\n");
for(i=0;i<n;i++)
sum+=arr[i];
printf("SUM IS:%d",sum);
sum=sum+sch;
checksum=~sum; //1's complement of sum
printf("\nCHECKSUM IS:%d",checksum);
}

void main()
{
int n,sch,rch;
printf("\nENTER SIZE OF THE STRING:");
scanf("%d",&n);
int arr[n];
printf("ENTER THE ELEMENTS OF THE ARRAY TO CALCULATE
CHECKSUM:\n");
for(int i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
sch=sender(arr,n);
receiver(arr,n,sch);
}

OUTPUT:-
ENTER SIZE OF THE STRING:4
ENTER THE ELEMENTS OF THE ARRAY TO CALCULATE CHECKSUM:3 6 8 9
****SENDER SIDE****
SUM IS: 26
CHECKSUM IS:-27
****RECEIVER SIDE****
SUM IS:26
CHECKSUM IS:0

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

EXPERIMENT-4
AIM:- A program for Hamming Code generation for error detection and
correction.
DESCRIPTION:-
Hamming code is a popular error detection and error correction
method in data Communication. Hamming code can only detect 2 bit error and correct
a single bit error which means it is unable to correct burst errors if may occur while
transmission of data.
Hamming code uses redundant bits (extra bits) which are calculated according to the
below formula:-
R is calculated by putting r = 1, 2, 3 … until the above equation becomes true.

R1 bit is appended at position 20

R2 bit is appended at position 21

R3 bit is appended at position 22 and so on.These redundant bits are then added to the
original data for the calculation of error at receiver’s end.

At receiver’s end with the help of even parity (generally) the erroneous bit position is
identified and since data is in binary we take complement of the erroneous bit position to
correct received data.

Respective index parity is calculated for r1, r2, r3, r4 and so on.

PROGRAM:-

#include<stdio.h>

void main()
{
int data[10];
int dataatrec[10],c,c1,c2,c3,i;

printf("Enter 4 bits of data one by one\n");


scanf("%d",&data[0]);
scanf("%d",&data[1]);

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

scanf("%d",&data[2]);
scanf("%d",&data[4]);

//Calculation of even parity


data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4];
data[3]=data[0]^data[1]^data[2];

printf("\nEncoded data is\n");


for(i=0;i<7;i++)
printf("%d",data[i]);

printf("\n\nEnter received data bits one by one\n");


for(i=0;i<7;i++)
scanf("%d",&dataatrec[i]);

c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];
c2=dataatrec[5]^dataatrec[4]^dataatrec[1]^dataatrec[0];
c3=dataatrec[3]^dataatrec[2]^dataatrec[1]^dataatrec[0];
c=c3*4+c2*2+c1 ;

if(c==0) {
printf("\nNo error while transmission of data\n");
}
else {
printf("\nError on position %d",c);

printf("\nData sent : ");


for(i=0;i<7;i++)
printf("%d",data[i]);

printf("\nData received : ");


for(i=0;i<7;i++)
printf("%d",dataatrec[i]);
printf("\nCorrect message is\n");

//if errorneous bit is 0 we complement it else vice versa


if(dataatrec[7-c]==0)
dataatrec[7-c]=1;

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

else
dataatrec[7-c]=0;
for (i=0;i<7;i++) {
printf("%d",dataatrec[i]);
}
}
}

OUTPUT:-
Enter 4 bits of data one by one
3457
Encoded data is
3452701
Enter received data bits one by one
67846785
6Error on position 50
Data sent : 3452701
Data received : 6846785
Correct message is 6846785

EXPERIMENT-5
AIM:- Write a Program to implement on a data set of characters the three CRC
polynomials – CRC 12, CRC 16 and CRC CCIP.
DESCRIPTION:- This Cyclic Redundancy Check is the most powerful and easy to implement
technique. Unlike checksum scheme, which is based on adition, CRC is based on binary division. In CRC,
a sequence of redundant bits, called cyclic redundancy check bits, are appended to the end of data unit so
that the resulting data unit becomes exactly divisible by a second, predetermined binary number. At the
destination, the incoming data unit is divided by the same number. If at this step there is no remainder, the
data unit is assumed to be correct and is therefore accepted.

A remainder indicates that the data unit has been damaged in transit and therefore must be rejected.

When this method is used, the sender and the receiver should agree upon a generator
polynomial, G(x) in advance.Both the high and low order bits of G(x) must be ‘1’To compute

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

checksum for some frame with ‘m’ bits ( polynomial = M(x), append ‘r’ zero bits to the lower
end of the frame (r = degree of the generator polynomial) so that this check summed frame is
divisible by G(x).Divide M(x) by G(x) using modulo-2 division and subtract the remainder
from M(x) using modulo-2subtraction. let the resultant be called as T(x)T(x) is passed to the
receiver and the receiver divides it by G(x). If there is a remainder, there has been a
transmission error.

Eg: frame = 1101011011 G(x) = x4


+x +1 = 10011
è degree = 4
Therefore, frame = 1101011011 + 0000
èM(x) = 11010110110000

Commonly used divisor polynomials are: CRC 12


: x12 + x11 + x3 + x2 + x + 1
CRC 16 : x16 + x15 + x2 + 1
CRC CCITT : x16 + x12 + x5 + 1

PROGRAM:-

#include<stdio.h>
#define N strlen(g) char
t[28],cs[28],g[28]; int a,e,c,b;
void xor()
{
for(c=1;c<N;c++) cs[c]=((cs[c]==g[c])?'0':'1');
}
void crc()
{
for(e=0;e<N;e++) cs[e]=t[e];
do
{ if(cs[0]=='1')
xor();

for(c=0;c<N-1;c++)
cs[c]=cs[c+1];
cs[c]=t[e++];
}while(e<=a+N-1);

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

}
int main()
{
int flag=0; do{
printf("\n1.crc12\n2.crc16\ncrc ccit\n4.exit\n\nEnter your option.");
scanf("%d",&b);
switch(b)
{
case 1:strcpy(g,"1100000001111"); break;
case 2:strcpy(g,"11000000000000101"); break;
case 3:strcpy(g,"10001000000100001"); break;
case 4:return 0;
}
printf("\n enter data:");
scanf("%s",t);
printf("\n --------------- \n");
printf("\n generating polynomial:%s",g);
a=strlen(t);
for(e=a;e<a+N-1;e++) t[e]='0';
printf("\n ----------------- \n");
printf("mod-ified data is:%s",t); printf("\n
-------------------------- \n")
crc();
printf("checksum is:%s",cs);
for(e=a;e<a+N-1;e++) t[e]=cs[e-a];
printf("\n --------------- \n");
printf("\n final codeword is : %s",t); printf("\n
---------------------------\n");
printf("\ntest error detection 0(yes) 1(no)?:");
scanf("%d",&e);
if(e==0)
{
do{
printf("\n\tenter the position where error is to be inserted:");
scanf("%d",&e);
}
while(e==0||e>a+N-1);

t[e-1]=(t[e-1]=='0')?'1':'0'; printf("\n \n");

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

printf("\n\terroneous data:%s\n",t);
}
crc();
for(e=0;(e<N-1)&&(cs[e]!='1');e++); if(e<N-1)
printf("error detected\n\n"); else
printf("\n no error detected \n\n"); printf("\n
-------------------------- ");
}while(flag!=1);
}
crc();
for(e=0;(e<N-1)&&(cs[e]!='1');e++); if(e<N-1)
printf("error detected\n\n"); else
printf("\n no error detected \n\n"); printf("\n
-------------------------- ");
}while(flag!=1);

OUTPUT:-
1.crc12
2.crc16
3.ccip
4.exit
Enter your option.1
enter data:1100110011100011

generating polynomial:1100000001111

mod-ified data is:11001100111000110000000000001100000001111

checksum is:1101110110001

final codeword is : 11001100111000111101110110001100000001111

test error detection 0(yes) 1(no)?:1 no error


detected

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Enter your option.2


enter data:11001100111000

generating polynomial:11000000000000101

modified data is:110011001110000000000000000000000000000000101

EXPERIMENT-6
AIM:-A Program to implement Sliding window protocol for Goback N.
DESCRIPTION:-The Go Back-N ARQ or Go Back Automatic Repeat Request is a way to
implement sliding window protocol. This protocol is used for flow control in networking and
is a part of the data-link layer. The sender’s window is of size N and the receiver’s window
size is always one. The window sizes for Go Back-N are
1. SENDER WINDOW SIZE (WS)
The WS is equal to N. If we say the protocol is GB-4, then WS = 4. In order to implement
pipelining, the window size should always be greater than one. If window size is one, the
protocol reduces to stop-and -wait protocol.

2. RECEIVER WINDOW SIZE (WR)


WR is always one in Go Back-N.
Now we will understand how Go Back-N actually works with the help of an example. In the
diagram below the sender’s window has a size of four, or Go Back-4. Assume that we’ve

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

plenty of sequence numbers, for the sake of explanation. Now the sender has dispatched the
packets zero, one, two and three. After acknowledging the packets zero and one, the receiver
is now awaiting packet two and the sender window has additionally slided to similarly
transmit the packets four and five.

3. ACKNOWLEDGEMENTS
There are 2 kinds of acknowledgments, namely:

Cumulative ACK
Independent ACK
GBN makes use of cumulative acknowledgement. On the receiver side, it starts an
acknowledgment timer when any packet is received, which is constant, and when it expires,
it’s going to send a cumulative ACK for the range of packets received in the interval of the
timer. If the receiver has obtained N packets, then the acknowledgement range might be
N+1. A crucial factor is that the ACK timer will now not begin after the expiration of the
primary timer, but after the receiver has received a packet. The timer at the sender side must
be greater than the ACK timer.

PROGRAM:-

#include<bits/stdc++.h>

#include<ctime>

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

#define ll long long int


using namespace std;

void transmission(ll & i, ll & N, ll & tf, ll & tt) {


while (i <= tf) {
int z = 0;
for (int k = i; k < i + N && k <= tf; k++) {
cout << "Sending Frame " << k << "..." << endl;
tt++;
}
for (int k = i; k < i + N && k <= tf; k++) {
int f = rand() % 2;
if (!f) {
cout << "Acknowledgment for Frame " << k << "..." << endl;
z++;
} else {
cout << "Timeout!! Frame Number : " << k << " Not Received" << endl;
cout << "Retransmitting Window..." << endl;
break;
}
}
cout << "\n";
i = i + z;
}
}

int main() {
ll tf, N, tt = 0;
srand(time(NULL));
cout << "Enter the Total number of frames : ";
cin >> tf;
cout << "Enter the Window Size : ";
cin >> N;
ll i = 1;
transmission(i, N, tf, tt);
cout << "Total number of frames which were sent and resent are : " << tt <<
endl;
return 0;
}

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

OUTPUT:-
Enter the Total number of frames: 12
Enter the Window Size : 4
Sending Frame 1…
Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Timeout!! Frame Number : 1 Not Received
Retransmitting Window…

Sending Frame 1…
Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Acknowledgment for Frame 1…
Timeout!! Frame Number : 2 Not Received
Retransmitting Window…

Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Sending Frame 5…

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Timeout!! Frame Number : 2 Not Received


Retransmitting Window…

Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Sending Frame 5…
Acknowledgment for Frame 2…
Acknowledgment for Frame 3…
Acknowledgment for Frame 4…
Timeout!! Frame Number : 5 Not Received
Retransmitting Window…

Sending Frame 5…
Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Timeout!! Frame Number : 5 Not Received
Retransmitting Window…Sending Frame 5…
Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Acknowledgment for Frame 5…

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Timeout!! Frame Number : 6 Not Received


Retransmitting Window…Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Sending Frame 9…
Acknowledgment for Frame 6…
Timeout!! Frame Number : 7 Not Received
Retransmitting Window…

Sending Frame 7…
Sending Frame 8…
Sending Frame 9…
Sending Frame 10…
Acknowledgment for Frame 7…
Acknowledgment for Frame 8…
Acknowledgment for Frame 9…
Acknowledgment for Frame 10…Sending Frame 11…
Sending Frame 12

Retransmitting Window…

Sending Frame 12…


Timeout!! Frame Number : 11 Not Received
Retransmitting Window…

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Sending Frame 11…


Sending Frame 12…
Acknowledgment for Frame 11…
Acknowledgment for Frame 12…

Total number of frames transmitted(sent + resent) are : 38

EXPERIMENT-7
AIM:- A Program to implement Sliding window protocol for Selective repeat.
DESCRIPTION:- 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. 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. 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. In sliding window protocol the receiver has to have some memory to compensate
any loss in transmission or if the frames are received unordered.

Efficiency of Sliding Window Protocol

η = (W*tx)/(tx+2tp)

W = Window Size

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

tx = Transmission time

tp = Propagation delay

Sliding window works in full duplex mode

It is of two types:-

1. Selective Repeat: Sender transmits only that frame which is erroneous or is lost.

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

PROGRAM:-

#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 corruption of
mes)\n\n");
printf("After sending %d frames at waits for acknowledgement sent by the

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

46
Acknowledgement of above frames sent is received by sender

EXPERIMENT-8
AIM:- A Program to implement Stop and Wait Protocol
DESCRIPTION:-Before understanding the stop and Wait protocol, we first know about
the error control mechanism. The error control mechanism is used so that the received data
should be exactly same whatever sender has sent the data. The error control mechanism is
divided into two categories, i.e., Stop and Wait ARQ and sliding window. The sliding window
is further divided into two categories, i.e., Go Back N, and Selective Repeat. Based on the
usage, the people select the error control mechanism whether it is stop and wait or sliding
window.

Here stop and wait means, whatever the data that sender wants to send, he sends the data to
the receiver. After sending the data, he stops and waits until he receives the acknowledgment

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

from the receiver. The stop and wait protocol is a flow control protocol where flow control is
one of the services of the data link layer.
It is a data-link layer protocol which is used for transmitting the data over the noiseless
channels. It provides unidirectional data transmission which means that either sending or
receiving of data will take place at a time. It provides flow-control mechanism but does not
provide any error control mechanism.
The idea behind the usage of this frame is that when the sender sends the frame then he waits
for the acknowledgment before sending the next frame.

Primitives of Stop and Wait Protocol

The primitives of stop and wait protocol are:

Sender side

Rule 1: Sender sends one data packet at a time.

Rule 2: Sender sends the next packet only when it receives the acknowledgment of the
previous packet.

Therefore, the idea of stop and wait protocol in the sender's side is very simple, i.e., send one
packet at a time, and do not send another packet before receiving the acknowledgment.

Receiver side

Rule 1: Receive and then consume the data packet.

Rule 2: When the data packet is consumed, receiver sends the acknowledgment to the
sender.

Therefore, the idea of stop and wait protocol in the receiver's side is also very simple, i.e.,
consume the packet, and once the packet is consumed, the acknowledgment is sent. This is
known as a flow control mechanism.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Working of Stop and Wait protocol

P
R
O
G
R
A
M
:
-
#
i
n
c
l
u
d

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

e
<
s
t
d
i
o
.
h
>
int sender();
int recv();
int timer=0,wait_for_ack=-
1,frameQ=0,cansend=1,t=0;
main()
{
int i,j;
int frame[5];
printf("enter the time when data frame will be
ready\n");
for(j=0;j<3;j++)
{
sender( i,frame[]);
recv(i);
}
sender(int i,int frame[])
{
wait_for_ack++;
if(wait_for_ack==3)
{

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

if(i==frame[t])
{
frameQ++;
t++;
}
if(frameQ==0)
printf("NO FRAME TO SEND at time=%d \n",i);
if(frameQ>0 && cansend==1)
{
printf("FRAME SEND AT TIME=%d\n",i);
cansend=-1;
frameQ--;
timer++;
printf("timer in sender=%d\n",timer);
}
if(frameQ>0 && cansend==-1)
printf("FRAME IN Q FOR TRANSMISSION AT
TIME=%d\n",i);
if(frameQ>0)
t++;
}
printf("frameQ=%d\n",frameQ);
printf("i=%d t=%d\n",i,t);
printf("value in frame=%d\n",frame[t]);
return 0;
}
int recv(int i )
{ printf("timer in recvr=%d\n",timer);
if(timer>0)
{

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

timer++;
}
if(timer==3)
{
printf("FRAME ARRIVED AT TIME= %d\n",i);
wait_for_ack=0;
timer=0;
}
else
printf("WAITING FOR FRAME AT TIME
%d\n",i);
return 0;
}
}

OUTPUT:-

Sender Receiver
Sending Frame : 1 Received Frame : 1
Acknowledgement : 1
Sending Frame : 2 ---
Timeout
Sending Frame : 2 Received Frame : 2
Acknowledgement : 2

Sending Frame : 3 Received Frame : 3


Acknowledgement : 3

Sending Frame : 4 Received Frame : 4


Acknowledgement : 4

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Sending Frame : 5 Received Frame : 5


Acknowledgement : 5

Sending Frame : 6 Received Frame : 6


Acknowledgement : 6

Sending Frame : 7 Received Frame : 7


Delayed Ack
Sending Frame : 7 Received Frame : 7 Duplicate
Delayed Ack

Sending Frame : 7 ---


Timeout
Sending Frame : 7 Received Frame : 7 Duplicate
Acknowledgement : 7

Sending Frame : 8 ---


Timeout
Delayed Ack

Sending Frame : 7 Received Frame : 7


Acknowledgement : 7
Sending Frame : 8 Received Frame : 8
Acknowledgement : 8
Sending Frame : 9 Received Frame : 9
Delayed Ack
Sending Frame : 9 ---
Timeout
Sending Frame : 9 Received Frame : 9 Duplicate
Delayed Ack
Sending Frame : 9 Received Frame : 9 Duplicate
Acknowledgement : 9
Sending Frame : 10 ---
Timeout
Sending Frame : 10 Received Frame : 10
Acknowledgement : 10

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

EXPERIMENT-9
AIM:- A program for congestion control using leaky bucket algorithm.
DESCRIPTION:- 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.

This approach to congestion management is widely used in ATM networks and is called
traffic shaping .he 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.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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<stdio.h>
#include<stdlib.h>
#include<unistd.h>

#define NOF_PACKETS 10

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

int main()
{
int packet_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);
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!!");

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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
{
printf("\nTime left for transmission: %d units", p_time-clk);
printf("\nNo packets to transmit!!");
}
}
}
}
}

OUTPUT:-

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

EXPERIMENT-10
AIM:- A Program to implement Dijkstra‘s algorithm to compute the Shortest path
through a graph.

DESCRIPTION:-
The Dijkstra’s algorithm finds the shortest path from a particular node,
called the source node to every other node in a connected graph. It produces a shortest path
tree with the source node as the root. It is profoundly used in computer networks to generate
optimal routes with the aim of minimizing routing costs.
PROGRAM:-
#include <limits.h>
#include <stdio.h>
#define V 9

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

int minDistance(int dist[], bool sptSet[]) {


int min = INT_MAX, min_index;
for (int v = 0; v < V; v++)
if (sptSet[v] == false && dist[v] <= min)
min = dist[v], min_index = v;
return min_index;
}
int printSolution(int dist[], int n) {
printf("Vertex Distance from Source");
for (int i = 0; i < V; i++)
printf("%d \t %d", i, dist[i]);
}
void dijkstra(int graph[V][V], int src)
{
int dist[V];
bool sptSet[V];
for (int i = 0; i < V; i++)
dist[i] = INT_MAX, sptSet[i] = false;
dist[src] = 0;
for (int count = 0; count < V - 1; count++) {
int u = minDistance(dist, sptSet);
sptSet[u] = true;
for (int v = 0; v < V; v++)
if (!sptSet[v] && graph[u][v] && dist[u] != INT_MAX && dist[u] + graph[u][v] <
dist[v]) dist[v] = dist[u] + graph[u][v];
}
printSolution(dist, V);
}
int main()
{

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

int graph[V][V] = { { 0, 6, 0, 0, 0, 0, 0, 8, 0 },
{ 6, 0, 8, 0, 0, 0, 0, 13, 0 },
{ 0, 8, 0, 7, 0, 6, 0, 0, 2 },
{ 0, 0, 7, 0, 9, 14, 0, 0, 0 },
{ 0, 0, 0, 9, 0, 10, 0, 0, 0 },
{ 0, 0, 6, 14, 10, 0, 2, 0, 0 },
{ 0, 0, 0, 0, 0, 2, 0, 1, 6 },
};
dijkstra(graph, 0);
return 0;
}
OUTPUT:-
Vertex Distance from Source
00
16
2 14
3 21
4 21
5 11
69
78
8 15

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

EXPERIMENT-11
AIM:- A Program to implement Distance vector routing algorithm by obtaining routing
table at each node (Take an example subnet graph with weights indicating delay
between nodes).

DESCRIPTION:-

Distance vector routing is an asynchronous algorithm in which node x sends the copy of its
distance vector to all its neighbors. When node x receives the new distance vector from one
of its neighboring vector, v, it saves the distance vector of v and uses the Bellman-Ford
equation to update its own distance vector.

o The Distance vector algorithm is a dynamic algorithm.

o It is mainly used in ARPANET, and RIP.

o Each router maintains a distance table known as Vector.

PROGRAM :-

#include<stdio.h>
struct node

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

{
unsigned dist[20];
unsigned from[20];
}rt[10];
int main()
{
int costmat[20][20];
int nodes,i,j,k,count=0;
printf("\nEnter the number of nodes : ");
scanf("%d",&nodes);//Enter the nodes
printf("\nEnter the cost matrix :\n");
for(i=0;i<nodes;i++)
{
for(j=0;j<nodes;j++)
{
scanf("%d",&costmat[i][j]);
costmat[i][i]=0;
rt[i].dist[j]=costmat[i][j];//initialise the distance equal to cost matrix
rt[i].from[j]=j;
}
}
do
{
count=0;
for(i=0;i<nodes;i++)//We choose arbitary vertex k and we calculate the direct
distance from the node i to k using the cost matrix
//and add the distance from k to node j
for(j=0;j<nodes;j++)
for(k=0;k<nodes;k++)
if(rt[i].dist[j]>costmat[i][k]+rt[k].dist[j])
{//We calculate the minimum distance
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;
}
}while(count!=0);
for(i=0;i<nodes;i++)
{
printf("\n\n For router %d\n",i+1);

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

for(j=0;j<nodes;j++)
{
printf("\t\nnode %d via %d Distance %d ",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n\n");
getch();
}

OUTPUT:-

Enter the number of nodes :


3
Enter the cost matrix :
027
201
710
For router 1
node 1 via 1 Distance 0
node 2 via 2 Distance 2
node 3 via 3 Distance 3
For router 2
node 1 via 1 Distance 2
node 2 via 2 Distance 0
node 3 via 3 Distance 1
For router 3
node 1 via 1 Distance 3
node 2 via 2 Distance 1
node 3 via 3 Distance 0

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

EXPERIMENT-12
AIM:- A Program to implement Broadcast tree by taking subnet of hosts.

DESCRIPTION:-Kruskal's algorithm is used to obtain the broadcast tree from the given
subnet.This algorithm constructs a minimal spanning tree for a connected weighted graph G.
Select any edge of minimal value that is not a loop. This is the first edge
of T.Select any remaining edge of G having minimal value that does not from a circuit with
the edges already included in T.Continue step2 until T contains n-1 edges where n is the
number of vertices of G.

PROGRAM:-
#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(int k)
{
int i,j;
printf(“Adjacent node of root node::\n”);
printf(“%d\n\n”,k);
for(j=1;j<=n;j++)

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

{
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))
Advertisements
printf(“%d”,i);
}
}
OUTPUT:-
Enter no.of nodes:5
Enter adjacent matrix
Enter connecting of 1–>1::0
Enter connecting of 1–>2::1
Enter connecting of 1–>3::1
Enter connecting of 1–>4::0
Enter connecting of 1–>5::0
Enter connecting of 2–>1::1
Enter connecting of 2–>2::0
Enter connecting of 2–>3::1
Enter connecting of 2–>4::1
Enter connecting of 2–>5::0
Enter connecting of 3–>1::1
Enter connecting of 3–>2::1
Enter connecting of 3–>3::0
Enter connecting of 3–>4::0
Enter connecting of 3–>5::0
Enter connecting of 4–>1::0
Enter connecting of 4–>2::1
Enter connecting of 4–>3::0
Enter connecting of 4–>4::0
Enter connecting of 4–>5::1

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Enter connecting of 5–>1::0


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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

EXPERIMENT-13
AIM:-
To study & observe about Wireshark Tool.
i. Packet Capture Using Wire shark
ii. Starting Wire shark
iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters.

Task 1: Prepare Wireshark to Capture Packets

Step 1: Start Wireshark.


Double-click the Wireshark icon, which is located on the desktop.

Step 2: Select an interface to use for capturing packets.


a. From the Capture menu, choose Interfaces.

Step 3: Start a network capture.


a. Choose the local network Ethernet interface adapter for capturing network
traffic. Click the Start
button of the chosen
interface.
b. Write down the IP address associated with the selected Ethernet
adapter, because that is the source IP address to look for when
examining captured packets.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

The host IP address:

Task 2: Generate and Analyze Captured Packets

Step 1: Open a browser and access a website.


a. Go to www.google.com. Minimize the Google
window, and return to Wireshark. You should
see captured traffic similar to that shown below.
Note: Your instructor may provide you with a
different website. If so, enter the website name or
address here:

b. The capture windows are now active. Locate the


Source, Destination, and Protocol columns on the
Wireshark display screen. The HTTP data that
carries web page text and graphics uses TCP for
reliability.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Step 2: Stop the capture.


From the Wireshark Capture menu, choose Stop.

Step 3: Analyze the captured output.


If the computer was recently started and there has been
no activity in accessing the Internet, you can see the
entire process in the captured output, including ARP,
DNS, and the TCP three-way handshake.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

The capture screen in Task 2, Step 1 shows all the


packets the computer needs to get to a website,
starting with the initial ARP for the gateway router
interface MAC address. (Your screen capture may
vary.)

Step 4: Filter the capture to view only TCP packets.


If you have many packets that are unrelated to the TCP
connection, it may be necessary to use the Wireshark filter
capability.
a. To use a preconfigured filter, click the Analyze menu
option, and then click Display Filters.
b. In the Display Filter window, click TCP only, and then
click OK.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

c. In the Wireshark window, scroll to the first captured

TCP packet. This should be the first packet in the


flow.

d. In the Info column, look for three packets similar


to the first three shown in the window above. The
first TCP packet is the [SYN] packet from the
initiating computer. The second is the [SYN, ACK]

response from the web server. The third packet


is the [ACK] from the source computer, which
completes the handshake.

Step 5: Inspect the TCP initialization Sequence


a. In the top Wireshark window, click on the line
containing the first packet identified in Step 4. This
highlights the line and displays the decoded
information from that packet in the two lower
windows fill.
Note: The Wireshark windows below were
adjusted to allow the information to be viewed

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

in a compact size. The middle window contains


the detailed decoding of the packet.
b. Click the + icon to expand the view of the TCP information.
To contract the view, click the – icon.
c. Notice in the first TCP packet that the relative

sequence number is set to 0, and the SYN bit is set


to 1 in the Flags field.

d. Notice in the second TCP packet of the handshake


that the relative sequence number is set to 0, and
the SYN bit and the ACK bit are set to 1 in the Flags
field.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

e. In the third and final frame of the handshake, only


the ACK bit is set, and the sequence number is set to

the starting point of 1. The acknowledgement

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

number is also set to 1 as a starting point. The TCP


connection is now established, and communication
between the source computer and the web server
can begin.

f. Close Wireshark.

EXPERIMENT-14

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

AIM:- TO RUN NMAP SCAN


Download the Nmap installer Downloading the Nmap installer includes
Zenmap, the graphical interface for Nmap which makes it easy for
newcomers to perform scans without having to learn command lines.

 The Zenmap program is available for Windows, Linux, and Mac OS


X. You can find the installation files for all operating systems on the
Nmap website.

Install Nmap. Run the installer once it is finished downloading.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Run the “Nmap – Zenmap” GUI program. If you left your settings at
default during installation, you should be able to see an icon for it on your
desktop. If not, look in your Start menu. Opening Zenmap will start the
program.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Enter in the target for your scan. The Zenmap program makes scanning
a fairly simple process. The first step to running a scan is choosing your
target. You can enter a domain (example.com), an IP address (127.0.0.1), a
network (192.168.1.0/24), or a combination of those.
 Depending on the intensity and target of your scan, running an Nmap
scan may be against the terms of your internet service provider, and
may land you in hot water. Always check your local laws and your
ISP contract before performing Nmap scans on targets other than
your own network.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

 Intense scan - A comprehensive scan. Contains Operating System


(OS) detection, version detection, script scanning, traceroute, and has
aggressive scan timing. This is considered an intrusive scan.
 Ping scan - This scan simply detects if the targets are online, it does
not scan any ports.
 Quick scan - This is quicker than a regular scan due to aggressive
timing and only scanning select ports.
 Regular scan - This is the standard Nmap scan without any
modifiers. It will return ping and return open ports on the target.

Click Scan to start scanning. The active results of the scan will be
displayed in the Nmap Output tab. The time the scan takes will depend on
the scan profile you chose, the physical distance to the target, and the
target’s network configuration.

Read your results. Once the scan is finished, you’ll see the message
“Nmap done” at the bottom of the Nmap Output tab. You can now check
your results, depending on the type of scan you performed. All of the
results will be listed in the main Nmap Output tab, but you can use the
other tabs to get a better look at specific data.[2]
 Ports/Hosts - This tab will show the results of your port scan,
including the services for those ports.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

 Topology - This shows the traceroute for the scan you performed.
You can see how many hops your data goes through to reach the
target.
 Host Details - This shows a summary of your target learned through
scans, such as the number of ports, IP addresses, hostnames,
operating systems, and more.
 Scans - This tab stores the commands of your previously-run scans.
This allows you to quickly re-scan with a specific set of parameters.

EXPERIMENT-15

AIM:- OS DETECTION USING NMAP


Now we need to run the actual commands to perform OS detection using NMAP, and
at first, we will get the IP address of the host system, and then will perform a scan to
get all active devices on the network.
Step 1: Getting the IP of the System
ifconfig

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Step 2: List of active devices in the Network


nmap -sn 192.168.232.128/24

Let’s do an SYN scan with OS detection in one of the active IPs


Let’s select IP: 192.168.232.2
nmap -sS 192.168.232.2 -O

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Running: VMware Player.


OS details: VMware Player virtual NAT device.

Let’s now perform an Aggressive scan To guess the OS

 -sV stands for Service version.


 -A stands for Aggressive.
It will only display the chance of Operation System (OS) on the host
computer with the help of Probability and Percentage.
nmap -sV 192.168.232.2 -A

16.
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.
How to

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Set up a Network Drive

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

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Network Simulator 2 (NS2) : Monitoring & Examples For


NS2
II. Monitoring

Queue monitoring refers to the capability of tracking the dynamics of packets at a


queue (or other object). A queue monitor tracks packet arrival/departure/drop
statistics, and may optionally compute averages of these values. Monitoring was useful
tools to find detail information about queue.

Flow monitor trace format is given below:

III. NAM trace files which are used by NAM for visualization of ns simulations. The NAM
trace file should contain topology information like nodes, links, queues, node
connectivity etc as well as packet trace information. A NAM trace file has a basic
format to it. Each line is a NAM event. The first character on the line defines the type
of event and is followed by several flags to set options on that event. There are 2
sections in that file, static initial configuration events and animation events. All events
with -t * in them are configuration events and should be at the beginning of the file.

Example of NAM file is:

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

6. Example on NS2
NS workbench is used in following examples to create scenarios and generate TCL
scripts, which are then run in NS2 to generate trace file and NAM file

To use NS workbench you will need Java Sdk installed on your system then download
ns-bench jar file and execute it to start ns workbench

Example 1:

The network consists of five nodes n0 to n4. In this scenario, node n0 sends constant
bit-rate (CBR) traffic to node n3, and node n1 transfers data to node n4 using a file
transfer protocol (FTP). These two carried traffic sources are carried by transport layer
protocols User Datagram Protocol (UDP) and Transmission Control Protocol (TCP),
respectively. In NS2, the transmitting object of these two protocols are a UDP agent
and a TCP agent, while the receivers are a Null agent and a TCP sink agent,
respectively.

Network created by ns workbench is shown below

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

7. Advantages and Disadvantages of NS2


Advantages

1. Cheap- Does not require costly equipment

2. Complex scenarios can be easily tested.

3. Results can be quickly obtained-more ideas can be tested in a smaller time


frame.

4. Supported protocols

5. Supported platforms

6. Modularity

7. Popular

Disadvantages

1. Real system too complex to model. i.e. complicated structure.

2. Bugs are unreliable

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

EXPERIMENT-16
AIM:- To study about NS2 Simulator

i. NS2 Simulator-Introduction

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

i. NS2 Simulator-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:

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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,

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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
runningthe 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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

ii. Simulate to Find the Number of Packets Dropped

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

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)

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

iii. Simulate to Find the Number of Packets Dropped by TCP/UDP

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.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

iv. Simulate to Find the Number of Packets Dropped due to Congestion

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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.
v. Simulate to Compare Data Rate& Throughput

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.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

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.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

ADDITIONAL PROGRAMS
AIM :-Configuration of TELNET protocols on router for remote access.

Telnet protocol:
Telnet is an application protocol that allows a user to communicate with a
remote device. A user on a client machine can use a software (known as a
Telnet client) to access a command-line interface of another, remote
machine that is running a Telnet server program.Telnet is often used by
network administrators to access and manage remote devices. A network
administrator can access the device by telnetting to the IP address or
hostname of a remote device. The network administrator will then be
presented with a virtual terminal that can interact with the remote host. To
use telnet, you must have a software (Telnet client) installed. On a remote
device, a Telnet server must be installed and running.

Steps to Configure Telnet on Cisco Router

1. First of all, execute the following command to change the current


hostname as Switch1. Switch(config)#hostname Switch1

2. configure an IP address on the switch. Unlike the routers,


typically switch does not require to be configured with an IP
address. However, we need to configure an IP address on the
switch’s VLAN 1 interface.
The following commands will configure 10.0.0.1/8 IP address on the VLAN 1
interface.
Switch1(config)#interface vlan 1
Switch1(config-if)#ip address
10.0.0.1
2
55.0.0.0 Switch1(config-if)#no
shutdown
Switch1(config-if)#exit

3. Once you have configured the appropriate hostname and IP

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

address on the switch, execute the following commands to enable


the Telnet protocol.
Switch1(config)#line vty 0 4
Switch1(config-
line)#password 123456
Switch1(config-line)#login
Switch1(config-line)#exit

4. The following figure shows the Telnet configuration on Switch1

5. In the preceding commands, vty −means virtual terminal and 0 4


means ─total five mm(0 to 4) users can access the switch remotely at a
time. 123456 is the password that the remote users need to know in
order to connect to the switch.

6. Once you have done your configuration on switch1, move on


to PC0. Configure 10.0.0.1/8 IP address on PC0.
7. After configuring the appropriate IP address on the PC, open the
Command Prompt window of the PC, type telnet 10.0.0.100 and
press Enter.
8. At the Password: prompt, type your telnet password (123456) and
verify that you are able to connect to switch’s console remotely.
onsider the following example:

The network administrator wants to use his computer (Host A) to access

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

and manage the router (R1). The administrator will start a Telnet client
program on Host A and enter the IP address of the router R1 (telnet
10.0.0.1):

The administrator can now manage the remote device (R1) from his own computer.
Although Telnet is simple and easy to use, it is not widely used anymore,
especially in production environments. This is because Telnet sends all data
in clear-text, including usernames and passwords! SSH is commonly used
today instead of Telnet. Telnet is only used if SSH is not available on the
device, for example on some older Cisco equipment.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

AIM:- Understand the working of basic networking commands (Ping, Route-


Add/Delete/Print,)

NetSim allows users to interact with the simulation at runtime via a socket or
through a file. User Interactions make simulation more realistic by allowing
command execution to view/modify certain device parameters during runtime.

Ping Command
The ping command is one of the most often used networking utilities for
troubleshooting network problems.
You can use the ping command to test the availability of a networking
device (usually a computer) on a network
When you ping a device, you send that device a short message, which it then
sends back (the echo)
If you receive a reply then the device is in the Network, if you do not, then the
device is faulty, disconnected, switched off, or incorrectly configured.

Route Commands
You can use the route commands to view, add and delete routes in IP routing tables.

route print: In order to view the entire contents of the IP routing table.
route delete: In order to delete all routes in the IP routing table.
route add: In order to add a static TCP/IP route to the IP routing table.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Network setup
Open NetSim and click Examples > Experiments > Basic-networking-

commands-Ping- Route-Add/Delete/Print-and-ACL > Sample-1 as shown


below Figure 26-1.

Figure 26-1: Experiments List

NetSim UI displays the configuration file corresponding to this experiment as


shown below
Figure 26-2.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Figure 26-2: Network topology in the sample scenario


Procedure
The following set of procedures were done to generate this sample:

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Step 1: A network scenario is designed in NetSim GUI comprising of 2 Wired


Nodes and 3 Routers in the “Internetworks” Network Library.

Step 2: In the Network Layer properties of Wired Node 1, “ICMP Status” is

set as TRUE. Similarly, ICMP Status is set as TRUE for all the devices as

shown Figure 26-3.

Figure 26-3: Network Layer properties of Wired Node 1

Step 3: In the General properties of Wired Node 1, Wireshark Capture is set as


Online.

Step 4: Right click on the Application Flow App1 CBR and select Properties or
click on the Application icon present in the top ribbon/toolbar.

A CBR Application is generated from Wired Node 1 i.e. Source to Wired Node 2
i.e. Destination with Packet Size remaining 1460Bytes and Inter Arrival Time
remaining 233.6µs. Transport Protocol is set to UDP.

Additionally, the “Start Time(s)” parameter is set to 30, while configuring the
application. This time is usually set to be greater than the time taken for OSPF
Convergence (i.e., Exchange of OSPF information between all the routers), and it
increases as the size of the network increases.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Step 5: Packet Trace is enabled in NetSim GUI. At the end of the simulation, a
very large .csv file is containing all the packet information is available for the users
to perform packet level analysis. Plots are enabled in NetSim GUI.

Step 6: Click on Run Simulation. Simulation Time is set to 300 Seconds and in the
Runtime Interaction tab Figure 26-4, Interactive Simulation is set to True.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Figure 26-4: Runtime Interaction window


NOTE: It is recommended to specify a longer simulation time to ensure that
there is sufficient time for the user to execute the various commands and see the
effect of that before the Simulation ends.

Click on Accept and then click on OK.

Simulation (NetSimCore.exe) will start running and will display a message

“waiting for first client to connect” as shown below Figure 26-5


Figure 26-5: Waiting for first client to connect

Go back to the network scenario. Click on “Display Settings” in the top


ribbon/toolbar and select the “Device IP” checkbox inorder to display the IP

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

address of all the devices. Now, Right click on Router 3 or any other Router
and select “NetSim Console” option as shown Figure 26-6.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Figure 26-6: Select NetSim Console


Now Client (NetSimCLI.exe) will start running and it will try to establish a
connection with NetSimCore.exe. After the connection is established, the
followingwill be displayed Figure 26-7.

Figure 26-7: Connection established

After this the command line interface can be used to execute all the supported
commands.

Network Commands

Ping Command
You can use the ping command with an IP address or Device name.
ICMP_Status should be set as True in all nodes for ping to work.

Ping <IP address> e.g. ping 11.4.1.2

Ping <Node Name> e.g. ping Wired_Node_2

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Route Commands

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

In order to view the entire contents of the IP routing table, use following command
route print

route print

You’ll see the routing table entries with network destinations and the
gateways to which packets are forwarded, when they are headed to that
destination. Unless you’ve already added static routes to the table, everything
you see here is dynamically generated.
In order to delete a route in the IP routing table you’ll type a command using
the following syntax

route delete destination_network

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

So, to delete the route with destination network 11.5.1.2, all we’d have to

route delete 11.5.1.2

do is type this command.

To check whether route has been deleted or not check again using route print
command.
To add a static route to the table, you will type a command using the following
syntax.

route ADD destination_network MASK subnet_mask gateway_ip metric_cost interface

So, for example, if you wanted to add a route specifying that all traffic
bound for the
11.5.1.2 subnet went to a gateway at 11.5.1.1

route ADD 11.5.1.2 MASK 255.255.0.0 11.5.1.1 METRIC 100 IF 2

If you were to use the route print command to look at the table now, you’d
see your new static route.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Figure 26-13: Packet Trace - ICMP Control Packets


In Wireshark, apply filter as ICMP. we can see the ping request and reply packets
in Wireshark as shown Figure 26-14.

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

How to
Change a Computer's Mac Address in Windows

How to
Access Shared Folders on a Network

Downloaded by Sony Swaroop ([email protected])


lOMoARcPSD|28209439

How to
Configure Your PC to a Local Area Network

Downloaded by Sony Swaroop ([email protected])

You might also like