0% found this document useful (0 votes)
477 views85 pages

CN Manual Lab (R20)

The document is a lab record from the Computer Networking lab of a B.Tech. program. It contains: 1) A cover page with the department name and lab record details like student name and experiments completed. 2) An index listing 16 networking experiments conducted by the student, including programming experiments on data link layer methods, error detection/correction, routing protocols, and network simulations. 3) Details and results of the first experiment on studying networking devices and setting up a local area network. This involves explaining devices like repeaters, hubs, switches, bridges, routers and configuring internet connection sharing and IP settings.

Uploaded by

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

CN Manual Lab (R20)

The document is a lab record from the Computer Networking lab of a B.Tech. program. It contains: 1) A cover page with the department name and lab record details like student name and experiments completed. 2) An index listing 16 networking experiments conducted by the student, including programming experiments on data link layer methods, error detection/correction, routing protocols, and network simulations. 3) Details and results of the first experiment on studying networking devices and setting up a local area network. This involves explaining devices like repeaters, hubs, switches, bridges, routers and configuring internet connection sharing and IP settings.

Uploaded by

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

DEPARTMENT OF COMPUTERSCIENCE & ENGINEERING

NH-5, Valluru-523272,Ongole,Prakasam District


DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Computer Networking Lab Record

CERTIFICATE

This is to Certify that the bonafide record of practical work done in the

Computer Networks laboratory by Mr./Miss. Of

B.Tech. lll:l semester, H.T.No: during the year 2021-2022

No. of experiments done:

Faculty-In-Charge Head of the Department

InternalExaminer ExternalExaminer
INDEX
S.NO List of Experiments DATE SIGNATURE

1 Study of Network devices in detail and connect the computers


in Local Area Network
2 Write a Program to implement the data link layer
farming methods such as
i) Character stuffing
ii) bit stuffing
3 Write a Program to implement data link layer farming method
checksum.
4 Write a program for Hamming Code generation for error
detection and correction
5 Write a program for Hamming Code generation for error
detection and correction
6 Write a Program to implement Sliding window protocol for
Goback N
7 Write a Program to implement Sliding window protocol for
Selective repeat
8 Write a Program to implement Stop and Wait Protocol
9 Write a program for congestion control using leaky bucket
algorithm
10 Write a Program to implement Dijkstra‘s algorithm to compute
the Shortest path through a graph
11 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).
12 Write a Program to implement Broadcast tree by taking subnet
of hosts
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


NS2 Simulator-Introduction

Simulate to Find the Number of Packets Dropped

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

Simulate to Find the Number of Packets Dropped due to


Congestion

Simulate to Compare Data Rate & Throughput.


EXPERIMENT-1
Aim: Study of Network devices in detail and connect the computers in Local Area Network

 Repeater
 Hub
 Switch
 Bridge
 Router
 Gate Way

Apparatus (Software): No software or hardware needed.

Procedure: Following should be done to understand this

practical.

Repeater:
Functioning at Physical Layer.A repeater is an electronic device that receives a signal and retransmits it at a
higher level and/or higher power, or onto the other side of an obstruction, so that the signal can cover longer
distances. Repeater have two ports,so cannot be use to connect for more than two devices

Hub:
An Ethernet hub, active hub, network hub, repeater hub, hub or concentrator is a device for connecting multiple
twisted pair or fiber optic Ethernet devices together and making them act as a single network segment. Hubs
work at the physical layer (layer1) of the OSI model. The device is a form of multiport repeater. Repeater hubs
also participate in collision detection, forwarding a jam signal to all ports if it detects a collision.

Switch:
A networkswitchor switching hubis a computer networking device that connects network segments.The
term commonly refers to a network bridge that processes androutes data at the data link layer (layer 2) of the
OSI model. Switches that additionally process data at the network layer (layer 3 and above) are often
referred to as Layer 3 switchesor multilayer switches.
Bridge:
A network bridge connects multiple network segments at the data link layer (Layer 2) of the OSI model. In
Ethernet networks, the term bridge formally means a device that behaves according to the IEEE 802.1D
standard. A bridge and switch are very much alike; a switch being a bridge with numerous ports.
Switch or Layer 2 switch is often used interchangeably with bridge. Bridges can analyze incoming data
packets to determine if the bridge is able to send the given packet to another segment of the network.

Router: A router is an electronic device that interconnects two or more computer networks, and selectively
interchanges packets of data between them. Each data packet contains address information that a router can
use to determine if the source and destination are on the same network, or if the data packet must be
transferred from one network to another. Where multiple routers are used in a large collection of
interconnected networks, the routers exchange information about target system addresses, so that each
router can build upa table showing the preferred paths between any two systems on the interconnected
networks.

Gate Way:
In a communications network, a network node equipped for interfacing with another network that uses different
protocols.
 A gateway may contain devices such as protocol translators, impedance matching devices, rate
converters, fault isolators, or signal translators as necessary to provide system interoperability. It also
requires the establishment of mutually acceptable administrative procedures between both networks.
A. protocol translation/mapping gateway interconnects networks with different network protocol
technologies by performing the required protocol conversions.
B. Connect the computers in Local Area Network.

Procedure: On the host computer


On the host computer, follow these steps to share the Internet connection:
1. Log on to the host computer as Administrator or as Owner.
2. Click Start, and then click Control Panel.
3. Click Network and Internet Connections.
4. Click Network Connections.

5. Right-click the connection that you use to connect to the Internet. For example, if
you connect to the Internet by using a modem, right-click the connection that you
want under Dial-up / other network available.

6. Click Properties.

7. Click the Advanced tab.

8. Under Internet Connection Sharing, select the Allow other network users to connect through this
computer's Internet connection check box.

9. If you are sharing a dial-up Internet connection, select the Establish a dial-up Connectionwhenever a
computer on my network attempts to access the Internet check box if you want to permit your computer
to automatically connect to the Internet.

10. Click OK. You receive the following message:


When Internet Connection Sharing is enabled, your LAN adapter will be set to use IP address 192.168.0.1.
Your computer may lose connectivity with other computers on your network. Ifthese other computers have
static IP addresses, it is a good idea to set them to obtain their IP addresses automatically. Are you sure you
want to enable Internet Connection Sharing?

11. Click Yes.


The connection to the Internet is shared to other computers on the local area network (LAN).
The network adapter that is connected to the LAN is configured with a static IP address of 192.168.0.1 and a
subnet mask of 255.255.255.0On the client computer
To connect to the Internet by using the shared connection, you must confirm the LAN
Adapter IP configuration, and then configure the client computer.

To confirm the LAN


adapter IP configuration, follow these steps:

1. Log on to the client computer as Administrator or as Owner.


2. Click Start, and then click Control Panel.
3. Click Network and Internet Connections.
4. Click Network Connections.
5. Right-click Local Area Connection and then click Properties.
6. Click the General tab, click Internet Protocol (TCP/IP) in the connection uses
The following items list, and then click Properties.

7. In the Internet Protocol (TCP/IP) Properties dialog box, click Obtain an


IP Address automatically (if it is not already selected), and then click OK.

Note: You can also assign a unique static IP address in the range of 192.168.0.2 to 192.168.0.254.
For example, you can assign the following static IP address, subnet mask, and default gateway:

8. IP Address 192.168.31.202

9. Subnet mask 255.255.255.0

10. Default gateway 192.168.31.1

11. In the Local Area Connection Properties dialog box, click OK.

12. Quit Control Panel.


EXPERIMENT:2
AIM : Implement the data link layer framing methods such as
i)character stuffing
ii)bit stuffing
Data Link Layer(DLL) :

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’s passed down
by above layers and convert 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

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

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

Code: //Program for Character Stuffing


#include<stdio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;
char a[20],b[50],ch;
printf("Enter string\n");
scanf("%s",&a);
n=strlen(a);
printf("Enter position\n");
scanf("%d",&pos);
if(pos>n)
{
printf("invalid position, Enter again :");
scanf("%d",&pos);}
printf("Enter the character\n");
ch=getche();
b[0]='d';
b[1]='l';
b[2]='e';
b[3]='s';
b[4]='t';
b[5]='x';
j=6;
while(i<n)
{
if(i==pos-1){
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]=ch;
b[j+4]='d';
b[j+5]='l';
b[j+6]='e';
j=j+7;
}
if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e')
{
b[j]='d';
b[j+1]='l';
b[j+2]='e';
j=j+3;
}
b[j]=a[i];
i++;
j++;
}
b[j]='d';
b[j+1]='l';
b[j+2]='e';
b[j+3]='e';
b[j+4]='t';
b[j+5]='x';
b[j+6]='\0';
printf("\nframe after stuffing:\n");
printf("%s",b);
}

Program Output:

Enter string
MLRITM
Enter position
2
Enter the character
frame after stuffing:
dlestxMdldleLRITMdleetx
Code: // BIT Stuffing program
#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
{
b[j]=a[i];
} i+
+;
j++;
}
printf("After stuffing the frame is:");
for(i=0;i<j;i++)
printf("%d",b[i]);
}
Program Output:
Enter frame length:5
Enter input frame (0's & 1's only):
1
1
1
1
1
After stuffing the frame is:111110
(program exited with code: 6)
EXPERIMENT:3

Checksum:
 A checksum is a error detection method in Data Communication. It is used for errors which may have
been introduced during transmission or storage. It is usually applied to an installation file after it is
received from the download server. Checksum method can only detect errors but is unable to correct
the error.

 In this method a checksum is calculated based on the given binary strings which is sent with the data
as redundant bits. This data + checksum is received at receiver end and checksum is calculated again,
if checksum is 0 it means no error in data received, else there exists some error in the received data.
 For the purpose of this program we are finding checksum for 2 binary strings.

Checksum Program in C
1 #include<stdio.h>
2 #include<string.h>
3
4 int main()
5{
6 char a[20],b[20];
7 char sum[20],complement[20];
8 int i,length;
9
10 printf("Enter first binary string\n");
11 scanf("%s",&a);
12 printf("Enter second binary string\n");
13 scanf("%s",&b);
14
15 if(strlen(a)==strlen(b)){
16 length = strlen(a);
17 char carry='0';
18
19 for(i=length-1;i>=0;i--)
20 {
21 if(a[i]=='0' && b[i]=='0' && carry=='0')
22 {
23 sum[i]='0';
24 carry='0';
25 }
26 else if(a[i]=='0' && b[i]=='0' &&
carry=='1') 27 {
28 sum[i]='1';
29 carry='0';
30
31 }
32 else if(a[i]=='0' && b[i]=='1' &&
carry=='0') 33 {
34 sum[i]='1';
35 carry='0';
36
37 }
38 else if(a[i]=='0' && b[i]=='1' &&
carry=='1') 39 {
40 sum[i]='0';
41 carry='1';
42
43 }
44 else if(a[i]=='1' && b[i]=='0' &&
carry=='0') 45 {
46 sum[i]='1';
47 carry='0';
48
49 }
50 else if(a[i]=='1' && b[i]=='0' &&
carry=='1') 51 {
52 sum[i]='0';
53 carry='1';
54
55 }
56 else if(a[i]=='1' && b[i]=='1' &&
carry=='0') 57 {
58 sum[i]='0';
59 carry='1';
60
61 }
62 else if(a[i]=='1' && b[i]=='1' &&
carry=='1') 63 {
64 sum[i]='1';
65 carry='1';
66
67 }
68 else
69 break;
70 }
71
72 printf("\nSum=%c%s",carry,sum);
73 for(i=0;i<length;i++)
74 {
75 if(sum[i]=='0')
76 complement[i]='1';
77 else
78 complement[i]='0';
79 }
80
81 if(carry=='1')
82 carry='0';
83 else
84 carry='1';
85
86 printf("\nChecksum=%c%s",carry,complement);
87 }
88 else {89
90
91
92
printf("\nWrong input strings");
}
}

Output:
Enter first binary string
101101
Enter second binary string
110010
Sum=1011111
Checksum=0100000
Process exited with return value 17
Press any key to continue……
EXPERIMENT:4

Hamming code:
 Hamming code is a popular error detection and error correction method in data communication.
 Hamming code can only detect 2 bit error and correct a single bit error which means it is unable
to correct burst errors if may occur while transmission of data.
 Hamming code uses redundant bits (extra bits) which are calculated according to the below
formula:- 2
r
≥ m+r+1
Where r is the number of redundant bits required and m is the number of data bits.
R is calculated by putting r = 1, 2, 3 … until the above equation becomes true.
R1 bit is appended at position 2
0
R2 bit is appended at position 2
1
R3 bit is appended at position 2
2
and so on.

 These redundant bits are then added to the original data for the calculation of error at receiver’s end.
 At receiver’s end with the help of even parity (generally) the erroneous bit position is identified
and since data is in binary we take complement of the erroneous bit position to correct received
data.
 Respective index parity is calculated for r1, r2, r3, r4 and so on.

Advantages of Hamming Code:

 Easy to encode and decode data at both sender and receiver end.
 Easy to implement.
Disadvantages of Hamming Code:
 Cannot correct burst errors.
 Redundant bits are also sent with the data therefore it requires more bandwidth to send the data.

Program:

#include<stdio.h>
void main() {
int data[10];
int dataatrec[10],c,c1,c2,c3,i;
printf("Enter 4 bits of data one by one\n");
scanf("%d",&data[0]); scanf("%d",&data[1]);
scanf("%d",&data[2]);
scanf("%d",&data[4]);
//Calculation of even parity
data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4];
data[3]=data[0]^data[1]^data[2];
printf("\nEncoded data is\n");
for(i=0;i<7;i++)
printf("%d",data[i]);
printf("\n\nEnter received data bits one by one\n");
for(i=0;i<7;i++)
scanf("%d",&dataatrec[i]);
c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];
c2=dataatrec[5]^dataatrec[4]^dataatrec[1]^dataatrec[0];
c3=dataatrec[3]^dataatrec[2]^dataatrec[1]^dataatrec[0];
c=c3*4+c2*2+c1 ;
if(c==0) {
printf("\nNo error while transmission of data\n");
}
else {
printf("\nError on position %d",c);
printf("\nData sent : ");
for(i=0;i<7;i++)
printf("%d",data[i]); printf("\
nData received : "); for(i=0;i<7;i+
+) printf("%d",dataatrec[i]);
printf("\nCorrect message is\n");
//if errorneous bit is 0 we complement it else vice
versa if(dataatrec[7-c]==0)
dataatrec[7-c]=1;
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
Enter received data bits one by one
1
0
1
0
0
EXPERIMENT:5

Aim : Implement on a dataset of characters the three CRCpolynomials–CRC12,CRC16andCRCCCIP.

Introduction to Cyclic Redundancy Check:

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

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

Program Code: // Program for Cyclic Redundency Check

Include header files stdio.h, 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");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:"); canf("%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);
}
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
ccit4.exit
Enter your option.1
enter data:1100110011100011

generating polynomial:1100000001111

mod-ified data is:11001100111000110000000000001100000001111

checksum is:1101110110001

final codeword is : 11001100111000111101110110001100000001111

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


detected

1. crc12 2.crc16 3.crc


ccit4.exit
Enter your option.2
enter data:11001100111000

generating polynomial:11000000000000101

mod-ified data is:110011001110000000000000000000000000000000101


EXPERIMENT-6
AIM:-Write a Program to implement Sliding window protocol for Go back N.

1. In computer networks sliding window protocol is a method to transmit data on a network.


2. Slidingwindow protocol is applied on the Data Link Layer of OSI model. At data link layer data is in
theformof frames. In Networking, Window simply means a buffer which has data frames that needs to
be transmitted.
3. Both sender and receiver agrees on some window size. If window size=w then after sending
w framessender waits for the acknowledgement (ack) of the first frame.
4. As soon as sender receives the acknowledgement of a frame it is replaced by the next frames to be
transmitted by the sender. If receiver sends a collective or cumulative acknowledgement to sender then
it understands that more than one frames are properly received, for eg:- if as k of frame 3 is received it
understands that frame 1 and frame 2 are received properly.

 Image Source
 In sliding window protocol the receiver has to have some memory to compensate any
loss intransmission or if the frames are received unordered.

 Efficiency of Sliding Window Protocol


 η = (W*tx)/(tx+2tp)
 W = Window Size
 tx = Transmissed timetp=Propagationdelay
Sliding window works in full duplex modeIt is of two types:-

 Selective Repeat: Sender transmits only that frame which is erroneous or is lost.
 Go back n: Sender transmits all frames present in the window that occurs after the error bit
including error bit also
.

Program:
#include<iostream>
#include<stdio.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<netdb.h>
#define cls() printf(“33[H33[J”)
//structure definition for designing the packet.
struct frame
{
int packet[40];
};
//structure definition for accepting the acknowledgement.
struct ack
{
int
acknowledge[40];
};
int main()
{
int serversocket;
sockaddr_in serveraddr,clientaddr;
socklen_t len;
int windowsize,totalpackets,totalframes,framessend=0,i=0,j=0,k,l,m,n,repacket[40];
ack acknowledgement;
frame f1;
char req[50];
serversocket=socket(AF_INET,SOCK_DGRAM,0);
bzero((char*)&serveraddr,sizeof(serveraddr));
serveraddr.sin_family=AF_INET;
serveraddr.sin_port=htons(5018);
serveraddr.sin_addr.s_addr=INADDR_ANY; bind(serversocket,
(sockaddr*)&serveraddr,sizeof(serveraddr));
bzero((char*)&clientaddr,sizeof(clientaddr));
len=sizeof(clientaddr);
//connection establishment. printf(“\
nWaiting for client connection.\n”); recvfrom(serversocket,req,sizeof(req),0,
(sockaddr*)&clientaddr,&len); printf(“\nThe client connection obtained.\t%s\
n”,req);
//sending request for
windowsize. printf(“\nSending request for window size.\n”);
sendto(serversocket,”REQUESTFORWINDOWSIZE.”,sizeof(“REQUESTFOR WINDOWSIZE.”),0,
(sockaddr*)&clientaddr,sizeof(clientaddr));
//obtaining windowsize.
printf(“\nWaiting for the windowsize.\n”);
recvfrom(serversocket,(char*)&windowsize,sizeof(windowsize),0,(sockaddr*)&clientaddr,&len);
cls();
printf(“\nThe windowsize obtained as:\t%d\n”,windowsize);
printf(“\nObtaining packets from network layer.\n”);
printf(“\nTotal packets obtained:\t%d\n”,(totalpackets=windowsize*5));
printf(“\nTotal frames or windows to be transmitted:\t%d\n”,(totalframes=5));
//sending details to client.

printf(“\nSending total number of packets.\n”); sendto(serversocket,


(char*)&totalpackets,sizeof(totalpackets),0,(sockaddr*)&clientaddr,sizeof(clienta ddr));
recvfrom(serversocket,req,sizeof(req),0,(sockaddr*)&clientaddr,&len); printf(“\
nSending total number of frames.\n”);
sendto(serversocket,(char*)&totalframes,sizeof(totalframes),0,(sockaddr*)&clientaddr,sizeof(clientad
dr));
recvfrom(serversocket,req,sizeof(req),0,(sockaddr*)&clientaddr,&len); printf(“\
nPRESS ENTER TO START THE PROCESS.\n”);
fgets(req,2,stdin);
cls();
j=0;
l=0; //starting the process of
sending while( l<totalpackets)
{
//initialising the transmit buffer.
bzero((char*)&f1,sizeof(f1));
printf(“\nInitialising the transmit buffer.\n”);
printf(“\nThe frame to be send is %d with packets:\t”,framessend);
//Builting the frame.
for(m=0;m<j;m++)
{
//including the packets for which negative acknowledgement was
received. printf(“%d “,repacket[m]);
f1.packet[m]=repacket[m];
}
while(j<windowsize && i<totalpackets)
{
printf(“%d “,i);
f1.packet[j]=i;
i++;
j++;
}
printf(“\nSending frame %d\n”,framessend);
//sending the frame. sendto(serversocket,(char*)&f1,sizeof(f1),0,
(sockaddr*)&clientaddr,sizeof(clientaddr));
//Waiting for the acknowledgement.
printf(“\nWaiting for the acknowledgement.\n”);
recvfrom(serversocket,(char*)&acknowledgement,sizeof(acknowledgement),0,(sockaddr*)&clientadd
r,&len);
cls();
//Checking acknowledgement of each packet.
j=0;
k=0;
m=0;
n=l;
while(m<windowsize && n<totalpackets)
{
if(acknowledgement.acknowledge[m]==-1)
{
printf(“\nNegative acknowledgement received for packet: %d\
n”,f1.packet[m]); k=1;
repacket[j]=f1.packet[m];
j++;
}
else
{ l+
+;
} m+
+; n+
+;
}
if(k==0)
{
printf(“\nPositive acknowledgement received for all packets within the frame: %d\n”,framessend);
}
framessend++;
printf(“\nPRESS ENTER TO PROCEED……\n”);
fgets(req,2,stdin);
cls();
}
printf(“\nAll frames send successfully.\n\nClosing connection with the client.\n”);
close(serversocket);
}
Output:
EXPERIMENT:7
1. AIM: Write a Program to implement Sliding window protocol for Selective repeat.

SELECTIVE REPEATPROTOCOL:
/*Program to demonstrate the working of ‘SELECTIVE REPEAT PROTOCOL’.
This module acts as a client which establishes a connection with the server, sends thewindowsize, accepts
the frames and then sends acknowledgement for each packet wihinthe given frame.
The connection used is UDP and the window size is taken from the user(should be<=40)
It uses two structures viz. ‘frame’ for accepting the frames send by the server and ‘ack’ forsending
the acknowledgement.
Here the acknowledgement for each packet is accepted from the user. The usercan enter -1for negative
acknowledgement or any other integer for positive acknowledgement.
NOTE: This module can be compiled using the command ‘c++ selectiverepeat_server.cpp –o b’ and executed
using the command ‘./b’
PROGRAM:

#include<iostream>
#include<stdio.h>
#include<sys/types.h>
#include<netinet/in.h>
#include<netdb.h>
#define cls()
printf(“33[H33[J”) //structure definition for accepting the packets.
struct frame
{
int packet[40];
};
//structure definition for constructing the acknowledgement frame
struct ack
{
int
acknowledge[40];
};
int main(){
int clientsocket;
sockaddr_in serveraddr;
socklen_t len;
hostent * server;
frame f1;
int windowsize,totalpackets,totalframes,i=0,j=0,framesreceived=0,k,l,m,repacket[40];
ack acknowledgement;
char req[50];
clientsocket=socket(AF_INET,SOCK_DGRAM,0);
bzero((char*)&serveraddr,sizeof(serveraddr));
serveraddr.sin_family=AF_INET;
serveraddr.sin_port=htons(5018);
server=gethostbyname(“127.0.0.1”);
bcopy((char*)server->h_addr,(char*)&serveraddr.sin_addr.s_addr,sizeof(server->h_addr));
//establishing the connection.
printf(“\nSending request to the client.\n”);
sendto(clientsocket,”HI I AM CLIENT.”,sizeof(“HI I AM CLIENT.”), 0, (sockaddr*) & serveraddr, size
of (serveraddr));
printf(“\nWaiting for reply.\n”);
recvfrom(clientsocket,req,sizeof(req),0,(sockaddr*)&serveraddr,&len);
printf(“\nThe server has send:\t%s\n”,req);
//accepting window size from the user.
printf(“\nEnter the window size:\t”);
scanf(“%d”,&windowsize);
//sending the window size.
printf(“\n\nSending the window size.\n”);
sendto(clientsocket,(char*)&windowsize,sizeof(windowsize),0,(sockaddr*)&serveraddr,sizeof(servera
ddr));
cls();
//collecting details from server.
printf(“\nWaiting for the server response.\n”);
recvfrom(clientsocket,(char*)&totalpackets,sizeof(totalpackets),0,(sockaddr*)&serveraddr,&len);
printf(“\nThetotalpacketare:\t%d\n”,totalpackets);
sendto(clientsocket,”RECEIVED.”,sizeof(“REEIVED.”),0,(sockaddr*)&serveraddr,sizeof(serveradd
r));
recvfrom(clientsocket,(char*)&totalframes,sizeof(totalframes),0,(sockaddr*)&serveraddr,&len);
printf(“\nThetotalframes/windowsare:\t%d\n”,totalframes);
sendto(clientsocket,”RECEIVED.”,sizeof(“RECEIVED.”),0,(sockaddr*)&serveraddr,sizeof(serveradd
r));
//starting the process.
printf(“\nStarting the process of receiving.\n”);
j=0;
l=0;
while(l<totalpackets)
{ //initialising the receive
buffer. printf(“\nInitialising the receive buffer.\n”);
printf(“\nThe expected frame is %d with packets: “,framesreceived);
for(m=0;m<j;m++)
{ //readjusting for packets with negative
acknowledgement. printf(“%d “,repacket[m]);
}
while(j<windowsize && i<totalpackets)
{
printf(“%d “,i);
i++;
j++;
}
printf(“\n\nWaiting for the frame.\n”);
//acceptingtheframe. recvfrom(clientsocket,(char*)&f1,sizeof(f1),0,
(sockaddr*)&serveraddr,&len); printf(“\nReceived frame %d\n\nEnter -1 to send negative
acknowledgement for the following

packets.\n”,framesreceived);
//constructing the acknowledgement frame.
j=0;
m=0;
k=l;
while(m<windowsize && k<totalpackets)
{
printf(“\nPacket: %d\n”,f1.packet[m]);
//accepting acknowledgement from the user.
scanf(“%d”,&acknowledgement.acknowledge[m]);
if(acknowledgement.acknowledge[m]==-1)
{
repacket[j]=f1.packet[m];
j++;
}
else
{ l+
+;
} m+
+; k+
+;
}
framesreceived++;
//sendingacknowledgementtotheserver. sendto(clientsocket,
(char*)&acknowledgement,sizeof(acknowledgement),0,(sockaddr*)&server
addr,si zeof(serveraddr));
cls();
}
printf(“\nAll frames received successfully.\n\nClosing connection with the server.\n”);
close(clientsocket);
}

Output:
EXPERIMENT-8
AIM:Write a Program to implement Stop and Wait Protocol.
Implement Stop and Wait Protocol.
#include <conio.h>
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#define TIMEOUT 5
#define MAX_SEQ 1
#define TOT_PACKETS 8
define inc(k) if(k<MAX_SEQ) k++; else k=0;
typedef struct
{
int data;
}packet; typedef struct
{
int kind; int seq; int ack;
packet info;
int err;
}frame; frame DATA;
Type def enum{frame_arrival,err,timeout,no_event} event_type;
void from_network_layer(packet *);
void to_network_layer(packet *);
void to_physical_layer(frame *);
void from_physical_layer(frame *);

void wait_for_event_sender(event_type *);


void wait_for_event_reciever(event_type *);
void reciever();
void sender();
int i=1;
//Data to be sent by sender char turn; //r , s
int DISCONNECT=0;
/*

_*/
void main()
{
clrscr();
randomize();
while(!DISCONNECT)
{
sender();
delay(400);
reciever();
}
getch();
}
/*
_*/
void sender()
{

static int
frame_to_send=0; static
frame s;
packet buffer;
event_type event;
static int flag=0;
if(flag==0)
{
from_network_layer(&buffer);
s.info = buffer;
s.seq = frame_to_send;
printf("SENDER :Info = %d,Seq No =
%d",s.info,s.seq); turn = 'r';
to_physical_layer(&s);
flag = 1;
}
wait_for_event_sender(&event);
if(turn=='s')
{
if(event==frame_arrival)
{
from_network_layer(&buffer);
inc(frame_to_send);
s.info = buffer;
s.seq = frame_to_send;
printf("SENDER : Info = %d Seq No = %d ",s.info,s.seq);
turn = 'r';
to_physical_layer(&s);

}
if(event==timeout)
{
printf("SENDER : Resending Frame ");
turn = 'r';
to_physical_layer(&s);
}
}
}
/*
*/
void reciever()
{
static int frame_expected=0;
frame r,s;
event_type event;

wait_for_event_reciever(&event);
if(turn=='r')
{
if(event==frame_arrival)
{
from_physical_layer(&r);
if(r.seq==frame_expected)

to_{ network_layer(&r.
info);

inc(frame_expected);
}
else

printf("RECIEVER : Acknowledgement Resent\n");


turn = 's';
to_physical_layer(&s);
}
if(event==err)
{
printf("RECIEVER : Garbled Frame\n");
turn = 's';
//if frame not recieved
}
//sender shold send it again
}
}
/*

_*/
void from_network_layer(packet *buffer)
{
(*buffer).data = i;
i++;
}
/*
*/

void to_physical_layer(frame *s)


{ //0 means error
s->err = random(4); //non zero means no error
DATA = *s; //probability of error = 1/4
}
/*
*/
void to_network_layer(packet *buffer)
{
printf("RECIEVER :Packet %d recieved , Ack Sent\n",(*buffer).data);
if(i>TOT_PACKETS) // if all packets recieved then disconnect
{
DISCONNECT = 1;
printf("\nDISCONNECTED");
}
}
/*
*/
void from_physical_layer(frame *buffer)
{
*buffer = DATA;
}
/*
*/
void wait_for_event_sender(event_type * e)
{
static int timer=0;

if(turn=='s')
{
timer++;
if(timer==TIMEOUT)
{
*e = timeout;
printf("SENDER : Ack not recieved=> TIMEOUT\n");
timer = 0;
return;
}
if(DATA.err==0)
*e = err;
else
{
timer = 0;
*e = frame_arrival;
}
}
}
wait_for_event_reciever(event_type *
e)
{
if(turn=='r')
{
if(DATA.err==0)
*e = err;
else

*e = frame_arrival;
}
}
OUTPUT:

Stop and Wait Protocol output


Experiment-9
AIM:Write a program for congestion control using leaky bucket algorithm Problem Statement

Theory
 The congesting control algorithms are basically divided into two groups: open loop and closed loop .

 Open loop solutions attempt to solve the problem by good design, in essence, to make sure it does
not occur in the first place. Once the system is up and running, midcourse corrections are not made.

 Open loop algorithms are further divided into ones that act at source versus ones that act at the
destination.

 In contrast, closed loop solutions are based on the concept of a feedback loop if there is any congestion.

 Closed loop algorithms are also divided into two sub categories: explicit feedback and implicit
feedback. In explicit feedback algorithms, packets are sent back from the point of congestion to warn
the source.

 In implicit algorithm, the source deduces the existence of congestion by making local
observation, such as the time needed for acknowledgment to come back.

 The presence of congestion means that the load is (temporarily) greater than the resources (in part of
the system)can handle. For subnets that use virtual circuits internally, these methods can be used at the
network layer.

 Another open loop method to help manage congestion is forcing the packet to be transmitted at
amorepredictablerate.ThisapproachtocongestionmanagementiswidelyusedinATMnetworksandis 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 outbursts and greatly reducing the chances of congestion.
Program:

#include<iostream.h>#include<dos.h>
#include<stdlib.h>#definebucketSize512

void bktInput(int a,int b)


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

if (a>0) cout<<"\n\t\tLast "<<a<<" bytessent\t";cout<<"\n\t\tBucket outputsuccessful";

voidmain(){

int op, pktSize;randomize();


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

}
Output

Enter output rate : 100Packetno0Packetsize=3


Bucket output successful Last 3 bytes sentPacketno1Packetsize=33
Bucket output successful Last 33 bytes
sentPacketno2Packetsize=117 Bucket out put successful
100 bytes outputted .Last 17 bytes sentPacketno3Packetsize= 95
Bucket output successful Last 95 bytes
sentPacketno4Packetsize=949 Bucket overflow
EXPERIMENT:10
AIM : Write a Program to implement Dijkstra‘s algorithm to compute the Shortest path through a graph.

Theory:
 Dijkstra algorithm is also called single source shortest path algorithm. It is based on greedy technique.
The algorithm maintains a list visited[ ] of vertices, whose shortest distance from the source is already
known.
 If visited[1], equals 1, then the shortest distance of vertex i is already known. Initially, visited[i]
is marked as, for source vertex.
 At each step, we mark visited[v] as 1. Vertex v is a vertex at shortest distance from thesource vertex.
At each step ofthe algorithm, shortest distance of each vertex is stored inan array distance[ ].
 C Program on Dijkstra Algorithm for Finding Minimum (shortest)Distance of Verticesfrom a
Given Source in a Graph

Fig: Source graph


Fig:Finding Minimum (shortest)Distance of Vertices from a Given Source in a Graph

PROGRAM:
C Program on Dijkstra Algorithm for Finding Minimum Distance of Vertices from a Given Program:

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

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

//print the path and distance of each node


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

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

THEORY:
 Distance Vector routing (DVR) algorithm is unlike Dijkstra's algorithm which is a non-adaptive
routing algorithm and means that it is purely static, that is pre-destined and fixed, not flexible in
networks where congestions are more prone to occur.
 DVR is an adaptive routing algorithm in which the information from neighbours is
maintained well by each and every node and this helps us to determine the simplest path
possible in a changing network. Though, one of the node may fail, still, the destined node is
reachable through other possible intermediate nodes that are found out by the DVR algorithm.

*/Distance Vector Routing in this program is implemented using Bellman Ford Algorithm:-/*
#include<stdio.h>
struct node
{
unsigneddist[20];
unsignedfrom[20];
}rt[10];
intmain()
{
intcostmat[20][20];
intnodes,i,j,k,count=0;
printf("\nEnter the number of nodes : ");
scanf("%d",&nodes);//Enter the nodes
printf("\nEnter the cost matrix :\n");
for(i=0;i<nodes;i++)
{
for(j=0;j<nodes;j++)
{
scanf("%d",&costmat[i][j]);
costmat[i][i]=0;
rt[i].dist[j]=costmat[i][j];//initialise the distance equal to cost matrix
rt[i].from[j]=j;
}
}
do
{
count=0;
for(i=0;i<nodes;i++)//We choose arbitary vertex k and we calculate the direct distance from the node
i to k using the cost matrix
//and add the distance from k to node j
for(j=0;j<nodes;j++)
for(k=0;k<nodes;k++)
if(rt[i].dist[j]>costmat[i][k]+rt[k].dist[j])
{//We calculate the minimum distance
rt[i].dist[j]=rt[i].dist[k]+rt[k].dist[j];
rt[i].from[j]=k;
count++;
}
}while(count!=0);
for(i=0;i<nodes;i++)
{
printf("\n\n For router %d\n",i+1);
for(j=0;j<nodes;j++)
{
printf("\t\nnode%d via %d Distance %d",j+1,rt[i].from[j]+1,rt[i].dist[j]);
}
}
printf("\n\n");
getch();
}
Output:
A sample run of the program works as:-
Enter the number of nodes :
3
Enter the cost matrix
:027
201
710
For router 1
node 1 via 1 Distance 0
node 2 via 2 Distance 2
node 3 via 3 Distance 3
For router 2
node 1 via 1 Distance 2
node 2 via 2 Distance 0
node 3 via 3 Distance 1
For router 3
node 1 via 1 Distance 3
node 2 via 2 Distance 1
node 3 via 3 Distance 0
EXPERIMENT:12

AIM:-Write aProgram to implement Broad cast tree by taking subnet of hosts

Theory:
 IP addressing is the allocation of unique ID to each and every system connected in a network
to maintan communication among them through out the affixed network.
 There are 5 classes of IP Addresses namely A through E with the range varying from one
class to the other class. A subnet is a network allocation to similar systems or same hierarchial
systems present in a allocated network like an organisation.
 Each and every system can be reachd through a client-server computing environment where
the server acts as the Master and the clients acts as the Slaves to form a MasterSlave
computing environment. Below programs show the calculation of network addresses with
subnet predefinition and subnet generation.

/ *PROGRAM TO IMPLEMENT BROADCAST ROUTING ALGORITHM*/


#include<stdio.h>
int a[10][10],n;
main()
{
int i,j,root;
clrscr();
printf(“Enter no.of nodes:”);
scanf(“%d”,&n);
printf(“Enter adjacent matrix\n”);
for(i=1;i<=n;i++) for(j=1;j<=n;j+
+)
{
printf(“Enter connecting of %d–>%d::”,i,j);
scanf(“%d”,&a[i][j]);
}
printf(“Enter root node:”);
scanf(“%d”,&root);
adj(root);
}
adj(int k)
{
int i,j;
printf(“Adjacent node of root node::\n”);
printf(“%d\n\n”,k);
for(j=1;j<=n;j++)
{
if(a[k][j]==1 || a[j][k]==1)
printf(“%d\t”,j);
}
printf(“\n”);
for(i=1;i<=n;i++)
{
if((a[k][j]==0) && (a[i][k]==0) && (i!=k))
printf(“%d”,i);
}
}

OUTPUT

Enter no.of nodes:5


Enter adjacent
matrix
Enter connecting of 1–>1::0
Enter connecting of 1–>2::1
Enter connecting of 1–>3::1
Enter connecting of 1–>4::0
Enter connecting of 1–>5::0
Enter connecting of 2–>1::1
Enter connecting of 2–>2::0
Enter connecting of 2–>3::1
Enter connecting of 2–>4::1
Enter connecting of 2–>5::0
Enter connecting of 3–>1::1
Enter connecting of 3–>2::1
Enter connecting of 3–>3::0
Enter connecting of 3–>4::0
Enter connecting of 3–>5::0
Enter connecting of 4–>1::0
Enter connecting of 4–>2::1
Enter connecting of 4–>3::0
Enter connecting of 4–>4::0
Enter connecting of 4–>5::1
Enter connecting of 5–>1::0
Enter connecting of 5–>2::0
Enter connecting of 5–>3::0
Enter connecting of 5–>4::1
Enter connecting of 5–>5::0
Enter root node :2
Adjacent node of root node::
2
134
5
EXPERIMENT:13
AIM:-
i. Wireshark
ii. PacketCaptureUsingWireshark
iii. StartingWireshark
iv. ViewingCapturedTraffic
v. AnalysisandStatistics&Filters.
Wireshark:
 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 (but at a higher level, of course).
 In the past, such tools were either very expensive, proprietary, or both. However, with the
advent of Wireshark, that has changed. Wireshark is available for free, is open source, and
is one of the best packet analyzers available today.
 Few tools are as useful to the IT professional as Wireshark, the go-to network packet capture
tool. Wireshark will help you capture network packets and display them at a granular level.
Once these packets are broken down, you can use them for real-time or offline analysis.
 This tool lets you put your network traffic under a microscope, and then filter and drill down
into it, zooming in on the root cause of problems, assisting with network analysis and
ultimately network security. This Wireshark is a free and open source packet analyzer used for
network troubleshooting and analysis. These activities will show you how to use Wireshark to
start a network capture.

(i) PacketCaptureUsingWireshark
Start a Wireshark Capture
To start a Wireshark capture from the Capture Interfaces dialog box:
 Observe the available interfaces. If you have multiple interfaces displayed, look for the
interface with the highest packet count. This is your most active network interface.
 Select the interface you want to use for the capture using the check box on the left.
 Select Start to begin the capture.
capture in Wireshark:

 Wireshark captures each packet sent to or from your system.


Capturing Packets
 After downloading and installing Wireshark, you can launch it and double-click the name of a
network interface under Capture to start capturing packets on that interface. For example, if
you want to capture traffic on your wireless network, click your wireless interface.
 You can configure advanced features by clicking Capture > Options, but this isn’t necessary
for now.

As soon as you click the interface’s name, you’ll see the packets start to appear in real time. Wireshark
captures each packet sent to or from your system.
If you have promiscuous mode enabled—it’s enabled by default—you’ll also see all the other packets
on the network instead of only packets addressed to your network adapter.
To check if promiscuous mode is enabled, click Capture > Options and verify the “Enable promiscuous
mode on all interfaces” checkbox is activated at the bottom of this window.
Click the red “Stop” button near the top left corner of the window when you want to stop capturing
traffic.

Sample capture:
if there’s nothing interesting on your own network to inspect, Wireshark’s wiki has you covered. The
wiki contains a page of sample capture files that you can load and inspect. Click File > Open in
Wireshark and browse for your downloaded file to open one.
You can also save your own captures in Wireshark and open them later. Click File > Save to save your
captured packets.
Figure :Wireshark captures packets and lets you examine their contents.

ii)Starting Wireshark:

Two different methods for starting Wireshark are available. These include the Start menu and the Run
command box.
Method 1 - Start Menu
To start Wireshark using the Start menu:
1.Open the Start menu.
2. Select All
Programs. 3.Select
Wireshark.

Method 2 - Run Command


To start Wireshark using the Run command box:
Open the Start menu or press the Windows key +
R. Type Wireshark in the Run command box.
Press Enter.
(iii) ViewingCapturedTraffic Viewing Packets You Have Captured:
 Once you have captured some packets or you have opened a previously saved capture file, you
can view the packets that are displayed in the packet list pane by simply clicking on a packet in
the packet list pane, which will bring up the selected packet in the tree view and byte view
panes.
 You can then expand any part of the tree to view detailed information about each protocol in
each packet. Clicking on an item in the tree will highlight the corresponding bytes in the byte
view.
 An example with a TCP packet selected is shown in Figure 6.1, “Wireshark with a TCP
packet selected for viewing”. It also has the Acknowledgment number in the TCP header
selected, which shows up in the byte view as the selected bytes.

Figure 6.1. Wireshark with a TCP packet selected for viewing


 You can also select and view packets the same way while Wireshark is capturing if you selected
“Update list of packets in real time” in the “Capture Preferences” dialog box.
 In addition you can view individual packets in a separate window as shown in Figure :
“Viewing a packet in a separate window”. You can do this by double-clicking on an item in
the packet list or by selecting the packet in which you are interested in the packet list pane and
selecting View → Show Packet in New Window. This allows you to easily compare two or more
packets, even across multiple files.
Figure :Viewing a packet in a separate window

Along with double-clicking the packet list and using the main menu there are a number of other ways to
open a new packet window:
 Hold down the shift key and double-click on a frame link in the packet details.
 From Table “The menu items of the “Packet List” pop-up menu”.
 From Table , “The menu items of the “Packet Details” pop-up menu”.

 How to capture WiFi traffic using Wireshark on Windows


 Wireshark uses libpcap or Winpcap libraries to capture network traffic on Windows. Winpcap
libraries are not intended to work with WiFi network cards, therefore they do not support
WiFi network traffic capturing using Wireshark on Windows. Monitor mode for Windows
using Wireshark is not supported by default.
Winpcap Capture Limitations and WiFi traffic on Wireshark:
 Capture is mostly limited by Winpcap and not by Wireshark. However, Wireshark
includes Airpcap support, a special -and costly- set of WiFi hardware that supports WiFi traffic
monitoring in monitor mode. In other words, it allows capturing WiFi network traffic
in promiscuous mode on a WiFi network. However these cards have been discontinued and are
deprecated, so they cannot capture traffic on networks running the latest WiFi standards
(802.11ac).
 Acrylic Wi-Fi Sniffer is an innovative alternative for capturing Wi-Fi traffic in monitor
mode from Windows, including the latest 802.11ac standard.
 Acrylic Wi-Fi Sniffer
 Acrylic Wi-Fi Sniffer also enables Wi-Fi packet capture in monitor mode with Wireshark on
Windows (in the latest versions Wireshark 3.0.0 or higher) and with other Acrylic Wi-Fi
products such as Heatmaps or Professional. Because it has been designed as an economical and
easily configurable alternative to AirPCAP hardware, it can capture all data available with
this type of card, including SNR values, and is compatible with the latest 802.11ac standard in
all channel widths (20, 40, 80 and 160 MHz).

 If you want to know more about capture modes or discover the features that these two
alternatives provide within Acrylic Wi-Fi products, please visit “Monitor mode and
native capture mode in Acrylic Wi-Fi” article.
Acrylic Wi-Fi Sniffer and WiFi interfaces in Wireshark

 This integration is much easier than the previous one. Just install Acrylic Wi-Fi Sniffer and in
the control panel of the sniffer click on the button “Install integration” as shown in the image
below

Acrylic Wi-Fi Sniffer control panel with integration and configuration section highlighted
Once done, start Wireshark as administrator and all Acrylic Wi-Fi Sniffer available interfaces will be
displayed.
 Select an interface to use with Acrylic Wi-Fi Sniffer and click on the configuration wheel as
seen in the previous screenshot and configure both channels and bandwidth where the capture
will be carried out.
 Once configured, we can start the capture in Wireshark and start receiving packets.
 We have added a toolbar in WireShark that allows to quickly change the configuration on-the-
go as shown in the image below
 In order to activate it please go to “View” menu > “Interface toolbars” > “Acrylic Wi-Fi
Sniffer interface integration”.

WiFi traffic capturing using Wireshark:

In short, after installing Acrylic Wi-Fi Sniffer we start Wireshark as Administrator (right-click on
Wireshark icon and select “Run as Administrator”) and select any Wi-Fi card that appears with the
name NDIS network interface or Acrylic Wi-Fi Sniffer. In our case “Dell Wireless 1702/b/g/n WiFi
Card” (integrated into Dell equipment) and the “RT8814X” (via Acrylic Wi-Fi Sniffer)
(iv) Analysis and Statistics & Filters
The “Analyze” Menu:
The Wireshark Analyze menu contains the fields shown in Table“Analyze menu items”.

Figure :The “Analyze” Menu


Table : Analyze menu items
Menu Item Accelerator Description

Display Filters… Displays a dialog box that allows you to create and edit display filters. You can
name filters, and you can save them for future use. See Section 6.6, “Defining And
Saving Filters”.

Display Filter Shows a dialog box that allows you to create and edit display filter macros. You can
Macros… 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.

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

Prepare as Filter 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 appended to by the
selected protocol field in the packet details pane.

Conversation Apply a conversation filter for various protocols.


Filter

Enabled Shift+Ctrl+E Enable or disable various protocol dissectors. See Section 11.4.1, “The “Enabled
Protocols… Protocols” dialog box”.

Decode As… Decode certain packets as a particular protocol. See Section 11.4.2, “User Specified
Decodes”.

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

Follow → Same functionality as “Follow TCP Stream” but for UDP “streams”.
UDP Stream

Follow → Same functionality as “Follow TCP Stream” but for TLS or SSL streams. See the wiki
TLS Stream page on TLS for instructions on providing TLS keys.

Follow → HTTP Same functionality as “Follow TCP Stream” but for HTTP streams.
Stream

Expert Info Open a window showing expert information found in the capture. Some protocol
dissectors add packet detail items for notable or unusual behavior, such as invalid
checksums or retransmissions. Those items are shown here. See Section 7.4, “Expert
Information” for more information.
The amount of information will vary depend on the protocol
The “Statistics” Menu:
The Wireshark Statistics menu contains the fields shown in Table : “Statistics menu items”.

Figure 3.9. The “Statistics” Menu

Each menu item brings up a new window showing specific statistics.


Table : Statistics menu items

Menu Item Accelerator 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”

I/O Graphs Display user specified graphs (e.g., the number of packets in
the course of time), see Section 8.8, “The “I/O Graphs”
Window”.

Service Response Display the time between a request and the


Time corresponding response, see Section 8.9, “Service
Response Time”.
DHCP (BOOTP) See Section 8.10, “DHCP (BOOTP) Statistics”

NetPerfMeter See Section 8.11, “NetPerfMeter Statistics”

ONC-RPC Programs See Section 8.12, “ONC-RPC Programs”

29West See Section 8.13, “29West”

ANCP See Section 8.14, “ANCP”

BACnet See Section 8.15, “BACnet”

Collectd See Section 8.16, “Collectd”

DNS See Section 8.17, “DNS”

Flow Graph See Section 8.18, “Flow Graph”


Menu Item Accelerator Description

HART-IP See Section 8.19, “HART-IP”

HPFEEDS See Section 8.20, “HPFEEDS”

HTTP HTTP request/response statistics, see Section 8.21, “HTTP


Statistics”

HTTP2 See Section 8.22, “HTTP2”

Sametime See Section 8.23, “Sametime”

TCP Stream Graphs See Section 8.24, “TCP Stream Graphs”

UDP Multicast See Section 8.25, “UDP Multicast Streams”


Streams

Reliable Server See Section 8.26, “Reliable Server Pooling (RSerPool)”


Pooling (RSerPool)

F5 See Section 8.27, “F5”

IPv4 Statistics See Section 8.28, “IPv4 Statistics”

IPv6 Statistics See Section 8.29, “IPv6 Statistics”


EXPERIMENT:14

AIM:-How to run Nmap scan


 Are you worried about the security of your network or the security of someone else's?
Ensuring that your router is protected from unwanted intruders is one of the
foundations of a secure network. One of the basic tools for this job is Nmap, or
Network Mapper.
 This program will scan a target and report which ports are open and which are
closed, among other things. Security specialists use this program to test the security
of a network. To learn how to use it yourself, see Step 1 below.
Method1:
Using Zenmap
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:[1]
 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.[2]

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.
EXPERIMENT:15.

AIM: Operating System Detection using Nmap

 Network Vulnerability and Scanning: Operating System Detection in Nmap


 First, one of the Nmap’s best known features is the remote Operating System Detection using
the TCP/IP stack fingerprinting Nmap sends a series of TCP and UDP packets to the remote
host and examines practically every bit in the response.
 Dozens of test is performing on the target machine/system:
 TCP ISN sampling
 TCP options support and ordering
 IP ID sampling
 Initial window size check

Then, Nmap compares the results to its “nmap-os-db” database which contain more than 2600 known
OS fingerprints and print outs any OS details when there is a match.

 Each fingerprint includes a free-form textual description of the OS and a classifications


which provides : Vendor name (eg. Sun)
underlying OS (eg.
Solaris) OS generation
(eg.10)
device type (general purpose, router, switch, game console, etc)
 Most fingerprints also have a Common Platform Enumeration (CPE) representation, like
cpe:/o:linux:linux_kernel:2.6. OS detection is far more effective if at least one open and
one closed TCP port are found.
 Let’s see the OS detection (-O) in action in Linux machine:
 We have to use OS detection with one of the port detection techniques and SYN scan will
be used in this demonstration.
Kali Linux Machine
Let’s create a nmap command to scan the target system which is metasploitable machine:
nmap is the application itself
-n to avoid DNS resolution
-sS is SYN Scan
Target IP for the Metasploitable machine
--top-ports 100 for the top 100 ports to be scanned
-O is for OS detection
Results of the OS detection(Kali Linux):
Running: General purpose device
OS CPE: cpe:/o:linux:linux_kernel:2.6
OS details: 2.6.9–2.6.33

Metasploitable machine
The actually OS version is 2.6.24 for the Metasploitable machine.
More aggressive Nmap Scan to have a more accurate result:

We can use a --osscan-guess parameter with the OS detection (-


O). Let’s see the OS detection (-O) in action in Windows machine:
Before that, let’s install windows 10 in virtual box:

Download the window 10 VM from the website: https://developer.microsoft.com/en-


us/windows/downloads/virtual-machines/
Unzip the folder and import the downloaded ova file downloaded.

Change the network to Natnetwork to ensure that the window machine stay in the same network as the
Kali Linux machine.
Start the window machine and open the command prompt to find out the IP address with command
“ipconfig”.
Let’s start the OS detection in windows 10:

First, we try the normal ping command in the terminal to ping the windows machine. The window
system does not responding to the ping requests or we cannot reach the system.
Second, we perform an Nmap ping scan to find out whether the machine is up or not. As a result, the
window machine is up running. Thus, we are unable to reach the system.
Now, I want to scan the top 10 TCP ports of the systems with SYN Scan. The reason parameter is
added to display the reasons of the results. All the port scanned is filtered as there are no responses
from them.

The OS detection is added to the latest Nmap Query and rerun it.In the result, Nmap cannot find the OS
details as it does not have a result set to probe or interrogate.
Enable the Internet Information Services to host a default website of IIS.

Start the Internet Information Services(IIS) Manager to start to host the default website of IIS
.
Open the web browser to reach the website by inserting the IP address of the system into the address bar.
Now, the web service is up.

Now, we test whether if we can reach the IIS website from Kali Linux machine.
If the website is not reachable in Kali machine’s web browser, then you probably need to navigate to the
window defender firewall and allow the HTTP Services. This allows the Kali machine to reach
the Port 80 of the Windows machine.

Run the SYN Scan for the Windows machine(IP address:10.0.2.5) top 10 ports. Here, we notice that the
port 80 is now open.
Now, we reply the scan with OS detection option. Now, we have the OS detection result. First,
Nmap warn us about the OS Scan is unreliable as nmap couldn’t find at least 1 open and 1
closed port to probe from. Here, we only able to find out that 85% is Windows XP SP2. Thus, we
only know the guessing of the Window Machine OS. However, the result is not accurate.
EXPERIMENT-16
AIM: Do the following using NS2 Simulator

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

 NS2 Simulator Tutorial for Beginners is one of our prime services started for the beginners,
who wish to learn NS-2 completely. It is also a widespread network simulator used by
majority of students and scholars today.
 Our Tutorial for Beginners provides basic information about NS2, which can be utilized
by students to get an idea about NS-2. Right start is the key for right success.
 This is the reason; we focus on guiding the beginners as they are like mud which can be
molded in any ways.
 We mold our students in a perfect way to make them to walk towards the right path of success.
Also, We start our guidance from the basics of NS-2 and support until the student becomes an
expert of NS-2. Along with tutoring service on NS-2, we offer support for NS-2 based
projects, assignments, lab cycles etc. As a step towards our guidance, we also have provided
few basic concepts of NS2 below, for students to get some knowledge about NS-2.
NS-2 BASICS:

 It is also an open source simulator widely used for Educational and research purpose.
Two major things one must know about it, is also the language used in it and it’s
supported Networks. It is also basically implemented in OTCL [Object oriented extension
of TCL].
 Two major languages, it also supports are C++ and TCL [Tool command language]. It
is also used to simulate both wired and wireless Networks [Mobile Ad hoc Networks,
Wireless sensor Networks, Wireless body area network etc].
 Simulation in NS2 is based on the following constraints i.e. Node creation and also
configuration, Node color description, creation of duplex links and also orientations,
labeling of Nodes, establishing queuing methods, TCP and also UDP connection and
data transmission.

INTRODUCTION

 Network simulation is an important to online developing, testing and evaluating network


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

Improving Network Simulation:


 Wang states that “Simulation results are not as convincing as those produced by real
hardware and software equipment.”
 This statement is followed by an explanation of the act that most existing network simulators
can only simulate real life network protocol implementations with limited detail, which can
lead to incorrect results.
 Another paper includes a similar statement, “running the actual TCP code is preferred to
running an abstract specification of the protocol.” Brakmo and Peterson go on to discuss how
the BSD implementations of TCP are quite important with respect to timers. Simulators
often use more accurate round trip time measurements than those used in the BSD
implementation
,making results differ.
 Using real world network stacks in a simulator should make results more accurate, but itis
not clear how such stacks should be integrated with a simulator. The network simulator
NCTUns shows how it is possible to use the network stack of the simulators machine.

Network Simulation Experience

The Network Simulator offers a simplified and complete network simulation experience.
The following diagram depicts this functionality offered by the Network Simulator
 The Network Simulator can design and simulate a network with
SNMP,TL1,TFTF,FTP,Telnet and IOS devices , in four simple steps:

 Add devices to the Device tree: Add devices with the required configuration to the device tree
in the Network Designer. Preconfigured devices are also bundled with the toolkit.
 Create the Network: Create and add bulk devices to the network, at one shot.
 Configure the Network devices : Configure the devices in the network, if required.
 Start the Network : Start the network or start individual agents in the network. The MIB
Browser and
 TL1 Craft Interface test tools, can be used as the manager tools for testing.

 Network Emulation: Network emulation refers to actual network traffic passing through
some software which might do some analysis or perhaps modify the traffic in some way. The
Emulation Network in the WAND group is used for testing and evaluation of networking
software and hardware.
 The scale is limited; it is made up 24 emulation machines and one central controlling
computer. Setup of such a network is time consuming and expensive: in addition to the
aforementioned 25 computers, a Cisco2950 switch and a Cyclades 32 port terminal server are
included in the network.
 Each emulation machine also has a 4 port network interface controller. The controlling
machine includes special capture cards (known as DAG [6] cards) to allow easier capture and
processing of network traffic. This network has no easy way of adding latency and bandwidth
bottlenecks, which means creating adverse conditions on the network is difficult. It is possible
to use Dummynett.add latency, but this is a lot of work.
 There is a project to solve this issue; a non blocking crossbar Ethernet switch is being created
for the network ,but the cost involve dislarge.
 Other network emulation done in the WAND group include validating the WAND
simulator. This was done by setting up a physical network with FreeBSD machines using
Dummynet to add latency. Dummynet is one example of network emulation software, NIST
Net is another,
 it claimsto “allow controlled ,reproducible experiments with network performance
sensitive/adaptive applications and control protocols in a simple laboratory
setting”.
 NS-2 also provides some network emulation functionality, it is able to capture packets from
the live network and drop, delay, re-order, or duplicate them. Emulation, especially in the case
of a network simulator like NS-2, is interesting because it is using real world data from real
world network stacks.
 Emulation offers something simulation never can: it is performed on a real network, using
actual equipment and real software. However, it is very limited compared to simulation in
other areas; for example scale.
 The WAND Emulation Network described earlier requires a lot of setup and is expensive,
yet only contains 24emulation machines. There is no theoretical limit to the number of nodes
a simulator can handle, and increasing the size of a simulation does not cost anything.
 The factors to consider are RAM, disk space and the small amount of time taken to change
a simulation script. In general, changing the simulation is a simple step, though it would be
complex in the case a huge amount of nodes being required (a million, for example).
 Also, network emulation must of course be run in real time, where simulation can sometimes
simulate large time periods in a small amount of time. In the case of a million nodes, the
simulation might run in greater than real time because the hardware it is run on would limit
performance.
Introduction to Network Simulators

 Network simulators implemented in software are valuable tools for researchers to develop,
test, and diagnose network protocols.
 Simulation is economical because it can carry out experiments with out the actual hardware.
 It is flexible because it can, for example, simulate a link with any bandwidth and
propagation delay.
 Simulation results are easier to analyze than experimental results because important information
at critical points can be easily logged to help researchers diagnose network protocols.
 Network simulators, however, have their limitations. A complete network simulator needs to
simulate networking devices (e.g., hosts and routers) and application programs that generate
network traffic.
 It also needs to provide network utility programs to configure, monitor, and gather
statistics about a simulated network. Therefore, developing a complete network simulator
is a large effort.
 Due to limited development resources, traditional network simulators usually have the
following drawbacks:
 Simulation results are not as convincing as those produced by real hardware and
software equipment . Inorder to constraint their complexity and development cost ,most
network simulators
 Usually can only simulate real-life network protocol implementations with limited details,
and this may lead to incorrect results.
 These simulators are not extensible in the sense that they lack the standard UNIX
POSIX application programming interface(API). As such ,existing or to-be-developed
real-life application programs can not run normally to generate traffic for a simulated
network
 .Instead, they must be rewritten to use the internal API provided by the simulator (if there
is any)and be compiled with the simulator to form a single ,big, and complex program.
 To overcome these problems, Wang invented a kernelre-entering simulation methodology and
used it to implement the Harvard network simulator. Later on, Wang further improved the
methodology and used it to design and implement the NCTU nsnetwork simulator and
emulator.

 Different types of simulators

Some of the different types of simulators are as

follows:- s MIT's NETSIM


s NIST
s CPSIM
s INSANE
s NEST
s REAL
s NS
s OPNET
s NCTUns
A brief explanation of some of the above simulators is as follows

REAL

REAL(Realistic And Large)is a network simulator written at Cornell University by


S.KeshavandbasedonamodifiedversionofNEST2.5.

Use

NESTisintendedforstudyingthedynamicbehaviorofflowandcongestioncontrolschemesinpacket-switched
data networks (namely TCP/IP).

The package

REAL provides 30 modules written in C that emulate flow-control protocols such as TCP, and 5
scheduling disciplines such as FIFO, Fair Queuing, DEC congestion avoidance and Hierarchical Round
Robin.

Implementation of the stimulation:

 The NEST code has been rewritten to make it less general, cleaner and faster. REAL is
still implemented as a client-server program. The code is freely available to anyone willing
to modify it.
 Node functions implement computation at each node in the network whereas queue
management and routing functions manage buffers in nodes and packet switching.
 Routing is static and is based on Dijkstras's shortest path algorithm. A node could be a source,
a router or a sink. Source nodes implement TCP-like transport layer functionality. Routers
implement the scheduling disciplines, while the sinks are universal receivers that only
acknowledge packets.
 Since NEST didn't not allow for timers, REAL sends out a timer packet from a source back to
it self to return after some specified time, but timers cannot be reset using this method.
 Simulate at three-node point-to-point network with a duplex link between them .Set the
queue size and vary the band width and find the number of packets dropped.
STEPS:

Step1: Select the hub icon on the tool bar and drag it on to the working window.

Step2:Selectthehosticononthetoolbaranddragitontotheworkingwindow.Repeat this for an otherhost


icon.

Step3: Select the link icon on the toolbar and drag it on the screen from host (node 1) to the hub and
again from host(node 2) to the hub. Here the hub acts as node 3 in the point-to-point network. This
leads to the creation of the 3-node point-to-point network topology. Save this topology as a .tpl file.

Step4:Double-click on host(node 1), a host dialog box will open up. Click on Node editor and you can
see the different layers- interface, ARP, FIFO, MAC, TCPDUMP, Physical layers.
 Select MAC and then select full-duplex for switches and routers and half duplex for hubs,
and in log Statistics, select Number of Drop Packets, Number of Collisions, Throughput of
incoming packets and Throughput of outgoing packets.
 Select FIFO and set the queue size to50 and press OK. Then click on Add. Another dialog
box popsup. Click on the Command box and type the Command according to the following
syntax:

stg[-t duration(sec)][-pportnumber]HostI Paddr and click OK.

Step5:Double-click on host(node2),and follow the same step as above with only change in command
according to the following syntax:
rtg[-t][-w log][-pportnumber] and click OK.

Step6: Double click on the link between node1 and the hub to set the bandwidth to some initial
Value say, 10Mbps. Repeat the same for the other node.

Step 7:Click on the E button (Edit Property)present on the toolbar in order to save the changes made
to the topology.
Now click on the R button (Run Simulation).
By doing so a user can run/pause/continue/stop/abort/disconnect/reconnect/submitasimulation.No
simulations settings can be changed in this mode.

Step 8: Now go to Menu->Simulation->Run. Executing this command will submit he current


simulation job tone available simulation server managed by the dispatcher .When the simulation
Server is executing ,the user will see the time k not at the bottom of the screen move . The time k not
reflects the current virtual time(progress)of the simulation case.

Step9:To start the play back, the user can left-click the start icon (|>) of the time bar located at the
bottom. The animation player will the n start playing there corded packet animation.

Step10:Changethebandwidth say, 9Mbps, and run the simulation and compare the two results.

Step11:Toview the results, go to the file name. results folder.


.

16.2Simulate 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.

STEPS:

Step1:Create the topology as specified in the question, in the draw mode of the simulator.

Step2: Go to edit mode and save the topology.

Step3:Setup a TCP connection betweennode1 andnode3 using the following commands:


stcp [-p port] [-l writesize] hostIPaddrrtcp[-p port] [-lreadsize]

Step4:Setupa UDPconnectionbetweennode2andnode3 using the following commands:


stg[-upayloadsize duration][Host address]
rtg[-u] [-w log]

Step5:Settheoutputthroughputlogtodeterminethenumberofpacketssentby TCP/UDP as described in


experiment 1.

Step6:Toview the result agents changing the parameters and determine the number of packets sent by
two agents.
The screen shot of the topology is shown below:

.
16.3)Simulate the transmission of pingmessagesoveranetworktopologyconsistingof6nodesandfind the
number of packets dropped due to congestion.

STEPS:

Step1:Clickonthesubneticononthetoolbarandthenclickonthescreenofthe working window.

Step2:Selecttherequirednumberofhostsandasuitableradiusbetweenthe host and the switch.

Step 3: In the edit mode, get the IP address of one of the hosts say, host 1 and then for
theotherhostsay,host2set the drop packet and no: of collisions statistics as described in the
earlier experiments.

Step4:Nowrunthesimulation.

Step5:Now click on anyone of the hosts and click on command console and ping the
destination node.
Ping IP Address of the host.

Note:Theno:ofdroppacketsareobtainedonlywhenthetrafficismoreinthenetwork.Forcheckingtheno of
packets dropped press ctrl+C.

The screen shot of the topology is shown below:


16.4Simulate an Ethernet LAN using N nodes (6-10), change error rate and data rate and compare
through put.

STEPS:

Step1:Connectonesetofhostswithahubandanothersetofhostsalsothrougha hub and connect these two


hubs through a switch .This forms an Ethernet LAN.

Step2:SetupaTCPconnection between a host on one hub and host on another hub using
the following command:

stcp [-p port] [-l writesize] hostIPaddrrtcp[-p port] [-lreadsize]

Step3:Setuptheerror rate, data retain the physical layer, input and output through put in the mac layers
described above.

Step 4: Change error rate and data rate and compare


thethroughputs.Step5:Viewtheresultsinthefilename.results.

The screen shot of the topology is shown below:

You might also like