0% found this document useful (0 votes)
124 views

CN Lab Manual (Master)

The document describes a lab manual for a Computer Networks lab. It includes the vision, mission and objectives of the department related to data science. It then lists 13 experiments related to networking topics like data link layer, routing, encryption, congestion control and simulations using tools like Wireshark and NS2.

Uploaded by

shoterking1357
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views

CN Lab Manual (Master)

The document describes a lab manual for a Computer Networks lab. It includes the vision, mission and objectives of the department related to data science. It then lists 13 experiments related to networking topics like data link layer, routing, encryption, congestion control and simulations using tools like Wireshark and NS2.

Uploaded by

shoterking1357
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 79

CMR Engineering College CSE-DS

Department Of Computer Science & Engineering

(DATA SCIENCE)

MASTER MANUAL

Name of lab : COMPUTER NETWORKS LAB

Class : III Year I Semester

Branch : Computer Science & Engineering

(DATA SCIENCE)

Regulation : R20

A.Y. : 2022-2023

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

DEPARTMENT VISION

To create the next generation and globally competent data scientists/data engineers in the field of
Data Science domain by providing quality engineering education along with cutting edge
technologies.

DEPARTMENT MISSION
To provide value based engineering education through continues learning and research by imparting
solid foundation in applied mathematics, algorithms and programming paradigms to build software
models and simulations.
To develop concepts building, logical and problem solving skills of graduates to address current global
challenges of industry and society.
To offer excellence in teaching and learning process, industry collaboration activities and researchto
mould graduates into industry ready professionals.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

PROGRAM EDUCATIONAL OBJECTIVES(PEO)


PEO 1: To prepare graduates with a varied range of expertise in different aspects of data science
such as data collection, processing, modeling and visualization of large data sets.
PEO 2: To acquire good knowledge of both theory and application of applied statistics,
mathematics and computer science based existing data science models to analyze huge data sets
originating from different application areas.
PEO 3: To create models using the knowledge acquired from the program to solve future
challenges and real-world problems requiring large scale data analysis.
PEO 4:. To make better trained professionals to cater the growing demand for data scientists,
data analysts, data architects and data engineers in industry.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

DS507PC: COMPUTER NETWORKS LAB


DS507PC: COMPUTER NETWORKS LAB (COMMON TO CSD,CSE and CSM)

III Year B.Tech CSE-DATA SCIENCE I-Semester L T P C


0 0 2 1
Course Objectives
1. To understand the working principle of various communication protocols.
2. To understand the network simulator environment and visualize a network topology and observe its
performance
3. To analyze the traffic flow and the contents of protocol frames

Course Outcomes
1. Implement data link layer farming methods
2. Analyze error detection and error correction codes.
3. Implement and analyze routing and congestion issues in network design.
4. Implement Encoding and Decoding techniques used in presentation layer
5. To be able to work with different network tools

List of Experiments

1. Implement the data link layer framing methods such as character, character-stuffing and bit stuffing.
2. Write a program to compute CRC code for the polynomials CRC-12, CRC-16 and CRC CCIP
3. Develop a simple data link layer that performs the flow control using the sliding window protocol, and
loss recovery using the Go-Back-N mechanism.
4. Implement Dijsktra’s algorithm to compute the shortest path through a network
5. Take an example subnet of hosts and obtain a broadcast tree for the subnet.
6. Implement distance vector routing algorithm for obtaining routing tables at each node.
7. Implement data encryption and data decryption
8. Write a program for congestion control using Leaky bucket algorithm.
9. Write a program for frame sorting technique used in buffers.
10. Wireshark
i. Packet Capture Using Wireshark
ii. Starting Wire shark
iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters.
11. How to run Nmap scan
12. Operating System Detection using Nmap
13. Do the following using NS2 Simulator
i. NS2 Simulator-Introduction
ii. Simulate to Find the Number of Packets Dropped
iii. Simulate to Find the Number of Packets Dropped by TCP/UDP
iv. Simulate to Find the Number of Packets Dropped due to Congestion
v. Simulate to Compare Data Rate& Throughput.
vi. Simulate to Plot Congestion for Different Source/Destination
vii. Simulate to Determine the Performance with respect to Transmission of Packets

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

LAB CODE

 Students should report to the concerned lab as per the time table.

 Students who turn up late to the labs will in no case be permitted to do the program
schedule for the day.
 After completion of the program, certification of the concerned staff in-charge in the
observation book is necessary.
 Student should bring a notebook of 100 pages and should enter the readings /observations into
the notebook while performing the experiment.
 The record of observations along with the detailed experimental procedure of the experiment
in the immediate last session should be submitted and certified staff member in-charge.
 The group-wise division made in the beginning should be adhered to and no mix up of
studentsamong different groups will be permitted.
 When the experiment is completed, should disconnect the setup made by them, and should
return all the components/instruments taken for the purpose.
 Any damage of the equipment or burn-out components will be viewed seriously either by
putting penalty or by dismissing the total group of students from the lab for the semester/year.
 Students should be present in the labs for total scheduled duration.

 Students are required to prepare thoroughly to perform the experiment before coming to
laboratory.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
INDEX
Experiment Page
Name of the
No. Experiment No.

1. Implement the data link layer framing methods such as


character, character-stuffing and bit stuffing. 7-15
2. Write a program to compute CRC code for the polynomials CRC-
12,CRC-16 and CRC CCIP 16-22
Develop a simple data link layer that performs the flow control
3. Using the sliding window protocol, and loss recovery using the
Go-Back-N mechanism. 23-26
4. Implement Dijsktra’s algorithm to compute the shortest path through a
network 27-31
5. Take an example subnet of hosts and obtain a broadcast tree for the
subnet. 32-35
6. Implement distance vector routing algorithm for obtaining routing tables
at each node. 36-39
7. Implement data encryption and data decryption 40-41

8. Write a program for congestion control using Leaky bucket algorithm. 42-44
9. Write a program for frame sorting technique used in buffers. 45-46
Wire shark
i. Packet Capture Using Wireshark 47-58
ii. Starting Wire shark
10. iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters Viewing
Captured Traffic
v. Analysis and Statistics & Filters.
11. How to run Nmap scan 59-60
12. Operating System Detection using Nmap 61-66
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
13. Dropped by TCP/UDP
67-79
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

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-I
Aim:
Implement the data link layer framing methods such as character count, Character stuffing and bit
stuffing.
Description:
The Data Link Layer is the second layer in the OSI model, above the Physical Layer, which ensures that the
error free data is transferred between the adjacent nodes in the network. It breaks the datagrams passed down
by above layers and converts them into frames ready for transfer. This is called Framing. It provides two main
functionalities
 Reliable data transfer service between two peer network layers
 Flow Control mechanism which regulates the flow of frames such that data congestion is not there at slow
receivers due to fast senders.
What is Framing?
Since the physical layer merely accepts and transmits a stream of bits without any regard to meaning or
structure, it is upto the data link layer to create and recognize frame boundaries. This can be accomplished by
attaching special bit patterns to the beginning and end of the frame. If these bit patterns can accidentally occur
in data, special care must be taken to make sure these patterns are not incorrectly interpreted as frame
delimiters. The four framing methods that are widely used are
 Character count
 Starting and ending characters, with character stuffing
 Starting and ending flags, with bit stuffing
 Physical layer coding violations
Character Count
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.

Character stuffing
In the second method, each frame starts with the ASCII character sequence DLE STX and ends with the
sequence DLE ETX.(where DLE is Data Link Escape, STX is Start of TeXt and ETX is End of TeXt.) This
method overcomes the drawbacks of the character count method. If the destination ever loses synchronization,
it only has to look for DLE STX and DLE ETX characters. If however, binary data is being transmitted then
there exists a possibility of the characters DLE STX and DLE ETX occurring in the data. Since this can
interfere with the framing, a technique called character stuffing is used. The sender's data link layer inserts an
ASCII DLE character just before the DLE character in the data. The receiver's data link layer removes this
DLE before this data is given to the network layer. However character stuffing is closely associated with 8-bit
characters and this is a major hurdle in transmitting arbitrary sized characters.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

Bit stuffing
The third method allows data frames to contain an arbitrary number of bits and allows character codes with an
arbitrary number of bits per character. At the start and end of each frame is a flag byte consisting of the special
bit pattern 01111110. Whenever the sender's data link layer encounters five consecutive 1s in the data, it
automatically stuffs a zero bit into the outgoing bit stream. This technique is called bit stuffing. When the
receiver sees five consecutive 1s in the incoming data stream, followed by a zero bit, it automatically destuffs
the 0 bit. The boundary between two frames can be determined by locating the flag pattern.

Physical layer coding violations


The final framing method is physical layer coding violations and is applicable to networks in which the
encoding on the physical medium contains some redundancy. In such cases normally, a 1 bit is a high-low pair
and a 0 bit is a low-high pair. The combinations of low-low and high-high which are not used for data may be
used for marking frame boundaries.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
NAME OF THE EXPERIMENT: Character count.
AIM: Implement the data link layer farming methods such as character, character stuffing.
HARDWARE REQUIREMENTS: Intel based DesktopPC: - RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.

SOURCE CODE:

#include<stdio.h>
#include<string.h>

char input[10][20];
int get_input();

void make_frames(int);
int count_chars(int s);

void main()
{
int no_of_words=get_input();
make_frames(no_of_words);
}

int get_input()
{
int answer;
int i=0;
do{
printf("\nEnter the Word:");
scanf("%s",input[i]);
fflush(stdin);
printf("\nDo you want to continue: (yes: 1 or no: 0)?:");
scanf("%d",&answer);
i++;
}
while(answer!=0);

return i;
}

void make_frames(int num_words){


int i=0;
printf("\nThe Transmitted Data is:\n\t");

for(;i<num_words;i++)
printf("%d%s",(count_chars(i)+1),input[i]);

printf("\n\n");
}
int count_chars(int index)
{

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
int i=0;
while(input[index][i]!='\0')
i++;
return i;
}

Output:

Enter the Word:cat


Do you want to continue: (y: 1/n: 0)?:1

Enter the Word:dog


Do you want to continue: (y: 1/n: 0)?:1

Enter the Word:apple


Do you want to continue: (y: 1/n: 0)?:0

The Transmitted Data is: 4cat4dog6apple

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
NAME OF THE EXPERIMENT: Bit Stuffing.
AIM: Implement the data link layer farming methods such as and bit stuffing.
HARDWARE REQUIREMENTS: Intel based Desktop PC:- RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.
THEORY:

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

SOURCE CODE:

#include<stdio.h>
#include<string.h>
void main()
{
int a[20],b[30],i,j,k,count,n;
printf("Enter frame length:");
scanf("%d",&n);
printf("Enter input frame (0's & 1's only):");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
i=0;
count=1;
j=0;
while(i<n)
{
if(a[i]==1)
{
b[j]=a[i];
for(k=i+1;a[k]==1 && k<n && count<5;k++)
{
j++;
b[j]=a[k];
count++;
if(count==5)
{
j++;
b[j]=0;
}
i=k;
}
}
else
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
{
b[j]=a[i];
}
i++;
j++;
}
printf("After stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]);
}

Output:
Enter frame length:5
Enter input frame (0's & 1's only):
1
1
1
1
1
After stuffing the frame is: 111110

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
NAME OF THE EXPERIMENT: Character Stuffing.
AIM: Implement the data link layer farming methods such as character, character stuffing.
HARDWARE REQUIREMENTS: Intel based DesktopPC:-
RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.

SOURCE CODE:
#include<stdio.h>
#include<string.h>
#include<conio.h>
void main()
{
int j,l,m,c,k;
char a[50],b[50];
printf("Enter the string:");
scanf("%s",a);
strcpy(b,"DLESTX");
m=strlen(a);
for(j=0;j<m;)
{
if(a[j]=='d')
{
if(a[j+1]=='l')
{
if(a[j+2]=='e')
{
c=j+2;
for(l=0;l<3;l++)
{
for(k=m;k>c;k--)
{
a[k]=a[k-1];
}
m++;
a[m]='\0';
c+=1;
}
a[j+3]='d';
a[j+4]='l';
a[j+5]='e';
a[m]='\0';
j+=5;
}
}
}
j++;
}
strcat(b,a);
strcat(b,"DLEETX");
printf("\n%s",b);
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
printf("\nReceiver side:");
m=strlen(a);
for(j=0;j<m;)
{
if(a[j]=='d')
{
if(a[j+1]=='l')
{
if(a[j+2]=='e')
{
c=j;
for(l=0;l<3;l++)
{
for(k=c;k<m;k++)
a[k]=a[k+1];
}
c++;
}
j=c;
}
}
j++;
}
printf("\n%s",a);
getch();
}

OUTPUT:
Enter the string: ABC

DLESTXABCDLEETX
Receiver side:
ABC

Viva Questions and Answers


1. What is framing?
Since the physical layer merely accepts and transmits a stream of bits without any regard to
meaning or structure, it is upto the data link layer to create and recognize frame boundaries. This can
be accomplished by attaching special bit patterns to the beginning and end of the frame. If these bit
patterns can accidentally occur in data, special care must be taken to make sure these patterns are
not incorrectly interpreted as frame delimiters. The four framing methods that are widely used are
Character count
Starting and ending characters, with character stuffing
Starting and ending flags, with bit stuffing
Physical layer coding violations

2. Character Count?
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

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
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.

3. Character stuffing?
In the second method, each frame starts with the ASCII character sequence DLE STX and
ends with the sequence DLE ETX.(where DLE is Data Link Escape, STX is Start of TeXt and ETX
is End of TeXt.) This method overcomes the drawbacks of the character count method. If the
destination ever loses synchronization, it only has to look for DLE STX and DLE ETX characters. If
however, binary data is being transmitted then there exists a possibility of the characters DLE STX
and DLE ETX occurring in the data. Since this can interfere with the framing, a technique called
character stuffing is used. The sender's data link layer inserts an ASCII DLE character just before
the DLE character in the data. The receiver's data link layer removes this DLE before this data is
given to the network layer. However character stuffing is closely associated with 8-bit characters
and this is a major hurdle in transmitting arbitrary sized characters.

4. Bit stuffing?
The third method allows data frames to contain an arbitrary number of bits and allows
character codes with an arbitrary number of bits per character. At the start and end of each frame is a
flag byte consisting of the special bit pattern 01111110 . Whenever the sender's data link layer
encounters five consecutive 1s in the data, it automatically stuffs a zero bit into the outgoing bit
stream. This technique is called bit stuffing. When the receiver sees five consecutive 1s in the
incoming data stream, followed by a zero bit, it automatically de-stuffs the 0 bit. The boundary
between two frames can be determined by locating the flag pattern.

5. Physical layer coding violations


The final framing method is physical layer coding violations and is applicable to networks in
which the encoding on the physical medium contains some redundancy. In such cases normally, a 1
bit is a high-low pair and a 0 bit is a low-high pair. The combinations of low-low and high-high
which are not used for data may be used for marking frame boundaries

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-2
NAME OF THE EXPERIMENT: Cyclic Redundancy Check.
AIM: Implement on a data set of characters the three CRC polynomials – CRC 12, CRC 16 and
CRCCCIP.
HARDWARE REQUIREMENTS: Intel based Desktop PC: - RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.
THEORY:

The Data Link Layer is the second layer in the OSI model, above the Physical Layer, which ensures
that the error free data is transferred between the adjacent nodes in the network. It breaks the datagram passed
down by above layers and converts them into frames ready for transfer. This is called Framing. It provides two
main functionalities
 Reliable data transfer service between two peer network layers
 Flow Control mechanism, which regulates the flow of frames such that data congestion is not there at
slow receivers due to fast senders.
There are two basic strategies for dealing with errors. One way is to include enough redundant
information (extra bits are introduced into the data stream at the transmitter on a regular and logical basis)
along with each block of data sent to enable the receiver to deduce what the transmitted character must have
been. The other way is to include only enough redundancy to allow the receiver to deduce that error has
occurred, but not which error has occurred and the receiver asks for a retransmission. The former strategy uses
Error-Correcting Codes and latter uses Error-detecting Codes.

CRC (Cyclic Redundancy Check)

This Cyclic Redundancy Check is the most powerful and easy to implement technique. Unlike
checksum scheme, which is based on addition, 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.
1. Bit strings are created as representation of polynomials with coefficients ‘0’ and ‘1’only.
2. A k-bit frame is regarded as coefficients list for a polynomial with ‘k’ terms (xk-1 to x0 )
Eg: x5 + x4 +x0 = 110001
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 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).

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
If there is a remainder, there has been a transmission error.
Algorithm for computing checksum:

1. Let ‘r’ be the degree of G(x). Append ‘r’ to the lower end of the frame so that it contains (m + r) bits.
2. Divide M(x) by G(x) using MOD-2 division.
3. Subtract the remainder from M(x) using MOD-2 subtraction.
4. The result is the check summed frame to be transmitted.

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 CCIP : x16 + x12 + x5 + 1

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
Performance:
CRC is a very effective error detection technique. If the divisor is chosen according to the previously
mentioned rules, its performance can be summarized as follows:
• CRC can detect all single-bit errors
• CRC can detect all double-bit errors (three 1’s)
• CRC can detect any odd number of errors (X+1)
• CRC can detect all burst errors of less than the degree of the polynomial.
• CRC detects most of the larger burst errors with a high probability.
• For example CRC-12 detects 99.97% of errors with a length 12 or more.

SOURCE CODE:

#include <stdio.h>
#include <string.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);
}

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");
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
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");
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);
}

Output:
1.crc12
2.crc16
3.crc ccit
4.exit

Enter your option.1

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
enter data: 1100110011100011
-----------------------
generating polynomial: 1100000001111
-------------------------
mod-ified data is: 1100110011100011000000000000
-----------------------
checksum is: 1101110110001
-----------------------
final codeword is: 11001100111000111101110110001100000001111
------------------------
test error detection 0(yes) 1(no)?:1
no error detected
-----------------------
1. crc12
2. crc16
3. crc ccit
4. exit
Enter your option.2
enter data: 11001100111000
-----------------------

generating polynomial: 11000000000000101


--------------------------
Mod-ified data is: 110011001110000000000000000000
Checksum is: 11111111110110000
-----------------------
final codeword is: 110011001110001111111111011000000000000000101
------------------------
Test error detection 0(yes) 1(no)?:1
No error detected
-----------------------
1.crc12
2.crc16
3.crc ccit
4.exit
Enter your option.3
enter data:11001100111000
-----------------------
generating polynomial:10001000000100001
--------------------------
mod-ified data is:11001100111000000000000000000000
-----------------------
checksum is:11100111100111010
-----------------------
final codeword is : 110011001110001110011110011101001000000100001
------------------------
test error detection 0(yes) 1(no)?:0

Enter the position where error is to be inserted:3


-----------------------
erroneous data:111011001110001110011110011101001000000100001
error detected
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

-----------------------
1. crc12
2. crc16
3. crc ccit
4. exit
Enter your option.4

Result:
Thus the program for cyclic redundancy check is executed.

Viva Question and Answers


1. What is CRC?
CRC, is the most powerful of the redundancy checking techniques, is based on binary division.

2. What is Redundancy?
The concept of including extra information in the transmission solely for the purpose of
comparison. This technique is called redundancy.

3. What is Error Detection? What are its methods?


Data can be corrupted during transmission. For reliable communication errors must be
deducted and corrected. Error Detection uses the concept of redundancy, which means adding extra
bits for detecting errors at the destination. The common Error Detection methods are
a. Vertical Redundancy Check (VRC)
b. Longitudinal Redundancy Check (VRC)
c. Cyclic Redundancy Check (VRC)
d. Checksum

4. List the steps involved in creating the checksum.


a. Divide the data into sections
b. Add the sections together using 1's complement arithmetic
c. Take the complement of the final sum, this is the checksum.

5. Compare Error Detection and Error Correction:


The correction of errors is more difficult than the detection. In error detection, checks only
any error has occurred. In error correction, the exact number of bits that are corrupted and location
in the message are known. The number of the errors and the size of the message are important
factors.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-3
NAME OF THE EXPERIMENT: 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
HARDWARE REQUIREMENTS: Intel based Desktop PC:- RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.

THEORY:
SLIDING WINDOW PROTOCOL

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]);
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
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);
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
46
Acknowledgement of above frames sent is received by sender

loss recovery using the Go-Back-N mechanism

Go-Back-N mechanism

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
SOURCE CODE:
#include<stdio.h>
int main()
{
int windowsize,sent=0,ack,i;
printf("enter window size\n");
scanf("%d",&windowsize);
while(1)
{
for( i = 0; i < windowsize; i++)
{
printf("Frame %d has been transmitted.\n",sent);
sent++;
if(sent == windowsize)
break;
}
printf("\nPlease enter the last Acknowledgement not received.\n");
scanf("%d",&ack);
if(ack == windowsize)
break;
else
sent = ack;
}
return 0;
}
Output:
enter window size
8
Frame 0 has been transmitted.
Frame 1 has been transmitted.
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.
Frame 5 has been transmitted.
Frame 6 has been transmitted.
Frame 7 has been transmitted.

Please enter the last Acknowledgement not received.


2
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.
Frame 5 has been transmitted.
Frame 6 has been transmitted.
Frame 7 has been transmitted.

Please enter the last Acknowledgement not received.


8

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
Viva Question and Answers

1. What are the Types of Sliding Window Protocol?


Sliding window protocol has two types: Go-Back-N ARQ, Selective Repeat ARQ

2. Difference between the Go-Back-N ARQ and Selective Repeat ARQ?

Go-Back-N ARQ Selective Repeat ARQ

If a frame is corrupted or lost in it, all In this, only the frame is sent again, whichis corrupted or lost.
subsequent frames have to be sent again.

If it has a high error rate ,it wastesa lot of There is a loss of low bandwidth.
bandwidth.
It is less complex. It is more complex because it has to dosorting and searching as
well. And it also requires more storage.
It does not require sorting. In this, sorting is done to get the frames inthe correct order.
It does not require searching. The search operation is performed in it.

It is used more. It is used less because it is more complex.

3. What is SNMP (Simple Network Management Protocol)?


NMP was defined by IETF (Internet Engineering Task Force). It is used to manage the network.
It is an internet standard protocol that monitors devices in IP networks and collects and organizes the
information (data) of these devices. SNMP is supported by most network devices such as the hub,
switch, router, bridge, server, modem, and printer, etc.

4. What are the SNMP basic operations?


o GetRequest: The GetRequest operation is used by the SNMP manager to derive one or more values from the
SNMP agent.
o GetNextRequest: The GetNextRequest is similar to the GetRequest operation, but it is used to get the next
value from the SNMP agent.
o SetRequest: It is used by the manager to set the value of the agent device.
o Trap: This command is used by the SNMP agent to send acknowledgment messages to the SNMP
manager.
o GetBulkRequest: It is used by the SNMP manager to retrieve the large data from the SNMP agent

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-4
NAME OF THE EXPERIMENT: Shortest Path.
Aim: Implement Dijkstra‘s algorithm to compute the Shortest path through a graph.
Description:
HARDWARE REQUIREMENTS: Intel based Desktop PC:- RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.

THEORY:
It is a static routing algorithm. It is used to build a graph of the subnet, with each node of graph representing a
router and each arc of the graph representing a communication line. To choose a route between a given pair of
routers, the algorithm just finds the shortest path between them on the graph. Different ways of measuring the
path length is the number of Hops, Geographical distance in kmts, Mean Queuing delay, Transmission delay,
Functions of distance, Bandwidth, Average traffic, communication cost etc.,
Several algorithms for computing the shortest path between two nodes of a graph are known. This one is due
to Dijkstra (1959). Each node is labeled (in parentheses) with its distance from the source node along the best
known path. Initially, no paths are known, so all nodes are labeled with infinity. As the algorithm proceeds
and paths are found, the labels may change, reflecting better paths. A label may be either tentative or
permanent. Initially, all labels are tentative. When it is discovered that a label represents the shortest possible
path from the source to that node, it is made permanent and never changed thereafter.
To illustrate how the labeling algorithm works, look at the weighted, undirected graph of Fig. (a), where the
weights represent, for example, distance. We want to find the shortest path from A to D. We start out by
marking node A as permanent, indicated by a filled-in circle. Then we examine, in turn, each of the nodes
adjacent to A (the working node), relabeling each one with the distance to A. Whenever a node is relabeled,
we also label it with the node from which the probe was made so that we can reconstruct the final path later.
Having examined each of the nodes adjacent to A, we examine all the tentatively labeled nodes in the whole
graph and make the one with the smallest label permanent, as shown in Fig. (b). This one becomes the new
working node.
We now start at B and examine all nodes adjacent to it. If the sum of the label on B and the distance from B to
the node being considered is less than the label on that node, we have a shorter path, so the node is relabeled.
After all the nodes adjacent to the working node have been inspected and the tentative labels changed if
possible, the entire graph is searched for the tentatively-labeled node with the smallest value. This node is
made permanent and becomes the working node for the next round. Figure shows the first five steps of the
algorithm.
To see why the algorithm works, look at Fig. (c). At that point we have just made E permanent. Suppose that
there were a shorter path than ABE, say AXYZE. There are two possibilities: either node Z has already been
made permanent, or it has not been. If it has, then E has already been probed (on the round following the one
when Z was made permanent), so the AXYZE path has not escaped our attention and thus cannot be a shorter
path.
Now consider the case where Z is still tentatively labeled. Either the label at Z is greater than or equal to that
at E, in which case AXYZE cannot be a shorter path than ABE, or it is less than that of E, in which case Z and
not E will become permanent first, allowing E to be probed from Z.
This algorithm is given in Fig. 5-8. The global variables n and dist describe the graph and are initialized before
shortest path is called. The only difference between the program and the algorithm described above is that in
Fig. 5-8, we compute the shortest path starting at the terminal node, t, rather than at the source node, s. Since
the shortest path from t to s in an undirected graph is the same as the shortest path from s to t, it does not
matter at which end we begin (unless there are several shortest paths, in which case reversing the search might
discover a different one). The reason for searching backward is that each node is labeled with its predecessor
rather than its successor. When the final path is copied into the output variable, path, the path is thus reversed.
By reversing the search, the two effects cancel, and the answer is produced in the correct order.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Figure: The first five steps used in computing the shortest path from A to D. The arrows indicate the working
node
Finally, Destination ‘D’ is relabeled as D (10, H). The path is (D-H-F-E-B-A) as follows:
D(10,H) = H(8,F)
= F(6,E)
= E(4,B)
= B(2,A)
= A
SOURCE CODE:
#include<stdio.h>
#include<stdlib.h>
#define MAX_NODES 1024
#define INFINITY 1000

int n=8,cost=0,dist[8][8]={{0,2,0,0,0,0,6,0},
{2,0,7,0,2,0,0,0},
{0,7,0,3,0,3,0,0},
{0,0,3,0,0,0,0,2},
{0,2,0,0,0,2,1,0},
{0,0,3,0,2,0,0,2},
{6,0,0,0,1,0,0,4},
{0,0,0,2,0,2,4,0}};

int shortest_dist(int s,int t,int path[])


{
int i,k,min;

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
struct state
{
int pre;
int length;
int label;
}state[1024];

struct state *p;

for(p=&state[0];p<&state[n];p++)
{
p->pre=-1;
p->length=INFINITY;
p->label=0;
}

state[0].length=0;
state[0].label=1;

state[0].pre=-1;
k=t;

do
{
for(i=0;i<n;i++)
if(dist[k][i]!=0 && state[i].label==0)
{
if(state[k].length+dist[k][i]<state[i].length)
{
state[i].pre=k;
state[i].length=state[k].length+dist[k][i];
}
}

k=0;
min=INFINITY;

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

if(state[i].label==0 && state[i].length<min)


{
min=state[i].length;
k=i;
}
state[k].label=1;

}while(k!=s);
i=0;
k=s;
do
{

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
path[i++]=k;
k=state[k].pre;
cost+=state[k].length;

}while(k>=0);
return i;
}

void main()
{
int i,j,m,path[102],q,p;

printf("\nEnter Number of nodes(1-8): ");


scanf("%d",&n);

printf("\nEnter Source Vertex(1-8): ");


scanf("%d",&p);

printf("\nEnter Destination vertex(1-8): ");


scanf("%d",&q);

m=shortest_dist(q-1,p-1,path);
for(i=0;i<m;i++)
{
printf(" %c-> ",path[i]+'A');

}
printf("\nCost is: %d \n",cost);
}

Output:
Enter Number of nodes(1-8): 7
Enter Source Vertex (1-8): 1
Enter Destination vertex(1-8): 7
G-> E-> B-> A->
Cost is: 6

Result:
Thus the program Implement Dijkstra ‘s algorithm to compute the Shortest path through a graph is
executed
Viva Question and Answers

1. What is the time complexity of Dijikstra’s algorithm?


Time complexity of Dijkstra’s algorithm is O(N2) because of the use of doubly nested for loops. It
depends on how the table is manipulated.

2. What happens when “While Q != 0” is changed to “while Q>1”?


In the normal execution of Dijkstra’s Algorithm, the while loop gets executed V times. The change
in the while loop statement causes it to execute only V – 1 times.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
3. Dijkstra’s Algorithm is the prime example for?
Dijkstra’s Algorithm is the prime example for greedy algorithms because greedy algorithms
generally solve a problem in stages by doing what appears to be the best thing at each stage.

4. Dijkstra’s Algorithm run on a weighted, directed graph G={V,E} with non-negative weight
function?
The equality d[u]=delta(s,u) holds good when vertex u is added to set S and this equality is
maintained thereafter by the upper bound property.

5. How Working of Dijkstra Algorithm?


Before diving into any algorithm, its very much necessary for us to understand what are the real world
applications of it. Majority of the problems that we encounter in real life scenarios deals with finding
solutions to shortest path based problems.
Following are the main applications of Dijkstra’s Algorithm:
1. It is most widely used in finding shortest possible distance and show directions between 2
geographical locations such as in Google Maps.
2. This is also widely used in routing of data in networking and telecommunication domains for
minimizing the delay occurred for transmission.
3. Wherever you encounter the need for shortest path solutions be it in robotics, transportation,
embedded systems, factory or production plants to detect faults, etc this algorithm is used.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-5
NAME OF THE EXPERIMENT: Broadcast Tree.
Aim: Take an example subnet of hosts. Obtain broadcast tree for it.
HARDWARE REQUIREMENTS: Intel based Desktop PC:- RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.

THEORY:
Sending a packet to all destinations simultaneously is called broadcasting. The set of optimal routes from a
source to all destinations form a tree rooted at the source. Such a tree is called a sink tree. It is illustrated in
Fig., where the distance metric is the number of hops. Note that a sink tree is not necessarily unique; other
trees with the same path lengths may exist. The goal of all routing algorithms is to discover and use the sink
trees for all routers

Figure: a) subnet b) sink tree for router B


A broadcast algorithm makes explicit use of the sink tree for the router initiating the broadcast. A sink tree is a
subset of the subnet that includes all the routers but contains no loops. If each router knows which of its lines
belong to the sink tree, it can copy an incoming broadcast packet onto all the sink tree lines except the one it
arrived on. This method makes excellent use of bandwidth, generating the absolute minimum number of
packets necessary to do the job. The only problem is that each router must have knowledge of some sink tree
for the method to be applicable.

SOURCE CODE:
#include<stdio.h>
#include<stdlib.h>
#define MAX_NODES 20
#define INFINITY 1000

void run_prim(int i,int num_nodes,int *hops);


int dist[MAX_NODES][MAX_NODES];
int path[MAX_NODES][MAX_NODES];
int main()
{
int num_nodes=0;
int i=0,j=0;
int path_len,hops[MAX_NODES];

printf("enter the number of nodes:");


scanf("%d",&num_nodes);
fflush(stdin);
printf("enter the connection matrix, 0 if not connected\n");
printf("otherwise,the distance\n");
for(;i<num_nodes;i++)
{
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
printf("enter the distances for node num:%d\n",i);
for(j=0;j<num_nodes;j++)
{
if(i==j)
{
dist[i][j]=0;
continue;
}
printf("distance from %d to %d= ",i,j);
scanf("%d",&dist[i][j]);
fflush(stdin);
if(dist[i][j]==0)
dist[i][j]=INFINITY;
}
}

printf("\nenter the root node");


scanf("%d",&i);
run_prim(i,num_nodes,hops);
for(j=0;j<num_nodes;j++)
{
for(i=0;i<hops[j];i++)
printf("->%d",path[j][i]);
printf("\n");
}
return 0;
}
void run_prim(int s,int n,int *hops)
{
struct state
{
int prev;
int length;
enum {perm,tent} label;
}state[MAX_NODES];
int i,j,k,min;
int count=0;
struct state *p;
for(p=&state[0];p<&state[n];p++)
{
p->prev= -1;
p->length= INFINITY;
p->label= tent;
}
state[s].length= 0;state[s].label= perm;
k=s;
do
{
for(i=0;i<n;i++)
if(dist[k][i]!=0&&state[i].label==tent)
{
if(state[k].length+dist[k][i]<state[i].length)
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
{
state[i].prev=k;
state[i].length=state[k].length+dist[k][i];
}
}
k=0;
min=INFINITY;
for(i=0;i<n;i++)
if(state[i].label==tent&&state[i].length<min)
{
min=state[i].length;
k=i;
}
state[k].label=perm;
count++;
}while(count<n);

for(j=0;j<n;j++)
{
i=0;k=j;
do
{
path[j][i++]=k;
k=state[k].prev;
}

while(k>=0);
hops[j]=i;
}
}

Output:

enter the number of nodes:4


enter the connection matrix, 0 if not connected, otherwise the distance
enter the distances for node num:0
distance from 0 to 1= 2
distance from 0 to 2= 1
distance from 0 to 3= 6
enter the distances for node num:1
distance from 1 to 0= 5
distance from 1 to 2= 1
distance from 1 to 3= 3
enter the distances for node num:2
distance from 2 to 0= 5
distance from 2 to 1= 1
distance from 2 to 3= 3
enter the distances for node num:3
distance from 3 to 0= 5
distance from 3 to 1= 4
distance from 3 to 2= 6
enter the root node2
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

->0->2
->1->2
->2
->3->2

Result:
Thus the program to obtain broadcast tree for an example subnet of hosts is executed.

Viva Question and Answers


1. What is Unicasting?
Uni-casting: If the message is sent to a single node from the source then it is known as unicasting. This is
commonly used in networks to establish a new connection.

2. What is Any-casting?
Any-casting: If the message is sent to any of the nodes from the source then it is known as anycasting. It is
mainly used to get the content from any of the servers in the Content Delivery System.

3. What is Multicasting?
Multicasting: If the message is sent to a subset of nodes from the source then it is known as multicasting.
Used to send the same data to multiple receivers.

4. What is Broadcasting?
Broadcasting: If the message is sent to all the nodes in a network from a source then it is known as
broadcasting. DHCP and ARP in the local network use broadcasting.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-6

NAME OF THE EXPERIMENT: Distance Vector routing.


Aim: Implement distance vector routing algorithm for obtaining routing tables at each node.
HARDWARE REQUIREMENTS: Intel based Desktop PC:- RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.

THEORY:

Each node constructs a one-dimensional array containing the "distances"(costs) to all other nodes and
distributes that vector to its immediate neighbors.
The starting assumption for distance-vector routing is that each node knows the cost of the link to each
of its directly connected neighbors.
A link that is down is assigned an infinite cost.
Example.

Information Distance to Reach Node


Stored at Node
A B C D E F G

A 0 1 1 � 1 1 �

B 1 0 1 � � � �

C 1 1 0 1 � � �

D � � 1 0 � � 1

E 1 � � � 0 � �

F 1 � � � � 0 1

G � � � 1 � 1 0
Table 1. Initial distances stored at each node(global view).
1. We can represent each node's knowledge about the distances to all other nodes as a table like the one
given in Table 1.
2. Note that each node only knows the information in one row of the table.
3. Every node sends a message to its directly connected neighbors containing its personal list of distance.
( for example, A sends its information to its neighbors B,C,E, and F. )
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
4. If any of the recipients of the information from A find that A is advertising a path shorter than the one
they currently know about, they update their list to give the new path length and note that they should
send packets for that destination through A. ( node B learns from A that node E can be reached at a cost of
1; B also knows it can reach A at a cost of 1, so it adds these to get the cost of reaching E by means
of A. B records that it can reach E at a cost of 2 by going through A.)
5. After every node has exchanged a few updates with its directly connected neighbors, all nodes will know
the least-cost path to all the other nodes.
6. In addition to updating their list of distances when they receive updates, the nodes need to keep track of
which node told them about the path that they used to calculate the cost, so that they can create their
forwarding table. ( for example, B knows that it was A who said " I can reach E in one hop" and so B puts
an entry in its table that says " To reach E, use the link to A.)

Information
Distance to Reach Node
Stored at Node

A B C D E F G

A 0 1 1 2 1 1 2

B 1 0 1 2 2 2 3

C 1 1 0 1 2 2 2

D 2 1 0 3 2 1

E 1 2 2 3 0 2 3
Table 2. final distances stored at each node ( global view).
In practice, each node's forwarding
F table
1 consists
2 of2a set 2of triples
2 of 0the form:1 ( Destination, Cost,
NextHop).

G complete routing 3table maintained


For example, Table 3 shows the 2 1 at node
3 B for
1 the network
0 in figure1.
Destination Cost NextHop

A 1 A

C 1 C

D 2 C

E 2 A

F 2 A

G 3 A
Table 3. Routing table maintained at node B.
SOURCE CODE:

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
#include<stdio.h>
struct node
{
unsigned dist[20];
unsigned from[20];
}rt[10];
int main()
{
int dmat[20][20];
int n,i,j,k,count=0;
printf("enter the number of nodes:");
scanf("%d",&n);
printf("enter the cost matrix :\n");

for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
scanf("%d",&dmat[i][j]);
dmat[i][i]=0;
rt[i].dist[j]=dmat[i][j];
rt[i].from[j]=j;
}
do
{
count=0;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
for(k=0;k<n;k++)
if(rt[i].dist[j]>dmat[i][k]+rt[k].dist[j])
{
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;
}

}while(count!=0);

for(i=0;i<n;i++)
for(j=0;j<n;j++)
{
printf("\n state value for router %d is\n",i+1);
for(j=0;j<n;j++)
{
printf("\n node %d via %d Distance %d", j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n");
}

Output:

enter the number of nodes:3


COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
enter the root matrix:
024
205
450
state value for router 1 is

node 1 via 1 distance 0


node 2 via 2 distance 2
node 3 via 3 distance 4

state value for router 2 is

node 1 via 1 distance 2


node 2 via 2 distance 0
node 3 via 3 distance 5

state value for router 3 is

node 1 via 1 distance 4


node 2 via 2 distance 5
node 3 via 3 distance 0

Result:
Thus the program for obtain Routing table art each node using distance vector routing algorithm is
executed.

Viva Question And Answers


1. What are Advantages of Distance Vector routing?
It is simpler to configure and maintain than link state routing.
2. What are Disadvantages of Distance Vector routing?
 It is slower to converge than link state.
 It is at risk from the count-to-infinity problem.
 It creates more traffic than link state since a hop count change must be propagated to all routers and
processed on each router. Hop count updates take place on a periodic basis, even if there are no
changes in the network topology, so bandwidth-wasting broadcasts still occur.

3. What Is Routing?
The ROUTING TABLE is a table maintained in the kernel that determines how packets are
routed to other systems. A number of programs may add or delete routes from the routing tables,
including route, ifconfig, in.routed and in.rdisc. The routing table consists of three types of routes:
HOST ROUTES are checked first and define a route to just one host. NETWORK ROUTES are
checked second and define a route to all the hosts on one network. DEFAULT ROUTES are used as a
catch-all, when no host or network routes are found to a destination. They usually send to a more
knowledgeable routing machine, which has a better chance of being able to find a host or network route
to the destination.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-7
AIM: Implement data encryption and data decryption
HARDWARE REQUIREMENTS: Intel based Desktop PC:- RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.

THEORY:
Data encryption and decryption
Encryption is the process of translating plain text data (plaintext) into something that appears to be
random and meaningless (ciphertext). Decryption is the process of converting ciphertext back to
plaintext.
To encrypt more than a small amount of data, symmetric encryption is used. A symmetric key is used
during both the encryption and decryption processes. To decrypt a particular piece of ciphertext, the
key that was used to encrypt the data must be used.
The goal of every encryption algorithm is to make it as difficult as possible to decrypt the generated
ciphertext without using the key. If a really good encryption algorithm is used, then there's no
technique significantly better than methodically trying every possible key. For such an algorithm, the
longer the key, the more difficult it is to decrypt a piece of ciphertext without possessing the key.
It's difficult to determine the quality of an encryption algorithm. Algorithms that look promising
sometimes turn out to be very easy to break, given the proper attack. When selecting an encryption
algorithm, it's a good idea to choose one that's been in use for several years, and has successfully
resisted all attacks.

SOURCE CODE:
#include <stdio.h>
int main()
{
int i, x;
char str[100];
printf("\nPlease enter a string:\t");
gets(str);
printf("\nPlease choose following options:\n");
printf("1 = Encrypt the string.\n");
printf("2 = Decrypt the string.\n");
scanf("%d", &x);

//using switch case statements


switch(x)
{
case 1:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] + 3; //the key for encryption is 3 that is added to ASCII value

printf("\nEncrypted string: %s\n", str);


break;

case 2:
for(i = 0; (i < 100 && str[i] != '\0'); i++)
str[i] = str[i] - 3; //the key for encryption is 3 that is subtracted to ASCII value

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
printf("\nDecrypted string: %s\n", str);
break;

default:
printf("\nError\n");
}
return 0;
}
}

OUTPUT:

Please enter a string:


SAIKIRAN

Please choose following options:


1 = Encrypt the string.
2 = Decrypt the string.
1
VDLNLUDQ

Please enter a string:


NETWORKS

Please choose following options:


1 = Encrypt the string.
2 = Decrypt the string.
2
KBQTLOHP

Viva Question and Answers

1. What is FDM?
FDM is an analog technique that can be applied when the bandwidth of a link is greater than the combined
bandwidths of the signals to be transmitted.
2. What is WDM?
WDM is conceptually the same as FDM, except that the multiplexing and de multiplexing involve light signals
transmitted through fiber optics channel.
3. What is TDM?
TDM is a digital process that can be applied when the data rate capacity of the transmission medium is greater than
the data rate required by the sending and receiving devices.
4. What is Synchronous TDM?
In STDM, the multiplexer allocates exactly the same time slot to each device at all times, whether or not a device has
anything to transmit.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-8
AIM : Write a program for congestion control using Leaky bucket algorithm.
HARDWARE REQUIREMENTS: Intel based Desktop PC :- RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.

The congesting control algorithms are basically divided into two groups: open loop and closed loop. Open
loop solutions attempt to solve the problem by good design, in essence, to make sure it does not occur in the
first place. Once the system is up and running, midcourse corrections are not made. Open loop algorithms are
further divided into ones that act at source versus ones that act at the destination.
In contrast, closed loop solutions are based on the concept of a feedback loop if there is any congestion.
Closed loop algorithms are also divided into two sub categories: explicit feedback and implicit feedback. In
explicit feedback algorithms, packets are sent back from the point of congestion to warn the source. In implicit
algorithm, the source deduces the existence of congestion by making local observation, such as the time
needed for acknowledgment to come back.
The presence of congestion means that the load is (temporarily) greater than the resources (in part of the
system) can handle. For subnets that use virtual circuits internally, these methods can be used at the network
layer.
Another open loop method to help manage congestion is forcing the packet to be transmitted at a more
predictable rate. This approach to congestion management is widely used in ATM networks and is called
traffic shaping.
The other method is the leaky bucket algorithm. Each host is connected to the network by an interface
containing a leaky bucket, that is, a finite internal queue. If a packet arrives at the queue when it is full, the
packet is discarded. In other words, if one or more process are already queued, the new packet is
unceremoniously discarded. This arrangement can be built into the hardware interface or simulate d by the
host operating system. In fact it is nothing other than a single server queuing system with constant service
time.
The host is allowed to put one packet per clock tick onto the network. This mechanism turns an uneven flow
of packet from the user process inside the host into an even flow of packet onto the network, smoothing out
bursts and greatly reducing the chances of congestion.

SOURCE CODE:
# #include<stdio.h>
#include<stdlib.h>
#define MIN(x,y) (x>y)?y:x
int main()
{
int orate,drop=0,cap,x,count=0,inp[10]={0},i=0,nsec,ch;
printf("\n enter bucket size : ");
scanf("%d",&cap);
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
printf("\n enter output rate :");
scanf("%d",&orate);
do{
printf("\n enter number of packets coming at second %d :",i+1);
scanf("%d",&inp[i]);
i++;
printf("\n enter 1 to contiue or 0 to quit..........");
scanf("%d",&ch);
}while(ch);
nsec=i;
printf("\n second \t recieved \t sent \t dropped \t remained \n");
for(i=0;count || i<nsec;i++)
{
printf(" %d",i+1);
printf(" \t%d\t ",inp[i]);
printf(" \t %d\t ",MIN((inp[i]+count),orate));
if((x=inp[i]+count-orate)>0)
{
if(x>cap)
{
count=cap;
drop=x-cap;
}
else
{
count=x;
drop=0;
}
}
else
{
drop=0;
count=0;
}
printf(" \t %d \t %d \n",drop,count);
}
return 0;
}
Output
enter bucket size : 50
enter output rate :120
enter number of packets coming at second 1 :200
enter 1 to contiue or 0 to quit..........1
enter number of packets coming at second 2 :85
enter 1 to contiue or 0 to quit..........0

Second received sent dropped remained


1 200 120 30 50
2 85 120 0 15
3 0 15 0 0

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
Viva Question and Answers

What is Leaky Bucket algorithm in computer networks?


When too many packets are present in the network it causes packet delay and loss of packet which degrades
the performance of the system. This situation is called congestion.
The network layer and transport layer share the responsibility for handling congestions. One of the most
effective ways to control congestion is trying to reduce the load that transport layer is placing on the network.
To maintain this, the network and transport layers have to work together.

With too much traffic, performance drops sharply.


There are two types of Congestion control algorithms, which are as follows −

 Leaky Bucket Algorithm


 Token Bucket Algorithm

Difference between Leaky and Token buckets –

Leaky Bucket Token Bucket

When the host has to send a packet , packet is In this leaky bucket holds tokens generated at regular
thrown in bucket. intervals of time.

Bucket leaks at constant rate Bucket has maximum capacity.

Bursty traffic is converted into uniform traffic If there is a ready packet , a token is removed from
by leaky bucket. Bucket and packet is send.

In practice bucket is a finite queue outputs at


finite rate If there is a no token in bucket, packet can not be send.
Advantage of token Bucket over leaky bucket –

 If bucket is full in token Bucket, tokens are discard not packets. While in leaky bucket, packets are discarded.
 Token Bucket can send Large bursts at a faster rate while leaky bucket always sends packets at constant rate.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS
EXPERIMENT-9
HARDWARE REQUIREMENTS: Intel based Desktop PC: - RAM of 512 MB
SOFTWARE REQUIREMENTS: Turbo C / Borland C.
AIM: Write a program for frame sorting technique used in buffers
Theory:
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.

SOURCE CODE:
#include<stdio.h>
struct frame{
int num;
char str[20];
};
struct frame arr[10];
int n;
void sort(){
int i,j;
struct frame temp;
for(i=0;i<n-1;i++)
for(j=0;j<n-i-1;j++)
if(arr[j].num>arr[j+1].num)
{ temp=arr[j];
arr[j]=arr[j+1];
arr[j+1]=temp;
}
}
int main()
{
int i;
system("clear");
printf("Enter the number of frames\n");
scanf("%d",&n);
printf("Enter the frame sequence number and frame contents\n");
for(i=0;i<n;i++)
scanf("%d%s",&arr[i].num,&arr[i].str);
sort();
printf("The frame in sequences\n");
for(i=0;i<n;i++)
printf("%d\t%s\n",arr[i].num,arr[i].str);
}

Output
Enter the number of frames
5
Enter the frame sequence number and frame contents
3
NETWORK LAYER
2
DATALINK LAYER
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS
5
APPLICATION LAYER
1
PHYSICAL LAYER
4
TRANSPORT LAYER

1 PHYSICAL LAYER
2 DATALINK LAYER
3 NETWORK LAYER
4 TRANSPORT LAYER
5 APPLICATION LAYER

Viva Question and Answers


Types of Framing
Framing can be of two types, fixed sized framing and variable sized framing.
Fixed-sized Framing
Here the size of the frame is fixed and so the frame length acts as delimiter of the frame.
Consequently, it does not require additional boundary bits to identify the start and end of the frame.
Example − ATM cells.
Variable – Sized Framing
Here, the size of each frame to be transmitted may be different. So additional mechanisms are kept
to mark the end of one frame and the beginning of the next frame.
It is used in local area networks.
Two ways to define frame delimiters in variable sized framing are −
 Length Field − Here, a length field is used that determines the size of the frame. It is used in
Ethernet (IEEE 802.3).
 End Delimiter − Here, a pattern is used as a delimiter to determine the size of frame. It is
used in Token Rings. If the pattern occurs in the message, then two approaches are used to
avoid the situation −
o Byte – Stuffing − A byte is stuffed in the message to differentiate from the delimiter.
This is also called character-oriented framing.
o Bit – Stuffing − A pattern of bits of arbitrary length is stuffed in the message to
differentiate from the delimiter. This is also called bit – oriented framing.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

EXPERIMENT-10
PACKET SNIFFING AND WIRESHARK
Wireshark

i. Packet Capture Using Wire shark


ii. Starting Wire shark
iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters

Introduction
Wireshark is a free open- source network protocol analyzer. It is used for network troubleshooting and
communication protocol analysis. Wireshark captures network packets in real time and display them in human-
readable format. It provides many advanced features including live capture and offline analysis, three-pane
packet browser, coloring rules for analysis. This document uses Wireshark for the experiments, and it covers
Wireshark installation, packet capturing, and protocol analysis.

Background

TCP/IP Network Stack

Figure 2: Encapsulation of Data in the TCP/IP Network Stack

- Application Layer: The application layer includes the protocols used by most applications for providing user

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

services. Examples of application layer protocols are Hypertext Transfer Protocol (HTTP), Secure Shell (SSH),
File Transfer Protocol (FTP), and Simple Mail Transfer Protocol (SMTP).
- Transport Layer: The transport layer establishes process-to-process connectivity, and it provides end-to-end
services that are independent of underlying user data. To implement the process-to-process communication, the
protocol introduces a concept of port. The examples of transport layer protocols are Transport Control Protocol
(TCP) and User Datagram Protocol (UDP). The TCP provides flow- control, connection establishment, and
reliable transmission of data, while the UDP is a connectionless transmission model.
- Internet Layer: The Internet layer is responsible for sending packets to across networks. It has two functions: 1)
Host identification by using IP addressing system (IPv4 and IPv6); and 2) packets routing from source to
destination. The examples of Internet layer protocols are Internet Protocol (IP), Internet Control Message
Protocol (ICMP), and Address Resolution Protocol (ARP).
- Link Layer: The link layer defines the networking methods within the scope of the local network link. It is used
to move the packets between two hosts on the same link.A common example of link layer protocols is Ethernet.

Packet Sniffer

Packet sniffer is a basic tool for observing network packet exchanges in a computer. As the name suggests, a
packet sniffer captures (“sniffs”) packets being sent/received from/by your computer; it will also typically store
and/or display the contents of the various protocol fields in these captured packets. A packet sniffer itself is
passive. It observes messages being sent and received by applications and protocols running on your computer,
but never sends packets itself.
Figure shows the structure of a packet sniffer. At the right of Figure are the protocols (in this case,
Internet protocols) and applications (such as a web browser or ftp client) that normally run on your computer.
The packet sniffer, shown within the dashed rectangle in Figure is an addition to the usual software in your
computer, and consists of two parts. The packet capture library receives a copy of every link-layer frame that is
sent from or received by your computer. Messages exchanged by higher layer protocols such as HTTP, FTP,
TCP, UDP, DNS, or IP all are eventually encapsulated in link-layer frames that are transmitted over physical
media such as an Ethernet cable. In Figure 1, the assumed physical media is an Ethernet, and so all upper-layer
protocols are eventually encapsulated within an Ethernet frame. Capturing all link-layer frames thus gives you
access to all messages sent/received from/by all protocols and applications executing in your computer.
The second component of a packet sniffer is the packet analyzer, which displays the contents of all fields
within a protocol message. In order to do so, the packet analyzer must “understand” the structure of all
messages exchanged by protocols. For example, suppose we are interested in displaying the various fields in
messages exchanged by the HTTP protocol in Figure. The packet analyzer understands the format of Ethernet
frames, and so can identify the IP datagram within an Ethernet frame. It also understands the IP datagram
format, so that it can extract the TCP segment within the IP datagram. Finally, it understands the TCP segment
structure, so it can extract the HTTP message contained in the TCP segment. Finally, it understands the HTTP
protocol and so, for example, knows that the first bytes of an HTTP message will contain the string “GET,”
“POST,” or “HEAD”.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Figure: Packet Sniffer Structure

We will be using the Wireshark packet sniffer [http://www.wireshark.org/] for these labs, allowing us to
display the contents of messages being sent/received from/by protocols at different levels of the protocol stack.
(Technically speaking, Wireshark is a packet analyzer that uses a packet capture library in your computer).
Wireshark is a free network protocol analyzer that runs on Windows, Linux/Unix, and Mac computers.

Getting Wireshark
Wireshark can be downloaded from here:
https://www.wireshark.org/download.html

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Figure 4: Download Page of Wireshark

Starting Wireshark

When you run the Wireshark program, the Wireshark graphic user interface will be shown as Figure 5.
Currently, the program is not capturing the packets.

Figure 5: Initial Graphic User Interface of Wireshark


Then, you need to choose an interface. If you are running the Wireshark on your laptop, you need to select WiFi
interface. If you are at a desktop, you need to select the Ethernet interface being used. Note that there could be
multiple interfaces. In general, you can select any interface but that does not mean that traffic will flow through
that interface. The network interfaces (i.e., the physical connections) that your computer has to the network are
shown. The attached Figure 6 was taken from my computer.
After you select the interface, you can click start to capture the packets as shown in Figure 7.

Figure 6: Capture Interfaces in Wireshark

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Figure 7: Capturing Packets in Wireshark

Figure 8: Wireshark Graphical User Interface on Microsoft Windows

The Wireshark interface has five major components:

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

The command menus are standard pulldown menus located at the top of the window. Of interest to us
now is the File and Capture menus. The File menu allows you to save captured packet data or open a file
containing previously captured packet data, and exit the Wireshark application. The Capture menu allows you
to begin packet capture.
The packet-listing window displays a one-line summary for each packet captured, including the packet
number (assigned by Wireshark; this is not a packet number contained in any protocol’s header), the time at
which the packet was captured, the packet’s source and destination addresses, the protocol type, and protocol-
specific information contained in the packet. The packet listing can be sorted according to any of these
categories by clicking on a column name. The protocol type field lists the highest- level protocol that sent or
received this packet, i.e., the protocol that is the source or ultimate sink for this packet.
The packet-header details window provides details about the packet selected (highlighted) in the
packet-listing window. (To select a packet in the packet-listing window, place the cursor over the packet’s one-
line summary in the packet-listing window and click with the left mouse button.). These details include
information about the Ethernet frame and IP datagram that contains this packet. The amount of Ethernet and IP-
layer detail displayed can be expanded or minimized by clicking on the right- pointing or down-pointing
arrowhead to the left of the Ethernet frame or IP datagram line in the packet details window. If the packet has
been carried over TCP or UDP, TCP or UDP details will also be displayed, which can similarly be expanded or
minimized. Finally, details about the highest-level protocol that sent or received this packet are also provided.
The packet-contents window displays the entire contents of the captured frame, in both ASCII and
hexadecimal format.
Towards the top of the Wireshark graphical user interface, is the packet display filter field, into which a
protocol name or other information can be entered in order to filter the information displayed in the packet-
listing window (and hence the packet-header and packet-contents windows). In the example below, we’ll use
the packet-display filter field to have Wireshark hide (not display) packets except those that correspond to
HTTP messages.

Capturing Packets

After downloading and installing Wireshark, you can launch it and click the name of an interface under
Interface List to start capturing packets on that interface. For example, if you want to capture traffic on the
wireless network, click your wireless interface.

Test Run
Do the following steps:
1.Start up the Wireshark program (select an interface and press start to capture packets).
2.Start up your favorite browser (Mozilla Firefox).
3.In your browser, go to Wayne State homepage by typing www.wayne.edu.
4.After your browser has displayed the http://www.wayne.edu page, stop Wireshark packet capture by
selecting stop in the Wireshark capture window. This will cause the Wireshark capture window to disappear
and the main Wireshark window to display all packets captured since you began packet capture see image
below:
5.Color Coding: You’ll probably see packets highlighted in green, blue, and black. Wireshark uses colors to
help you identify the types of traffic at a glance. By default, green is TCP traffic, dark blue is DNS traffic,
light blue is UDP traffic, and black identifies TCP packets with problems — for example, they could have
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

been delivered out-of-order.

6.You now have live packet data that contains all protocol messages exchanged between your computer and
other network entities! However, as you will notice the HTTP messages are not clearly shown because there
are many other packets included in the packet capture. Even though the only action you took was to open

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

your browser, there are many other programs in your computer that communicate via the network in the
background. To filter the connections to the ones we want to focus on, we have to use the filtering
functionality of Wireshark by typing “http” in the filtering field as shown below:

Notice that we now view only the packets that are of protocol HTTP. However, we also still do not have the
exact communication we want to focus on because using HTTP as a filter is not descriptive enough to allow us
to find our connection to http://www.wayne.edu. We need to be more precise if we want to capture the correct
set of packets.
7. To further filter packets in Wireshark, we need to use a more precise filter. By setting the
http.host==www.wayne.edu, we are restricting the view to packets that have as an http host the
www.wayne.edu website. Notice that we need two equal signs to perform the match “==” not just one. See the

screenshot below:

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

1. Now, we can try another protocol. Let’s use Domain Name System (DNS) protocol as an example here.

2. Let’s try now to find out what are those packets contain by following one of the conversations (also called
network flows), select one of the packets and press the right mouse button (if you are on a Mac use the
command button and click), you should see something similar to the screen below:

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Click on Follow UDP Stream, and then you will see following screen.

3. If we close this window and change the filter back to “http.host==www.wayne.edu” and then follow a packet

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

from the list of packets that match that filter, we should get the something similar to the following screens. Note
that we click on Follow TCP Stream this time.

Viva Questions And Answers

1. What is Wireshark?
Wireshark is a network protocol analyzer. It lets you capture and interactively browse the traffic
running on a computer network. It has a rich and powerful feature set and is world's most popular tool of its
kind. It runs on most computing platforms including Windows, macOS, Linux, and UNIX. Network
professionals, security experts, developers, and educators around the world use it regularly. It is freely
available as open source, and is released under the GNU General Public License version 2. It
is developed and maintained by a global team of protocol experts, and it is an example of a disruptive
technology.
Wireshark used to be known as Ethereal®. See the next question for details about the name change. If you're
still using Ethereal, it is strongly recommended that you upgrade to Wireshark as Ethereal is
unsupported and has known security vulnerabilities.

2. How would you setup wireshark to monitor packets passing through an internet router
A system on the network can be configured and setup with wireshark. The appropriate port on the
switch to which the system and internet router is connected can be configured for port mirroring. All packets
passing through the switch interface to the router can be mirrored to the system on which wireshark is setup.

3. Can wireshark be setup on a Cisco router


Wireshark is an executable. It can be setup on operating systems like windows and linux. It cannot be
setup on a Cisco router, as it runs a proprietary operating system on which additional tools or software cannot
be installed.

4. Is it possible to start wireshark from command line on Windows


Yes, it is possible to start using the appropriate executable on Windows which is wireshark.exe

5. A user is unable to ping a system on the network. How can wireshark be used to solve the problem.
Ping uses ICMP. Wireshark can be used to check if ICMP packets are being sent out from the
system. If it is sent out, it can also be checked if the packets are being received.

6. Which wireshark filter can be used to check all incoming requests to a HTTP Web server
HTTP web servers use TCP port 80. Incoming requests to the web server would have the destination
port number as 80. So the filter tcp.dstport==80.

7. Which wireshark filter can be used to monitor outgoing packets from a specific system on the network?
Outgoing packets would contain the IP address of the system as it’s source address. So assuming
that the IP address of the system is 192.168.1.2, the filter would be ip.src==192.168.1.2

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

8. What's up with the name change? Is Wireshark a fork?


In May of 2006, Gerald Combs (the original author of Ethereal) went to work for CACE
Technologies (best known for WinPcap). Unfortunately, he had to leave the Ethereal trademarks behind. This
left the project in an awkward position. The only reasonable way to ensure the continued success of the
project was to change the name. This is how Wireshark was born. Wireshark is
almost (but not quite) a fork. Normally a "fork" of an open source project results in two names, web sites,
development teams, support infrastructures, etc. This is the case with Wireshark except for one notable
exception -- every member of the core development team is now working on Wireshark. There has been no
active development on Ethereal since the name change. Several parts of the Ethereal web site (such as the
mailing lists, source code repository, and build farm) have gone offline.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

EXPERIMENT-11
How to run Nmap scan
HOW TO RUN A SIMPLE NMAP SCAN
1. Download the Nmap installer. This can be found for free from the developer’s website. It is highly
recommended that you download directly from the developer to avoid any potential viruses or fake files.
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.
2. Install Nmap. Run the installer once it is finished downloading. You will be asked which components you
would like to install. In order to get the full benefit of Nmap, keep all of these checked. Nmap will not install
any adware or spyware.
3. 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.
4. 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.
5. Choose your Profile. Profiles are preset groupings of modifiers that change what is scanned. The profiles
allow you to quickly select different types of scans without having to type in the modifiers on the command
line. Choose the profile that best fits your needs:
 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.
6. 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.
7. 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.
 Ports/Hosts - This tab will show the results of your port scan, including the services for those ports.
 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.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

EXPERIEMENT: 12
Operating System Detection using Nmap

OPERATING SYSTEM DETECTION USING NMAP

Syntax: nmap –O IPADDRESS

Ex: nmap –O 192.168.0.86

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Viva Questions and Answers

Q1. Write a ping scan command in Nmap.


Ans:

$nmap -sn <target>

Q2. Write a Nmap command to scan targets from a file.


Ans:

$nmap -iL <target-file>

<target-file> indicates list of IP

$cat <target-file>
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

192.168.1.1
192.168.1.10-100

Q3. How to write Nmap command for specific ports and services?
Ans:

$nmap -p80,443 <target>

#Scan ports 1 to 1000


$nmap -p1-1000 <target>

#Scan all ports


$nmap -p- <target>

$nmap -p snmp <target>

#using wildcard
$nmap -p snmp* <target>

Q4. How to scan a target using default scripts?


Ans:

nmap -sC <target>

-sC option runs default scripts against target


Q5. How to scan a target using a TCP SYN scan? List out advantages for the
same.
Ans:

$nmap -sS -p1-100 <target>

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

EXPERIMENT NO: 13
NAME OF THE EXPERIMENT: NS2 Simulator

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

Description:

NS2 Simulator-Introduction
1. NS2 stands for Network Simulator Version
2. It is an open-source event-driven simulator designedspecifically 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. Uses TCL as its scripting language.

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.

GETTING STARTED
Setting up the environment
A user using the NCTUns in single machine mode, needs to do the following steps before
he/she starts the GUI program:
1. Set up environment variables:
Before the user can run up the dispatcher, coordinator, or NCTUns GUI programhe/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 nctunsclient on terminal 3.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

After the above steps are followed, the starting screen of NCTUns disappears and the user is
presented with the working window as shown below:

i) 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.

Step1: Drawing topology


1. Select/click the HOST icon onthe toolbar and click the left mouse button on the editor,to place a
HOST1 on the editor.
Repeat the above procedure and place another host “HOST2” on the editor.
2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor,to place HUB1
on the editor.
3. Click on the LINK icon on the toolbar and connect HOST1 to HUB1 and HUB1 to HOST2
4. Click on the “E” icon on the toolbar to save the current topology
e.g: file1.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

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 toexit.
7. Click NODE EDITOR Button on the HOST window and select the MAC tab fromthe modal window
that pops up.
8. Select LOG STATISTICS and select checkboxes for Number of Drop Packetand Number of
Collisions in the MAC window
9. Click OK button on the MAC window to exit and once again click on the OK buttonon the HOST
window to exit.
Note: To set QUEUEsize
1. Double click the left mouse button while cursor is on HOST2 to open the HOST window.
2. Click NODE EDITOR Button on the HOST window and select the FIFO tab from the modal
window that pops up.
3. Change Queue size (Default 50).
4. Click OK button on the FIFO window to exit and once again click on the OK buttonon the HOST
window to exit.
5.
Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the dropdownlist 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.
v.
Changing configurationsChange1
1. Open the above file,
2. Do not change the topology or any other configuration,
3. Select E icon on thetoolbar
4. Reduce the bandwidth at link2 by double clicking the left mouse button while cursor ison link2
.(Change bandwidth on both tabs Uplink/Downlink)
5. Repeat Step3 (Simulate)

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Change 2
1. Open the above file.
2. Remove HUB and replace it with SWITCH.
3. Do not change anything in theconfiguration
4. Repeat Step3(Simulate)

ii) 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.

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,to place a
host on the editor.
Repeat the above procedure and place two other hosts “HOST2” and“HOST3” on the editor.
2. Select/click the HUB (or SWITCH) icon on the toolbar and click the left mouse button on the editor,
to place a HUB (or SWITCH) on theeditor.
3. Click on the LINK icon on the toolbar and connect HOST1 to HUB, HOST2 to HUB andHUB 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. Change simulation time from 0 to 20 for HOST1
3. Select Add button on the HOST1 window to invoke the command window and provide the following
command in the command textbox.
ttcp –t –u –s –p 8000 1.0.1.3
4. Click OK button onthe command window to exit
5. Click NODE EDITOR Button on the HOST window and select the MAC tab from the modal
window that pops up.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

6. Select LOG STATISTICS and select checkbox for output throughput in the MAC window
7. Click OK button on the MAC window to exit and once again click on the OK button on
the HOST window to exit.
8. Double click the left mouse button while cursor is on HOST2 to open the HOST window.
9. Change simulation time from 21 to 40 for HOST2
10. Select Add button on the HOST2 window to invoke the command window and provide the following
command in the command textbox.

stg –u 1024 100 1.0.1.3


11. Click OK button on the command window to exit
12. Click NODE EDITOR Button on the HOST window and select the MAC tab from themodal window
that pops up.
13. Select LOG STATISTICS and select checkbox for output throughput in the MAC window
14. Click OK button on the MAC window to exit and once again click on the OK button on the HOST
window to exit.
15. Double click the left mouse button while cursor is on HOST3 to open the HOST window.
16. Change simulation time from 0 to 20 for HOST3
17. Select Add button on the HOST window to invoke the command window and provide the following
command in the command textbox.
ttcp –r –u –s –p 8000
18. Click OK button on the command window to exit.
19. Change simulation time from21 to 40 for HOST3
20. Also add the following command on HOST3 rtg –u–
w log1
21. Click NODE EDITOR Button on the HOST window and select the MAC tab from themodal window
that pops up.
22. Select LOG STATISTICS and select checkbox for input and output throughput in the MAC window
23. 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 dropdownlist 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 open input and
output throughput log files in separate TERMINAL window.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

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

Step1: Drawing topology


1. Select/click the SUBNET icon on the toolbar and click the left mouse button on the editor, to place a
SUBNET on the editor.
2. A pop up window appears requesting the number of nodes and radius for the subnet
Set number of nodes=6; Set radius of subnet >150

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

Step2: Configuration
1. Make 5 HOST as sender and make 1 HOST as receiver and give the commands with particular port
number
2. Sender Commands
Sender 1 : stcp –p 21 –l 1024 1.0.1.1
Sender 2 : stcp –p 22 –l 1024 1.0.1.1
Sender 3 : stcp –p 23 –l 1024 1.0.1.1
Sender 4 : stcp –p 24 –l 1024 1.0.1.1
Sender 5 : stcp –p 25 –l 1024 1.0.1.1
Receiver Commands
rtcp –p 21 –l 1024
rtcp –p 22 –l 1024
rtcp –p 23 –l 1024
rtcp –p 24 –l 1024
rtcp –p 25 –l 1024
3. For each sender HOST select the Out through put, Collision and Droppackets.
4. For receiver HOST select the In throught put, Collision and Drop packets.
5.
Step3: Simulate
i. Click “R” icon on the tool bar
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

ii. Select Simulation in the menu bar and click/ select RUN in the dropdown list to execute the
simulation.
iii. During simulation, double click the mouse button on any sender HOST, the HOST window pops
up, select / click on command console button located atthe bottom.
iv. A terminal window appears, type ping IP address of a receiver HOST in the subnet atthe command
prompt.
v. To view results, Open up new TERMINAL window, move to file4.results folder andopen drop and
collision log files in separate TERMINAL window.
vi.
iv) Simulate an ETHERNET LAN using n nodes (6-10), change error rate and data rate
and compare throughput.

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.
i. Repeat the above procedure and place 5 other hosts “HOST2”, “HOST3”, “HOST4”, “HOST5”, and
“HOST6”on the editor.
2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor, to place
HUB1 on the editor.
Repeat the above procedure and place another host “HUB2” on the editor
3. Click on the LINK icon on the toolbar and connect HOST1, HOST2 and HOST3 to HUB1, HOST4,
HOST5 and HOST6toHUB2.
4. Select/click the SWITCH icon on the toolbar and click the left mouse button on the editor, to place
SWITCH1 on theeditor.
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 currenttopology
e.g: file5.tpl
(Look for the ******.tpl extension.)

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

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1to open theHOST window.
2. Select Add button on the HOST window to invoke the command window and provide the following
command in the command textbox.
ttcp –t –u –s –p 8001 1.0.1.4 (Split time from 0 to 10)
3. Change error rate and data rate in the physical layer and selectOut throughput in MAC layer
4. Click OK button on the command window to exit and once againclick on the OK button on the
HOST window to exit.
5. Repeat this step at HOST 2 and HOST3 by changing port number& IP address of receiver. Change
error rate and data rate.
ttcp –t –u –s –p 8002 1.0.1.5 (Split time from 11 to 20)
ttcp –t –u –s –p 8003 1.0.1.6 (Split time from 21 to 30)
5. Double click the left mouse button while cursor is on HOST4to open theHOST window.
6. Select Add button on the HOST window to invoke the commandwindow and provide the following
command in the command textbox.
ttcp –r –u –s –p 8001(Split time from 0 to 10)
7. Change error rate and data rate in the physical layer and selectIN throughput in MAC layer
8. Repeat this step at HOST 5 and HOST6, but use different commands. Change error rate and data
rate.
ttcp –r –u –s –p 8002(Split time from 11 to 20)ttcp –r –u –s –p 8003(Split time from 21 to 30)

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. To view results,
Open up new TERMINAL window, move to file5.results folder and open output throughput log
files in separate TERMINAL window.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

v) Simulate an ETHERNET LAN using n nodes and set multiple traffic nodes and plot
congestion window for different source/destination.

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.
i. Repeat the above procedure and place 3 other hosts “HOST2”, “HOST3”, “HOST4”, “HOST5”, and
“HOST6”on the editor.
2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor, to place
HUB1 on the editor.
Repeat the above procedure and place another host “HUB2” on the editor
3. Click on the LINK icon on the toolbar and connect HOST1, HOST2 and HOST3 to HUB1, HOST4,
HOST5 and HOST6 to HUB2.
4. Select/click the SWITCH icon on the toolbar and click the left mousebutton on the editor, to place
SWITCH1 the editor.
5. Click on the LINK icon on the toolbar and connect HUB1 to SWITCH1 and HUB2 to SWITCH1.
Click on the “E” icon on the toolbar to save the current topology e.g:
file7.tpl (Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selectingthe “E” icon.

Step2: Configuration

1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Select Add button on the HOST window to invoke the command window and provide the following
command in the command textbox.
ttcp –t –u –s –p 8001 1.0.1.4
3. Click OK button on the command window to exit and once againclick on the OK button on the
HOST window to exit.
4. Repeat this step at HOST 2 and HOST3 by changing port number & IP address of receiver. Change
error rate and data rate.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

ttcp –t –u –s –p 8002 1.0.1.5


ttcp –t –u –s –p 8003 1.0.1.6
5. Select Outthroughput, Collision & Drop in MAC layer for allsenders
6. Double click the left mouse button while cursor is on HOST4 to open the HOST window.
7. Select Add button on the HOST window to invoke the command window and provide the following
command in the command textbox.
ttcp –r –u –s –p 8001
8. Repeat this step at HOST 5 and HOST6, but use differentcommands. Change error rate and data rate.
ttcp –r –u –s –p 8002ttcp –r –u –s –p 8003
9. select Inthroughput, Collision & Drop in MAC layer for all receivers

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

vi) Simulate simple BSS and with transmitting nodes in wireless LAN by simulation and
determine the performance with respect to transmission of packets.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Step1: Drawing topology


1. Select/click the HOST icon on the toolbar and click the left mouse button onthe editor, to place
HOST1 on the editor.
2. Select/click the ROUTER icon on the toolbar and click the left mouse buttonon the editor, to place
ROUTER1 on the editor.
3. Select/click the WIRELESS ACCESS POINT(802.11b) icon on the toolbar and click the left mouse
button on the editor, to place ACCESS POINT 1 ontheeditor.
Repeat this procedure and place ACCESS POINT 2 on the editor.
4. Select/click the MOBILE NODE (infrastructure mode) icon on the toolbar and click the left mouse
button on the editor, to place MOBILE NODE 1 onthe editor. Repeat this procedure and place
MOBILE NODE 2, MOBILE NODE3 and MOBILE NODE 4 on the editor.
5. Click on the LINK icon on the toolbar and connect ACCESS POINT1 to ROUTER1 and ACCESS
POINT2 to ROUTER1
6. Click on the “Create a moving path” icon on the toolbar and draw movingpath across MOBILE
NODE 1 and 2, Repeat for MOBILE NODE 3and 4 (Accept the default speed value 10 and close
the window, Click the right mouse button to terminate the path).

To create Subnet
7. Select wireless subnet icon in the toolbar now select MOBILE NODE1, MOBILE NODE2 and
ACCESS POINT1 by clicking on left mouse button, and clicking right mouse button will create a
subnet.
8. Repeat the above step for MOBILE NODE3, MOBILE NODE4 and ACCESS POINT2.
9. Click on the “E” icon on the toolbar to save the current topology e.g:
file8.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.

Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST window.
2. Select Add button on the HOST window to invoke the command window and providethe following
command in the command textbox.
ttcp –r –u –s –p 8001
3. Click OK button onthe command window to exit
4. Repeat this step and add the following commands at HOST1ttcp –r –u –s –p 8002
ttcp –r –u –s –p 8003ttcp –r –u –s –p 8004 ttcp –r –u –s –p 8005
5. Click NODE EDITOR Button on the HOST1 window and select the MACtab from the modal
window that pops up.
6. Select LOG STATISTICS and select checkbox for Input throughput in the MAC window
7. Click OK button on the MAC window to exit and once again click on theOK button on the HOST
window to exit.
COMPUTER NETWORKS LAB
CMR Engineering College CSE-DS

8. Double click the left mouse button while cursor is on MOBILE NODE 1 to open the MOBILE
NODE window.
9. Select Application tab and select Add button to invoke the command window and provide the
following command in the command textbox.
ttcp –t –u –s –p 8001 1.0.2.2 (host’s ip address)
10. Click NODE EDITOR Button on the MOBILE NODE1 window andselect the MAC tab
from the nodal window that pops up.
11. Select LOG STATISTICS and select checkbox for Output throughput in the MACwindow
12. Click OK button on the MAC window to exit and once again click onthe OK button onthe
MOBILE NODE1 window to exit.
13. Repeat the above steps (step 8 to step12) for the MOBILE NODE2,3 and4 and add
thefollowing commands at
MOBILE NODE2:- ttcp –t –u –s –p 8002 1.0.2.2 MOBILE NODE 3:- ttcp –t–u –s –p 8003
1.0.2.2 MOBILE NODE4:- ttcp –t –u –s –p 8004 1.0.2.2
14. Double click the left mouse button while cursor is on ROTER1 to open the ROUTER
window.
15. Click NODE EDITOR Button on the ROUTER1 window and you can see three stacks.
two stacks for two ACCESS POINTS and another stackfor HOST1 which is connected to the
ROUTER1.
16. Select the MAC tab of ACCESS POINT1 and Select LOG STATISTICS and select
checkbox for Input throughput in the MAC window. Click OK button on the MAC window to exit.
17. Select the MAC tab of ACCESS POINT2 and Select LOG STATISTICS and select
checkbox for Input throughput in the MAC window. Click OK button on the MAC window to exit.
18. Select the MAC tab of HOST1 and Select LOG STATISTICS and select checkbox
forOutput throughput in the MAC window. Click OK button onthe MAC window to exit.
19. Add the following command for router
ttcp –t –u –s –p 8005 1.0.2.2 (host’s ip address)

Step3: Simulate
I Click “R” icon on the tool bar
.
I Select Simulation in the menu bar and click/ select
I RUN in the
.
dropdown list to execute the simulation.
III. To start playback select “►” icon located at the bottom right corner of theeditor.
IV. MOBILE NODE’s start moving across the paths alreadydrawn.

COMPUTER NETWORKS LAB


CMR Engineering College CSE-DS

Viva Questions and Answers


1. What is NS2 network simulation?
Network simulation (NS) is one of the types of simulation, which is used to simulate the networks
such as in MANETs, VANETs, etc. It provides simulation for routing and multicast protocols for
both wired and wireless networks. NS is licensed for use under version 2 of the GNU (General
Public License) and is popularly known as NS2

2. What is the use of NS in Java simulator?


set ns [new Simulator] The simulator object has member functions which enables to create the
nodes and define the links between them. The class simulator contains all the basic functions. Since
ns was defined to handle the Simulator object, the command $ns is used for using the functions
belonging to the simulator class

3. What is the use of C++ in ns2?


In ns2, C++ is used for detailed protocol implementation and Otcl is used for the setup. The
compiled C++ objects are made available to the Otcl interpreter and in this way, the ready-made
C++ objects can be controlled from the OTcl level. Nam is also needed to install.

COMPUTER NETWORKS LAB

You might also like