CNLab FinalFormatted
CNLab FinalFormatted
isadeviceforconnectingmultipletwistedpairorfiberopticEthernetdevicestogether and
making them act as a single networksegment.Hubsworkat thephysical layer (layer 1)
of the OSI model. The device is a form of multiport repeater.Repeater
hubsalsoparticipate incollision detection,forwardinga jam signaltoallportsif it detects
acollision.
Page | 1
3. Switch:Anetwork switch or switching hub isacomputer networking devicethat connects
network segments.The term commonly refers to a network bridge thatprocessesandroutesdata at
the data link layer (layer 2) of the OSI
model.Switchesthatadditionallyprocessdataatthenetworklayer(layer3andabove)areoftenre ferred
toas Layer 3switchesormultilayerswitches.
Switch
4. Bridge: A network bridge connects multiple network segments at the data linklayer (Layer 2)
of the OSI model.In Ethernetnetworks,the term bridgeformallymeans a device that behaves
according to the IEEE 802.1D standard. A bridge andswitch are very much alike; a switch being
a bridge with numerous ports. Switch
orLayer2switchisoftenusedinterchangeablywithbridge.Bridgescananalyzeincoming data packets
to determine if the bridge is able to send the given packet toanothersegmentof thenetwork.
Page | 2
interconnected networks, the routers exchange information about targetsystem addresses, so
that each router can build up a table showing the preferred pathsbetweenany two systems
on the interconnectednetworks.
b. Aprotocoltranslation/mappinggatewayinterconnectsnetworkswithdifferen
tnetworkprotocoltechnologiesbyperformingtherequiredprotocolconversio ns.
Page | 3
b) AIM: Connect thecomputersin localareanetwork.
1. LogontothehostcomputerasAdministratororasOwner.
2. ClickStart,andthenclickControlPanel.
3. ClickNetworkandInternetConnections.
4. ClickNetworkConnections.
5. Right-click the connection that you use to connect to the Internet. For example, ifyou connect to
the Internet by using a modem, right-click the connection that youwantunderDial-up / other
networkavailable.
6. ClickProperties.
7. ClicktheAdvancedtab.
8. Under Internet Connection Sharing, select the Allow other network users
toconnectthroughthiscomputer'sInternetconnectioncheckbox.
9. If you are sharing a dial-up Internet connection, select the Establish a dial-
upconnectionwheneveracomputeronmynetworkattemptstoaccess theInternet check box if you
want to permit your computer to automatically connecttotheInternet.
To connect to the Internet by using the shared connection, you must confirm the
LANadapter IP configuration, and then configure the client computer.To confirm the
LANadapterIPconfiguration,follow thesesteps:
Page | 4
1. LogontotheclientcomputerasAdministratororasOwner.
2. ClickStart,andthenclickControlPanel.
3. ClickNetworkandInternetConnections.
4. ClickNetworkConnections.
5. Right-clickLocalAreaConnectionandthenclickProperties.
6. Click the General tab, click Internet Protocol (TCP/IP) in the
connectionusesthefollowingitemslist, andthenclickProperties.
7. In the Internet Protocol (TCP/IP) Properties dialog box, click Obtain an
IPaddressautomatically(if it isnotalreadyselected),andthenclickOK.
Note: You can also assign a unique static IP address in the range of 192.168.0.2
to192.168.0.254. For example, you can assign the following static IP address,
subnetmask,anddefault gateway:
8.IPAddress192.168.31.202
9.Subnet mask255.255.255.0
10. Default gateway192.168.31.1
11. IntheLocalAreaConnectionPropertiesdialogbox,clickOK.
12. QuitControlPanel.
Ping Output:
Traceroute Output:
Page | 5
Page | 6
EXPERIMENT-2
2. AIM: Write a program to implement the data link layer farming methods such as
i) Character stuffing ii) bit stuffing.
i)Character Stuffing
Program:
#include<stdio.h>
#include<string.h>
main()
{
char a[30], fs[50] = " ", t[3], sd, ed, x[3], s[3], d[3], y[3];
int i, j, p = 0, q = 0;
clrscr();
printf("Enter characters to be stuffed:");
scanf("%s", a);
printf("\nEnter a character that represents starting delimiter:");
scanf(" %c", &sd);
printf("\nEnter a character that represents ending delimiter:");
scanf(" %c", &ed);
x[0] = s[0] = s[1] = sd;
x[1] = s[2] = '\0';
y[0] = d[0] = d[1] = ed;
d[2] = y[1] = '\0';
strcat(fs, x);
for(i = 0; i<strlen(a); i++)
{
t[0] = a[i];
t[1] = '\0';
if(t[0] == sd)
strcat(fs, s);
else if(t[0] == ed)
strcat(fs, d);
else
strcat(fs, t);
}
strcat(fs, y);
printf("\n After stuffing:%s", fs);
}
OUTPUT:
Page | 7
ii) Bit stuffing
Program:
#include<stdio.h>
#include<string.h>
int main()
{
int a[20],b[30],i,j,k,count,n;
printf("Enter frame size (Example: 8):");
scanf("%d",&n);
printf("Enter the frame in the form of 0 and 1 :");
for(i=0; i<n; i++)
scanf("%d",&a[i]);
i=0;
count=1;
j=0;
while(i<n)
{
if(a[i]==1)
{
j++;
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)
{
}
i=k; b[j]=0;
} }
else
{
b[j]=a[i];
}
i++;
j++;
}
printf("After Bit Stuffing :");
for(i=0; i<j; i++)
printf("%d",b[i]);
return 0;
}
OUTPUT for BIT STUFFING:
Enter frame size (Example: 8):12
Enter the frame in the form of 0 and 1 :0 1 0 1 1 1 1 1 1 0 0 1
After Bit Stuffing :0101111101001
Page | 8
EXPERIMENT-3
3. AIM: Write a program to implement data link layer farming method checksum.
program:
#include<stdio.h>
#include<string.h>
int main()
{
char a[20],b[20];
char sum[20],complement[20];
int i,length;
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';
}
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';
Page | 9
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;
}
printf("\nSum=%c%s",carry,sum);
for(i=0;i<length;i++)
{
if(sum[i]=='0')
complement[i]='1';
else
complement[i]='0';
}
if(carry=='1')
carry='0';
else
carry='1'; printf("\nChecksum=%c
%s",carry,complement);
Page | 10
}
else {
printf("\nWrong input strings");
}
}
OUTPUT:
Page | 11
EXPERIMENT-4
4. AIM: Write a program for hamming code generation for error detection and
correction.
Program:
#include<stdio.h>
void main() {
int data[10];
int dataatrec[10],c,c1,c2,c3,i;
scanf("%d",&data[1]);
scanf("%d",&data[2]);
scanf("%d",&data[4]);
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);
Page | 12
for(i=0;i<7;i++)
printf("%d",dataatrec[i]); printf("\
nCorrect message is\n");
OUTPUT:
Encoded data is
1010010
Page | 13
EXPERIMENT-5
5. AIM: Write a program to implement on a data set of characters the three crc
polynomials – crc 12, crc 16 and crc ccip.
Program:
#include<stdio.h>
# include<string.h>
#define N strlen(g)
char t[28],cs[28],g[28];
int a,e,c,b;
void xor()
{
for(c=1;c<N;c++)
cs[c]=((cs[c]==g[c])?'0':'1');
}
void crc()
{
for(e=0;e<N;e++)
cs[e]=t[e];
do
{ if(cs[0]=='1')
xor();
for(c=0;c<N-1;c++)
cs[c]=cs[c+1];
cs[c]=t[e++];
}while(e<=a+N-1);
} int main()
{ int flag=0;
do{
printf("\n1.crc12\n2.crc16\ncrcccit\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);
Page | 14
for(e=a;e<a+N-1;e++)
t[e]='0';
printf("\n \n");
printf("mod-ified data is:%s",t);
printf("\n \n");
crc();
printf("checksum is:%s",cs);
for(e=a;e<a+N-1;e++)
t[e]=cs[e-a];
printf("\n \n");
printf("\n final codeword is : %s",t);
printf("\n \n");
printf("\ntest error detection 0(yes) 1(no)?:");
scanf("%d",&e);
if(e==0)
{
do{
printf("\n\tenter the position where error is to be inserted:");
scanf("%d",&e);
}
while(e==0||e>a+N-1);
t[e-1]=(t[e-1]=='0')?'1':'0';
printf("\n \n");
printf("\n\terroneous data:%s\n",t);
} crc();
for(e=0;(e<N-1)&&(cs[e]!='1');e+
+); if(e<N-1)
printf("error detected\n\n");
else
printf("\n no error detected \n\n");
printf("\n ");
}while(flag!=1);
} 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);
Page | 15
OUTPUT:
1.crc12
2.crc16
3.crc ccit
4.exit
Enter your option.1
enter data:1100110011100011
generating polynomial:1100000001111
checksum is:1101110110001
1.crc12
2.crc16
3.crc ccit
4.exit
enter data:11001100111000
generating polynomial:11000000000000101
Page | 16
EXPERIMENT-6
if(ack == windowsize)
break;
}
els sent = ack;
} e
return 0;
OUTPUT:
enter window size
8
Frame 0 has been transmitted.
Frame 1 has been transmitted.
Frame 2 has been transmitted.
Frame 3 has been transmitted.
Frame 4 has been transmitted.
Frame 5 has been transmitted.
Frame 6 has been transmitted.
Frame 7 has been transmitted.
Page | 17
Frame 3 has been transmitted.
Frame 4 has been transmitted.
Frame 5 has been transmitted.
Frame 6 has been transmitted.
Frame 7 has been transmitted.
Page | 18
EXPERIMENT-7
7. AIM: Write a program to implement sliding window protocol for selective repeat.
Program:
#include<stdio.h>
int main()
{
int w,i,f,frames[50];
for(i=1;i<=f;i++)
scanf("%d",&frames[i]);
printf("\nWith sliding window protocol the frames will be sent in the following manner
(assuming no corruption of frames)\n\n");
printf("After sending %d frames at each stage sender waits for acknowledgement sent by the
receiver\n\n",w);
for(i=1;i<=f;i++)
{
if(i%w==0)
{
printf("%d\n",frames[i]);
printf("Acknowledgement of above frames sent is received by sender\n\n");
}
else
printf("%d ",frames[i]);
}
if(f%w!=0)
printf("\nAcknowledgement of above frames sent is received by sender\n");
return 0;
}
Page | 19
OUTPUT:
Enter window size: 3
Enter number of frames to transmit: 5
Enter 5 frames: 12 5 89 4 6
With sliding window protocol the frames will be sent in the following manner (assuming no
corruption of frames)
After sending 3 frames at each stage sender waits for acknowledgement sent by the receiver
12 5 89
Acknowledgement of above frames sent is received by sender
46
Acknowledgement of above frames sent is received by sender
int main()
{
int w,i,f,frames[50];
for(i=1;i<=f;i++)
cin>>frames[i];
cout<<"\nWith sliding window protocol the frames will be sent in the following manner
(assuming no corruption of frames)\n\n";
cout<<"After sending "<<w<<" frames at each stage sender waits for acknowledgement sent
by the receiver\n\n";
for(i=1;i<=f;i++)
{
if(i%w==0)
{
cout<<frames[i]<<"\n";
Page | 20
cout<<"Acknowledgement of above frames sent is received by sender\n\n";
}
else
cout<<frames[i]<<" ";
}
if(f%w!=0)
cout<<"\nAcknowledgement of above frames sent is received by sender\n";
return 0;
}
OUTPUT:
Enter window size: 3
Enter 5 frames: 12 5 89 4 6
With sliding window protocol the frames will be sent in the following manner (assuming no
corruption of frames)
After sending 3 frames at each stage sender waits for acknowledgement sent by the receiver
12 5 89
Acknowledgement of above frames sent is received by sender
46
Acknowledgement of above frames sent is received by sender
Page | 21
EXPERIMENT-8
Page | 22
{
sender();
delay(400);
reciever();
}
}
/*
_*/
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 ");
Page | 23
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+
+;
Page | 24
}
/*
*/
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;
Page | 25
else
{
timer = 0;
*e = frame_arrival;
}
}
}
/*
*/
void wait_for_event_reciever(event_type * e)
{
if(turn=='r')
{
if(DATA.err==0)
*e = err;
else
*e = frame_arrival;
}
OUTPUT:
Page | 26
EXPERIMENT-9
9. AIM: Write a program for congestion control using leaky bucket algorithm.
program:
#include <stdio.h>
#include<stdio.h>
#include<stdlib.h>
int main()
int orate,drop=0,cap,x,count=0,inp[10]={0},i=0,nsec,ch;
scanf("%d",&cap);
scanf("%d",&orate);
do{
scanf("%d",&inp[i]);
i++;
scanf("%d",&ch);
}while(ch);
nsec=i;
for(i=0;count || i<nsec;i++)
printf(" %d",i+1);
Page | 27
printf(" \t %d\t ",MIN((inp[i]
+count),orate)); if((x=inp[i]+count-
orate)>0)
if(x>cap)
count=cap;
drop=x-cap;
else
count=x;
drop=0;
else
drop=0;
count=0;
printf(" \t %d \t %d \n",drop,count);
return 0;
OUTPUT:
enter bucket size : 5
1 1 1 0 0
2 2 2 0 0
Page | 29
EXPERIMENT-10
10. AIM: Write a program to implement dijkstra‘s algorithm to compute the shortest
path through a graph.
Program:
#include <limits.h>
#include <stdio.h>
#define V 9
int minDistance(int dist[], bool sptSet[])
{ int min = INT_MAX, min_index;
for (int v = 0; v < V; v++)
if (sptSet[v] == false &&dist[v] <= min)
min = dist[v], min_index = v;
return min_index;
}
int printSolution(int dist[], int n)
{ printf("Vertex Distance from Source\
n");
for (int i = 0; i< V; i++)
printf("%d \t %d\n", i, dist[i]);
}
void dijkstra(int graph[V][V], int src)
{ int dist[V];
bool sptSet[V];
for (int i = 0; i< V; i++)
dist[i] = INT_MAX, sptSet[i] = false;
dist[src] = 0;
for (int count = 0; count < V - 1; count++)
{ int u = minDistance(dist, sptSet);
sptSet[u] = true;
for (int v = 0; v < V; v++)
if (!sptSet[v] && graph[u][v] &&dist[u] != INT_MAX &&dist[u] + graph[u][v]
<dist[v]) dist[v] = dist[u] + graph[u][v];
}
printSolution(dist, V);
}
int main() {
int graph[V][V] = { { 0, 6, 0, 0, 0, 0, 0, 8, 0 },
{ 6, 0, 8, 0, 0, 0, 0, 13, 0 },
{ 0, 8, 0, 7, 0, 6, 0, 0, 2 },
{ 0, 0, 7, 0, 9, 14, 0, 0, 0 },
{ 0, 0, 0, 9, 0, 10, 0, 0, 0 },
{ 0, 0, 6, 14, 10, 0, 2, 0, 0 },
Page | 30
{ 0, 0, 0, 0, 0, 2, 0, 1, 6 },
{ 8, 13, 0, 0, 0, 0, 1, 0, 7 },
{ 0, 0, 2, 0, 0, 0, 6, 7, 0 }
};
dijkstra(graph, 0);
return 0;
}
OUTPUT:
Vertex Distance from Source
00
16
2 14
3 21
4 21
5 11
69
78
8 15
Page | 31
EXPERIMENT-11
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).
Program:
/*
Distance Vector Routing in this program is implemented using Bellman Ford Algorithm:-
*/
#include<stdio.h>
struct node
{
unsigned dist[20];
unsigned from[20];
}rt[10];
int main()
{
int costmat[20][20];
int nodes,i,j,k,count=0;
printf("\nEnter the number of nodes : ");
scanf("%d",&nodes);//Enter the nodes
printf("\nEnter the cost matrix :\n");
for(i=0;i<nodes;i++)
{
for(j=0;j<nodes;j++)
{
scanf("%d",&costmat[i][j]); costmat[i]
[i]=0;
rt[i].dist[j]=costmat[i][j];//initialise the distance equal to cost matrix
rt[i].from[j]=j;
}
}
do
{
count=0;
for(i=0;i<nodes;i++)//We choose arbitary vertex k and we calculate the direct distance
from the node i to k using the cost matrix
//and add the distance from k to node j
for(j=0;j<nodes;j++) for(k=0;k<nodes;k+
+)
if(rt[i].dist[j]>costmat[i][k]+rt[k].dist[j])
Page | 32
{//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
*/
Page | 33
EXPERIMENT-12
12. AIM: Write a program to implement broadcast tree by taking subnet of hosts.
program:
#include<stdio.h>
#include<conio.h
> int p,q,u,v,n;
int min=99,mincost=0;
int t[50][2],i,j;
int parent[50],edge[50][50];
main()
{
clrscr();
printf("\n Enter the number of nodes");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("%c\t",65+i);
parent[i]=-1;
}
printf("\n");
for(i=0;i<n;i++)
{
printf("%c",65+i);
for(j=0;j<n;j++)
scanf("%d",&edge[i][j]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
if(edge[i][j]!=99)
if(min>edge[i][j])
{
min=edge[i][j];
u=i;
v=j;
}
p=find(u);
q=find(v);
if(p!=q)
{
Page | 34
t[i][0]=u;
t[i][1]=v;
mincost=mincost+edge[u][v];
sunion(p,q);
}
Else
{
t[i][0]=-1;t[i][1]=-1;
}
min=99;
}
printf("Minimum cost is %d\n Minimum spanning tree is\n" ,mincost);
for(i=0;i<n;i++)
if(t[i][0]!=-1 && t[i][1]!=-1)
{
printf("%c %c %d", 65+t[i][0],65+t[i][1],edge[t[i][0]][t[i][1]]);printf("\n");
}
getch();
}
sunion(int l,int m)
{
parent[l]=m;
}
find(int l)
{
if(parent[l]>0)
i=parent[i];
return i;
}
OUTPUT:
Page | 35
EXPERIMENT-13
13. AIM: Study about wireshark
Wireshark is an open-source packet analyzer, which is used for education, analysis, software
development, communication protocol development, and network troubleshooting.
It is used to track the packets so that each one is filtered to meet our specific needs. It is commonly
called as a sniffer, network protocol analyzer, and network analyzer. It is also used by network
security engineers to examine security problems.
Wireshark is a free to use application which is used to apprehend the data back and forth. It is
often called as a free packet sniffer computer application. It puts the network card into an
unselective mode, i.e., to accept all the packets which it receives.
A packet is a unit of data which is transmitted over a network between the origin and the destination.
Network packets are small, i.e., maximum 1.5 Kilobytes for Ethernet packets and 64 Kilobytes for
IP packets. The data packets in the Wireshark can be viewed online and can be analyzed offline
Installation of Wireshark Software
Below are the steps to install the Wireshark software on the computer:
On the network and Internet settings option, we can check the interface connected to our
computer.
If you are Linux users, then you will find Wireshark in its package repositories.
Page | 36
1. Select Capture | Interfaces
2. Select the interface on which packets need to be captured. This will usually be the
interface where the Packet/s column is constantly changing, which would indicate the
presence of live traffic). If you have multiple network interface cards (i.e. LAN card
and Wi-Fi adapter) you may need to check with your IT administrator to determine the
right interface.
3. Click the Start button to start the capture.
4. Recreate the problem. The capture dialog should show the number of packets
increasing. Try to avoid running any other internet applications while capturing,
closing other browsers, Instant messengers etc.
5. Once the problem which is to be analyzed has been reproduced, click on Stop. It may
take a few seconds for Wireshark to display the packets captured.
6. Save the packet trace in the default format. Click on the File menu option and select
Save As. By default Wireshark will save the packet trace in libpcap format. This is a
filename with a.pcap extension.
You can start Wireshark from the command line, but it can also be started from most
Window managers as well. In this section we will look at starting it from the command line.
Wireshark supports a large number of command line parameters. To see what they are,
simply enter the command wireshark –h
Capture interface:
-i <interface>, --interface <interface>
name or idx of interface (def: first non-loopback)
-f <capture filter> packet filter in libpcap filter syntax
Page | 37
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.
iv. Analysis and Statistics & Filters.
Page | 38
Filters in wireshark
Wireshark has two filtering languages: capture filters and display filters. Capture filters are
used for filtering when capturing packets, “Filtering while capturing”. Display filters are
used for filtering which packets are displayed.
Page | 39
Page | 40
EXPERIMENT-14
14. AIM: How to run nmap scan.
1
Download the Nmap installer. This can be found for free from the developer’s website. It is
highly recommended that you download directly from the developer to avoid any potential
viruses or fake files. Downloading the Nmap installer includes Zenmap, the graphical
interface for Nmap which makes it easy for newcomers to perform scans without having to
learn command lines.
The Zenmap program is available for Windows, Linux, and Mac OS X. You
can find the installation files for all operating systems on the Nmap website.
2
Install Nmap. Run the installer once it is finished downloading. You will be asked
which components you would like to install. In order to get the full benefit of Nmap,
keep all of these checked. Nmap will not install any adware or spyware.
3
Run the "Nmap – Zenmap" GUI program. If you left your settings at default during
installation, you should be able to see an icon for it on your desktop. If not, look in
your Start menu. Opening Zenmap will start the program.
4
Enter in the target for your scan. The Zenmap program makes scanning a fairly
simple process. The first step to running a scan is choosing your target. You can
enter a domain (example.com), an IP address (127.0.0.1), a network
(192.168.1.0/24), or a combination of those.
5
Choose your Profile. Profiles are preset groupings of modifiers that change what is scanned.
The profiles allow you to quickly select different types of scans without having to type in the
modifiers on the command line. Choose the profile that best fits your needs:
Intense scan - A comprehensive scan. Contains Operating System (OS) detection,
version detection, script scanning, traceroute, and has aggressive scan timing.
This is considered an intrusive scan.
Ping scan - This scan simply detects if the targets are online, it does not scan any
ports.
Quick scan - This is quicker than a regular scan due to aggressive timing and only
scanning select ports.
Regular scan - This is the standard Nmap scan without any modifiers. It will
return ping and return open ports on the target.
6
Click Scan to start scanning. The active results of the scan will be displayed in the Nmap
Output tab. The time the scan takes will depend on the scan profile you chose, the
physical distance to the target, and the target’s network configuration.
7
Read your results. Once the scan is finished, you’ll see the message "Nmap done" at the
bottom of the Nmap Output tab. You can now check your results, depending on the type of
Page | 41
scan you performed. All of the results will be listed in the main Nmap Output tab, but you
can use the other tabs to get a better look at specific data.
Ports/Hosts - This tab will show the results of your port scan, including the
services for those ports.
Topology - This shows the traceroute for the scan you performed. You can see
how many hops your data goes through to reach the target.
Host Details - This shows a summary of your target learned through scans, such
as the number of ports, IP addresses, hostnames, operating systems, and more.
Scans - This tab stores the commands of your previously-run scans. This
allows you to quickly re-scan with a specific set of parameters.
Page | 42
EXPERIMENT-15
15. AIM: Operating system detection using nmap
program:
nmap -O -sVx.x.x.x
Starting Nmap 7.92 ( https://nmap.org ) at 2021-09-17 11:02 PDT
Nmap scan report for x.x.x.x
Host is up (0.22s latency).
Not shown: 994 closed tcp ports (reset)
Page | 43
EXPERIMENT-16
i. NS2 Simulator-Introduction
What is NS2
NS2 stands for Network Simulator Version 2. It is an open-source event-driven simulator
designed specifically for research in computer communication networks.
2. Features of NS2
1. It is a discrete event simulator for networking research.
2. It provides substantial support to simulate bunch of protocols like TCP, FTP, UDP, https and DSR.
3. Basic Architecture
NS2 consists of two key languages: C++ and Object-oriented Tool Command Language
(OTcl). While the C++ defines the internal mechanism (i.e., a backend) of the simulation
objects, the OTcl sets up simulation by assembling and configuring the objects as well as
scheduling discrete events. The C++ and the OTcl are linked together using TclCL
Page | 44
Additional program
17 AIM: Implement an Ethernet LAN using n nodes and set multiple traffic nodes and
plot conges the window for different source/destination.
Program:
#Create Simulator
#Open trace and NAM trace file set ntrace [open prog5.tr w]
#Use some flat file to create congestion graph windows set winFile0 [open WinFile0 w]
#Dump all trace data and Close the files global ns ntrace namfile
Page | 45
#Plot the Congestion Window graph using xgraph exec xgraph WinFile0 WinFile1 &
exit 0
#Create 6 nodes
Page | 46
#Nodes n(3) , n(4) and n(5) are considered in a LAN
set lan [$ns newLan "$n(3) $n(4) $n(5)" 0.5Mb 40ms LL Queue/DropTail MAC/802_3
Channel]
#Setup queue between n(2) and n(3) and monitor the queue
#Set error model on link n(2) to n(3) set loss_module [new ErrorModel]
#Set up the TCP connection between n(0) and n(4) set tcp0 [new Agent/TCP/Newreno]
Page | 47
set sink0 [new Agent/TCPSink/DelAck]
#Set up another TCP connection between n(5) and n(1) set tcp1 [new Agent/TCP/Newreno]
Page | 48
#Schedule Events
$ns run
OUTPUT:
Page | 49