0% found this document useful (0 votes)
42 views27 pages

Bis Practical 1 To 4

The document outlines practical exercises for a 6th semester engineering course, focusing on basic TCP/IP utilities and commands such as ipconfig, ping, tracert, pathping, and netstat. It also includes programming assignments to implement the Caesar Cipher and Playfair Cipher in C language, detailing the algorithms and example code for each. The practicals aim to enhance understanding of networking commands and encryption techniques.

Uploaded by

Devanshi Dave
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)
42 views27 pages

Bis Practical 1 To 4

The document outlines practical exercises for a 6th semester engineering course, focusing on basic TCP/IP utilities and commands such as ipconfig, ping, tracert, pathping, and netstat. It also includes programming assignments to implement the Caesar Cipher and Playfair Cipher in C language, detailing the algorithms and example code for each. The practicals aim to enhance understanding of networking commands and encryption techniques.

Uploaded by

Devanshi Dave
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/ 27

PROF.

DEVANSHI DAVE

GROW MORE FACULTY DIPLOMA OF


ENGINEERING

DEPARTMENT : CE

SEMESTER : 6TH

SUBJECT : 4360702 (BIS)

PRACTICAL: 1
1. Execute Basic TCP/IP utilities and commands. (eg: ping, ipconfig, tracert, arp,
tcpdump, whois, host, netstat, nslookup, ftp, telnet etc... )

Ipconfig
Displays all current TCP/IP network configuration values and refreshes Dynamic
Host Configuration Protocol (DHCP) and Domain Name System (DNS) settings.
Used without parameters, ipconfig displays the IP address, subnet mask, and default
gateway for all adapters.

This command is most useful on computers that are configured to obtain an IP address
automatically. This enables users to determine which TCP/IP configuration values
PROF.DEVANSHI DAVE

have been configured by DHCP, Automatic Private IP Addressing (APIPA), or an


alternate configuration. Syntax

ipconfig [/all]
[/renew [Adapter]]
[/release [Adapter]]
[/flushdns]
[/displaydns]
[/registerdns]
[/showclassid Adapter]
[/setclassid Adapter [ClassID]]
Examples

To display the basic TCP/IP configuration for all adapters, type:

ipconfig
To display the full TCP/IP configuration for all adapters, type:

ipconfig /all
To renew a DHCP-assigned IP address configuration for only the Local Area
Connection adapter, type:

ipconfig /renew "Local Area Connection"


To flush the DNS resolver cache when troubleshooting DNS name resolution
problems, type:

ipconfig /flushdns
To display the DHCP class ID for all adapters with names that start with Local, type:

ipconfig /showclassid Local*


To set the DHCP class ID for the Local Area Connection adapter to TEST, type:

ipconfig /setclassid "Local Area Connection" TEST


Ping
Verifies IP-level connectivity to another TCP/IP computer by sending Internet
Control Message Protocol (ICMP) Echo Request messages. The receipt of
corresponding Echo Reply messages are displayed, along with round-trip times. Ping
is the primary TCP/IP command used to troubleshoot connectivity, reachability, and
name resolution. Used without parameters, ping displays help.
PROF.DEVANSHI DAVE

You can use ping to test both the computer name and the IP address of the computer.
If pinging the IP address is successful, but pinging the computer name is not, you
might have a name resolution problem. In this case, ensure that the computer name
you are specifying can be resolved through the local Hosts file, by using Domain
Name System (DNS) queries, or through NetBIOS name resolution techniques.
Syntax

ping [-t]
[-a]
[-n Count]
[-l Size]
[-f]
[-i TTL]
[-v TOS]
[-r Count]
[-s Count]
[{-j HostList | -k HostList}]
[-w Timeout]
[TargetName]
Examples

The following example shows ping command output: C:\

>ping example.microsoft.com
Pinging example.microsoft.com [192.168.239.132] with 32 bytes of data:
Reply from 192.168.239.132: bytes=32 time=101ms TTL=124
PROF.DEVANSHI DAVE
Reply from 192.168.239.132: bytes=32 time=100ms TTL=124
PROF.DEVANSHI DAVE

Reply from 192.168.239.132: bytes=32 time=120ms TTL=124


Reply from 192.168.239.132: bytes=32 time=120ms TTL=124
To ping the destination 10.0.99.221 and resolve 10.0.99.221 to its host name, type:

ping -a 10.0.99.221
To ping the destination 10.0.99.221 with 10 Echo Request messages, each of which
has a Data field of 1000 bytes, type:

ping -n 10 -l 1000 10.0.99.221


To ping the destination 10.0.99.221 and record the route for 4 hops, type:

ping -r 4 10.0.99.221
To ping the destination 10.0.99.221 and specify the loose source route of 10.12.0.1-
10.29.3.1-10.1.44.1, type:

ping -j 10.12.0.1 10.29.3.1 10.1.44.1 10.0.99.221

Tracert
Determines the path taken to a destination by sending Internet Control Message
Protocol (ICMP) Echo Request messages to the destination with incrementally
increasing Time to Live (TTL) field values. The path displayed is the list of near-side
router interfaces of the routers in the path between a source host and a destination.
The near-side interface is the interface of the router that is closest to the sending host
in the path. Used without parameters, tracert displays help.
PROF.DEVANSHI DAVE

This diagnostic tool determines the path taken to a destination by sending ICMP Echo
Request messages with varying Time to Live (TTL) values to the destination. Each
router along the path is required to decrement the TTL in an IP packet by at least 1
before forwarding it. Effectively, the TTL is a maximum link counter. When the TTL
on a packet reaches 0, the router is expected to return an ICMP Time Exceeded
message to the source computer. Tracert determines the path by sending the first Echo
Request message with a TTL of 1 and incrementing the TTL by 1 on each subsequent
transmission until the target responds or the maximum number of hops is reached. The
maximum number of hops is 30 by default and can be specified using the -h
parameter. The path is determined by examining the ICMP Time Exceeded messages
returned by intermediate routers and the Echo Reply message returned by the
destination. However, some routers do not return Time Exceeded messages for
packets with expired TTL values and are invisible to the tracert command. In this case,
a row of asterisks (*) is displayed for that hop.

Syntax

tracert [-d]
[-h MaximumHops]
[-j HostList]
[-w Timeout]
[TargetName]
Examples

To trace the path to the host named corp7.microsoft.com, type:

tracert corp7.microsoft.com
To trace the path to the host named corp7.microsoft.com and prevent the resolution of
each IP address to its name, type:

tracert -d corp7.microsoft.com
To trace the path to the host named corp7.microsoft.com and use the loose source
route 10.12.0.1-10.29.3.1-10.1.44.1, type:

tracert -j 10.12.0.1 10.29.3.1 10.1.44.1 corp7.microsoft.com

Pathping
Provides information about network latency and network loss at intermediate hops
between a source and destination. Pathping sends multiple Echo Request messages to
each router between a source and destination over a period of time and then computes
PROF.DEVANSHI DAVE

results based on the packets returned from each router. Because pathping displays the
degree of packet loss at any given router or link, you can determine which routers or
subnets might be having network problems. Pathping performs the equivalent of the
tracert command by identifying which routers are on the path. It then sends pings
periodically to all of the routers over a specified time period and computes statistics
based on the number returned from each. Used without parameters, pathping displays
help.

Syntax

pathping [-n]
[-h MaximumHops]
[-g HostList]
[-p Period]
[-q NumQueries]
[-w Timeout]
[-T]
[-R]
[TargetName]
Examples

The following example shows pathping command output: D:\

>pathping -n corp1
Tracing route to corp1 [10.54.1.196]
over a maximum of 30 hops:
0 172.16.87.35
PROF.DEVANSHI DAVE

1 172.16.87.218
2 192.168.52.1
3 192.168.80.1
4 10.54.247.14
5 10.54.1.196
Computing statistics for 125 seconds...
Source to Here This Node/Link
Hop RTT Lost/Sent = Pct Lost/Sent = Pct Address
0 172.16.87.35
0/ 100 = 0% |
1 41ms 0/ 100 = 0% 0/ 100 = 0% 172.16.87.218
13/ 100 = 13% |
2 22ms 16/ 100 = 16% 3/ 100 = 3% 192.168.52.1
0/ 100 = 0% |
3 24ms 13/ 100 = 13% 0/ 100 = 0% 192.168.80.1
0/ 100 = 0% |
4 21ms 14/ 100 = 14% 1/ 100 = 1% 10.54.247.14
0/ 100 = 0% |
5 24ms 13/ 100 = 13% 0/ 100 = 0% 10.54.1.196
Trace complete.
When pathping is run, the first results list the path. This is the same path that is shown
using the tracert command. Next, a busy message is displayed for approximately 90
seconds (the time varies by hop count). During this time, information is gathered
from all routers previously listed and from the links between them. At the end of this
period, the test results are displayed.

In the sample report above, the This Node/Link, Lost/Sent = Pct and Address
columns show that the link between 172.16.87.218 and 192.168.52.1 is dropping 13
percent of the packets. The routers at hops 2 and 4 also are dropping packets
addressed to them, but this loss does not affect their ability to forward traffic that is
not addressed to them.

The loss rates displayed for the links, identified as a vertical bar (|) in the Address
column, indicate link congestion that is causing the loss of packets that are being
forwarded on the path. The loss rates displayed for routers (identified by their IP
addresses) indicate that these routers might be overloaded.
PROF.DEVANSHI DAVE

Netstat
Displays active TCP connections, ports on which the computer is listening, Ethernet
statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP
protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over
IPv6 protocols). Used without parameters, netstat displays active TCP connections.

Syntax

netstat [-a]
[-e]
[-n]
[-o]
[-p Protocol]
[-r]
[-s]
[Interval]
Examples

To display both the Ethernet statistics and the statistics for all protocols, type the
following command:

netstat -e -s
To display the statistics for only the TCP and UDP protocols, type the following
command:

netstat -s -p tcp udp


To display active TCP connections and the process IDs every 5 seconds, type the
following command:
PROF.DEVANSHI DAVE

netstat -o 5
To display active TCP connections and the process IDs using numerical form, type the
following command:

netstat -n –o

PRACTICAL: 2
PROF.DEVANSHI DAVE

2. Write a Program to implement Caesar Cipher.


AIM:

To implement the simple substitution technique named Caesar cipher


using C language.

DESCRIPTION:

To encrypt a message with a Caesar cipher, each letter in the


message is changed using a simple rule: shift by three. Each letter is
replaced by the letter three letters ahead in the alphabet. A becomes D, B
becomes E, and so on. For the last letters, we can think of the
alphabet as a circle and "wrap around". W becomes Z, X bec oomes A, Y bec
mes B, and Z
becomes C. To change a message back, each letter is replaced by the one three
before it.

EXAMPLE:

ALGORITHM:

STEP-1: Read the plain text from the user.


STEP-2: Read the key value from the user.
STEP-3: If the key is positive then encrypt the text by adding the
key with eachcharacter in the plain text.
STEP-4: Else subtract the key from the plain text.
STEP-5: Display the cipher text obtained above.

PROGRAM: (Caesar Cipher)

#include <stdio.h>
#include <string.h>
#include<conio.h>
PROF.DEVANSHI DAVE

#include <ctype.h>
void main()
PROF.DEVANSHI DAVE

char plain[10], cipher[10];int


key,i,length;
int result;clrscr();
printf("\n Enter the plain text:");
scanf("%s", plain);
printf("\n Enter the key value:");
scanf("%d", &key);
printf("\n \n \t PLAIN TEXt: %s",plain);printf("\n
\n \t ENCRYPTED TEXT: ");
for(i = 0, length = strlen(plain); i < length; i++)

cipher[i]=plain[i] + key;

if (isupper(plain[i]) && (cipher[i] > 'Z'))cipher[i]


= cipher[i] - 26;
if (islower(plain[i]) && (cipher[i] > 'z'))cipher[i]
= cipher[i] - 26;
printf("%c", cipher[i]);
}

printf("\n \n \t AFTER DECRYPTION : ");


for(i=0;i<length;i++)
{

plain[i]=cipher[i]-key;
if(isupper(cipher[i])&&(plain[i]<'A'))
plain[i]=plain[i]+26;
if(islower(cipher[i])&&(plain[i]<'a'))
plain[i]=plain[i]+26; printf("%c",plain[i]);
}

getch();

6
PROF.DEVANSHI DAVE
OUTPUT

7
PROF.DEVANSHI DAVE

PRACTICAL: 3
3. Write a Program to implement Playfair Cipher.

AIM:

To write a C program to implement the Playfair Substitution technique.

DESCRIPTION:

The Playfair cipher starts with creating a key table. The key table
is a 5×5 grid ofletters that will act as the key for encrypting your plaintext.
Each of the 25 letters must be unique and one letter of the alphabet is
omitted from the table (as there are 25 spots and 26 letters in the alphabet).

To encrypt a message, one would break the message into digrams


(groups of 2 letters) such that, for example, "HelloWorld" becomes "HE
LL OW OR LD", and map them out on the key table. The two letters of
the diagram are considered as the opposite corners of a rectangle in the
key table. Note the relative position of the corners of this rectangle. Then
apply the following 4 rules, in order, to each pair of letters in the plaintext:

1. If both letters are the same (or only one letter is left), add an "X" after the
first letter
2. If the letters appear on the same row of your table, replace them
with the letters totheir immediate right respectively
3. If the letters appear on the same column of your table, replace them
with the letters immediately below respectively
4. If the letters are not on the same row or column, replace them with
the letters on the same row respectively but at the other pair of
corners of the rectangle defined by the original pair.

8
PROF.DEVANSHI DAVE
EXAMPLE:

9
PROF.DEVANSHI DAVE

ALGORITHM:

STEP-1: Read the plain text from the user.


STEP-2: Read the keyword from the user.

STEP-3: Arrange the keyword without duplicates in a 5*5 matrix in


the row order and fill the remaining cells with missed out
letters in alphabetical order. Note that ‘i’ and ‘j’ takes the
same cell.
STEP-4: Group the plain text in pairs and match the corresponding
corner letters by forming a rectangular grid.
STEP-5: Display the obtained cipher text.

PROGRAM: (Playfair Cipher)

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<ctype.h>
#define MX 5
void playfair(char ch1,char ch2, char key[MX][MX])
{

int i,j,w,x,y,z;FILE
*out;
if((out=fopen("cipher.txt","a+"))==NULL)
{

printf("File Currupted.");

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

10
PROF.DEVANSHI DAVE
for(j=0;j<MX;j++)
}}}
{

if(ch1==key[i][j])

w=i;
x=j;
}

else if(ch2==key[i][j])

y=i;
z=j;
//printf("%d%d %d%d",w,x,y,z);
if(w==y)
{
x=(x+1)%5;z=(z+1)%5;

printf("%c%c",key[w][x],key[y][z]);

fprintf(out, "%c%c",key[w][x],key[y][z]);

else if(x==z)

11
PROF.DEVANSHI DAVE

w=(w+1)%5;y=(y+1)%5;

printf("%c%c",key[w][x],key[y][z]);
}
fprintf(out, "%c%c",key[w][x],key[y][z]);
else

printf("%c%c",key[w][z],key[y][x]);

} fprintf(out, "%c%c",key[w][z],key[y][x]);

fclose(out);

void main()

int i,j,k=0,l,m=0,n;

char key[MX][MX],keyminus[25],keystr[10],str[25]={0}; char


alpa[26]={'A','B','C','D','E','F','G','H','I','J','K','L'
,'M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}
;

clrscr(); printf("\nEnter
key:");gets(keystr);
printf("\nEnter the plain text:");
gets(str);
n=strlen(keystr);
//convert the characters to uppertextfor
(i=0; i<n; i++)
{

if(keystr[i]=='j')keystr[i]='i';

else if(keystr[i]=='J')keystr[i]='I';keystr[i]
= toupper(keystr[i]);
}
12
PROF.DEVANSHI DAVE
//convert all the characters of plaintext to uppertextfor (i=0;
i<strlen(str); i++)
{

if(str[i]=='j')str[i]='i';

else if(str[i]=='J')str[i]='I';str[i] =
} toupper(str[i]);
j=0;

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

for(k=0;k<n;k++)

if(keystr[k]==alpa[i])break;
else if(alpa[i]=='J')
break;
}

if(k==n)

keyminus[j]=alpa[i];j++;

13
PROF.DEVANSHI DAVE

//construct key keymatrix


k=0;
for(i=0;i<MX;i++)

for(j=0;j<MX;j++)

if(k<n)

key[i][j]=keystr[k]; k+
+;}
else
{

key[i][j]=keyminus[m];m++;

printf("%c ",key[i][j]);

printf("\n");

printf("\n\nEntered text :%s\nCipher Text :",str); for(i=0;i<strlen(str);i+


+)
{

if(str[i]=='J')str[i]='I';
if(str[i+1]=='\0')
playfair(str[i],'X',key); else
{

getch();
14
PROF.DEVANSHI DAVE
} if(str[i+1]=='J')str[i+1]='I';if(str[i]==str[i+1])
playfair(str[i],'X',key);
else
{

playfair(str[i],str[i+1],key);i++;

}}

15
PROF.DEVANSHI DAVE

OUTPUT:

RESULT:

Thus the Playfair


cipher substitution
technique had
been implemented
successfully

16
PROF.DEVANSHI DAVE

PRACTICAL: 4
4. Write a Program to implement Hill Cipher.
AIM:

To write a C program to implement the hill cipher substitution techniques.

DESCRIPTION:

Each letter is represented by a number modulo 26. Often the simple


scheme A = 0, B
= 1... Z = 25, is used, but this is not an essential feature of the cipher. To
encrypt a message,each block of n letters is multiplied by an invertible
n × n matrix, against modulus 26. To
decrypt the message, each block is multiplied by the invearse of the m
trix used for u
encryption. The for encryption is the cipher key, ld be chosen
matrix used
and it sho

randomly from the set of invertible n × n matrices (modulo 26).

EXAMPLE:

ALGORITHM:

STEP-1: Read the plain text and key from


the user. STEP-2: Split the plain text into
groups of length three.STEP-3: Arrange the

17
PROF.DEVANSHI DAVE
keyword in a 3*3 matrix.
STEP-4: Multiply the two matrices to obtain the cipher text of length
three.
STEP-5: Combine all these groups to get the complete cipher text.

PROGRAM: (Hill Cipher)

#include<stdio.h>
#include<conio.h>
#include<string.h>
int main(){

unsigned int a[3][3]={{6,24,1},{13,16,10},{20,17,15}};

unsigned int b[3][3]={{8,5,10},{21,8,21},{21,12,8}};

int i,j, t=0;

unsigned int c[20],d[20];


char msg[20];

clrscr();

printf("Enter plain text\n ");


scanf("%s",msg);
for(i=0;i<strlen(msg);i++)

{ c[i]=msg[i]-65;

18
PROF.DEVANSHI DAVE

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

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

{ t=0;

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

t=t+(a[i][j]*c[j]);

d[i]=t%26;

printf("\nEncrypted Cipher Text


:");for(i=0;i<3;i++)

printf("
%c",d[i]+65);
for(i=0;i<3;i++)

{
t=0;

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

t=t+(b[i][j]*d[j]);

c[i]=t%26;

printf("\nDecrypted Cipher Text


:");for(i=0;i<3;i++)

printf("
%c",c[i]+65);
getch();

return 0;

}
19
PROF.DEVANSHI DAVE

OUTPUT:

20

You might also like