Professional Documents
Culture Documents
INDEX
ALGORITHM:
Step 1: Start
Step 2: Read the bit string to be transmitted in 0s and 1s.
Step 3: For stuffing process, append at begin and end of the string.
Step 4: Check the string whether it has five consecutive 1s except the appending
string.
Step 5: If yes, insert 0 bit as stuff in the next bit else transmit the next bit.
Step 6: Continue this process until the completion of string.
Step 7: Stuffed data is obtained.
Step 8: Now destuffing process, remove the appended string at start and end
of string.
Step 9: Check the stuffed string again whether it has five consecutive 1s.
Step 10: If yes then remove the next bit i.e. do not transmit the next bit else
transmit the data.
Step 11: Continue this process until the last bit of string.
Step 12: Original bit data has been obtained.
Step 13: Stop
PROGRAM:
#include<stdio.h>
main()
{
int a[50],b[50],i,j,count=0,n,c[]={0,1,1,1,1,1,1,0};
clrscr();
printf("Enter the length of the string:\n");
scanf("%d",&n);
printf("Enter the string:\n");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
j=0;
/* Stuffing */
for(i=0;i<8;i++)
{
b[j]=c[i];
j++;
}
for(i=0;i<n;i++)
{
if(a[i]==1)
{
b[j]=a[i];
count++;
if(count==5)
{
b[j]=a[i];
j++;
b[j]=0;
count=0;
}
j++;
}
else
{
b[j]=a[i];
j++;
count=0;
}
}
for(i=0;i<8;i++)
{
b[j]=c[i];
j++;
}
n=j;
printf("The frame after bit stuffing is:\n");
for(i=0;i<n;i++)
printf("%d",b[i]);
printf("\n");
/*Destuffing*/
count=j=0;
for(i=8;i<n-8;i++)
{
if(b[i]==1)
{
a[j]=b[i];
count++;
if(count==5)
{
i++;
count=0;
}
j++;
}
else
{
a[j]=b[i];
j++;
count=0;
}
}
printf("The destuffed data is:\n");
for(i=0;i<j;i++)
printf("%d",a[i]);
getch();
}
INPUT1:
Enter the length of the string:
15
Enter the string:
1
1
1
1
1
1
1
0
0
1
1
1
1
1
1
OUTPUT1:
The frame after bit stuffing is:
011111101111101100111110101111110
The destuffed data is:
111111100111111
INPUT2:
Enter the length of the string:
8
Enter the string:
1
1
1
1
1
1
1
1
OUTPUT 2:
The frame after bit stuffing is:
0111111011111011101111110
The destuffed data is:
11111111
1b)PROBLEM SPECIFICATION:
Program to implement character stuffing.
ALGORITHM:
Step 1: Start
Step 2: Read the character string to be transmitted in upper case.
Step 3: For stuffing process, append at begin with DLE STX as starting
flag byte and end with DLE ETX as ending flag byte of the string.
Step 4: Check the string whether it has DLE, STX, and ETX.
Step 5: If yes then insert the string DLE before the character else transmit
the next character
Step 6: Continue this process until the completion of string.
Step 7: Stuffed data is obtained.
Step 8: Now destuffing process, remove the appended string at start and
end of string.
Step 9: Check the stuffed string again whether it has DLE, STX, and
ETX.
Step 10: If yes then remove the string DLE that is encountered first else
transmit the data.
Step 11: Continue this process until the last character of string.
Step 12: Original data has been obtained.
Step 13: Stop
PROGRAM:
#include<stdio.h>
#include<conio.h>
main()
{
char a[30],b[30],c[30];
inti,j,n,m;
clrscr();
printf("\tSTUFFING:\n");
printf("\nEnter the string in upper case:\n");
scanf("%s",&a);
n=strlen(a);
b[0]='D';
b[1]='L';
b[2]='E';
b[3]=' ';
b[4]='S';
b[5]='T';
b[6]='X';
b[7]=' ';
j=8;i=0;
while(i<n)
{
if((a[i]=='D'&&a[i+1]=='L'&&a[i+2]=='E')||(a[i]=='S'&&a[i+1]=='T'&&a[i+2]=='
X')||(a[i]=='E'&&a[i+1]=='T'&&a[i+2]=='X'))
{
b[j]='D';
b[j+1]='L';
b[j+2]='E';
j=j+3;
}
b[j]=a[i];
i++;
j++;
}
b[j]=' ';
b[j+1]='D';
b[j+2]='L';
b[j+3]='E';
b[j+4]=' ';
b[j+5]='E';
b[j+6]='T';
b[j+7]='X';
b[j+8]='\0';
INPUT1:
STUFFING:
Enter the string in upper case:
ETXWITHSTXCANDLE
OUTPUT1:
Frames after stuffing:
DLE STX DLEETXWITHDLESTXCANDLEDLE DLE ETX
DESTUFFING:
Frames after destuffing:
ETXWITHSTXCANDLE
INPUT2:
STUFFING:
Enter the string in upper case:
STXETX
OUTPUT2:
Frames after stuffing:
DLE STX DLESTXDLEETX DLE ETX
DESTUFFING:
Frames after destuffing:
STXETX
10
2) PROGRAM SPECIFICATION:
Program to implement CRC-12.
ALGORITHM:
Step 1: Start
Step 2: Let r be the degree of G(x). Append r bits to the low order end
of the frame. So it now contains M+r bits and corresponds to the polynomial
XM(X).
Step 3: Divide the bit string corresponding to G(x) into the bit string
corresponding to xM(X) using Modulo 2 division.
Step 4: Subtract the remainder from the bit string corresponding to XM(X)
using Modulo 2 subtraction. The result is checksummed frame to be transmitted
call its polynomial T(X).
Step 5: Stop
11
PROGRAM:
#include<string.h>
#include<stdio.h>
#define crc 12
main()
{
char pola1[39],pola2[30],ch[2]="";
int ad=0,i=0,j=0,mp[crc+1],pp1[10],pp2[10],gp[crc+1],rm[crc+1],p1,p2,k;
clrscr();
printf("Enter the message polynomial(in the \"x7+x4+...\" form):\n ");
gets(pola1);
for(i=0,p1=0;i<strlen(pola1);i++)
if(pola1[i]>='0'&&pola1[i]<='9')
{
ch[0]=pola1[i];
ch[1]=pola1[i+1];
if(pola1[i+1]>='0'&&pola1[i+1]<='9')
i++;
pp1[p1++]=atoi(ch);
}
printf("Enter the generator polynomial(in the \"x7+x4+...\" form):\n ");
gets(pola2);
for(i=0,p2=0;i<strlen(pola2);i++)
if(pola2[i]>='0'&&pola2[i]<='9')
{
ch[0]=pola2[i];
ch[1]=pola2[i+1];
if(pola2[i+1]>='0'&&pola2[i+1]<='9')
i++;
pp2[p2++]=atoi(ch);
}
if((pp1[0]+pp2[0])<=crc)
{
ad=pp1[0];
j=0;
for(i=ad;i>=0;i--)
{
if(i==pp1[j]&&j<p1)
{
mp[ad-i]=1;
12
j++;
}
else
mp[ad-i]=0;
}
for(j=ad+1;j<=(ad+pp2[0]);j++)
mp[j]=0;
ad=pp2[0];
k=0;
for(i=ad;i>=0;i--)
{
if(i==pp2[k]&&k<p2)
{
gp[ad-i]=1;
k++;
}
else
gp[ad-i]=0;
}
printf("the message bit string is:\n ");
for(i=0;i<j;i++)
printf("%d",mp[i]);
printf("\nthe generator bit string is:\n ");
for(i=0;i<=ad;i++)
printf("%d",gp[i]);
printf("\n\nThe message to be transmitted is:\n ");
for(i=0;i<=ad;i++)
rm[i]=mp[i];
k=0;
while(1)
{
if(rm[0]==1&&k<=(j-(ad+1)))
{
for(i=0;i<=ad;i++)
{
if(rm[i]==gp[i])
rm[i]=0;
else
rm[i]=1;
}
if(rm[0]==0&&k<(j-(ad+1)))
13
do
{
for(p1=0;p1<ad;p1++)
rm[p1]=rm[p1+1];
rm[p1]=mp[i+k];
k++;
}while(rm[0]==0&&k<(j-(ad+1)));
}
else
{
k=j-ad;
for(i=1;i<=ad;i++)
mp[k++]=rm[i];
for(i=0;i<j;i++)
printf("%d",mp[i]);
printf("\nthe CHECK SUM is:\n ");
for(i=1;i<=ad;i++)
printf("%d",rm[i]);
break;
}
}
}
else
printf("INVALID GENERATOR POLONOMIAL........");
getch();
}
14
Output 1:
Enter the message polynomial(in x7+x4+ form):
X0
Enter the message polynomial(in x7+x4+ form):
X12+x10+x2
The message bit string is:
1
The message bit string before adding checksum is:
1000000000000
The generator bit string is:
1010000000100
The message to be transmitted is:
1010000000100
The CHECK SUM is:
010000000100
Output 2:
Enter the message polynomial(in x7+x4+ form):
X10+X8+X6+X5+X3+X1
Enter the message polynomial(in x7+x4+ form):
X2+X0
The message bit string is:
10101101010
The message bit string before adding checksum is:
1010110101000
The generator bit string is:
101
The message to be transmitted is:
1010110101011
The CHECK SUM is:
11
15
3) PROBLEM SPECIFICATION:
Program to implement Dijkastra Shortest path routing algorithm.
ALGORITHM:
Step1: Enter the number of nodes of the subnet and the node names.
Step2: Enter the cost between each and every node in the subnet.
Step3: Enter the source node and destination node for the subnet.
Step4:Calculate the shortest distance from source node to every other
nodes.
Step5: Print the shortest distance from source node to destination.
Step6: Print the path from source to destination.
16
PROGRAM:
#include<stdio.h>
#include<conio.h>
void main()
{
intar[20][20],n,i,j,k,s,c,spd[10];
charst[20],spn[10];
charspath[10];
clrscr();
printf("Enter the number of nodes:\n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter node %d name:\n",i);
scanf("%s",&st[i]);
}
for(i=0;i<n;i++)
{
for(j=i;j<n;j++)
{
if(i==j)
{
ar[i][j]=0;
}
else
{
printf("Enter cost between %c and %c:\n",st[i],st[j]);
scanf("%d",&ar[i][j]);
ar[j][i]=ar[i][j];
}
}
}
printf("\n Enter starting and Ending nodes:");
scanf("%d %d",&s,&c);
for(k=0;k<n;k++)
{
printf(" %c",st[k]);
}
for(i=0;i<n;i++)
17
{
printf(" ");
printf("\n%c",st[i]);
for(j=0;j<n;j++)
{
printf(" ");
printf("%d",ar[i][j]);
}
}
for(i=0;i<n;i++)
spd[i]=0;
i=0;
while(i!=n)
{
for(j=0;j<n;j++)
{
if(ar[i][j]!=0&&(spd[j]>ar[i][j]+spd[i]||spd[j]==0))
{
spd[j]=spd[i]+ar[i][j];
spn[j]=st[i];
}
}
i++;
}
printf("\nThe shortest distance is %d",spd[c]);
spath[0]=st[c];
for(i=c,j=1;spn[i]!=st[0];)
{
spath[j]=spn[i];
for(k=0;k<n;k++)
if(spn[i]==st[k])
break;
i=k;
j++;
}
printf("\n Shortest path is %c",st[0]);
for(i=j-1;i>=0;i--)
{
printf("%c",spath[i]);
}
getch();
}
18
OUTPUT:
Enter the number of nodes:
6
Enter node 0 name:
a
Enter node 1 name:
b
Enter node 2 name:
c
Enter node 3 name:
d
Enter node 4 name:
e
Enter node 5 name:
f
Enter cost between a and b:
5
Enter cost between a and c:
7
Enter cost between a and d:
1
Enter cost between a and e:
3
Enter cost between a and f:
2
Enter cost between b and c:
8
Enter cost between b and d:
4
Enter cost between b and e:
6
Enter cost between b and f:
9
Enter cost between c and d:
1
Enter cost between c and e:
5
Enter cost between c and f:
8
Enter cost between d and e:
3
Enter cost between d and f:
2
Enter cost between e and f:
1
19
20
4) PROBLEM SPECIFICATION:
Program to implement Data Encryption Standard.
ALGORITHM:
Step 1: START
Step 2: Enter the 8 bit plain text and 10 bit key.
Step 3: The given key is divided into two halves one left and the other right
and the halves are applied to the left shift.
Step 4: The given plain text is also divided into two halves and right half is
applied to Expansion table.
Step 5: The plain text is then xor with the key.
Step 6: Now the value is applied to the substitution boxes.
Step 7: Now the permutation is applied.
Step 8: The obtained value is xor with the left half of plain text and this
becomes the Right half for the next DES and the right half becomes left half
for next DES.
Step 9: Now the cipher text is taken and the plain text is
generated. By the process which is exactly opposite to
the process of Encryption
Step10: STOP
21
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<math.h>
static char a[10],pp[10],z[10],k[10],ak[10],rp[10],
static char bk[10],k1[10],k2[10],ap[10],bp[10];
static char k1[10],b[10],rk[10],x[10],ax[10],c[10],s[10],tem[10],p10[10];
char i,j,s0[4][4],s1[4][4],kk[10],rr[10],bp1[10];
int y1,y2;
xor(char d,char d1)
{
if(d==d1)
return('0');
else
return('1');
}
lr(char x[],int x1)
{
for(i=0;i<5;i++)
z[i]=x[i];
for(i=0;i<4;i++)
x[i]=z[i+1];
x[i]=z[0];
x1--;
if(x1!=0)
lr(x,x1);
}
key()
{
a[0]=bk[0];
a[1]=ak[2];
a[2]=bk[1];
a[3]=ak[3];
a[4]=bk[2];
a[5]=ak[4];
a[6]=bk[4];
a[7]=bk[3];
}
22
ep()
{
b[0]=bp[3];
b[1]=bp[0];
b[2]=bp[1];
b[3]=bp[2];
b[4]=bp[1];
b[5]=bp[2];
b[6]=bp[3];
b[7]=bp[0];
}
ss(char e,char f)
{
if((e=='0')&&(f=='0'))
return(0);
if((e=='0')&&(f=='1'))
return(1);
if((e=='1')&&(f=='0'))
return(2);
if((e=='1')&&(f=='1'))
return(3);
}
s1s(char m)
{
if(m=='0')
{
kk[0]='0';kk[1]='0';
}
if(m=='1')
{
kk[0]='0';kk[1]='1';
}
if(m=='2')
{
kk[0]='1';kk[1]='0';
}
if(m=='3')
{
kk[0]='1';kk[1]='1';
}
}
23
p1(char x[])
{
ax[0]=x[1];
ax[1]=x[3];
ax[2]=x[2];
ax[3]=x[0];
}
sos()
{
rk[0]=k[2];
rk[1]=k[4];
rk[2]=k[1];
rk[3]=k[6];
rk[4]=k[3];
rk[5]=k[9];
rk[6]=k[0];
rk[7]=k[8];
rk[8]=k[7];
rk[9]=k[5];
printf("\n rearranged key:");
for(i=0;i<5;i++)
{
ak[i]=rk[i];
printf("%3c",rk[i]);
}
for(i=5,j=0;i<10;i++,j++)
{
bk[j]=rk[i];
printf("%3c",rk[i]);
}
lr(ak,1);
lr(bk,1);
printf("\n key1;");
key();
for(i=0;i<8;i++)
{
k1[i]=a[i];
printf("%3c",a[i]);
}
24
lr(ak,2);
lr(bk,2);
key();
printf("\n key2:");
for(i=0;i<8;i++)
{
k2[i]=a[i];
printf("%3c",a[i]);
}
}
prg(char p[])
{
rp[0]=p[1];
rp[1]=p[5];
rp[2]=p[2];
rp[3]=p[0];
rp[4]=p[3];
rp[5]=p[7];
rp[6]=p[4];
rp[7]=p[6];
printf("\n rearranged plain text:");
for(i=0;i<8;i++)
printf("%3c",rp[i]);
for(i=0;i<4;i++)
ap[i]=rp[i];
for(i=4,j=0;i<8;i++,j++)
bp[j]=rp[i];
ep();
printf("\n e/p:");
for(i=0;i<8;i++)
{
bp[i]=b[i];
printf("%3c",bp[i]);
}
printf("\n xor;");
for(i=0;i<8;i++)
{
c[i]=xor(bp[i],k1[i]);
printf("%3c",c[i]);
}
25
[0][0]='1';
s0[0][1]='0';
s0[0][2]='3';
s0[0][3]='2';
s0[1][0]='3';
[1][1]='2';
s0[1][2]='1';
[1][3]='0';
s0[2][0]='0';
s0[2][1]='2';
s0[2][2]='1';
s0[2][3]='3';
s0[3][0]='3';
s0[3][1]='1';
s0[3][2]='3';
s0[3][3]='2';
s1[0][0]='0';
s1[0][1]='1';
s1[0][2]='2';
s1[0][3]='3';
s1[1][0]='2';
s1[1][1]='0';
s1[1][2]='1';
s1[1][3]='3';
s1[2][0]='3';
s1[2][1]='0';
s1[2][2]='1';
s1[2][3]='0';
s1[3][0]='2';
s1[3][1]='1';
s1[3][2]='0';
s1[3][3]='3';
y1=ss(c[0],c[3]);
=ss(c[1],c[2]);
s1s(s0[y1][y2]);
for(i=0;i<2;i++)
s[i]=kk[i];
y1=ss(c[4],c[7]);
y2=ss(c[5],c[6]);
s1s(s1[y1][y2]);
for(i=0,j=2;i<2;i++,j++)
s[j]=kk[i];
26
p1(s);
printf("\n p4:");
for(i=0;i<4;i++)
{
s[i]=ax[i];
printf("%3c",s[i]);
}
for(j=0;j<4;j++)
{
rp[j]=xor(s[j],ap[j]);
}
for(i=0;i<4;i++)
{
bp[i]=rp[i];
bp1[i]=rp[i];
}
for(i=4,j=0;i<8;i++,j++)
ap[j]=rp[i];
ep();
printf("\n e/p:");
for(i=0;i<8;i++)
{
bp[i]=b[i];
printf("%3c",bp[i]);
}
printf("\n xor:");
for(i=0;i<8;i++)
{
c[i]=xor(bp[i],k2[i]);
printf("%3c",c[i]);
}
y1=ss(c[0],c[3]);
y2=ss(c[1],c[2]);
s1s(s0[y1][y2]);
for(i=0;i<2;i++)
s[i]=kk[i];
y1=ss(c[4],c[7]);
y2=ss(c[5],c[6]);
(s1[y1][y2]);
for(i=0,j=2;i<2;i++,j++)
s[j]=kk[i];
p1(s);
27
printf("\n p4:");
for(i=0;i<4;i++)
{
s[i]=ax[i];
printf("%3c",s[i]);
}
printf("\n IP inverse;");
for(i=0;i<4;i++)
{
rp[i]=xor(s[i],ap[i]);
printf("%3c",rp[i]);
}
for(j=0,i=4;i<8;j++,i++)
{
rp[i]=bp1[j];
printf("%3c",rp[i]);
}
rr[0]=rp[3];
rr[1]=rp[0];
rr[2]=rp[2];
rr[3]=rp[4];
rr[4]=rp[6];
rr[5]=rp[1];
rr[6]=rp[7];
rr[7]=rp[5];
printf("\n cipher text:");
for(i=0;i<8;i++)
printf("%3c",rr[i]);
for(i=0;i<8;i++)
{
tem[i]=k1[i];
k1[i]=k2[i];
k2[i]=tem[i];
}
}
main()
{
intch,na;
clrscr();
do
28
{
printf("\nenterur choice:");
printf("1-->encryption 2-->decryption 3-->exit:");
scanf("%d",&ch);
switch(ch)
{
case 1: printf("enter 8 bit plain text:");
scanf("%s",&p10);
printf("enter 10 bit key:");
scanf("%s",&k);
na='2';
sos();
prg(p10);
break;
case 2: if(na!='2')
printf("\n decryption is not possible without
encryption");
else
prg(rr);
break;
case 3: exit();
}
}
while(ch<3);
getch();
}
29
OUTPUT 1:
Enter ur choice:
1encryption 2decryption 3exit:1
Enter 8 bit plain text: 11100010
Enter the 10 bit key: 0011001010
Rearranged key: 1 0 0 1 1 0 0 1 0 0
Key 1:0 1 1 10 1 10 0
Key 2:0 1 0 0 0 0 1 0
Rearranged plain text:1 0 1 1 0 0 0 1
e/p : 1 0 0 0 0 0 1 0
xor: 1 1 1 1 0 1 1 0
p4: 0 1 1 1
e/p:0 1 1 0 1 0 0 1
xor: 0 0 1 0 1 0 1 1
p4: 0 1 0 0
IP inverse: 0 1 0 1 1 1 0 0
Cipher text: 1 0 0 1 0 1 0 1
OUTPUT 2:
Enter ur choice:
1encryption 2decryption 3exit:1
Enter 8 bit plain text: 10101010
Enter the 10 bit key: 0101010101
Rearranged key: 0 0 1 0 1 1 0 0 1 1
Key 1:0 0 0 1 1 0 1 1
Key 2:0 1 0 1 1 0 0
Rearranged plain text:0 0 1 1 0 0
e/p : 1 0 0 1 0 1 1 0
xor: 1 0 0 0 1 1 0 1
p4: 0 0 0 0
e/p:1 0 0 1 0 1 1 0
xor: 0 0 1 1 1 0 1 0
p4: 0 0 0 1
IP inverse: 0 0 1 0 0 0 1 1
Cipher text: 0 0 1 0 1 0 1 0
30
INFORMATIONSECURITY ( JNTU )
S.N
o
1
2
31
32
Step15:
ctl=ip_hdr->protocol
Step16:
Step17:
Step18:
Step19:
Step20:
Step21:
33
Step22:
Step23:
Step24:
Step25:
if(sockfd<0)
perror("socket")
fp=fopen("./output/ether.txt","a")
if(!fp)
perror("fopen")
setvbuf(fp,NULL,_IONBF,0)
The following infinite while loop is used to continuously
capture packets and afterwards the packet will be passed
to appropriate handler
while(1)
sl=sizeof(struct sockaddr_ll);
retval=recvfrom(sockfd,buf,2000,0,(struct sockaddr *)&sa,&sl)
if(retval==-1)
perror("recvfrom")
eth_hdr=(struct ethhdr *) buf
output(fp,"\t ----------------------------\n")
system("date>>./output/ether.txt")
hadd=ether_ntoa((struct ether_addr *)eth_hdr->h_source)
fprintf(fp,"source ethernet address is %s\n",hadd)
hadd=ether_ntoa((struct ether_addr *)eth_hdr->h_dest)
fprintf(fp,"destination ethernet address is %s\n",hadd)
fprintf(fp,"packet protocol id is %x\n",ntohs(eth_hdr->h_proto))
fprintf(fp,"\t ----------------------------\n")
ctl=ntohs(eth_hdr->h_proto)
switch(ctl)
case 0x0800:
print("received IP packet\n")
Handle_IP(buf)
break
case 0x0806
print("received ARP packet\n")
Handle_ARP(buf)
break
case 0x8035
print("received RARP packet\n")
Handle_RARP(buf)
break
fclose(fp)
34
Step26:
Step27:
Step28:
Step29:
Step30:
35
Step31:
Step32:
Step33:
Step34:
Step35:
36
fp=fopen("./output/ip.txt","a")
if(!fp)
perror("fopen")
print(fp,"\t -------------------------------\n")
system("date>> ./output/ip.txt")
print(fp,"type of service : %d\n",ip_hdr->tos)
print(fp,"protocol id is %d\n",ip_hdr->protocol)
print(fp,"total len %d\n",ntohs(ip_hdr->tot_len))
print(fp,"fragment offset %d\n",ntohs(ip_hdr->frag_off))
Step36:
Step37:
Step38:
37
case UDP:
Step39:
Step40:
Step41:
Step 42:
Handle_UDP(buf,len);
break;
This file is part of sniffer, a packet capturing utility and
Network Monitor
void Handle_ICMP(char *buf,int len)
declaring pointer of type icmp header
struct icmphdr *icmp_hdr
FILE *fp
fp=fopen("./output/icmp.txt","a")
if(!fp)
perror("icmp.fopen")
The following header is used to adjust offset so that icmp header
can point to currect location
icmp_hdr=(struct icmphdr *) (buf+len);
print(fp,"\t --------------------------------\n")
system("date>> ./output/icmp.txt")
print(fp,"message type : %d\n",icmp_hdr->type)
print(fp,"sub-code : %d\n",icmp_hdr->code)
print(fp,"\t --------------------------------\n")
void Handle_IGMP(char *buf,int len)
declaring pointer of type igmp header
struct igmp *igmp_hdr
declaring a structure to store ip address
struct in_addr in
FILE *fp
igmp_hdr=(struct igmp *) (buf+len)
fp=fopen("./output/igmp.txt","a")
if(!fp)
perror("igmp.fopen")
print(fp,"\t ---------------------------------\n")
system("date>> ./output/igmp.txt")
print(fp,"igmp type : %d\n",igmp_hdr->igmp_type)
Step43:
38
Step44:
Step45:
Step 46:
Step47:
Step48:
39
RESULT:
40
hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:03:56 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:03:57 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
--------------------------------Fri Jul 16 20:03:59 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 1
sender hardware address : 0:2:44:10:f6:41
sender protocol address : 192.168.100.5
target protocol address : 192.168.100.254
41
42
43
protocol length : 4
operation code : 1
sender hardware address : 0:50:bf:d8:48:a1
sender protocol address : 192.168.100.2
target protocol address : 192.168.100.1
--------------------------------Fri Jul 16 20:04:22 IST 2004
-------------------------------hardware type : 1
protocol type : 2048
hardware length : 6
protocol length : 4
operation code : 2
sender hardware address : 0:2:44:10:f6:47
sender protocol address : 192.168.100.1
target protocol address : 192.168.100.2
44
Switch
Description
-sT
-sS
45
Scan Type
Switch
Description
the connection. Because this scan
doesn't open the connection, it is less
likely to be logged.
Stealth FIN
-sF
Xmas Tree
-sX
Null
-sN
Ping
-sP
UDP scan
-sU
ACK scan
-sA
List scan
-sL
46
Scan Type
Switch
Description
can use this FTP bounce (mis)feature
to scan ports that might otherwise be
protected.
Cons:
Not totally stealthy
Easily blocked
47
Cons:
Inaccurate with certain operating systems
Nmap command line prompt:
C:\nmap> nmap -sX 192.168.0.7
Nmap command line prompt:
C:\nmap> nmap -sN 192.168.0.7
Pros:
Fairly fast
Easy to implement
Stealthy to a certain extent
Cons:
Works only with UNIX and some other operating systems
Nmap command line prompt:
C:\nmap> nmap -sU 192.168.0.10
Nmap command line prompt:
C:\nmap> nmap -sA 68.46.234.161
Nmap command line prompt:
C:\nmap> nmap -sA 68.46.234.161
48
Option
-P0
-f
-v
-oN <logfile>
-oM <logfile>
--resume
<logfile&;
-iL <logfile>
-g
<portnumber>
-p <port
range>
Explanation
Tells nmap not to ping hosts before
scanning. (This is used to scan hosts that
sit behind packet filters that don't allow
ICMP traffic.)
Causes nmap to fragment its scanning
packets, making it more difficult to
block the scan with packet filters.
Puts nmap into verbose mode, causing it
to display much more information about
what it's doing.
Writes output into a human readable
logfile.
Writes output into a machine-parsable
logfile.
Resumes an incomplete scan from a
logfile.
Causes nmap to read input from a logfile
instead of really scanning a host.
Allows you to define the port nmap uses
as its source port.
Allows you to define the range of ports
nmap will scan. If no range is given,
nmap will scan all the ports listed in its
own services file. A range of ports can
be given in the following format: -p 2030,79,6000-6010.
Test Data:
Valid Data Set:
IP address
Invalid IP address
Not applicable
Result:
Nmap command line prompt:
C:\nmap> nmap -O www.hackingmobilephones.com
Nmap command line prompt for TCP SYN Scan:
49
STATE SERVICE
50
STATE SERVICE
51
52
Experiment: 1
Aim: To analyze the data in contact-lenses data base and visualize it in different ways.
Description:
Step1: Click on the weka 3.6 option then it gives weka GUI chooser window as shown
below:.
53
Step2: In that window, click on explorer option then weka explorer window will be
displayed as shown below:
Step3: The contact-lenses relation has 24 instances and 5 attributes. The records in the contactlenses relation are shown below:
54
55
Case2: Analyze Spectacle-prescript attribute based on the class contact-lenses
Step1: select the attribute Spectacle-prescript
Step2: select contact-lenses as a class attribute. The Spectacle-prescript details and its graph
is as follows:
56
Case4: Analyze Tear-prod-rate attribute based on the class contact-lenses
Step1: select the attribute Tear-prod-rate
Step2: select contact-lenses as a class attribute. The Tear-prod-rate details and its
graph is as follows:
57
Experiment-2
Aim: Write details on the table Weather. Nominal and class play classified on outlook
attribute.
Description:
Step1: Click on the weka 3.6 option then it gives weka GUI chooser window as shown
below:.
Step2: In that window, click on explorer option then weka explorer window will be
displayed as
shown
below:
www.jntuworld.com
58
8
Step3: The Weather. Nominal relation has 14 instances and 5 attributes. The records in the
Weather. Nominal relation is shown below:
59
60
61
Experiment-3
Aim: Describe preprocessing details on the table Iris relation and visualize all details based on
class
class .
Description:
Step1: Click on the weka 3.6 option then it gives weka GUI chooser window as shown
below:
62
Step2: In that window, click on explorer option then weka explorer window will be
displayed as
shown below:
14
63
Case2: Analyze sepal width attribute based on the class class
Step1: select the attribute sepal width
Step2: select class as a class attributes. The sepal width details and its graph is as follows:
64
65
66
Experiment-4
Aim: Generate Association rules for the relation Weather. Nominal on any three
attributes
Description:
Step1: Click on the weka 3.6 option then it gives weka GUI chooser window as shown
below:
Step2: In that window, click on explorer option then weka explorer window will be
displayed as
67
Step3: In that window, click on the open file option and select data folder and then select
the Weather. Nominal relation for the data analyzation
Step4: On that window click Associate tab. In that click choose and select apriori. The
window is display as shown below
19
68
Step5: click on the start button. Then the output is displayed as follows
output:
69
Experiment-5
o&Naidu
College of
engineering
Aim: Generate Association rules for the relation Soybean on any three
attributes
Description:
Step1: Click on the weka 3.6 option then it gives weka GUI chooser window as shown
follows:.
Step2:In that window ,click on explorer option then weka explorer window will be
displayed as shown below :
70
Step3: In that window ,click on the open file option and select data folder and then select the
Soybean relation for the data analyzation
Step4: On that window click Associate tab. In that click choose and select apriori. The window is
display as shown below
Step5: click on the start button. Then the output is displayed as follows
Output: