0% found this document useful (0 votes)
18 views62 pages

III-I CN r20 Lab Manual (Final)

The document is a lab manual for a computer networks course, detailing objectives, outcomes, and a list of experiments focused on practical networking concepts and protocols, particularly TCP/IP. It includes instructions for studying network devices, implementing data link layer framing methods, and using various network management tools. The manual aims to equip students with hands-on experience in establishing local area networks and understanding network protocols through programming exercises.

Uploaded by

csecgirls0203
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)
18 views62 pages

III-I CN r20 Lab Manual (Final)

The document is a lab manual for a computer networks course, detailing objectives, outcomes, and a list of experiments focused on practical networking concepts and protocols, particularly TCP/IP. It includes instructions for studying network devices, implementing data link layer framing methods, and using various network management tools. The manual aims to equip students with hands-on experience in establishing local area networks and understanding network protocols through programming exercises.

Uploaded by

csecgirls0203
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/ 62

LABMANUAL

for
computer network

1
COMPUTER NETWORKS LAB

Course Objectives:
Learn basic concepts of computer networking and acquire practical notions of protocols with
the emphasis on TCP/IP. A lab provides a practical approach to Ethernet/Internet networking:
networks are assembled, and experiments are made to understand the layered architecture and
how do some important protocols work
Course Outcomes:
 By the end of the course student will be able to
 Know how reliable data communication is achieved through data link layer.
 Suggest appropriate routing algorithm for the network.
 Provide internet connection to the system and its installation.
 Work on various network management tools
List of Experiments:
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 to implement on a data set of characters the three CRC polynomials – CRC
12, CRC16 and CRC CCIP.
6. Write a Program to implement Sliding window protocol for Go back 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.
13. Wireshark
i. Packet Capture Using Wire shark
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
16. Do the following using NS2 Simulator
i. NS2 Simulator-Introduction
ii. Simulate to Find the Number of Packets Dropped
iii. Simulate to Find the Number of Packets Dropped by TCP/UDP
iv. Simulate to Find the Number of Packets Dropped due to Congestion
v. Simulate to Compare Data Rate& Throughput.EXPERIMENT1:

2
1. Study of Network devices in detail and connect the computers in Local Area Network

STUDY OF NETWORK DEVICES IN DETAIL AND CONNECT THE COMPUTRS


IN LOCAL AREA NETWORK

Aim: Study of following Network Devices in Detail


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

Hub:

Advantages:

1.It can extend total distance of the network.

2.It does not effect the performance.

3.It is a cheap.

4.It can connect different Media types.

Disadvantages:

1.It will broadcast to all port.

2.Cannot filter information.

Repeater

3
Repeaters:

Advantages of Repeaters:

 Repeaters are simple to install and can easily extend the length or the coverage area of
networks.
 They are cost effective.
 Repeaters don’t require any processing overhead. The only time they need to be investigated
is in case of degradation of performance.
 They can connect signals using different types of cables.

Disadvantages of Repeaters:

 Repeaters cannot connect dissimilar networks.


 They cannot differentiate between actual signal and noise.
 They cannot reduce network traffic or congestion.
 Most networks have limitations upon the number of repeaters that can be deployed.
Switch:

Advantages:

1.Increase capacity.

2.It is more intelligent than hub.

Disadvantages:

1.Limited broadcast.

2.Network connectivity problem can be difficult to trace

4
Bridge:

Advantages:

1.To extend the network.

2.Increase the bandwith.

Disadvantages:

1.It does not filter the data.

2.It is slow compare to repeaters to filtering process.

Router:

Advantages:

1.It reduce network traffic.

2.It can choose best pat

5
Disadvantages:

1.Less bandwith.

2.They are slow to analyze the data.

Gateway:

Advantages:

1.It can connect devices of two different networks.

2.It is intelligent with filtering capabilities.

3.It control the collision.

Disadvantages:

1.Time delay.

2.Connection fail.

3.Trouble Shooting.

Modem:

6
Advantages:

1.Connecting Lan.

2.Speed depend on the cost.

3.Data Communication.

Disadvantages:

1.No traffic Maintainence.

2.It does not own destination path.

Repeaters:

Advantages of Repeaters:

 Repeaters are simple to install and can easily extend the length or the coverage area of
networks.
 They are cost effective.
 Repeaters don’t require any processing overhead. The only time they need to be investigated
is in case of degradation of performance.
 They can connect signals using different types of cables.

Disadvantages of Repeaters:

 Repeaters cannot connect dissimilar networks.


 They cannot differentiate between actual signal and noise.
 They cannot reduce network traffic or congestion.
 Most networks have limitations upon the number of repeaters that can be deployed.
Aim: 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
connection whenever a computer on my network attempts to access the Internet

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

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

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

Experiment2: Write a Program to implement the data link layer farming methods such as

i) Character stuffing ii) bit stuffing.

EXPERIMENT-II(WITHOUT STUFING DLE)

AIM: Implement the data link layer framing methods such as character stuffing.

Source Code:

#include<stdio.h>

#include<string.h>

#include<conio.h>

void main()

int j,l,m,c,k;

char a[50],b[50];

printf("Enter the string:");

8
scanf("%s",a);

strcpy(b,"DLESTX");

m=strlen(a);

for(j=0;j<m;)

if(a[j]=='d')

if(a[j+1]=='l')

if(a[j+2]=='e')

c=j+2;

for(l=0;l<3;l++)

for(k=m;k>c;k--)

a[k]=a[k-1];

m++;

a[m]='\0';

c+=1;

a[j+3]='d';

a[j+4]='l';

a[j+5]='e';

a[m]='\0';

j+=5;

9
}

j++;

strcat(b,a);

strcat(b,"DLEETX");

printf("\n%s",b);

printf("\nReceiver side:");

m=strlen(a);

for(j=0;j<m;)

if(a[j]=='d')

if(a[j+1]=='l')

if(a[j+2]=='e')

c=j;

for(l=0;l<3;l++)

for(k=c;k<m;k++)

a[k]=a[k+1];

c++;

j=c;

10
}

j++;

printf("\n%s",a);

getch();

CHARACTERSTUFFING(USING INDEX STUFFING DLE)

#include<stdio.h>

#include<string.h>

#include<conio.h>

void main()

char a[20],b[20]=" ",c[50]="dle";

int n,i,j;

clrscr();

printf("enter the string");

scanf("%s",a);

printf("enter the index");

scanf("%d",&j);

if(j>strlen(a))

printf("enter correct index");

else{

strncat(b,a,j);

11
strcat(b,c);

for(i=j;i<strlen(a);i++)

b[i+4]=a[i];

strcpy(c,"DLESTX");

strcat(c,b);

strcat(c,"DLEETXA");

printf("%s\n",c);

printf("the recived string is\n %s",a);

getch();

BITSTUFFING

#include<stdio.h>

int main()

int i=0,count=0;

char databits[80];

printf("Enter Data Bits: ");

scanf("%s",databits);

12
printf("Data Bits Before Bit Stuffing:%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;

return 0;

Experiment3:Write a Program to implement data link layer farming method checksum.

#include<stdio.h>

#include<conio.h>

int add(int, int);

int com(int);

void main()

13
{

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 data1 : \n");

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

scanf("%d", &data1[i]);

printf("\n Enter the data2 : \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]);

printf("\n\n Data 1 : ");

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

printf("%d", data1[i]);

printf("\n Data 2 : ");

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

printf("%d", data2[i]);

printf("\n\n The new data is : ");

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

printf("%d", newdata[i]);

14
}

printf("\n Checksum : ");

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

checksum[i] = com(newdata[i]);

printf("%d", checksum[i]);

printf("\n\n Receiver Side : \n");

printf("\n Data : ");

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

printf("%d", data1[i]);

printf(" ");

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

printf("%d", data2[i]);

printf(" ");

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

printf("%d", checksum[i]);

printf("\n Addition : ");

for (i = dl - 1; i >= 0; i--)

newdata[i] = add(newdata[i], checksum[i]);

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

printf("%d", newdata[i]);

15
}

printf("\n Compliment : ");

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

comp[i] = com(newdata[i]);

printf("%d", comp[i]);

int add(int x, int y)

static int carry = 0;

if (x == 1 && y == 1 && carry == 0)

carry = 1;

return 0;

else if (x == 1 && y == 1 && carry == 1)

carry = 1;

return 1;

else if (x == 1 && y == 0 && carry == 0)

carry = 0;

return 1;

16
else if (x == 1 && y == 0 && carry == 1)

carry = 1;

return 0;

else if (x == 0 && y == 1 && carry == 0)

carry = 0;

return 1;

else if (x == 0 && y == 1 && carry == 1)

carry = 1;

return 0;

else if (x == 0 && y == 0 && carry == 0)

carry = 0;

return 0;

else

carry = 0;

return 1;

int com(int a)

17
{

if (a == 0)

return 1;

else

return 0;

EXPERIMENT4: Write a program for Hamming Code generation for error detection and correction.

HAMMING CODE

#include<stdio.h>

#include<conio.h>

void main() {

int data[10];

int dataatrec[10],r,r2,r1,r4,i;

printf("Enter 4 bits of data one by one\n");

scanf("%d",&data[7]);

scanf("%d",&data[6]);

scanf("%d",&data[5]);

18
scanf("%d",&data[3]);

//Calculation of even parity

data[1]=data[3]^data[5]^data[7];

data[2]=data[3]^data[6]^data[7];

data[4]=data[5]^data[6]^data[7];

printf("\nEncoded data is\n");

for(i=7;i>0;i--)

printf("%d",data[i]);

printf("\n\nEnter received data bits one by one\n");

for(i=7;i>0;i--)

scanf("%d",&dataatrec[i]);

r1=dataatrec[1]^dataatrec[3]^dataatrec[5]^dataatrec[7];

r2=dataatrec[2]^dataatrec[3]^dataatrec[6]^dataatrec[7];

r4=dataatrec[4]^dataatrec[5]^dataatrec[6]^dataatrec[7];

r=r4*4+r2*2+r1 ;

if(r==0) {

printf("\nNo error while transmission of data\n");

else {

printf("\nError on position %d",r);

printf("\nData sent : ");

for(i=7;i>0;i--)

printf("%d",data[i]);

19
printf("\nData received : ");

for(i=7;i>0;i--)

printf("%d",dataatrec[i]);

printf("\nCorrect message is\n");

//if errorneous bit is 0 we complement it else vice versa

if(dataatrec[r]==0)

dataatrec[r]=1;

else

dataatrec[r]=0;

for (i=7;i>0;i--) {

printf("%d",dataatrec[i]);

20
Experiment5:Write a Program to implement on a data set of characters the three CRC
polynomials – CRC 12, CRC16 and CRC CCIP.

C Program to implement CRC (Cyclic Redundancy Code)

#include <stdio.h>

#include <conio.h>

#include <string.h>

void main()

int i,j,keylen,msglen;

char input[100], key[30],temp[30],quot[100],rem[30],key1[30];

clrscr();

printf(&quot;Enter Data: &quot;);

gets(input);

printf(&quot;Enter Key: &quot;);

gets(key);

keylen=strlen(key);

msglen=strlen(input);

strcpy(key1,key);

for(i=0;i&lt;keylen-1;i++)

input[msglen+i]=&#39;0&#39;;

for(i=0;i&lt;keylen;i++)

temp[i]=input[i];

for(i=0;i&lt;msglen;i++)

quot[i]=temp[0];

if(quot[i]==&#39;0&#39;)

for(j=0;j&lt;keylen;j++)

21
key[j]=&#39;0&#39;;

else

for(j=0;j&lt;keylen;j++)

key[j]=key1[j];

for(j=keylen-1;j&gt;0;j--)

if(temp[j]==key[j])

rem[j-1]=&#39;0&#39;;

else

rem[j-1]=&#39;1&#39;;

rem[keylen-1]=input[i+keylen];

strcpy(temp,rem);

strcpy(rem,temp);

printf(&quot;\nQuotient is &quot;);

for(i=0;i&lt;msglen;i++)

printf(&quot;%c&quot;,quot[i]);

printf(&quot;\nRemainder is &quot;);

for(i=0;i&lt;keylen-1;i++)

printf(&quot;%c&quot;,rem[i]);

printf(&quot;\nFinal data is: &quot;);

for(i=0;i&lt;msglen;i++)

printf(&quot;%c&quot;,input[i]);

for(i=0;i&lt;keylen-1;i++)

printf(&quot;%c&quot;,rem[i]);

getch();

22
OUTPUT:

Enter data: 11110110101

Enter key: 111010

Quotient is 10010010000

Remainder is 00000

Final data is: 1111011010100000

Experiment6: Write a Program to implement Sliding window protocol for Goback N.

#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 %dhas been transmitted.\n",sent);

sent++;

if(sent==windowsize)

break;

printf("\n please enter the last acknowledgement received.\n");

scanf("%d",&ack);

if(ack==windowsize)

break;

else

23
sent=ack;

return 0;

output

Experiment7:. Write a Program to implement Sliding window protocol for Selective repeat.

#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);

printf("Frame %d has been transmitted.\n",ack);

24
break;

return 0;

output

Experiment8: Write a Program to 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

25
int kind;

int seq;

int ack;

packet info;

int err;

}frame;

frame DATA;

typedef 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)

26
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')

27
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')

28
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++;

/*___________________________________________________________________________*/

29
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++;

30
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;

/*____________________________________________________________________________*/

void wait_for_event_reciever(event_type * e)

if(turn=='r')

if(DATA.err==0)

*e = err;

else

*e = frame_arrival;

31
output

Experiment9: Write a program for congestion control using leaky bucket algorithm

#include<stdio.h>

#include<dos.h>

#include<stdlib.h>

#define bucketSize 100

void bktInput(int a,int b) {

if(a>bucketSize)

printf("\n\t\tBucket overflow");

else {

delay(500);

while(a>b){

printf("\n\t\t%d bytes outputted.",b);

a-=b;

delay(500);

if (a>0) printf("\n\t\tLast%d bytes sent\t",a);

32
printf("\n\t\tBucket output successful");

void main() {

int op, pktSize,i;

randomize();

printf("Enter output rate : ");

scanf("%d",&op);

for( i=1;i<=5;i++){

delay(random(100));

pktSize=random(100);

printf("\nPacket no %d\tPacket size =%d ",i,pktSize);

bktInput(pktSize,op);

output

Experiment10 Write a Program to implement Dijkstra‘s algorithm to compute the Shortest


path through a graph

#include <stdio.h>

#include <conio.h>

33
#define infinity 999

void dij(int n,int v,int cost[10][10],int dist[])

int i,u,count,w,flag[10],min;

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

flag[i]=0,dist[i]=cost[v][i];

count=2;

while(count<=n)

min=99;

for(w=1;w<=n;w++)

if(dist[w]<min && !flag[w])

min=dist[w],u=w;

flag[u]=1;

count++;

for(w=1;w<=n;w++)

if((dist[u]+cost[u][w]<dist[w]) && !flag[w])

dist[w]=dist[u]+cost[u][w];

void main()

int n,v,i,j,cost[10][10],dist[10];

clrscr();

printf("\n Enter the number of nodes:");

scanf("%d",&n);

printf("\n Enter the cost matrix:\n");

34
for(i=1;i<=n;i++)

for(j=1;j<=n;j++)

scanf("%d",&cost[i][j]);

if(cost[i][j]==0)

cost[i][j]=infinity;

printf("\n Enter the source matrix:");

scanf("%d",&v);

dij(n,v,cost,dist);

printf("\n Shortest path:\n");

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

if(i!=v)

printf("%d->%d,cost=%d\n",v,i,dist[i]);

getch();

output

Experiment11: Write a Program to implement Distance vector routing algorithm by obtaining


routing table at each

#include<stdio.h>

struct node

35
{

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++)

36
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();

return;

output

37
Experiment12: Write a Program to implement Broadcast tree by taking subnet of hosts.

#include<stdio.h>

#include<conio.h>

void main()

unsigned int compad[4];

unsigned int mask[4];

unsigned int netadr[4];

int i;

clrscr();

printf("Enter the ip address:\n");

scanf("%u%*c%u%*c%u%*c%u%*c",&compad[3],&compad[2],&compad[1],&compad[0]);

printf("Enter the subnet address:\n");

scanf("%u%*c%u%*c%u%*c%u%*c",&mask[3],&mask[2],&mask[1],&mask[0]);

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

netadr[i]= compad[i]&mask[i];

printf("\nNetwork address is:\n");

printf("%u.%u.%u.%u",netadr[3],netadr[2],netadr[1],netadr[0]);

printf("\nsubnet address is:\n");

printf("%u.%u.%u.%u",mask[3],mask[2],mask[1],mask[0]);

printf("\nip address is:\n");

printf("%u.%u.%u.%u",compad[3],compad[2],compad[1],compad[0]);

getch();

Output

38
13. Wireshark
i. Packet Capture Using Wire shark
ii. Starting Wire shark
iii. Viewing Captured Traffic
iv. Analysis and Statistics & Filters.
Wireshark is a network protocol analyzer, or an application that captures packets from
a network connection,

How does Wireshark work? Wireshark is a packet sniffer and analysis tool. It captures
network traffic from ethernet, Bluetooth, wireless (IEEE. 802.11), token ring, and frame
relay connections, among others, and stores that data for offlin

Why is it called Wireshark?


It is used for network troubleshooting, analysis, software and communications
protocol development, and education. Originally named Ethereal, the project was
renamed Wireshark in May 2006 due to trademark issues.
Is Wireshark a software?

Wireshark is an open source software project, and is released under the GNU
General Public License (GPL

39
40
i.packet capture using wire shark

41
What is packet capture used for?
Packet capturing helps to analyze networks, manage network traffic,
and identify network performance issues. It allows IT teams to detect
intrusion attempts, security issues, network misuse, packet loss, and
network congestion. It enables network managers to capture data packets
directly from the computer network

How does Wireshark capture packets?


Wireshark uses pcap to capture packets, so it can only capture packets
on the types of networks that pcap supports. Data can be captured "from
the wire" from a live network connection or read from a file of already-
captured packets.

42
43
ii)Starting wire shark

44
iii) viewing captured trafic

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.

45
Figure 6.1. Wireshark with a TCP packet selected for
viewing

Figure 6.2. Viewing a packet in a separate window

46
iv)analysis and statistics & filters

When exploring data it can be useful to analyse a subset of the cases from the
dataset, for example to see summary statistics for just Male or Female subjects.

To allow analysis of just a subset of cases Analyse-it only analyses the cases
that are visible on the worksheet. Observations on hidden rows will not be
included in the analysis. Rows can be manually hidden to exclude them from
analysis, or Excel's AutoFilter or Advanced Filter can be used to hide rows based
on conditions:
 A specific value or category, e.g. filter by Sex to just show Female cases.

 A range of the highest or lowest values of the variable. The number of values to
show, e.g. 10, or a percentage of the total number of values, e.g. show 10% of
the top values, can be chosen.

47
 A boolean condition using operators such as <, >, <=, >= and using boolean
AND or OR to combine up to two conditions.

IMPORTANT When Analyse-it updates a report it will analyse the cases that are
currently visible in the dataset, rather than the cases that were visible when the
analysis was first performed.

To use AutoFilter to limit analysis to a subset of the dataset:


1. Select a cell in range containing a List dataset.

2. Click Filter on the Analyse-it tab/toolbar.

3. Excel shows drop-down arrows alongside the names of the variables of the
dataset. Click the drop-down arrow then click the value to filter to, Top 10... to
filter to a range of values, or Custom... to use a boolean condition.

4. Analyse-it will now analyse just the subset of the dataset.

14. How to run Nmap scan

How to Run a Simple


Nmap Scan

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

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

50
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

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

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

53
1. Install Nmap. Before using Nmap, you will need to install it so
that you can run it from the command line of your operating
system. Nmap is small and available for free from the developer.
Follow the instructions below for your operating system:
 Linux - Download and install Nmap from your repository.
Nmap is available through most of the major Linux
repositories. Enter in the command below based on your
distribution:
 Red Hat, Fedora, SUSE
rpm -vhU http://nmap.org/dist/nmap-6.40-
1.i386.rpm (32-bit) OR
rpm -vhU http://nmap.org/dist/nmap-6.40-
1.x86_64.rpm (64-bit)
 Debian, Ubuntu
sudo apt-get install nmap
 Windows - 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.
Using the installer allows you to quickly install the
command line Nmap tools without having to worry about
extracting to the right folder.

54
 If you don’t want the Zenmap graphical user
interface, you can uncheck it during the installation
process.
 Mac OS X – Download the Nmap disk image. 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. Use
the included installer to install Nmap on your system.
Nmap requires OS X 10.6 or later.
2.

2
Open your command line. Nmap commands are run from the
command line, and the results are displayed beneath the command. You
can use variables to modify the scan. You can run the scan from any
directory on the command line.
 Linux - Open the terminal if you are using a GUI for your
Linux distribution. The location of the terminal varies by
distribution

55
 Windows - This can be accessed by pressing the
Windows key + R and then typing “cmd” into the Run
field. Windows 8 users can press Windows key + X and
select Command Prompt from the menu. You can run an
Nmap scan from any directory.
 Mac OS X - Open the Terminal application located in the
Utility subfolder of your Applications folder.

3
Run a scan of you target’s ports. To start a basic scan, type nmap
<target>. This will ping the target and scan the ports. This is an easily-
detected scan. The results will be displayed on your screen. You may need
to scroll back up to see all of the results.

4
Run a modified scan. You can use command line variables to change
the parameters of the scan, resulting in more detailed or less detailed
results. Changing the scan variables will change the intrusiveness of the
scan. You can add multiple variables by placing a space between each
one. Variables come before the target: nmap <variable> <variable>
<target>[3]

56
 -sS - This is a SYN stealth scan. It is less detectable than
a standard scan, but may take longer. Many modern
firewalls can detect an –sS scan.
 -sn - This is a ping scan. This will disable port scanning,
and will only check to see if the host is online.
 -O - This is an operating system scan. The scan will
attempt to determine the operating system of the target.
 -A - This variable enables several of the most commonly
used scans: OS detection, version detection, script
scanning, and traceroute.
 -F - This enables fast mode, and will reduce the number
of ports scanned.
 -v - This will show more information in your results,
making them easier to read.

Output the scan to an XML file. You can set your scan results to
be outputted as an XML file so that you can easily read them in any web
browser. To do this, you will need to use the -oX variable, as well as set a
filename for the new XML file. A completed command would look similar
to nmap –oX Scan Results.xml <target>.

57
 The XML file will be saved to whatever your current
working location is.

15. Operating System Detection using Nmap


OS Detection in 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.

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

58
59
16. Do the following using NS2 Simulator
i. NS2 Simulator-Introduction
ii. Simulate to Find the Number of Packets Dropped
iii. Simulate to Find the Number of Packets Dropped by TCP/UDP
iv. Simulate to Find the Number of Packets Dropped due to Congestion
v. Simulate to Compare Data Rate& Throughput.EXPERIMENT1:

i)NS2 simulator introduction

ii)simulate to find number of packets dropped

60
Column 1 represents event type (s: send, r: receive, d: drop, f: forward)

Columns 2 and 3 provide time of the event.

Columns 4 to 7 provide next-hop information.

Columns 8 to 21 are called node property tags.

Column 11 gives the reason for a packet drop and the various reasons
possible for a packet drop are as follows.

END drop due to end of simulation


COL drop due to collision at MAC layer
DUP drop due to duplicate packet
ERR drop due to MAC packet error
RET drop due to exceeding retry count

61
STA drop due to MAC invalid state
BSY drop due to MAC busy
NRTE drop due to no route available
LOOP drop due to routing loop
TTL drop due to TTL=0
TOUT drop due to packet expired
IFQ drop due to no buffer space in IFQ
ARP dropped ARP
OUT dropped by base stations

62

You might also like