0% found this document useful (0 votes)
6 views56 pages

CN - Lab - Manual CSM

The document is a lab record for Computer Networks at Avanthi's St. Theressa Institute of Engineering & Technology, detailing various experiments related to networking concepts and protocols. It includes a certificate section, an index of experiments, and detailed descriptions of network devices, programming tasks for data link layer methods, and checksum implementation. The lab focuses on practical applications of networking principles in a Bachelor of Technology program for Computer Science Engineering (AI&ML).

Uploaded by

Sirela Meena
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)
6 views56 pages

CN - Lab - Manual CSM

The document is a lab record for Computer Networks at Avanthi's St. Theressa Institute of Engineering & Technology, detailing various experiments related to networking concepts and protocols. It includes a certificate section, an index of experiments, and detailed descriptions of network devices, programming tasks for data link layer methods, and checksum implementation. The lab focuses on practical applications of networking principles in a Bachelor of Technology program for Computer Science Engineering (AI&ML).

Uploaded by

Sirela Meena
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/ 56

AVANTHI’S ST.

THERESSA INSTITUTE OF ENGINEERING & TECHNOLOGY


GARIVIDI
Vizianagaram Dist (AP)

COMPUTER NETWORKS LAB RECORD

R20 CSE (AI&ML)

SEMISTER : III-II

BACHELOR OF TECHNOLOGY
IN
COMPUTER SCIENCE ENGINEERING (AI&ML)
III-II CSE (AI&ML) PAGE NO:

AVANTHI’S ST.THERESSA INSTITUTE OF ENGINEERING & TECHNOLOGY


GARIVIDI
Vizianagaram Dist (AP)

CERTIFICATE
This is certify that is the bona fide record of the work done in_______________________________

Laboratory by Mr./Ms________________________________________________________________

Bearing Regd.No./Roll no_____________________________ of______________________________

Course during_______________________________________________________________________

Total Number of Total Number of


Experiments held______________ Experiments done_____________

LAB INCHARGE HEAD OF THE DEPARTMENT

EXTERNAL EXAMINAR

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

INDEX

SNO DATE EXPERIMENTS PAGE NO REMARKS

Study of Network devices in detail and connect


1
the computers in Local Area Network

Write a Program to implement the data link


2 layer farming methods such as
i) Character stuffing ii) bit stuffing
Write a Program to implement data link layer
3 farming method checksum

Write a program for Hamming Code generation


4
for error detection and correction

Write a Program to implement on a data set


5
of characters the three CRC polynomials –
CRC 12, CRC 16 and CRC CCIP
Write a Program to implement Sliding
6
window protocol for Goback N
Write a Program to implement Sliding window
7
protocol for Selective repeat
Write a Program to implement Stop and
8
Wait Protocol
Write a program for congestion control using
9
leaky bucket algorithm

Write a Program to implement Dijkstra‘s


10
algorithm to compute the Shortest path
through a graph.
Write a Program to implement Distance vector
routing algorithm by obtaining routing table at
11 each node

(Take an example subnet graph with weights


indicating delay between nodes)
Write a Program to implement Broadcast tree
12
by taking subnet of hosts

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Wireshark
i. Packet Capture Using Wire shark
13 ii. Starting Wire shark
iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters

14 How to run Nmap scan

15 Operating System Detection using Nmap


Do the following using NS2 Simulator
i. NS2 Simulator-Introduction
ii. Simulate to Find the Number of Packets Dropped
16 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

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-1
AIM: Study of Network devices in detail and connect the computers in Local Area Network.

Network Devices: Network devices, also known as networking hardware, are physical
devices that allow hardware on a computer network to communicate and interact with one
another. For example Repeater, Hub, Bridge, Switch, Routers, Gateway and NIC, etc.

1. Repeater – A repeater operates at the physical layer. Its job is to regenerate the signal over
the same network before the signal becomes too weak or corrupted to extend the length to
which the signal can be transmitted over the same network. An important point to be noted
about repeaters is that they not only amplify the signal but also regenerate it. When the
signal becomes weak, they copy it bit by bit and regenerate it at its star topology connectors
connecting following the original strength. It is a 2-port device.

2. Hub – A hub is a basically multi-port repeater. A hub connects multiple wires coming from
different branches, for example, the connector in star topology which connects different
stations. Hubs cannot filter data, so data packets are sent to all connected devices. In other
words, the collision domain of all hosts connected through Hub remains one. Also, they do
not have the intelligence to find out the best path for data packets which leads to
inefficiencies and wastage.

Types of Hub

 Active Hub:- These are the hubs that have their power supply and can clean, boost, and
relay the signal along with the network. It serves both as a repeater as well as a wiring
center. These are used to extend the maximum distance between nodes.

 Passive Hub:- These are the hubs that collect wiring from nodes and power supply from
the active hub. These hubs relay signals onto the network without cleaning and boosting
them and can’t be used to extend the distance between nodes.

 Intelligent Hub:- It works like an active hub and includes remote management
capabilities. They also provide flexible data rates to network devices. It also enables an
administrator to monitor the traffic passing through the hub and to configure each port in
the hub.

3. Bridge – A bridge operates at the data link layer. A bridge is a repeater, with add on the
functionality of filtering content by reading the MAC addresses of the source and
destination. It is also used for interconnecting two LANs working on the same protocol. It
has a single input and single output port, thus making it a 2 port device.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
Types of Bridges

 Transparent Bridges:- These are the bridge in which the stations are completely unaware
of the bridge’s existence i.e. whether or not a bridge is added or deleted from the network,
reconfiguration of the stations is unnecessary. These bridges make use of two processes i.e.
bridge forwarding and bridge learning.

 Source Routing Bridges:- In these bridges, routing operation is performed by the source
station and the frame specifies which route to follow. The host can discover the frame by
sending a special frame called the discovery frame, which spreads through the entire
network using all possible paths to the destination.

4. Switch – A switch is a multiport bridge with a buffer and a design that can boost its
efficiency(a large number of ports imply less traffic) and performance. A switch is a data
link layer device. The switch can perform error checking before forwarding data, which
makes it very efficient as it does not forward packets that have errors and forward good
packets selectively to the correct port only. In other words, the switch divides the collision
domain of hosts, but the broadcast domain remains the same.

Types of Switches

 Unmanaged switches: These switches have a simple plug-and-play design and do not
offer advanced configuration options. They are suitable for small networks or for use as
an expansion to a larger network.

 Managed switches: These switches offer advanced configuration options such as VLANs,
QoS, and link aggregation. They are suitable for larger, more complex networks and allow
for centralized management.

 Smart switches: These switches have features similar to managed switches but are
typically easier to set up and manage. They are suitable for small- to medium-sized
networks.

 PoE switches: These switches have Power over Ethernet capabilities, which allows them
to supply power to network devices over the same cable that carries data.

 Gigabit switches: These switches support Gigabit Ethernet speeds, which are faster than
traditional Ethernet speeds.

 Rack-mounted switches: These switches are designed to be mounted in a server rack and
are suitable for use in data centers or other large networks.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

 Desktop switches: These switches are designed for use on a desktop or in a small office
environment and are typically smaller in size than rack-mounted switches.

 Modular switches: These switches have modular design, which allows for easy expansion
or customization. They are suitable for large networks and data centers.

5. Routers – A router is a device like a switch that routes data packets based on their IP
addresses. The router is mainly a Network Layer device. Routers normally connect LANs
and WANs and have a dynamically updating routing table based on which they make
decisions on routing the data packets. The router divides the broadcast domains of hosts
connected through it.

6. Gateway – A gateway, as the name suggests, is a passage to connect two networks that may
work upon different networking models. They work as messenger agents that take data from
one system, interpret it, and transfer it to another system. Gateways are also called protocol
converters and can operate at any network layer. Gateways are generally more complex than
switches or routers. A gateway is also called a protocol converter.

7. Brouter – It is also known as the bridging router is a device that combines features of both
bridge and router. It can work either at the data link layer or a network layer. Working as a
router, it is capable of routing packets across networks and working as the bridge, it is
capable of filtering local area network traffic.

8. NIC – NIC or network interface card is a network adapter that is used to connect the
computer to the network. It is installed in the computer to establish a LAN. It has a unique
id that is written on the chip, and it has a connector to connect the cable to it. The cable acts
as an interface between the computer and the router or modem. NIC card is a layer 2 device
which means that it works on both the physical and data link layers of the network model.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-2
AIM: Write a Program to implement the data link layer farming methods such as
i) Character stuffing ii) bit stuffing.
i) Character Stuffing:
SOURCE CODE:
#include<stdio.h>
#include<string.h>
int main()
{
char a[30], b[30], c[30];
int len, i, j = 0, k = 0;
printf("Enter the string: ");
gets(a);
len = strlen(a);
printf("The frames after stuffing:\n");
printf("dlestx\t");
for (i = 0; i < len; i++)
{
if ((a[i] == 'd' && a[i + 1] == 'l' && a[i + 2] == 'e') ||
(a[i] == 's' && a[i + 1] == 't' && a[i + 2] == 'x') ||
(a[i] == 'e' && a[i + 1] == 't' && a[i + 2] == 'x'))
{
b[j++] = 'D';
b[j++] = 'L';
b[j++] = 'E';
b[j++] = a[i];
b[j++] = a[i + 1];
b[j++] = a[i + 2];
i += 2;
}

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
else {
b[j++] = a[i];
}}
for (i = 0; i < j; i++)
{
printf("%c", b[i]);
}
printf("\tdleetx\n");
printf("The character destuffing is: ");
for (i = 0; i < j; i++)
{
if (b[i] == 'D' && b[i + 1] == 'L' && b[i + 2] == 'E')
{
i += 3;
}
else {
c[k++] = b[i];
}}
for (i = 0; i < k; i++)
{
printf("%c", c[i]);
}
return 0;
}

OUTPUT:
Enter the string: IAMLOVINGYOU
The frames after stuffing:
dlestx IAMLOVINGYOU dleetx
The character destuffing is: IAMLOVINGYOU

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

ii) Bit Stuffing


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
{

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
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

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-3
AIM: Write a Program to implement data link layer farming method checksum.
SOURCE CODE:
#include <stdio.h>
#include <string.h>
int main()
{
char a[20], b[20];
char sum[20], complement[20];
int i, length;
printf("Enter first binary string\n");
scanf("%s", a);
printf("Enter second binary string\n");
scanf("%s", b);
if (strlen(a) == strlen(b))
{
length = strlen(a);
char carry = '0';
for (i = length - 1; i >= 0; i--)
{
if (a[i] == '0' && b[i] == '0' && carry == '0')
{
sum[i] = '0';
carry = '0';
}
else if (a[i] == '0' && b[i] == '0' && carry == '1')
{
sum[i] = '1';
carry = '0';
}

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
else if (a[i] == '0' && b[i] == '1' && carry == '0')
{
sum[i] = '1';
carry = '0';
}
else if (a[i] == '0' && b[i] == '1' && carry == '1')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '0' && carry == '0')
{
sum[i] = '1';
carry = '0';
}
else if (a[i] == '1' && b[i] == '0' && carry == '1')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '1' && carry == '0')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '1' && carry == '1')
{
sum[i] = '1';
carry = '1';
}

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
else
{
break;
}
}
if (carry == '1')
{
strcpy(a, sum);
b[length - 1] = '1';
for (i = length - 2; i >= 0; i--)
{
b[i] = '0';
}
carry = '0';
for (i = length - 1; i >= 0; i--)
{
if (a[i] == '0' && b[i] == '0' && carry == '0')
{
sum[i] = '0';
carry = '0';
}
else if (a[i] == '0' && b[i] == '0' && carry == '1')
{
sum[i] = '1';
carry = '0';
}
else if (a[i] == '0' && b[i] == '1' && carry == '0')
{
sum[i] = '1';
carry = '0';

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
}
else if (a[i] == '0' && b[i] == '1' && carry == '1')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '0' && carry == '0')
{
sum[i] = '1';
carry = '0';
}
else if (a[i] == '1' && b[i] == '0' && carry == '1')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '1' && carry == '0')
{
sum[i] = '0';
carry = '1';
}
else if (a[i] == '1' && b[i] == '1' && carry == '1')
{
sum[i] = '1';
carry = '1';
}
else
{
break;
}

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
}}
printf("\nSum=%s", sum);
for (i = 0; i < length; i++)
{
if (sum[i] == '0')
{
complement[i] = '1';
}
else
{
complement[i] = '0';
}
}
printf("\nChecksum=%s", complement);
}
else
{
printf("\nWrong input strings");
}
return 0;
}

OUTPUT:
Enter first binary string
1011
Enter second binary string
1100

Sum=1000
Checksum=0111

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-4
AIM: Write a program for Hamming Code generation for error detection and correction.
SOURCE CODE:
#include<stdio.h>
void main()
{
int data[10];
int dataatrec[10],c,c1,c2,c3,i;
printf("Enter 4 bits of data one by one\n");
scanf("%d",&data[0]);
scanf("%d",&data[1]);
scanf("%d",&data[2]);
scanf("%d",&data[4]);
data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4];
data[3]=data[0]^data[1]^data[2];
printf("\nEncoded data is\n");
for(i=0;i<7;i++) {
printf("%d",data[i]);
}
printf("\n\nEnter received data bits one by one\n");
for(i=0;i<7;i++) {
scanf("%d",&dataatrec[i]);
}
c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];
c2=dataatrec[5]^dataatrec[4]^dataatrec[1]^dataatrec[0];
c3=dataatrec[3]^dataatrec[2]^dataatrec[1]^dataatrec[0];
c=c3*4+c2*2+c1 ;
if(c==0)
{

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
printf("\nNo error while transmission of data\n");
}
else{
printf("\nError on position %d",c);
}
printf("\nData sent : ");
for(i=0;i<7;i++) {
printf("%d",data[i]);
}
printf("\nData received : ");
for(i=0;i<7;i++) {
printf("%d",dataatrec[i]);
}
printf("\nCorrect message is\n");
if(dataatrec[7-c]==0)
dataatrec[7-c]=1;
else
dataatrec[7-c]=0;
for (i=0;i<7;i++) {
printf("%d",dataatrec[i]);
}}

OUTPUT:
Enter 4 bits of data one by one
1
0
1
0
Encoded data is
1010010

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-5
AIM: Write a Program to implement on a data set of characters the three CRC polynomials –
CRC 12, CRC 16 and CRC CCIP.

SOURCE CODE:
#include<stdio.h>
#include<string.h>
int main()
{
int i, j, keylen, msglen, msglen1;
char input[100], key[30], temp[30], quot[100], rem[30], key1[30], r[100];
printf("Enter Data: ");
gets(input);
printf("Enter Key: ");
gets(key);
keylen = strlen(key);
msglen = strlen(input);
strcpy(key1, key);
for (i = 0; i < keylen - 1; i++)
{
input[msglen + i] = '0';
}
printf("After adding 0's in the input is: ");
for (i = 0; i < msglen + keylen - 1; i++)
{
temp[i] = input[i];
printf("%c", input[i]);
}
for (i = 0; i < keylen; i++)
{
temp[i] = input[i];

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
}
for (i = 0; i < msglen; i++)
{
quot[i] = temp[0];
if (quot[i] == '0')
{
for (j = 0; j < keylen; j++)
{
key[j] = '0';
}}
else
{
for (j = 0; j < keylen; j++)
{
key[j] = key1[j];
}}
for (j = keylen - 1; j > 0; j--)
{
if (temp[j] == key[j])
{
rem[j - 1] = '0';
}
else
{
rem[j - 1] = '1';
}}
rem[keylen - 1] = input[i + keylen];
strcpy(temp, rem);
}
strcpy(rem, temp);

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
printf("\nQuotient is: ");
for (i = 0; i < msglen; i++)
{
printf("%c", quot[i]);
}
printf("\nRemainder is: ");
for (i = 0; i < keylen - 1; i++)
{
printf("%c", rem[i]);
}
printf("\nTransmitted data is: ");
for (i = 0; i < msglen; i++)
{
printf("%c", input[i]);
}
for (i = 0; i < keylen - 1; i++)
{
printf("%c", rem[i]);
}
rem[i] = '\0';
quot[i] = '\0';
printf("\nEnter the received data: ");
gets(r);
msglen1 = strlen(r);
for (i = 0; i < msglen1; i++)
{
for (j = 0; j < keylen; j++)
{
if (r[j] == key1[j])
{

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
rem[j] = '0';
}
else
{
rem[j] = '1';
}}}
for (i = 0; i < msglen1; i++)
{
if (rem[i] == '0')
{
printf("Success\n");
break;
}
else {
printf("ERROR\n");
break;
}}
return 0;
}

OUTPUT:
Enter Data: 1101011011
Enter Key: 10011
After adding 0's in the input is: 11010110110000
Quotient is: 1100001010
Remainder is: 1110
Transmitted data is: 11010110111110
Enter the received data: 11010110111110
Success

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-6
AIM: Write a Program to implement Sliding window protocol for Goback N.
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 received.\n");
scanf("%d",&ack);
if(ack == windowsize)
break;
else
sent = ack;
}
return 0;
}

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

OUTPUT:
enter window size
5
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.

Please enter the last Acknowledgement received.


2
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.

Please enter the last Acknowledgement received.


5

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-7
AIM: Write a Program to implement Sliding window protocol for Selective repeat.
SOURCE CODE:
#include<stdio.h>
int main()
{
int windowsize,sent=0,nack[10],neg,i;
printf("enter window size\n");
scanf("%d",&windowsize);
for( i = 0; i < windowsize; i++)
{
printf("Frame %d has been transmitted.\n",i);
}
printf("\nPlease enter the number of negative acknowledgements received.\n");
scanf("%d",&neg);
printf("\nPlease enter the negative acknowledgements received.\n");
for( i = 0; i < neg; i++)
{
scanf("%d",&nack[i]);
}
for( i = 0; i < neg; i++)
{
printf("Frame %d has been retransmitted.\n",nack[i]);
}
return 0;
}

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

OUTPUT:
enter window size
4
Frame 0 has been transmitted.
Frame 1 has been transmitted.
Frame 2 has been transmitted.
Frame 3 has been transmitted.

Please enter the last Acknowledgement received.


3
Frame 3 has been transmitted.

Please enter the last Acknowledgement received.


4

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-8
AIM: Write a Program to implement Stop and Wait Protocol.
SOURCE CODE:
#include<stdio.h>
int main() {
int i,framesize,frame[50];
printf("Enter number of frames to transmit:");
scanf("%d",&framesize);
printf("\nEnter the data frames to transmit:");
for(i=0;i<framesize;i++) {
scanf("%d",&frame[i]);
}
for(i=0;i<framesize;i++) {
printf("frame %d containing data %d has been transmitted",i,frame[i]);
printf("ack %d has been received",i);
}
printf("stop and wait protocol ends");
return 0;
}

OUTPUT:
Enter number of frames to transmit:2
Enter the data frames to transmit:
1
3
frame 0 containing data 1 has been transmitted
ack 0 has been received
frame 1 containing data 3 has been transmitted
ack 1 has been received
stop and wait protocol ends

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-9
AIM: Write a program for congestion control using leaky bucket algorithm.
SOURCE CODE:
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#define BUCKET_SIZE 100
#define OUTPUT_RATE 10
void leakyBucket(int inputRate, int duration)
{
int bucketSize = BUCKET_SIZE;
int outputRate = OUTPUT_RATE;
int packetSize, i;
printf("Simulation Start\n");
for (i = 0; i < duration; i++)
{
printf("\nSecond %d:\n", i + 1);
packetSize = rand() % inputRate;
printf("Incoming packet size: %d\n", packetSize);
if (packetSize <= bucketSize)
{
bucketSize -= packetSize;
printf("Bucket output successful\n");
}
else
{
printf("Bucket overflow - Packet discarded\n");
}
printf("Bucket size after operation: %d\n", bucketSize);
sleep(1);

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
bucketSize += outputRate;
if (bucketSize > BUCKET_SIZE)
{
bucketSize = BUCKET_SIZE;
}
printf("Bucket size after output: %d\n", bucketSize);
}
printf("\nSimulation End\n");
}
int main()
{
int inputRate, duration;
printf("Enter input rate (in Bytes/Second): ");
scanf("%d", &inputRate);
printf("Enter duration of simulation (in seconds): ");
scanf("%d", &duration);
leakyBucket(inputRate, duration);
return 0;
}

OUTPUT:
Enter input rate (in Bytes/Second): 50
Enter duration of simulation (in seconds): 5
Simulation Start

Second 1:
Incoming packet size: 33
Bucket output successful
Bucket size after operation: 67
Bucket size after output: 77

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
Second 2:
Incoming packet size: 36
Bucket output successful
Bucket size after operation: 41
Bucket size after output: 51

Second 3:
Incoming packet size: 27
Bucket output successful
Bucket size after operation: 24
Bucket size after output: 34

Second 4:
Incoming packet size: 15
Bucket output successful
Bucket size after operation: 19
Bucket size after output: 29

Second 5:
Incoming packet size: 43
Bucket overflow - Packet discarded
Bucket size after operation: 29
Bucket size after output: 39
Simulation End

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-10
AIM: Write a Program to implement Dijkstra‘s algorithm to compute the Shortest
path through a graph.
SOURCE CODE:
#include<stdio.h>
int graph[10][10], source, n, mark[10], pe[10], pred[10], count = 0, u, v, i, j;
void printpath(int, int, int[]);
int min(int[], int[], int);
int main()
{
printf("\nEnter number of vertices: ");
scanf("%d", &n);
printf("\nEnter the adjacency matrix:\n");
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
scanf("%d", &graph[i][j]);
}}
printf("\nEnter the source vertex: ");
scanf("%d", &source);
for (j = 1; j <= n; j++) {
mark[j] = 0;
pe[j] = 999;
pred[j] = 0;
}
pe[source] = 0;
while (count < n)
{
u = min(pe, mark, n);
mark[u] = 1;
for (i = 1; i <= n; i++)

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
{
if (graph[u][i] > 0 && mark[i] != 1)
{
if (pe[i] > pe[u] + graph[u][i])
{
pe[i] = pe[u] + graph[u][i];
pred[i] = u;
}}}
count++;
}
for (i = 1; i <= n; i++) {
printpath(source, i, pred);
if (pe[i] != 999)
{
printf("(%d)\n", pe[i]);
}}
return 0;
}
int min(int a[], int m[], int n)
{
int min_val = 999, t = 0, i;
for (i = 1; i <= n; i++) {
if (m[i] != 1 && a[i] < min_val)
{
min_val = a[i];
t = i;
}}
return t;
}
void printpath(int x, int i, int pr[])

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
{
if (i == x)
{
printf("%d", x);
}
else if (pr[i] == 0)
{
printf(" no path from %d to %d", x, i);
}
else {
printpath(x, pr[i], pr);
printf("->%d", i);
}
}

OUTPUT:
Enter number of vertices: 5
Enter the adjacency matrix:
01020
10536
05047
23400
06700

Enter the source vertex: 1


1(0)
1->2(1)
1->2->3(6)
1->4(2)
1->2->5(7)

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-11
AIM: Write a Program to implement Distance vector routing algorithm by
obtaining routing table at each node.

(Take an example subnet graph with weights indicating delay between nodes).
SOURCE CODE:
#include<stdio.h>
int main()
{
int n, na, min, i, j, tdel[10][10], del[10];
char ch, adj[10];
printf("Enter the no. of vertices: ");
scanf("%d", &n);
printf("Enter the no. of adjacent vertices: ");
scanf("%d", &na);
for (i = 0; i < na; i++)
{
printf("Enter the name of the vertex and time delay: ");
scanf(" %c%d", &adj[i], &del[i]);
}
for (i = 0; i < na; i++) {
printf("Enter the delay from adjacent vertex %c to all other vertices: ", adj[i]);
for (j = 0; j < n; j++) {
scanf("%d", &tdel[i][j]);
}
}
printf("SNO.\tDIST\tLINE\n");
for (i = 0; i < n; i++) {
min = 1000;
ch = 'a';
for (j = 0; j < na; j++) {

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
if (min > tdel[j][i] + del[j])
{
min = tdel[j][i] + del[j];
ch = adj[j];
}
}
printf("%d\t%d\t%c\n", i + 1, min, ch);
}
return 0;
}

OUTPUT:
Enter the no. of vertices: 9
Enter the no. of adjacent vertices: 3
Enter the name of the vertex and time delay: A
1
Enter the name of the vertex and time delay: C
1
Enter the name of the vertex and time delay: E
3
Enter the delay from adjacent vertex A to all other vertices: 3
3
7
8
7
6
5
9
8

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
Enter the delay from adjacent vertex C to all other vertices: 4
5
1
3
3
5
7
2
4
Enter the delay from adjacent vertex E to all other vertices: 5
6
4
7
8
8
4
9
4
SNO DIST LINE
1 4 A
2 4 A
3 2 C
4 4 C
5 4 C
6 6 C
7 6 A
8 3 C
9 5 C

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-12
AIM: Write a Program to implement Broadcast tree by taking subnet of hosts.
SOURCE CODE:
#include<stdio.h>
struct ed
{
int v1, v2, w;
} edj[20], temp;
int main()
{
int i, j, n = 0, s, d, par[20], s1, d1;
printf("\nEnter number of edges: ");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
printf("\nEnter the node1, node2, weights for edge %d: ", i + 1);
scanf("%d %d %d", &edj[i].v1, &edj[i].v2, &edj[i].w);
par[i] = 0;
}
for (i = 0; i < n; i++)
{
for (j = 0; j < n - i - 1; j++)
{
if (edj[j].w > edj[j + 1].w)
{
temp = edj[j];
edj[j] = edj[j + 1];
edj[j + 1] = temp;
}
}

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
}
printf("\nSorted edges based on weight:\n");
for (i = 0; i < n; i++)
{
printf("Edge %d: %d\t%d\t%d\n", i + 1, edj[i].v1, edj[i].v2, edj[i].w);
}
printf("\nBROADCAST TREE FOR THE GIVEN GRAPH:\n");
for (i = 0; i < n; i++)
{
s = edj[i].v1;
d = edj[i].v2;
s1 = s;
d1 = d;
while (par[s1] > 0)
{
s1 = par[s1];
}
while (par[d1] > 0)
{
d1 = par[d1];
}
if (s1 != d1)
{
par[d] = s;
printf("%d\t%d\t%d\n", s, d, edj[i].w);
}
}
return 0;
}

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

OUTPUT:
Enter number of edges: 5
Enter the node1, node2, weights for edge 1: 4 5 2
Enter the node1, node2, weights for edge 2: 5 1 3
Enter the node1, node2, weights for edge 3: 1 2 4
Enter the node1, node2, weights for edge 4: 2 3 9
Enter the node1, node2, weights for edge 5: 3 4 10

Sorted edges based on weight:


Edge 1: 4 5 2
Edge 2: 5 1 3
Edge 3: 1 2 4
Edge 4: 2 3 9
Edge 5: 3 4 10

BROADCAST TREE FOR THE GIVEN GRAPH:


4 5 2
5 1 3
1 2 4
2 3 9

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-13
AIM: Wireshark
i. Packet Capture Using Wire shark
ii. Starting Wire shark
iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters

i. Packet Capture Using Wire shark:


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

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

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
3.Under Capture, click on AirPcap USB wireless capture adapter to select the capture
interface.

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

packet capture interfaces. Note: The AirPcap has been discontinued by

RiverBed and is 802.11n only.

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

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

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Saving the Capture

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

2. Name the file, and click Save.

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

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

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

ii. Starting Wire shark:

Wireshark is a network packet analyzer. A network packet analyzer presents captured packet
data in as much detail as possible. You could think of a network packet analyzer as a measuring
device for examining what’s happening inside a network cable, just like an electrician uses a
voltmeter for examining what’s happening inside an electric cable
Here are some reasons people use Wireshark:

 Network administrators use it to troubleshoot network problems


 Network security engineers use it to examine security problems
 QA engineers use it to verify network applications
 Developers use it to debug protocol implementations
 People use it to learn network protocol internals

You can start Wireshark from your shell or window manager.

Simply install Win10Pcap on your Windows PC, either before or after your favorited WinPcap-
compatible applications (e.g. Wireshark).

Since Win10Pcap has the binary-compatibility with the original WinPcap DLLs, Wireshark will
begin to work in Windows 10 immediately after installing Win10Pcap.

Step 1. Install Win10Pcap Download and install Win10Pcap.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Step 2. Install Wireshark (or other WinPcap–compatible applications)


Download Wireshark or other WinPcap-compatible applications. Install the application as usual

Step 3. Run Wireshark

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

iii. Viewing Captured Traffic:


The Wireshark Capture menu contains the fields shown in Table
Figure: The “Capture” Menu

Table: Capture menu items

Menu Item Accelerator Description

Shows the Capture Options dialog box, which allows you to

Options Ctrl+K configure interfaces and capture options. See section “The
“Capture Options” Dialog Box”.

Start Ctrl+E Immediately starts capturing packets with the same settings
as the last time.

Stop Ctrl+E Stops the currently running capture. See Section “Stop the
running capture”.

Restart Ctrl+R Stops the currently running capture and starts it again with
the same options.

Shows a dialog box that allows you to create and edit capture
__ filters. You can name filters and save them for future use. See
Capture Filters
Section “Defining And Saving Filters”.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

iv. Analysis and Statistics & Filters:


The Wireshark Analyze menu contains the fields shown in Table
Figure: The “Analyze” Menu

Table: Analyze menu items

Menu Item Accelerator Description

Displays a dialog box that allows you to create

Display Filters and edit display filters. You can name filters, and
you can save them for future use. See Section 6.6,
“Defining And Saving Filters”.

Shows a dialog box that allows you to create and

Display Filter Macros edit display filter macros. You can name filter
macros, and you can save them for future use. See
Section 6.7, “Defining And Saving Filter Macros”.

Apply as Column Shift+Ctrl+I Adds the selected protocol item in the packet
details pane as a column to the packet list.

Change the current display filter and apply it


immediately. Depending on the chosen menu
Apply as Filter item, the current display filter string will be
replaced or appended to by the selected protocol
field in the packet details pane.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Change the current display filter but won’t apply


it. Depending on the chosen menu item, the
current display filter string will be replaced or
Prepare as Filter
appended to by the selected protocol field in the
packet details pane.

Conversation Filter Apply a conversation filter for various protocols.

Enable or disable various protocol dissectors. See

Enabled Protocols Shift+Ctrl+E Section 11.4.1, “The “Enabled Protocols” dialog


box”.

Decode certain packets as a particular protocol. See

Decode As Section 11.4.2, “User Specified Decodes”.

Open a window that displays all the TCP segments

Follow → TCP Stream captured that are on the same TCP connection as a
selected packet. See Section 7.2, “Following
Protocol Streams”.

Follow → UDP Stream Same functionality as “Follow TCP


Stream” but for UDP “streams”.

Same functionality as “Follow TCP Stream”

Follow → TLS Stream but for TLS or SSL streams. See the wiki page
on TLS for instructions on providing TLS
keys.

Menu Item Accelerator Description

Follow → HTTP Stream Same functionality as “Follow TCP Stream”


but for HTTP streams.
Some protocol dissectors add packet detail
items for notable or unusual behavior, such as
invalid checksums or retransmissions. Those
Expert Info items are shown here. The amount of
information will vary depend on the protocol

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

The “Statistics” Menu


The Wireshark Statistics menu contains the fields shown in “Statistics menu items”.

The “Statistics” Menu

Table: Statistics menu items

Menu Item Description

Capture File Properties Show information about the capture file, see Section 8.2,
“The “Capture File Properties” Dialog”.
Resolved Addresses See Section 8.3, “Resolved Addresses”

Protocol Hierarchy Display a hierarchical tree of protocol statistics, see


Section 8.4, “The “Protocol Hierarchy” Window”.
Conversations Display a list of conversations (traffic between two
endpoints), see Section 8.5.1, “The “Conversations”
Window”.
Endpoints Display a list of endpoints (traffic to/from an address), see
Section 8.6.1, “The “Endpoints” Window”.
Packet Lengths See Section 8.7, “Packet Lengths”

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-14
AIM: How to run Nmap scan.

Nmap is a network mapper that has emerged as one of the most popular, free network discovery
tools on the market. Nmap is now one of the core tools used by network administrators to map
their networks. The program can be used to find live hosts on a network, perform port scanning,
ping sweeps, OS detection, and version detection.

What is Nmap?

At its core, Nmap is a network scanning tool that uses IP packets to identify all the devices
connected to a network and to provide information on the services and operating systems they
are running.

What Does Nmap Do?

At a practical level, Nmap is used to provide detailed, real-time information on your networks,
and on the devices connected to them. The primary uses of Nmap can be broken into three core
processes. First, the program gives you detailed information on every IP active on your
networks, and each IP can then be scanned. This allows administrators to check whether an IP
is being used by a legitimate service, or by an external attacker.

Secondly, Nmap provides information on your network as a whole. It can be used to provide a
list of live hosts and open ports, as well as identifying the OS of every connected device. This
makes it a valuable tool in ongoing system monitoring, as well as a critical part of pen testing.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

This makes it a valuable tool in ongoing system monitoring, as well as a critical part of
pentesting. Nmap can be used alongside the Metasploit framework, for instance, to probe and
then repair network vulnerabilities.

Thirdly, Nmap has also become a valuable tool for users looking to protect personal and business
websites. Using Nmap to scan your own web server, particularly if you are hosting your website
from home, is essentially simulating the process that a hacker would use to attack your site.
“Attacking” your own site in this way is a powerful way of identifying security vulnerabilities.

How To Run a Ping Scan


One of the most basic functions of Nmap is to identify active hosts on your network. Nmap does
this by using a ping scan. This identifies all of the IP addresses that are currently online without
sending any packers to these hosts.

To run a ping scan, run the following command:

# nmap -sp 192.100.1.1/24

This command then returns a list of hosts on your network and the total number of assigned IP
addresses. If you spot any hosts or IP addresses on this list that you cannot account for, you can
then run further commands (see below) to investigate them further.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

How To Run A Host Scan


A more powerful way to scan your networks is to use Nmap to perform a host scan. Unlike a
ping scan, a host scan actively sends ARP request packets to all the hosts connected to your
network. Each host then responds to this packet with another ARP packet containing its status
and MAC address.
To run a host scan, use the following command:
# nmap -sp <target IP range>

This returns information on every host, their latency, their MAC address, and also any
description associated with this address. This can be a powerful way of spotting suspicious hosts
connected to your network.

Nmap Commands:

There are several ways to execute port scanning using Nmap. The most commonly used are
these:
# sS TCP SYN scan

# sT TCP connect scan

# sU UDP scans

# sY SCTP INIT scan

# sN TCP NULL

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Ping Scanning

As mentioned above, a ping scan returns information on every active IP on your network.
You can execute a ping scan using this command:

# nmap -sn 192.168.1.0/24

Port Scanning

Host Scanning

Host scanning returns more detailed information on a particular host or a range of IP addresses.
As mentioned above, you can perform a host scan using the following command:

#nmap -sp <target IP range>

OS Scanning

OS scanning is one of the most powerful features of Nmap. When using this type of scan, Nmap
sends TCP and UDP packets to a particular port, and then analyze its response. It compares this
response to a database of 2600 operating systems, and return information on the OS (and version)
of a host.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:
To run an OS scan, use the following command:
#nmap -O <target IP>

Scan The Most Popular Ports

If you are running Nmap on a home server, this command is very useful. It automatically scans
a number of the most ‘popular’ ports for a host. You can run this command using:

#nmap --top-ports 20 192.168.1.106

Replace the “20” with the number of ports to scan, and Nmap quickly scans that many ports. It
returns a concise output that details the status of the most common ports, and this lets you
quickly see whether you have any unnecessarily open ports.

Output to a File

If you want to output the results of your Nmap scans to a file, you can add an extension to your
commands to do that. Simply add:

-oN output.txt

To your command to output the results to a text file, or: -oX output.xml To output to n XML.

Disable DNS Name Resolution

Finally, you can speed up your Nmap scans by using the -n parameter to disable reverse DNS
resolution. This can be extremely useful if you want to scan a large network. For example, to
turn off DNS resolution for the basic ping scan mentioned above, add -n:

# nmap -sp -n 192.100.1.1/24

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-15
AIM: Operating System Detection using Nmap.

OS Scanning
OS scanning is one of the most powerful features of Nmap. When using this type of scan, Nmap sends
TCP and UDP packets to a particular port, and then analyze its response. It compares this response to
a database of 2600 operating systems, and return information on the OS (and version) of a host.

To run an OS scan: nmap -O <target IP>

Simply add -O to your scan options. You may want to also increase the verbosity with - v for
even more OS-related details. This is shown in Example

Example: OS detection with verbosity (-O -v)

#nmap -O -v scanme.nmap.org
Starting Nmap ( http://nmap.org )
Nmap scan report for scanme.nmap.org

(74.207.244.221) Not shown: 994 closed ports


PORT STATE SERVICE

22/tcp OPEN Ssh

80/tcp OPEN http

646/tcp FILTERED hdp


1720/tcp FILTERED H.323/Q.931
9929/tcp OPEN nping-echo
31337/tcp OPEN Elite

Device type: General


Purpose Running: Linux 2.6.X
OS CPE: cpe:/o:linux:linux_kernel:2.6.39 OS
Details: Linux 2.6.39
Uptime Guess: 1.674 days (since Fri Sep 9 12:03:04 2011) Network Distance: 10 hops
TCP Sequence Prediction: Difficulty=205 (Good luck!) IP ID
Sequence Generation: All zeros
Read data files from: /usr/local/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 5.58 seconds
Raw packets sent: 1063 (47.432KB) | Rcvd: 1031 (41.664KB)

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Experiment-16
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.

What is NS2:
 NS2 simulator is a piece of software or hardware used to predict the performance of overall
network.
 Supports a number of algorithms for Queuing and Routing and used to verify the viability
of new algorithms, check topologies, test architectures etc.
 Discrete event simulator used for the simulation of routing protocols and are at present
heavily used in ad-hoc networking research.
 It supports wide range of network protocols and provide simulation environment for both
wired and wireless networks.

Major Features of NS2:


 Supports Unix like systems and Windows.
 It is written in C++ and TCL scripting language.
 OTCL in NS2 adds object-oriented concept to TCL.
 Open-source simulator, which is object oriented in nature.

Supports the following:


 Traffic Models [CBR, VBR, Web]
 Error Models [Uniform, bursty etc]
 Protocol support [TCP, HTTP, UDP, MAC protocols, Routing protocols]
 Misc [Radio propagation Model, Energy Model, Mobility Models]
 Visualization tools [NAM] and trace file [.tr for performance evaluation]
 Topology generation tools.

Basic Structure of Ns2:


 It maintains a list of Events and executes it one after the other

 No locking or race conditions[Single thread of control]


 Back-end support[C++ Event Scheduler]-Fast to run and have more control
 Front End Support[OTCL-Creates Scenarios, extension to C++ protocols and it is fast to
write and change]

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42


III-II CSE (AI&ML) PAGE NO:

Platform Support for NS2:

 Unix Systems[FreeBSD, Solaris, Linux]


 Windows

Protocol Support in NS2:

 Network Layer [Routing agent]


 Transport layer [Traffic agent-TCP and UDP]
 Logic link Control layer [IEEE 802.2, AR]
 Interface Queue [Priority queue, FIFO queue, Drop tail queue]

Implementation of NS2:

 Source code implementation [C++]


 Scripting language [TCL and OTCL [Object oriented extension of TCL]]

Three basic steps:

 Design Simulation and determine the simulation scenario


 Build NS2 Script using TCL
 Run the Simulation by using $ns filename.tcl.

ASTC COMPUTER NETWORKS - LAB (R20) ROLL NO : 21991A42

You might also like