CN Lab Manual - Bhavani.k
CN Lab Manual - Bhavani.k
CN Lab Manual - Bhavani.k
2. 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
(layer 1) 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.
Figure: Hub as a multi-port repeater can be connected in a hierarchical manner to
form a single LAN with many nodes
• Types of bridges:
i)Transparent Bridges
They basically works as the messenger agents that take data from one system,
interpret it, and transfer it to another system. Gateways are also called protocol
converters and can operate at any network layer. Gateways are generally more
complex than switch or router. A gateway can translate information between
different network data formats or network architectures.
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.
On the host computer, follow these steps to share the Internet connection:
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
connection whenever 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.
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. If these 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?
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.0
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:
6. Click the General tab, click Internet Protocol (TCP/IP) in the connection uses
the following items list, and then click Properties.
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.
PROGRAM:
#include<stdio.h>
#include<string.h>
#include<process.h>
void main()
{
int i=0,j=0,n,pos;
char a[20],b[50],ch;
printf("Enter string\n");
scanf("%s",&a);
n=strlen(a);
printf("Enter position\n");
scanf("%d",&pos);
if(pos>n)
{
printf("invalid position, Enter again :");
scanf("%d",&pos);}
printf("Enter the character\n");
ch=getche();
b[0]='d';
b[1]='l';
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);
}
OUTPUT:
ENTER STRING: COMPUTER
ENTER POSITION:3
ENTER THE CHARATER: @
FRAME AFTER STUFFING: dlestxcodle@dlemputerdleetx
AIM 2.B: Write a Program to implement the data link layer farming methods such as
Bit stuffing
#include<stdio.h>
#include<conio.h>
void main()
{
int i=0,count=0;
char databits[80];
printf("Enter Data Bits: ");
scanf("%s",databits);
printf("\nData Bits After Bit stuffing: ");
for(i=0; i<strlen(databits); i++)
{
if(databits[i]=='1')
count++;
else
count=0;
printf("%c",databits[i]);
if(count==5)
{
printf("0");
count=0;
}
}
getch();
}
Output:
Enter data bits: 0111110111110
Data bits after data stuffing: 01111100111110
AIM 3:
Write a Program to implement data link layer farming method checksum.
PROGRAM:
AIM 3: Write a Program to implement data link layer farming method checksum.
PROGRAM:
#include<stdio.h>
#include<conio.h>
int add(int, int);
int com(int);
void main() {
int i, j, dl, dil;
int data1[10], data2[10], newdata[10], comp[10], checksum[10];
printf("\n Enter the data length=");
scanf("%d", &dl);
printf("\n Enter the frame1 or data1 in the form of 0's and 1's : \n");
for (i = 0; i < dl; i++)
scanf("%d", &data1[i]);
printf("\n Enter the frame2 or data2 in the form of 0's and 1's: \n");
for (i = 0; i < dl; i++)
scanf("%d", &data2[i]);
for (i = dl - 1; i >= 0; i--) {
newdata[i] = add(data1[i], data2[i]);
}
Output:
Enter the data length= 4
Enter the frame1 or data1 in the form of 0's and 1's:1100
Enter the frame2 or data2 in the form of 0's and 1's:0101
Data 1:1100
Data 2:0101
New data is:10001
Checksum:01110
Receiver side:
Data:1100 0101 0110
Addition:11111
Compliment:00000
AIM 4: Write a program for Hamming Code generation for error detection and correction.
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main() {
int data[7],rec[7],i,c1,c2,c3,c;
printf("this works for message of 4bits in size \nenter message bit one by one:
");
scanf("%d%d%d%d",&data[0],&data[1],&data[2],&data[4]);
data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4];
data[3]=data[0]^data[1]^data[2];
for (i=0;i<7;i++) {
printf("%d ",data[i]);
for (i=0;i<7;i++) {
scanf("%d",&rec[i]);
c1=rec[6]^rec[4]^rec[2]^rec[0];
c2=rec[5]^rec[4]^rec[1]^rec[0];
c3=rec[3]^rec[2]^rec[1]^rec[0];
c=c3*4+c2*2+c1 ;
if(c==0) {
} else {
rec[7-c]=1; else
rec[7-c]=0;
for (i=0;i<7;i++) {
printf("%d ",rec[i]);
getch();
Output:
AIM 5: 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<conio.h>
#include<string.h>
#define N strlen(g)
char t[28],cs[28],g[28];
int a,e,c,b;
void xor()
{
for(c=1;c<N;c++)
cs[c]=((cs[c]==g[c])?'0':'1');
}
void crc()
{
for(e=0;e<N;e++)
cs[e]=t[e];
do
{ if(cs[0]=='1')
xor();
for(c=0;c<N-1;c++)
cs[c]=cs[c+1];
cs[c]=t[e++];
}while(e<=a+N-1);
}
int main()
{
int flag=0;
do{
printf("\n1.crc12\n2.crc16\ncrc ccit\n4.exit\n\nEnter your option.");
scanf("%d",&b);
switch(b)
{
case 1:strcpy(g,"1100000001111");
break;
case 2:strcpy(g,"11000000000000101");
break;
case 3:strcpy(g,"10001000000100001");
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("modified 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);
OUTPUT:
1.crc12
2.crc16
3.crc ccit
4.exit
Enter your option.1
enter data:1100110011100011
generating polynomial:1100000001111
checksum is:1101110110001
generating polynomial:11000000000000101
PROGRAM.CPP:
#include<bits/stdc++.h>
#include<ctime>
int main() {
ll tf, N, tt = 0;
srand(time(NULL));
cout << "Enter the Total number of frames : ";
cin >> tf;
cout << "Enter the Window Size : ";
cin >> N;
ll i = 1;
transmission(i, N, tf, tt);
cout << "Total number of frames which were sent and resent are : " << tt <<
endl;
return 0;
}
OUTPUT:
Enter the Total number of frames : 12
Enter the Window Size : 4
Sending Frame 1…
Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Timeout!! Frame Number : 1 Not Received
Retransmitting Window…
Sending Frame 1…
Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Acknowledgment for Frame 1…
Timeout!! Frame Number : 2 Not Received
Retransmitting Window…
Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Sending Frame 5…
Timeout!! Frame Number : 2 Not Received
Retransmitting Window…
Sending Frame 2…
Sending Frame 3…
Sending Frame 4…
Sending Frame 5…
Acknowledgment for Frame 2…
Acknowledgment for Frame 3…
Acknowledgment for Frame 4…
Timeout!! Frame Number : 5 Not Received
Retransmitting Window…
Sending Frame 5…
Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Timeout!! Frame Number : 5 Not Received
Retransmitting Window…
Sending Frame 5…
Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Acknowledgment for Frame 5…
Timeout!! Frame Number : 6 Not Received
Retransmitting Window…
Sending Frame 6…
Sending Frame 7…
Sending Frame 8…
Sending Frame 9…
Acknowledgment for Frame 6…
Timeout!! Frame Number : 7 Not Received
Retransmitting Window…
Sending Frame 7…
Sending Frame 8…
Sending Frame 9…
Sending Frame 10…
Acknowledgment for Frame 7…
Acknowledgment for Frame 8…
Acknowledgment for Frame 9…
Acknowledgment for Frame 10…
#include<stdio.h>
int main()
{
int windowsize,sent=0,ack,i;
printf("enter window size\n");
scanf("%d",&windowsize);
while(1)
{
for( i = 0; i < windowsize; i++)
{
printf("Frame %d has been transmitted.\n",sent);
sent++;
if(sent == windowsize)
break;
}
printf("\nPlease enter the last Acknowledgement received.\n");
scanf("%d",&ack);
if(ack == windowsize)
break;
else
sent = ack;
}
return 0;
}
output:-
AIM 7: Write a Program to implement Sliding window protocol for Selective repeat.
PROGRAM:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<unistd.h>
int n,r;
struct frame
{
char ack;
int data;
}frm[10];
int sender(void);
void recvack(void);
void resend(void);
void selective(void);
int main()
{
int c;
do
{
printf("\n\n1.Selective repeat ARQ\n \n2.exit");
printf("\nEnter your choice:");
scanf("%d",&c);
switch(c)
{
case 1:selective();
break;
case 2:exit(0);
break;
}
}while(c>=4);
}
void selective()
{
sender();
recvack();
resend();
printf("\nAll packets sent successfully");
}
int sender()
{
int i;
printf("\nEnter the no. of packets to be sent:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
printf("\nEnter data for packets[%d]",i);
scanf("%d",&frm[i].data);
frm[i].ack='y';
}
return 0;
}
void recvack()
{
int i;
rand();
r=rand()%n;
frm[r].ack='n';
for(i=1;i<=n;i++)
{
if(frm[i].ack=='n')
printf("\nThe packet number %d is not received\n",r);
}
}
void resend() //SELECTIVE REPEAT
{
printf("\nresending packet %d",r);
sleep(2);
frm[r].ack='y';
printf("\nThe received packet is %d",frm[r].data);
}
OUTPUT:
1.selective repeat ARQ
2.exit
Enter your choice:1
Enter the no.of packets to be sent:3
Enter data for packets[1] 101
Enter data for packets[2] 010
Enter data for packets[3] 111
The packet number 2 is not received
resending packet 2
The received packet is 010
All packets sent successfully.
sender( i,frame[]);
recv(i);
}
sender(int i,int frame[])
{
wait_for_ack++;
if(wait_for_ack==3)
{
if(i==frame[t])
{
frameQ++;
t++;
}
if(frameQ==0)
printf("NO FRAME TO SEND at time=%d \n",i);
if(frameQ>0 && cansend==1)
{
printf("FRAME SEND AT TIME=%d\n",i);
cansend=-1;
frameQ--;
timer++;
printf("timer in sender=%d\n",timer);
}
if(frameQ>0 && cansend==-1)
printf("FRAME IN Q FOR TRANSMISSION AT
TIME=%d\n",i);
if(frameQ>0)
t++;
}
printf("frameQ=%d\n",frameQ);
printf("i=%d t=%d\n",i,t);
printf("value in frame=%d\n",frame[t]);
return 0;
}
int recv(int i )
{ printf("timer in recvr=%d\n",timer);
if(timer>0)
{
timer++;
}
if(timer==3)
{
printf("FRAME ARRIVED AT TIME= %d\
n",i);
wait_for_ack=0;
timer=0;
}
Else
printf("WAITING FOR FRAME AT TIME
%d\n",i);
return 0;
}
}
OUTPUT:
enter the time when data frame will be ready
frameQ=0
i=1,t=0
value in frame=3
time in recvr=0
WAITING FOR FRAME AT TIME 1
enter the time when data frame will be ready
frameQ=0
i=1,t=0
value in frame=3
time in recvr=0
WAITING FOR FRAME AT TIME 1
enter the time when data frame will be ready
frameQ=0
i=1,t=0
value in frame=3
time in recvr=0
WAITING FOR FRAME AT TIME 1
AIM 9: Write a program for congestion control using leaky bucket algorithm
Program:
#include<stdio.h>
int main()
{
int incoming, outgoing, buck_size, n, store = 0;
printf("Enter bucket size, outgoing rate and no of inputs: ");
scanf("%d %d %d", &buck_size, &outgoing, &n);
while (n != 0)
{
printf("Enter the incoming packet size : ");
scanf("%d", &incoming);
printf("Incoming packet size %d\n", incoming);
if (incoming <= (buck_size - store)){
store += incoming;
printf("Bucket buffer size %d out of %d\n", store, buck_size);
}
else {
printf("Dropped %d no of packets\n", incoming - (buck_size - store));
printf("Bucket buffer size %d out of %d\n", store, buck_size);
store = buck_size;
}
store = store - outgoing;
printf("After outgoing %d packets left out of %d in buffer\n", store, buck_size);
n--;
}
}
Output
AIM 10: Write a Program to implement Dijkstra‘s algorithm to compute the Shortest path through a
graph.
PROGRAM:
#include<stdio.h>
#include<string.h>
#include<math.h>
main()
{
int u,v,num,i,j,l,k,s[10],min,cost[10][10],dist[10],path[10],n;
clrscr();
printf("\n ENTER VERTECES:");
scanf("%d",&n);
printf("\n ENTER ADJECENCY MATRIX:\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
scanf("%d",&cost[i][j]);
}
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(i==j) cost[i][j]=0;
else if(cost[i][j]==-1)
cost[i][j]=30000;
printf("\nENTER SOURCE VERTEX:");
scanf("%d",&v); clrscr();
for(i=1;i<=n;i++)
{
s[i]=0;
path[i]=v; dist[i]=cost[v][i];
}
dist[v]=0; for(num=2;num<=n;num+
+)
{
min=30000; u=0;
for(i=1;i<=n;i++)
{
if(s[i]!=1) if(min>dist[i])
{
u=i; min=dist[i];
}
}
s[u]=1;
for(i=1;i<=n;i++)
{ if(s[i]!=1) if(dist[i]>(min+cost[u]
[i]))
{
dist[i]=min+cost[u][i];
path[i]=u;
}
}
}
printf("\n");
printf("\nPATH MATRIX:\n"); printf("\
nDISTANCE NODE PATH\n");
for(i=1;i<=n;i++)
{ printf("\n
%d",dist[i]); printf("
%d ",i);
j=i;
do
{
printf(" --> %d
",path[j]); u=path[j];
j=u;
}while(u!=v);
}
getch();
}
INPUT/OUTPUT:
ENTER VERTECES:8
0 2 -1 -1 -1 -1 6 -1
2 0 7 -1 2 -1 -1 -1
-1 7 0 3 -1 3 -1 -1
-1 -1 3 0 -1 -1 -1 2
-1 2 -1 -1 0 2 1 -1
-1 -1 3 -1 2 0 -1 2
6 -1 -1 -1 1 -1 0 4
-1 -1 -1 2 -1 2 4 0
PATH MATRIX:
0 1 --> 1
2 2 --> 1
9 3 --> 2 --> 1
10 4 --> 8 --> 6 --> 5 --> 2 --> 1
4 5 --> 2 --> 1
6 6 --> 5 --> 2 --> 1
5 7 --> 5 --> 2 --> 1
8 8 --> 6 --> 5 --> 2 --> 1
AIM 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).
PROGRAM:
Take an example subnet graph with weights indicating delay between nodes
PROGRAM:
#include<stdio.h>
#include<conio.h>
struct full
{
char line[10],dest[10]; int hops;
}f[20];
main()
{
int nv,min,minver,i; char sv[2],temp;
clrscr();
printf("\nEnter number of vertices:"); scanf("%d",&nv);
printf("\n Enter source vertex: "); scanf("%s",sv);
printf("\n Enter full table for source vertex %s :\n",sv); for(i=0;i<nv;i++)
scanf("%s %s %d",f[i].dest,f[i].line,&f[i].hops); printf("\n HIERARCHIAL TABLE\n\n");
for(i=0;i<nv;)
{
if(sv[0]==f[i].dest[0])
{
printf("\n %s %s %d",f[i].dest,f[i].line,f[i].hops); i++;
}
else
{
min=1000;
minver=0;
temp=f[i].dest[0];
while(temp==f[i].dest[0])
{
if(min>f[i].hops)
{
min=f[i].hops; minver=i;
} i++;
}
printf("\n %c %s %d ",temp,f[minver].line,f[minver].hops);
}
}
getch();
}
INPUT/OUTPUT:
Enter number of vertices: 8
Enter source vertex :1A
Enter full table for source vertex 1A
: 1A - -
1B 1B 1
1C 1C 1
2A 1B 1
2B 1B 2
3A 1C 2
3B 1C 3
4A 1C 3
HIERARCHIAL TABLE
1A - 0
1B 1B 1
1C 1C 1
2 1B 1
3 1C 2
4 1C 3
PROGRAM: Now obtain Routing table for each node using distance vector routing.
#include<stdio.h>
#include<math.h>
#include<conio.h>
main()
{
int i,j,k,nv,sn,noadj,edel[20],tdel[20][20],min; char sv,adver[20],ch;
clrscr();
printf("\n ENTER THE NO.OF VERTECES:");
scanf("%d",&nv);
printf("\n ENTER THE SOURCE VERTEX NUM,BER AND NAME:");
scanf("%d",&sn);
flushall(); sv=getchar();
printf("\n NETER NO.OF ADJ VERTECES TO VERTEX %c",sv);
scanf("%d",&noadj);
for(i=0;i<noadj;i++)
{
printf("\n ENTER TIME DELAY and NODE NAME:");
scanf("%d %c",&edel[i],&adver[i]);
}
for(i=0;i<noadj;i++)
{
printf("\n ENTER THE TIME DELAY FROM %c to ALL OTHER
NODES: ",adver[i]); for(j=0;j<nv;j++) scanf("%d",&tdel[i][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
AIM 13: Wireshark
What is 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.
Uses of Wireshark:
Wireshark can be used in the following ways:
Functionality of Wireshark:
Wireshark is similar to tcpdump in networking. Tcpdump is a common packet analyzer which
allows the user to display other packets and TCP/IP packets, being transmitted and received over a
network attached to the computer.
It has a graphic end and some sorting and filtering functions. Wireshark users can see all the traffic
passing through the network.
Wireshark can also monitor the unicast traffic which is not sent to the network's MAC address
interface. But, the switch does not pass all the traffic to the port.
Hence, the promiscuous mode is not sufficient to see all the traffic. The various network taps or port
mirroring is used to extend capture at any point.
Port mirroring is a method to monitor network traffic. When it is enabled, the switch sends
the copies of all the network packets present at one port to another port.
Features of Wireshark
o It is multi-platform software, i.e., it can run on Linux, Windows, OS X, FreeBSD, NetBSD,
etc.
o It is a standard three-pane packet browser.
o It performs deep inspection of the hundreds of protocols.
o It often involves live analysis, i.e., from the different types of the network like the Ethernet,
loopback, etc., we can read live data.
o It has sort and filter options which makes ease to the user to view the data.
o It is also useful in VoIP analysis.
o It can also capture raw USB traffic.
o Various settings, like timers and filters, can be used to filter the output.
o It can only capture packet on the PCAP (an application programming interface used to
capture the network) supported networks.
o Wireshark supports a variety of well-documented capture file formats such as the PcapNg
and Libpcap. These formats are used for storing the captured data.
o It is the no.1 piece of software for its purpose. It has countless applications ranging from the tracing
down, unauthorized traffic, firewall settings, etc.
On the network and Internet settings option, we can check the interface connected to our computer.
I. Packet Capture Using Wire shark
When installing, ensure all components are selected for installation, including the optional
“Winpcap” application.
In some cases, you may want to perform packet captures with Wireshark. One case might be
when you want to perform a packet capture on channel 12 or 13.
1. Click View > Wireless Toolbar. The Wireless Toolbar will appear just below the Main
toolbar.
2.Use the Wireless Toolbar to configure the desired channel and channel width.
3.Under Capture, click on AirPcap USB wireless capture adapter to select the capture
interface.
Note: If the AirPcap isn't listed, press F5 to refresh the list of available packet capture interfaces.
Note: The AirPcap has been discontinued by RiverBed and is 802.11n only.
Note: .Pcap and .Pcap-ng are good filetypes to use for the capture if you plan to use Eye P.A. to
open the capture.
2. Eye P.A. can now open the capture file.
II. STARTING WIRESHARK:
Two different methods for starting Wireshark are available. These include the Start menu and the Run
command box
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.
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 6.2, “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 6.2. 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.
AIM 14: How to run Nmap scan
PROCEDURE:
NMAP: NMAP stands for Network Mapper which is an open-source tool used for network
exploration and security auditing, in comparison to this, a tool named Nessus is used by
industry professionals. These tools are mainly used by cybersecurity experts and hackers .
1. Nmap is a network scanner created by Gordon Lyon.
2. Nmap is used to discover hosts and services on a computer network by sending packets
and analyzing the responses.
3. Nmap provides a number of features for probing computer networks, including host
discovery and service and operating system detection
4. Ensuring that your router is protected from unwanted intruders is
6. 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.
METHOD 1:
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.
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.
AIM 15: Operating System Detection using Nmap
Now we need to run the actual commands to perform OS detection using NMAP, and at first, we
will get the IP address of the host system, and then will perform a scan to get all active devices on
the network.
Step 1: Getting the IP of the System
Ifconfig
Network Simulator (Version 2), widely known as NS2, is simply an event-driven simulation tool that has
proved useful in studying the dynamic nature of commu-nication networks. Simulation of wired as well as
wireless network functions and protocols (e.g., routing algorithms, TCP, UDP) can be done using NS2. In
general, NS2 provides users with a way of specifying such network protocols and simulating their
corresponding behaviors.
Due to its flexibility and modular nature, NS2 has gained constant popularity in the networking research
community since its birth in 1989. Ever since, several revolutions and revisions have marked the growing
maturity of the tool, thanks to substantial contributions from the players in the field. Among these are the
University of California and Cornell University who developed the REAL network simulator,1 the
foundation on which NS is invented. Since 1995 the Defense Advanced Research Projects Agency
(DARPA) supported the development of NS through the Virtual InterNetwork Testbed (VINT) project
Currently the National Science Foundation (NSF) has joined the ride in development. Last but not the least,
the group of researchers and developers in the community are constantly working to keep NS2 strong and
versatile.
Again, the main objective of this book is to provide the readers with insights into the NS2 architecture. This
chapter gives a brief introduction to NS2. NS2 Beginners are recommended to go thorough the detailed
introductory online resources. For example, NS2 official website provides NS2 source code as well as
detailed installation instruction. The web pages in and are among highly recommended ones which provide
tutorial and examples for setting up basic NS2 simulation.
Simulate a three-node point-to-point network with a duplex link between them. Set the queue size
and vary the bandwidth and find the number of packets dropped.
Sender:-
stcp –p 2000 –l 1024 1.0.1.2
Receiver:-
rtcp –p 2000 –l 1024
Parameters:-
Drop Packets and Collision Packets.
2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor,
to place HUB1 on the editor.
3. Click on the LINK icon on the toolbar and connect HOST1 to HUB1 and HUB1 to
HOST2
4. Click on the “E” icon on the toolbar to save the current topology
e.g: file1.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.
Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.
2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stg –u 1024 100 1.0.1.2
3. Click OK button on the command window to exit and once again click on the OK
button on the HOST window to exit.
4. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.
5. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtg –u –w log1
7. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.
8. Select LOG STATISTICS and select checkboxes for Number of Drop Packet and
Number of Collisions in the MAC window
9. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.
1. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.
2. Click NODE EDITOR Button on the HOST window and select the FIFO tab from the
modal window that pops up.
Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the
dropdown list to execute the simulation.
iii. To start playback select “►” icon located at the bottom right corner of the
editor.
iv. To view results, Open up new TERMINAL window, move to file1.results
folder and open collision and drop log files in separate TERMINAL
window.
Caution: file1 is the hypothetical name given to this simulation.
(Refer Step 1.4)
Changing configurations
Change 1
1. Open the above file,
2. Do not change the topology or any other configuration,
3. Select E icon on the toolbar
4. Reduce the bandwidth at link2 by double clicking the left mouse button while cursor
is on link2 .(Change bandwidth on both tabs Uplink/Downlink)
5. Repeat Step3 (Simulate)
Change 2
1. Open the above file,
2. Remove HUB and replace it with SWITCH.
3. Do not change anything in the
configuration Repeat Step3(Simulate)
III. Simulate to Find the Number of Packets Dropped by
TCP/UDP
Simulate a four-node point-to-point network and connect the link as follows: Apply a TCP
agent between n0 to n3 and apply a UDP agent between n1 and n3. Apply relevant
applications over TCP and UDP agents changing the parameters and determine the number
of packets sent by two agents.
Topology:-
Sender:-
stcp –p 3000 –l 1024 1.0.1.3
stg –u 1024 1.0.1.3
Receiver:-
rtcp –p 3000 –l 1024
rtg –u 3000
Parameters:-
Throughput of incoming and outgoing Packets
2. Select/click the HUB (or SWITCH) icon on the toolbar and click the left mouse
button on the editor, to place a HUB (or SWITCH) on the editor.
3. Click on the LINK icon on the toolbar and connect HOST1 to HUB, HOST2 to HUB and
HUB to HOST3
4. Click on the “E” icon on the toolbar to save the current topology e.g: file2.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.
Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.
2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stcp –p 21 –l 1024 1.0.1.3
4. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.
5. Select LOG STATISTICS and select checkbox for output throughput in the MAC
window
6. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.
7. Double click the left mouse button while cursor is on HOST2 to open the HOST
window.
8. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stg –u 1024 100 1.0.1.3
10. Click NODE EDITOR Button on the HOST window and select the MAC tab from
the modal window that pops up.
11. Select LOG STATISTICS and select checkbox for output throughput in the
MAC window
12. Click OK button on the MAC window to exit and once again click on the OK button
on the HOST window to exit.
13. Double click the left mouse button while cursor is on HOST3 to open the
HOST window.
14. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtcp –p 21 –l 1024
17. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.
18. Select LOG STATISTICS and select checkbox for input and
output throughput in the MAC window
19. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.
Step3: Simulate
i. Click “R” icon on the tool bar
ii. Select Simulation in the menu bar and click/ select RUN in the
dropdown list to execute the simulation.
iii. To start playback select “►” icon located at the bottom right corner of the editor.
iv. To view results, Open up new TERMINAL window, move to file2.results
folder and open input and output throughput log files in separate TERMINAL
window.
Caution: file2 is the hypothetical name given to this simulation.
(Refer Step 1.4)
IV. Simulate to Find the Number of
Packets Dropped due to Congestion
Simulate the transmission of ping messages over a network topology consisting of 6 nodes and
find the number of packets dropped due to congestion.
Topology:-
Sender:-
stcp –p 2000 –l 1024 1.0.1.4
Receiver:-
rtcp –p 2000 –l 1024
Command Console:-
Goto tools-> simulation time and change Simulation time to 100. During run mode, double
click host 2 and then click command console. And execute the following command.
ping 1.0.1.4
Parameters:-
Drop Packets and Collision Packets.
Step1: Drawing topology
1. Select/click the SUBNET icon on the toolbar and click the left mouse button on the
editor, to place a SUBNET on the editor.
2. A pop up window appears requesting the number of nodes and radius for the
subnet Set number of nodes=6;
Set radius of subnet >150
3. Click on the “E” icon on the toolbar to save the current topology e.g: file4.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting
Step2: Configuration
4. Double click the left mouse button while cursor is on a HOST to open the HOST
window.
5. Click NODE EDITOR Button on the HOST window and select the
INTERFACE tab (1st tab) from the modal window that pops up.
7. Click OK button on the INTERFACE window to exit and once again click on the OK
button on the HOST window to exit.
9. Also click NODE EDITOR Button on the HOST window and select the MAC tab
from the modal window that pops up.
10. Select LOG STATISTICS and select checkbox for drop and collision log statistics
in the MAC window
11. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.
13. Select G_Setting from the menu bar and select Simulation from the drop down list
Set simulation time>600sec
Step3: Simulate
Simulate an Ethernet LAN using N nodes (6-10), change error rate and data rate and compare
throughput.
Topology:-
Sender:-
stcp –p 2000 –l 1024 1.0.1.4
Receiver:-
rtcp –p 2000 –l 1024
Double click on receiver link and change BER to 0.000001, Run Again.
Parameters:-
Throughput of outgoing Packets
1. Select/click the HOST icon on the toolbar and click the left mouse button on the editor,
to place HOST1 on the editor.
Repeat the above procedure and place 5 other hosts “HOST2”, “HOST3”, “HOST4”,
“HOST5”, and “HOST6”on the editor.
2. Select/click the HUB icon on the toolbar and click the left mouse button on the editor,
to place HUB1 on the editor.
Repeat the above procedure and place another host “HUB2” on the editor
3. Click on the LINK icon on the toolbar and connect HOST1, HOST2 and HOST3 to
HUB1, HOST4, HOST5 and HOST6 to HUB2.
4. Select/click the SWITCH icon on the toolbar and click the left mouse button on the
editor, to place SWITCH1 on the editor.
5. Click on the LINK icon on the toolbar and connect HUB1 to SWITCH1 and HUB2 to
SWITCH1.
6. Click on the “E” icon on the toolbar to save the current topology e.g: file5.tpl
(Look for the ******.tpl extension.)
NOTE: Changes cannot / (should not) be done after selecting the “E” icon.
Step2: Configuration
1. Double click the left mouse button while cursor is on HOST1 to open the HOST
window.
2. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
stcp –p 21 –l 1024 1.0.1.4
3. Click OK button on the command window to exit and once again click on the OK
button on the HOST window to exit.
4. Repeat this step at HOST 2 and HOST3, but use different commands
stcp –p 21 –l 1024 1.0.1.5 at HOST2
stcp –p 21 –l 1024 1.0.1.6 at HOST3
5. Double click the left mouse button while cursor is on HOST4 to open the HOST
window.
6. Select Add button on the HOST window to invoke the command window and
provide the following command in the command textbox.
rtcp –p 21 –l 1024
8. Click NODE EDITOR Button on the HOST window and select the MAC tab from the
modal window that pops up.
9. Select LOG STATISTICS and select checkbox for output throughput in the MAC
window
10. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.
11. Repeat this step at HOST 5 and HOST6, but use different commands
rtcp –p 21 –l 1024 at
HOST5 rtcp –p 21 –l 1024
at HOST6
12. Double click the left mouse button while cursor is on HOST5 to open the
HOST window.
13. Click NODE EDITOR Button on the HOST5 window and select
the PHYSICAL tab from the modal window that pops up.
15. Click OK button on the PHYSICAL window to exit and once again click on the
OK button to return to the HOST window
16. Click NODE EDITOR Button on the HOST window and select the MAC tab from
the modal window that pops up.
17. Select LOG STATISTICS and select checkbox for output throughput in the
MAC window
18. Click OK button on the MAC window to exit and once again click on the OK
button on the HOST window to exit.
19. Repeat this step HOST6, Change Bandwidth this time while undoing the
change in Bit Error Rate, also select the output throughput at HOST6.
Step3: Simulate