Computer Networks Lab Manual Whats
Computer Networks Lab Manual Whats
LAB MANUAL
(Approvedby AICTE-NewDelhi, Accreditedby NAACwith‘A’ &
AffiliatedtoJNTU,Hyderabad)RecognisedUnderSection2(f)&12(B)oftheUGCact,1956
Dundigal,Quthbullapur(M),Hyderabad-500043
ProgrammeEducationalObjectives(PEO’s)
ComputerScienceandEngineering
PEO2: academia.Gainmultidisciplinaryknowledgeprovidingasustainablecompetitiveedgein
higherstudiesorResearch.
leadershipandethicalskills,tosucceedanentrepreneurial.
II.PROGRAMMEOUTCOMES(PO’s)
PO1 Engineeringknowledge:Applytheknowledgeofmathematics,science,
engineeringfundamentals,andanengineeringspecializationtothesolutionofcomplexengi
neeringproblems.
PO2 Problemanalysis:Identify,formulate,reviewresearchliterature,andanalyzecomplexen
gineeringproblemsreachingsubstantiatedconclusionsusingfirstprinciplesofmathematic
s,naturalsciences,andengineeringsciences.
PO3 Design/developmentofsolutions:Designsolutionsforcomplexengineeringproblems
and design system components or processes that meet the specified
needswithappropriateconsiderationforthepublichealthandsafety,andthecultural,
societal,andenvironmentalconsiderations.
PO4 Conduct investigationsofcomplex problems:Useresearch-based
knowledgeandresearchmethodsincludingdesignofexperiments,analysisandinterpretat
ionofdata,andsynthesisoftheinformationtoprovidevalidconclusions.
PO5 Modern tool usage :Create,select, and apply appropriate techniques, resources,and
modern engineering and IT tools including prediction and modeling to
complexengineeringactivitieswithanunderstandingofthelimitations.
PO6 The engineer and society: Apply reasoning informed by the contextual
knowledgetoassesssocietal,health,safety,legalandculturalissuesandtheconsequentres
ponsibilitiesrelevanttotheprofessionalengineeringpractice.
PO7 Environment
andsustainability:Understandtheimpactoftheprofessionalengineeringsolutionsinsoci
etalandenvironmentalcontexts,anddemonstratetheknowledgeandneedforsustainabled
evelopment.
PO8 Ethics:Applyethicalprinciplesandcommittoprofessionalethicsandresponsibilities
andnormsoftheengineeringpractice.
PO9 Individualandteamwork:Functioneffectivelyasanindividual,andasamemberorleaderi
ndiverseteams,andinmultidisciplinarysettings.
PO10 Communication: Communicate effectively on complex engineering activities
withthe engineering community and with society at large, such as, being able to
compre-
hendandwriteeffectivereportsanddesigndocumentation,makeeffectivepresenta-
tions,andgiveandreceiveclearinstructions.
PO11 Project management and finance: Demonstrate knowledge and understanding
oftheengineeringandmanagementprinciplesandapplythesetoone’sownwork,asamem
berandleaderinateam,tomanageprojectsandinmultidisciplinaryenvironments.
PO12 Life-longlearning:
Recognizetheneedfor,andhavethepreparationandabilitytoengageinindependentandlife
-longlearninginthebroadestcontextoftechnological
change.
(Approvedby AICTE-NewDelhi, Accreditedby NAACwith‘A’ &
AffiliatedtoJNTU,Hyderabad)RecognisedUnderSection2(f)&12(B)oftheUGCact,1956
Dundigal,Quthbullapur(M),Hyderabad-500043
COURSESTRUCTURE,OBJECTIVES
COURSESTRUCTURE
Outofthe30 marksforinternalevaluation,day-to-
dayworkinthelaboratorywillbeevaluatedfor15marksandinternalpracticalexaminationshallbeevalu
atedfor15marksconductedbythe concernedfaculty.
The end semester examination will be conducted with an external examiner and
internalexaminer.TheexternalexaminerwillbeappointedbythePrincipal.
COURSEOBJECTIVES
2. To understand the network simulator environment and visualize a network topology and
observe its performance.
CourseOutcomes(CO’s)
CO3: Implement and analyze routing and congestion issues in network design.
CourseOutcomes(CO’s)–ProgramOutcomes(PO’s)Mapping
CO’sPo’s PO1 PO2 PO PO PO5 PO PO7 PO PO9 PO1 PO1 PO1 PSO PSO
3 4 6 8 0 1 2 1 2
CO1 √
CO2 √ √ √
CO3 √ √ √ √ √
CO4 √ √ √ √ √ √
√ √ √ √
CO5 √ √ √
INDEX
1. Implement the data link layer framing methods such as character, character-
stuffing and bit stuffing.
RESOURCE: Turbo C
PROGRAM LOGIC:
The new technique allows data frames to contain an arbitrary number if bits and allows
character codes with an arbitrary no of bits per character. Each frame begins and ends with
special bit pattern, 01111110, called a flag byte. Whenever the sender’s data link layer
encounters five consecutive ones in the data, it automatically stuffs a 0 bit into the outgoing
bit stream. This bit stuffing is analogous to character stuffing, in which a DLE is stuffed into
the outgoing character stream before DLE in the data.
ALOGRITM:
Begin
Step 1: Read frame length n
Step 2: Repeat step (3 to 4) until i<n(: Read values into the input frame (0’s and1’s) i.e.
Step 3: initialize I i=0;
Step 4: read a[i] and increment i
Step 5: Initialize i=0, j=0,count =0
Step 6: repeat step (7 to 22) until i<n
Step 7: If a[i] == 1 then
Step 8: b[j] = a[i]
Step 9: Repeat step (10 to 18) until (a[k] =1 and k<n and count <5)
Step 10: Initialize k=i+1;
Step 11: Increment j and b[j]= a[k];
Step 12: Increment count ;
Step 13: if count =5 then
Step 14: increment j,
Step 15: b[j] =0
Step 16: end if
Step 17: i=k;
Step 18: increment k
Step 19: else
Step 20: b[j] = a[i]
Step 21: end if
Step 22: increment I and j
Step 23: print the frame after bit stuffing
Step 24: repeat step (25 to 26) until i< j
Step 25: print b[i]
Step 26: increment i
End
2
1. c. NAME OF THE EXPERIMENT: Character count
SOURCE CODE:
#include<stdio.h>
#include<string.h>
char data[20][20];
int n;
void main()
{
int i,ch,j;
char tmp[20][20];
printf("enter the number of frames:");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
if(i!=0)
{
printf("frame%d:",i);
scanf("%s",&data[i]);
}
}
for(i=0;i<=n;i++)
{
tmp[i][0]=49+strlen(data[i]);
tmp[i][1]='\0';
strcat(tmp[i],data[i]);
}
printf("\n\t\t AT THE SENDER:\n");
printf("data as frames:\n");
for(i=1;i<=n;i++)
{
printf("frame%d:",i);
puts(tmp[i]);
}
printf("data transmitted:");
for(i=1;i<=n;i++)
printf("%s",tmp[i]);
printf("\n\t\t AT THE RECEIVER\n");
printf("the data received:");
for(i=1;i<=n;i++)
{
ch=(int)(tmp[i][0]-49);
for(j=1;j<=ch;j++)
3
data[i][j-1]=tmp[i][j];
data[i][j-1]='\0';
}
printf("\n the data after removing count char:");
for(i=1;i<=n;i++)
printf("%s",data[i]);
printf("\n the data in frame form:\n");
for(i=1;i<=n;i++)
{
printf("frame%d:",i);
puts(data[i]);
}
}
Viva Questions:
1. What is meant by data communication?
2. What are the components used in data communication?
3. How many data transfer modes are there?
4. Name the different types of communication between devices?
5. What is meant by protocol?
6. What is the use of point to point network?
7. What is multi point network?
8. What is meant by topology?
9. Name the different types of topologies?
10. What is the use of mesh topology?
11. What is the use of star topology?
12. What is the use of bus topology?
13. What is the use of ring topology
14. To link n devices fully connected mesh has how many physical channels are required?
15. How many ports are required in n devices mesh topology?
16. What are the advantages of mesh topology?
17. What are the disadvantages of mesh topology?
18. What are the advantages of star topology?
19. What are the disadvantages of star topology?
20. What are the advantages of bus topology?
21. What are the disadvantages of bus topology?
22. What are the advantages of ring topology?
23. What are the disadvantages of ring topology?
24. In which network bus topology is implemented?
25. What is meant by hybrid network?
26. Name the different categories in network connections?
27. What is the difference between protocol and standard?
4
28. Name the different categories in standards.
29. Abbreviate OSI and ISO
30. How many layers are there in OSI model
31. Name the different layers in OSI model
32. What is the full form of TCP/IP
33. How many layers are there in the TCP/IP
34. Differentiate between OSI model and TCP/IP
35. What is the use of physical layer/
36. What is Character stuffing?
37. What is the use of character stuffing?
38. ----------are the delimiters for the character stuffing?
39. Expand DLE STX?
40. Expand DLE ETX?
41. What is Stuffing?
42. What is use of Stuffing?
43. With bit stuffing the boundary between two frames can be unambiquously recognize by?
44. . ………..is a analogous to character stuffing?
45. The senders data link layer encounters……..no of 1’s consecutively
5
Experiment: 2
2. Write a program to compute CRC code for the polynomials CRC-12 and
CRC-16
OBJECTIVE: Implement on a data set of characters the three CRC polynomials – CRC
12,CRC 16
RESOURCE: Turbo C
PROGRAM LOGIC:
CRC method can detect a single burst of length n, since only one bit per column will be
changed, a burst of length n+1 will pass undetected, if the first bit is inverted, the last bit is
inverted and all other bits are correct. If the block is badly garbled by a long burst or by
multiple shorter burst, the probability that any of the n columns will have the correct parity
that is 0.5. so the probability of a bad block being expected when it should not be 2 power(-
n). This scheme sometimes known as Cyclic Redundancy Code
ALGORITHM:
Step 1:A string of n as is appended to the data unit. The length of predetermined divisor is
n+ 1.
Step 2:The newly formed data unit 1. A string of n as is appended to the data unit. The
length of predetermined divisor is n+ 1. i.e. original data + string of n as are divided by
the divisor using binary division and remainder is obtained. This remainder is called
CRC.
Step 3:Now, string of n Os appended to data unit is replaced by the CRC remainder
(which is also of n bit).
Step 4: The data unit + CRC is then transmitted to receiver.
Step 5: The receiver on receiving it divides data unit + CRC by the same divisor & checks
the remainder.
Step 6: If the remainder of division is zero, receiver assumes that there is no error in data
and it accepts it.
Step 7: If remainder is non-zero then there is an error in data and receiver rejects it .
Viva Questions:
1. What is CRC?
2. What is the use of the CRC?
3. Name the CRC standards?
4. Define Checksum?
5. Define generator polynomial?
6
6. What are the techniques use for error correction and detection methods
7. Name the different techniques used for data error checking methods?
8. Name the different techniques used for data correcting methods?
9. What is the use of data link layer?
10. What is meant by framing?
11. How many types of framing methods are there?
12. What is meant by single bit error?
13. What is meant by burst error?
14. What is meant by redundancy bits?
15. What is meant by fixed frame- size?
16. What is meant by variable-size framing?
17. What is meant by byte stuffing?
18. What is the use of hamming code?
19. Who invented hamming code?
20. What is meant by even parity?
21. What is meant by odd parity?
22. How many bits are corrected by using hamming code?
23. What is meant by multiplexing?
24. Name the different types of multiplexing?
25. What is the use of TDM?
26. What is the use of WDM?
27. What is the use of TDM?
28. Which multiplexing combines optical signals?
29. How many types of switched networks are available?
30. Name the different types of switched networks?
31. What is meant by circuit switched network?
32. Name the different types of packet switched networks?
33. What are the three phases used in virtual circuit network?
34. How any types of transmission medias are there?
35. What is the use of transmission media?
36. In which network transmission media used?
37. Differentiate between guided and unguided media?
38. Which are called guided media?
39. Which are called unguided media?
40. How the data can be corrupted?
7
Experiment: 3
3. Develop a simple data link layer that performs the flow control using the
sliding window protocol, and loss recovery using the Go-Back-N mechanism.
SOURCE CODE :
#include<stdio.h>
int main()
{
int w,i,f,frames[50];
printf("enter window size:");
scanf("%d",&w);
printf("\n Enter number of frames to transmmit:");
scanf("%d",&f);
printf("\n Enter %d frames:",f);
for(i=1;i<=f;i++)
scanf("%d",&frames[i]);
printf("\n With sliding window protocol the frames will be sent in the following
manner(assuming no corruption of frames)\n\n");
printf("After sending %d frames at each stage sender waits for acknowledgement sent by the
receiver\n\n",w);
for(i=1;i<=f;i++)
{
if(i%w==0)
{
printf("%d\n",frames[i]);
printf("Acknowledgement of above frames sent is received by sender\n\n");
}
else printf("%d",frames[i]);
}
if(f%w!=0)
printf("\n Acknowledgement of above frames sent is received by sender\n");
return 0;
}
8
3.b. - Sliding window protocol using go-bach N:
SOURCE CODE :
#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;
}
9
Experiment 4
RESOURCE: Turbo C
Program Logic: Dijkstra's algorithm is very similar to Prim's algorithm for minimum
spanning tree. Like Prim's MST, we generate a SPT (shortest path tree) with given source as
root. We maintain two sets, one set contains vertices included in shortest path tree, and other
set includes vertices not yet included in shortest path tree.
ALGORITM:
1. In distance vector routing algorithm, the cost is considered as the hop count (number
of networks passed to reach the destination node). So a cost between two neighbouring
routers is set to 1.
2. Each router updates its routing table when it receives the information (distance vector)
form the neighbouring routers.
3. After updating its routing table, a router must forward its result to its neighbouring
router So that they can update their routing table.
4. Each router keeps the three information in its routing table i.e. destination
network, cost & the next hop.
5. The router sends the information of each route as a record R.
Viva questions:
1. Define Dijkstra’s algorithm?
2. What is the use of Dijkstra’s algorithm?
3. What is path?
4. What is minimum cost path?
5. How to find shortest path using Dijkstra’s algorithm?
10
Experiment 5
5. Take an example subnet of hosts and obtain a broadcast tree for the subnet.
PROGRAM LOGIC:
This technique is widely used because it is simple and easy to understand. The idea of this
algorithm is to build a graph of the subnet with each node of the graph representing a router
and each arc of the graph representing a communication line. To choose a route between a
given pair of routers the algorithm just finds the broadcast between them on the graph.
SOURCE CODE:
#include<stdio.h>
#include<conio.h>
int p,q,u,v,n;
int min=99,mincost=0;
int t[50][2],i,j;
int parent[50],edge[50][50];
main()
{
clrscr();
printf("\n Enter the number of nodes");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("%c\t",65+i);
parent[i]=-1;
}
printf("\n");
for(i=0;i<n;i++)
{
printf("%c",65+i);
for(j=0;j<n;j++)
scanf("%d",&edge[i][j]);
}
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
if(edge[i][j]!=99)
11
if(min>edge[i][j])
{
min=edge[i][j];
u=i;
v=j;
}
p=find(u);
q=find(v);
if(p!=q)
{
t[i][0]=u;
t[i][1]=v;
mincost=mincost+edge[u][v];
sunion(p,q);
}
Else
{
t[i][0]=-1;t[i][1]=-1;
}
min=99;
}
printf("Minimum cost is %d\n Minimum spanning tree is\n" ,mincost);
for(i=0;i<n;i++)
if(t[i][0]!=-1 && t[i][1]!=-1)
{
printf("%c %c %d", 65+t[i][0],65+t[i][1],edge[t[i][0]][t[i][1]]);printf("\n");
}
getch();
}
sunion(int l,int m)
{
parent[l]=m;
}
find(int l)
{
if(parent[l]>0)
i=parent[i];
return i;
}
Viva questions:
1. What is spanning tree?
2. What is broad cast tree?
3. What are the advantages of broadcast tree?
4. What is flooding?
12
5. What is subnet?
13
Experiment 6
6. Implement distance vector routing algorithm for obtaining routing tables at each
node.
OBJECTIVE: Obtain Routing table at each node using distance vector routing algorithm for
a given subnet.
RESOURCE: Turbo C
PROGRAM LOGIC:
Distance Vector Routing Algorithms calculate a best route to reach a destination based solely
on distance. E.g. RIP. RIP calculates the reach ability based on hop count. It’s different from
link state algorithms which consider some other factors like bandwidth and other metrics to
reach a destination. Distance vector routing algorithms are not preferable for complex
networks and take longer to converge.
Viva Questions:
1. What is routing?
2. What is best algorithm among all routing algorithms?
3. What is static routing?
4. Differences between static and dynamic?
5. What is optimality principle?
14
Experiment 7
OBJECTIVE: Take a 64 bit playing text and encrypt the same using DES algorithm.
RESOURCE: Turbo C
PROGRAM LOGIC:
Data encryption standard was widely adopted by the industry in security products. Plain text
is encrypted in blocks of 64 bits yielding 64 bits of cipher text. The algorithm which is
parameterized by a 56 bit key has 19 distinct stages. The first stage is a key independent
transposition and the last stage is exactly inverse of the transposition. The remaining stages
are functionally identical but are parameterized by different functions of the key. The
algorithm has been designed to allow decryption to be done with the same key as encryption.
ALOGRITHM:
It is a simple type of substitution cipher, in this, each letter or word of a given text
message is replaced by a letter some fixed number down the original alphabet.
We decide that fixed number, for example, if we select that number as 2 then A will be
replaced by C, B will be replaced by D, and so on.
This fixed number here indicates the shift, which means the number of positions by which
each letter of the text has to be moved down.
SOURCE CODE:
#include<stdio.h>
int main()
{
char message[100], ch;
int i, key;
printf("Enter a message to encrypt: ");
gets(message);
printf("Enter key: ");
scanf("%d", &key);
for(i = 0; message[i] != '\0'; ++i){
ch = message[i];
if(ch >= 'a' && ch <= 'z'){
15
ch = ch + key;
if(ch > 'z'){
ch = ch - 'z' + 'a' - 1;
}
message[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch + key;
if(ch > 'Z'){
ch = ch - 'Z' + 'A' - 1;
}
message[i] = ch;
}
}
printf("Encrypted message: %s", message);
return 0;
Viva Questions:
RESOURCE: Turbo C
PROGRAM LOGIC:
Data encryption standard was widely adopted by the industry in security products. Plain text
is encrypted in blocks of 64 bits yielding 64 bits of cipher text. The algorithm which is
parameterized by a 56 bit key has 19 distinct stages. The first stage is a key independent
transposition and the last stage is exactly inverse of the transposition. The remaining stages
are functionally identical but are parameterized by different functions of the key. The
algorithm has been designed to allow decryption to be done with the same key as encryption.
16
PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.
ALOGRITHM:
It is a simple type of substitution cipher, in this, each letter or word of a given text
message is replaced by a letter some fixed number down the original alphabet.
We decide that fixed number, for example, if we select that number as 2 then A will be
replaced by C, B will be replaced by D, and so on.
This fixed number here indicates the shift, which means the number of positions by which
each letter of the text has to be moved down.
SOURCE CODE:
/*Write a program to break the above DES coding*/
#include<stdio.h>
int main()
{
char message[100], ch;
int i, key;
printf("Enter a message to decrypt: ");
gets(message);
printf("Enter key: ");
scanf("%d", &key);
for(i = 0; message[i] != '\0'; ++i){
ch = message[i];
if(ch >= 'a' && ch <= 'z'){
ch = ch - key;
if(ch < 'a'){
ch = ch + 'z' - 'a' + 1;
}
message[i] = ch;
}
else if(ch >= 'A' && ch <= 'Z'){
ch = ch - key;
if(ch < 'A'){
ch = ch + 'Z' - 'A' + 1;
}
message[i] = ch;
}}
printf("Decrypted message: %s", message);
return 0;
}
17
Viva Questions:
1. Define decryption
2. What is private key?
3. What is cipher feedback mode?
4. Define product cipher
5. What is DES chaining?
Experiment 8
SOURCE CODE:
#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:
18
Experiment 9
SOURCE CODE:
#include<stdio.h>
#include<string.h>
#define FRAM_TXT_SIZ 3
#define MAX_NOF_FRAM 127
char str[FRAM_TXT_SIZ*MAX_NOF_FRAM];
struct frame // structure maintained to hold frames
{ char text[FRAM_TXT_SIZ];
int seq_no;
}fr[MAX_NOF_FRAM], shuf_ary[MAX_NOF_FRAM];
int assign_seq_no() //function which splits message
{ int k=0,i,j; //into frames and assigns sequence no
for(i=0; i < strlen(str); k++)
{ fr[k].seq_no = k;
for(j=0; j < FRAM_TXT_SIZ && str[i]!='\0'; j++)
fr[k].text[j] = str[i++];
}
printf("\nAfter assigning sequence numbers:\n");
for(i=0; i < k; i++)
printf("%d:%s ",i,fr[i].text);
return k; //k gives no of frames
}
void generate(int *random_ary, const int limit) //generate array of random nos
{ int r, i=0, j;
while(i < limit)
{ r = random() % limit;
for(j=0; j < i; j++)
if( random_ary[j] == r )
break;
if( i==j ) random_ary[i++] = r;
}}
void shuffle( const int no_frames ) // function shuffles the frames
{
int i, k=0, random_ary[no_frames];
generate(random_ary, no_frames);
for(i=0; i < no_frames; i++)
shuf_ary[i] = fr[random_ary[i]];
19
printf("\n\nAFTER SHUFFLING:\n");
for(i=0; i < no_frames; i++)
printf("%d:%s ",shuf_ary[i].seq_no,shuf_ary[i].text);
}
void sort(const int no_frames) // sorts the frames
{
int i,j,flag=1;
struct frame hold;
for(i=0; i < no_frames-1 && flag==1; i++) // search for frames in sequence
{
flag=0;
for(j=0; j < no_frames-1-i; j++) //(based on seq no.) and display
if(shuf_ary[j].seq_no > shuf_ary[j+1].seq_no)
{
hold = shuf_ary[j];
shuf_ary[j] = shuf_ary[j+1];
shuf_ary[j+1] = hold;
flag=1;
}
}
}
int main()
{
int no_frames,i;
printf("Enter the message: ");
gets(str);
no_frames = assign_seq_no();
shuffle(no_frames);
sort(no_frames);
printf("\n\nAFTER SORTING\n");
for(i=0;i<no_frames;i++)
printf("%s",shuf_ary[i].text);
printf("\n\n");
}
20
Experiment 10
Wireshark
What is Wireshark?
There are questions about the legality of Wireshark since it is a powerful packet sniffer.
The Light side of the Force says that you should only use Wireshark on networks where
you have permission to inspect network packets. Using Wireshark to look at packets
without permission is a path to the Dark Side.
21
How does Wireshark work?
Wireshark is a packet sniffer and analysis tool. It captures network traffic on the local
network and stores that data for offline analysis. Wireshark captures network traffic from
Ethernet, Bluetooth, Wireless (IEEE.802.11), Token Ring, Frame Relay connections, and
more.
Ed. Note: A “packet” is a single message from any network protocol (i.e., TCP, DNS,
etc.)
Ed. Note 2: LAN traffic is in broadcast mode, meaning a single computer with Wireshark
can see traffic between two other computers. If you want to see traffic to an external site,
you need to capture the packets on the local computer.
Wireshark allows you to filter the log either before the capture starts or during analysis,
so you can narrow down and zero into what you are looking for in the network trace. For
example, you can set a filter to see TCP traffic between two IP addresses. You can set it
only to show you the packets sent from one computer. The filters in Wireshark are one of
the primary reasons it became the standard tool for packet analysis.
Downloading and installing Wireshark is easy. Step one is to check the official Wireshark
Download page for the operating system you need. The basic version of Wireshark is
free.
Wireshark for Windows
Wireshark comes in two flavors for Windows, 32 bit and 64 bit. Pick the correct version
for your OS. The current release is 3.0.3 as of this writing. The installation is simple and
shouldn’t cause any issues.
22
brew install wireshark
Homebrew will download and install Wireshark and any dependencies so it will run
correctly.
Ubuntu
Kali Linux
Wireshark is probably already installed! It’s part of the basic package. Check your menu
to verify. It’s under the menu option “Sniffing & Spoofing.”
Now that we have Wireshark installed let’s go over how to enable the Wireshark packet
sniffer and then analyze the network traffic.
23
i) Capturing Data Packets on Wireshark
When you open Wireshark, you see a screen that shows you a list of all of the network
connections you can monitor. You also have a capture filter field, so you only capture the
network traffic you want to see.
You can select one or more of the network interfaces using “shift left-click.” Once you
have the network interface selected, you can start the capture, and there are several ways
to do that.
Click the first button on the toolbar, titled “Start Capturing Packets.”
24
Or you could use the keystroke Control – E.
During the capture, Wireshark will show you the packets that it captures in real-time.
Once you have captured all the packets you need, you use the same buttons or menu
options to stop the capture.
Best practice says that you should stop Wireshark packet capture before you do analysis.
Packet Details, the middle pane, shows you as much readable information about the
packet as possible, depending on what kind of packet it is. You can right-click and create
filters based on the highlighted text in this field.
The bottom pane, Packet Bytes, displays the packet exactly as it got captured in
hexadecimal.
When you are looking at a packet that is part of a conversation, you can right-click the
packet and select Follow to see only the packets that are part of that conversation.
Wireshark Filters
One of the best features of Wireshark is the Wireshark Capture Filters and Wireshark
Display Filters. Filters allow you to view the capture the way you need to see it so you
can troubleshoot the issues at hand. Here are several filters to get you started.
26
port not 53 and not arp: capture all traffic except DNS and ARP traffic
tcp.port eq 25: This filter will show you all traffic on port 25, which is usually SMTP
traffic.
icmp: This filter will show you only ICMP traffic in the capture, most likely they are
pings.
ip.addr != IP_address: This filter shows you all traffic except the traffic to or from the
specified computer.
Analysts even build filters to detect specific attacks, like this filter to detect the Sasser
worm:
ls_ads.opnum==0x09
Beyond the capture and filtering, there are several other features in Wireshark that can
make your life better.
27
Wireshark Promiscuous Mode
By default, Wireshark only captures packets going to and from the computer where it
runs. By checking the box to run Wireshark in Promiscuous Mode in the Capture
Settings, you can capture most of the traffic on the LAN.
28
Capture File Properties:
29
i. Packet Capture Using Wireshark
ii. Starting Wireshark
iii. Viewing Captured Traffic
iv. Analysis and Statistics &Filters.
In order to investigate your issues further, we would like to run an analysis of the traffic
being sent between you and Salesforce. To do this, we will use the Wireshark application.
Wireshark is a tool that allows packet traces to be monitored, captured and analysed.
Please follow the steps below in order to obtain a capture of your network traffic using
Wireshark.
Note: You will require some administrator rights on your machine in order to complete
these tests. If you are unsure, please contact your IT administrator.
Installing the Wireshark package
Visit the Wireshark download site, and download the appropriate Wireshark package or
installer for the operating system running on the system which is to be used for packet
capture.
When installing, ensure all components are selected for installation, including the
optional “Winpcap” application.
30
4. Recreate the problem. The capture dialog should show the number of packets
increasing. Try to avoid running any other internet applications while capturing,
closing other browsers, Instant messengers etc.
5. Once the problem which is to be analyzed has been reproduced, click on Stop. It
may take a few seconds for Wireshark to display the packets captured.
6. Save the packet trace in the default format. Click on the File menu option and
select Save As. By default Wireshark will save the packet trace in libpcap format.
This is a filename with a.pcap extension.
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.
31
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.
32
4. Click the Start Capture button to begin the capture.
33
Saving the Capture
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.
34
35
Experiment 11
11. How to run Nmapscan
What is Nmap?
At its core, Nmap is a network scanning tool that uses IP packets to identify all the
devices connected to a network and to provide information on the services and operating
systems they are running.
The program is most commonly used via a command-line interface (though GUI front-
ends are also available) and is available for many different operating systems such as
Linux, Free BSD, and Gentoo. Its popularity has also been bolstered by an active and
enthusiastic user support community.
Nmap was developed for enterprise-scale networks and can scan through thousands of
connected devices. However, in recent years Nmap is being increasingly used by smaller
companies. The rise of the IoT, in particular, now means that the networks used by these
companies have become more complex and therefore harder to secure.
This means that Nmap is now used in many website monitoring tools to audit the traffic
between web servers and IoT devices. The recent emergence of IoT botnets, like Mirai,
has also stimulated interest in Nmap, not least because of its ability to interrogate devices
connected via the UPnP protocol and to highlight any devices that may be malicious.
36
What Does Nmap Do?
The primary uses of Nmap can be broken into three core processes. First, the program
gives you detailed information on every IP active on your networks, and each IP can then
be scanned. This allows administrators to check whether an IP is being used by a
legitimate service, or by an external attacker.
37
a critical part of pentesting. Nmap can be used alongside the Metasploit framework, for
instance, to probe and then repair network vulnerabilities.
Thirdly, Nmap has also become a valuable tool for users looking to protect personal and
business websites. Using Nmap to scan your own web server, particularly if you are
hosting your website from home, is essentially simulating the process that a hacker would
use to attack your site. “Attacking” your own site in this way is a powerful way of
identifying security vulnerabilities.
Nmap is straightforward to use, and most of the tools it provides are familiar to system
admins from other programs. The advantage of Nmap is that it brings a wide range of
these tools into one program, rather than forcing you to skip between separate and
discrete network monitoring tools.
In order to use Nmap, you need to be familiar with command-line interfaces. Most
advanced users are able to write scripts to automate common tasks, but this is not
necessary for basic network monitoring.
Once you’ve installed Nmap, the best way of learning how to use it is to perform some
basic network scans.
39
To run a host scan, use the following command:
If you see anything unusual in this list, you can then run a DNS query on a specific host,
by using:
That said, there are advantages to using Kali when running Nmap scans. Most modern
distros of Kali now come with a fully-features Nmap suite, which includes an advanced
GUI and results viewer (Zenmap), a flexible data transfer, redirection, and debugging tool
(Ncat), a utility for comparing scan results (Ndiff), and a packet generation and response
analysis tool (Nping).
40
Nmap Commands
Most of the common functions of Nmap can be executed using a single command, and
the program also uses a number of ‘shortcut’ commands that can be used to automate
common tasks.
1. Ping Scanning
As mentioned above, a ping scan returns information on every active IP on your network.
You can execute a ping scan using this command:
41
2. Port Scanning
There are several ways to execute port scanning using Nmap. The most commonly used
are these:
The most basic of these scans is the sS TCP SYN scan, and this gives most users all
the information they need. It scans thousands of ports per second, and because it
doesn’t complete a TCP connection it does not arouse suspicion.
The main alternative to this type of scan is the TCP Connect scan, which actively
queries each host, and requests a response. This type of scan takes longer than a
SYN scan, but can return more reliable information.
42
The UDP scan works in a similar way to the TCP connect scan but uses UDP
packets to scan DNS, SNMP, and DHCP ports. These are the ports most frequently
targeted by hackers, and so this type of scan is a useful tool for checking for
vulnerabilities.
The SCTP INIT scan covers a different set of services: SS7 and SIGTRAN. This
type of scan can also be used to avoid suspicion when scanning an external network
because it doesn’t complete the full SCTP process.
The TOP NULL scan is also a very crafty scanning technique. It uses a loophole in
the TCP system that can reveal the status of ports without directly querying them,
which means that you can see their status even where they are protected by a
firewall.
3. Host Scanning
Host scanning returns more detailed information on a particular host or a range of IP
addresses. As mentioned above, you can perform a host scan using the following
command:
4. OS Scanning
OS scanning is one of the most powerful features of Nmap. When using this type of scan,
Nmap sends TCP and UDP packets to a particular port, and then analyze its response. It
compares this response to a database of 2600 operating systems, and return information
on the OS (and version) of a host.
43
If you are running Nmap on a home server, this command is very useful. It automatically
scans a number of the most ‘popular’ ports for a host. You can run this command using:
1. nmtop-ports 20 192.168.1.106
Replace the “20” with the number of ports to scan, and Nmap quickly scans that many
ports. It returns a concise output that details the status of the most common ports, and this
lets you quickly see whether you have any unnecessarily open ports.
44
6. Output to a File
If you want to output the results of your Nmap scans to a file, you can add an extension to
your commands to do that. Simply add:
1. -oN output.txt
To your command to output the results to a text file, or:
1. -oX output.xml
To output to an XML.
Nmap FAQ
The commands above cover most of the basic functionality of Nmap. You might still
have some questions though, so let’s run through the most common ones.
45
network and then analyze these packets to provide information on each host and IP, as
well as the operating systems they are running.
Q: Is Nmap Legal?
Yes. If used properly, Nmap helps protect your network from hackers, because it allows
you to quickly spot any security vulnerabilities in your systems.
Whether port scanning on external servers is legal is another issue. The legislation in this
area is complex and varies by territory. Using Nmap to scan external ports can lead to you
being banned by your ISP, so make sure you research the legal implications of using the
program before you start using it more widely.
46
Experiment 12
OS Detection
One of Nmap's best-known features is remote OS detection using TCP/IP stack
fingerprinting. Nmap sends a series of TCP and UDP packets to the remote host and
examines practically every bit in the responses. After performing dozens of tests such as
TCP ISN sampling, TCP options support and ordering, IP ID sampling, and the initial
window size check, Nmap compares the results to its nmap-os-db database of more than
2,600 known OS fingerprints and prints out the OS details if there is a match. Each
fingerprint includes a freeform textual description of the OS, and a classification which
provides the vendor name (e.g. Sun), underlying OS (e.g. Solaris), OS generation (e.g.
10), and device type (general purpose, router, switch, game console, etc). Most
fingerprints also have a Common Platform Enumeration (CPE) representation,
like cpe:/o:linux:linux_kernel:2.6.
If Nmap is unable to guess the OS of a machine, and conditions are good (e.g. at least one
open port and one closed port were found), Nmap will provide a URL you can use to
submit the fingerprint if you know (for sure) the OS running on the machine. By doing
this you contribute to the pool of operating systems known to Nmap and thus it will be
more accurate for everyone.
OS detection enables some other tests which make use of information that is gathered
during the process anyway. One of these is TCP Sequence Predictability Classification.
This measures approximately how hard it is to establish a forged TCP connection against
the remote host. It is useful for exploiting source-IP based trust relationships (rlogin,
firewall filters, etc) or for hiding the source of an attack. This sort of spoofing is rarely
performed any more, but many machines are still vulnerable to it. The actual difficulty
number is based on statistical sampling and may fluctuate. It is generally better to use the
English classification such as “worthy challenge” or “trivial joke”. This is only reported
in normal output in verbose (-v) mode. When verbose mode is enabled along with -O, IP
ID sequence generation is also reported. Most machines are in the “incremental” class,
which means that they increment the ID field in the IP header for each packet they send.
This makes them vulnerable to several advanced information gathering and spoofing
attacks.
47
Another bit of extra information enabled by OS detection is a guess at a target's uptime.
This uses the TCP timestamp option (RFC 1323) to guess when a machine was last
rebooted. The guess can be inaccurate due to the timestamp counter not being initialized
to zero or the counter overflowing and wrapping around, so it is printed only in verbose
mode.
-O (Enable OS detection)
Enables OS detection, as discussed above. Alternatively, you can use -A to enable
OS detection along with other things.
48
Experiment 13
13. Do the following using NS2Simulator
i. NS2Simulator-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.
vi. Simulate to Plot Congestion for Different Source/Destination
vii. Simulate to Determine the Performance with respect to Transmission of
Packets
NS2 is an open-source simulation tool that runs on Linux. It is a discreet event simulator
targeted at networking research and provides substantial support for simulation of
routing, multicast protocols and IP protocols, such as UDP, TCP, RTP and SRM over
wired and wireless (local and satellite) networks.
Widely known as NS2, is simply an event driven simulation tool.
Useful in studying the dynamic nature of communication 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.
49
TCL – Tool Command Language
Tcl is a very simple programming language. If you have programmed before, you can
learn enough to write interesting Tcl programs within a few hours. This page provides a
quick overview of the main features of Tcl. After reading this you'll probably be able to
start writing simple Tcl scripts on your own; however, we recommend that you consult
one of the many available Tcl books for more complete information.
Basic syntax
Tcl scripts are made up of commands separated by newlines or semicolons.
Commands all have the same basic form illustrated by the following example:
expr 20 + 10
This command computes the sum of 20 and 10 and returns the result, 30. You can try out
this example and all the others in this page by typing them to a Tcl application such as
tclsh; after a command completes, tclsh prints its result.
Each Tcl command consists of one or more words separated by spaces. In this example
there are four words: expr, 20, +, and 10. The first word is the name of a command and
the other words are arguments to that command. All Tcl commands consist of words, but
different commands treat their arguments differently. The expr command treats all of its
arguments together as an arithmetic expression, computes the result of that expression,
and returns the result as a string. In the expr command the division into words isn't
significant: you could just as easily have invoked the same command as
expr 20+10
However, for most commands the word structure is important, with each word used for a
distinct purpose.
All Tcl commands return results. If a command has no meaningful result then it returns
an empty string as its result.
Variables
Tcl allows you to store values in variables and use the values later in commands. The set
command is used to write and read variables. For example, the following command
modifies the variable x to hold the value 32:
set x 32
The command returns the new value of the variable. You can read the value of a variable
by invoking set with only a single argument:
set x
You don't need to declare variables in Tcl: a variable is created automatically the
first time it is set. Tcl variables don't have types: any variable can hold any value.
To use the value of a variable in a command, use variable substitution as in the following
example:
expr $x*3
50
When a $ appears in a command, Tcl treats the letters and digits following it as a variable
name, and substitutes the value of the variable in place of the name. In this example, the
actual argument received by the expr command will be 32*3 (assuming that variable x
was set as in the previous example). You can use variable substitution in any word of any
command, or even multiple times within a word:
Command substitution
You can also use the result of one command in an argument to another command.
This is called command substitution:
set a 44
set b [expr $a*4]
When a [ appears in a command, Tcl treats everything between it and the matching ] as a
nested Tcl command. Tcl evaluates the nested command and substitutes its result into the
enclosing command in place of the bracketed text. In the example above the second
argument of the second set command will be 176.
Control structures
Tcl provides a complete set of control structures including commands for conditional
execution, looping, and procedures. Tcl control structures are just commands that take Tcl
scripts as arguments. The example below creates a Tcl procedure called power, which
raises a base to an integer power:
proc power {base p} {
set result 1
51
while {$p > 0} {
set result [expr $result * $base]
set p [expr $p - 1]
}
return $result
}
This script consists of a single command, proc. The proc command takes three arguments:
the name of a procedure, a list of argument names, and the body of the procedure, which
is a Tcl script. Note that everything between the curly brace at the end of the first line and
the curly brace on the last line is passed verbatim to proc as a single argument. The proc
command creates a new Tcl command named power that takes two arguments. You can
then invoke power with commands like the following:
power 2 6
power 1.15 5
When power is invoked, the procedure body is evaluated. While the body is executing it
can access its arguments as variables: base will hold the first argument and p will hold the
second.
The body of the power procedure contains three Tcl commands: set, while, and return.
The while command does most of the work of the procedure. It takes two arguments, an
expression ($p > 0) and a body, which is another Tcl script. The while command
evaluates its expression argument using rules similar to those of the C programming
language and if the result is true (nonzero) then it evaluates the body as a Tcl script. It
repeats this process over and over until eventually the expression evaluates to false (zero).
In this case the body of the while command multiplied the result value by base and then
decrements p. When p reaches zero the result contains the desired power of base. The
return command causes the procedure to exit with the value of variable result as the
procedure's result.
52
also implemented using this same extension mechanism; their command procedures are
simply part of the Tcl library.
When Tcl is used inside an application, the application incorporates its key features into
Tcl using the extension mechanism. Thus the set of available Tcl commands varies from
application to application. There are also numerous extension packages that can be
incorporated into any Tcl application. One of the best known extensions is Tk, which
provides powerful facilities for building graphical user interfaces. Other extensions
provide object-oriented programming, database access, more graphical capabilities, and a
variety of other features. One of Tcl's greatest advantages for building integration
applications is the ease with which it can be extended to incorporate new features or
communicate with other resources.
The third group of commands consists of procedures created with the proc command,
such as the power command created above. Typically, extensions are used for lower-level
functions where C programming is convenient, and procedures are used for higher-level
functions where it is easier to write in Tcl.
NS Simulator Preliminaries.
Initialization and termination aspects of the ns simulator.
Definition of network nodes, links, queues and topology.
Definition of agents and of applications.
The nam visualization tool.
Tracing and random variables.
Features of NS2
NS2 can be employed in most unix systems and windows. Most of the NS2 code is in
C++. It uses TCL as its scripting language, Otcl adds object orientation to
TCL.NS(version 2) is an object oriented, discrete event driven network simulator that is
freely distributed and open source.
• Traffic Models: CBR, VBR, Web etc
53
• Misc: Radio propagation, Mobility models , Energy Models
Structure of NS
● NS is an object oriented discrete event simulator
– Simulator maintains list of events and executes one event after another
– Single thread of control: no locking or race conditions
● Back end is C++ event scheduler
– Protocols mostly
– Fast to run, more control
• Front end is OTCL
54
NS programming Structure
● Create the event scheduler
● Turn on tracing
● Generate traffic
● Insert errors
ii& iii) 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.
STEPS:
Step1: Select the hub icon on the toolbar and drag it onto the working window.
Step2: Select the host icon on the toolbar and drag it onto the working window. Repeat
this for another host icon.
Step3: Select the link icon on the toolbar and drag it on the screen from host (node 1) to
the hub and again from host(node 2) to the hub. Here the hub acts as node 3 in the point-
to-point network. This leads to the creation of the 3-node point-to-point network
topology. Save this topology as a .tpl file.
Step4:Double-click on host(node 1), a host dialog box will open up. Click on Node editor
and you can see the different layers- interface, ARP, FIFO, MAC, TCPDUMP, Physical
layers. Select MAC and then select full-duplex for switches and routers and half duplex
for hubs, and in log Statistics, select Number of Drop Packets, Number of Collisions,
Throughput of incoming packets and Throughput of outgoing packets. Select FIFO and
set the queue size to 50 and press OK. Then click on Add. Another dialog box pops up.
Click on the Command box and type the Command according to the following syntax:
stg [-t duration(sec)] [-p port number]HostIPaddr
and click OK.
Step 5: Double-click on host (node 2), and follow the same step as above with only
change in command according to the following syntax:
rtg [-t] [-w log] [-p port number]
and click OK.
Step 6: Double click on the link between node 1 and the hub to set the bandwidth to some
initial
55
value say, 10 Mbps. Repeat the same for the other node.
Step 7: Click on the E button (Edit Property) present on the toolbar in order to save the
changes made to the topology. Now click on the R button (RunSimulation). By doing so a
user can run/pause/continue/stop/abort/disconnect/reconnect/submit a simulation. No
simulation settings can be changed in this mode.
Step 8: Now go to Menu->Simulation->Run. Executing this command will submit he
current simulation job to one available simulation server managed by the dispatcher.
When the simulation server is executing, the user will see the time knot at the bottom of
the screen move. The time knot reflects the current virtual time (progress) of the
simulation case.
Step 9:To start the playback, the user can left-click the start icon( |>) of the time bar
located at the bottom. The animation player will then start playing the recorded packet
animation.
Step 10: Change the bandwidth say, 9 Mbps, and run the simulation and compare the two
results.
Step 11: To view the results, go to the filename. results folder.
Note: To get the syntax of any command, double click on the host icon. Host dialog
boxes appear and then choose App. Usage.
56
iv )Simulate the transmission of ping messages over a network topology consisting
of 6 nodes and find the number of packets dropped due to congestion.
STEPS:
Step 1: Click on the subnet icon on the toolbar and then click on the screen of the
working window.
Step 2: Select the required number of hosts and a suitable radius between the host and the
switch.
Step 3: In the edit mode, get the IP address of one of the hosts say, host 1 and then for
the other host say, host2 set the drop packet and no: of collisions statistics
as described in the earlier experiments.
Step 4: Now run the simulation.
Step 5: Now click on any one of the hosts and click on command console and ping the
destination node.
ping IP Address of the host
Note: The no: of drop packets are obtained only when the traffic is more in the
network. For checking the no of packets dropped press ctrl+C
The screenshot of the topology is shown below:
57
vi) Simulate an Ethernet LAN using N nodes and set multiple traffic nodes and plot
congestion window for different source/destination.
STEPS:
Step 1: Connect one set of hosts with a hub and another set of hosts also through a hub
and connect these two hubs through a switch. This forms an Ethernet LAN.
Step 2: Setup multiple traffic connections between the hosts on one hub and hosts on
another hub using the following command:
stcp [-p port] [-l writesize] hostIPaddr rtcp [-p port] [-l readsize]
Step 3: Setup the collision log at the destination hosts in the MAC layer as described in
the earlier experiments.
Step 4: To plot the congestion window go to Menu->Tools->Plot Graph->File->open-
>filename.results->filename.coll.log
Step 5: View the results in the filename.results.
58
vii) Simulate simple ESS and with transmitting nodes in wireless LAN by simulation
and determine the performance with respect to transmission of packets.
STEPS:
Screenshot:
59
ADD ON PROGRAMS
1. Implement RSA
NAME OF THE EXPERIMENT: Implementation of RSA.
OBJECTIVE: Using RSA algorithm encrypt a text data and Decrypt the same.
RESOURCE: Turbo C
PROGRAM LOGIC:
`RSA method is based on some principles from number theory. In encryption process divide
the plain text into blocks, so that each plain text message p falls in the interval 0<p<n this can
be done by grouping the plain text into blocks of k bits. Where k is the largest integer for
which 2 power k <n is true. The security of this method is based on the difficulty of factoring
large numbers. The encryption and decryption functions are inverses
PROCEDURE: Go to debug -> run or press CTRL + F9 to run the program.
SOURCE CODE:
/*Using RSA algorithm encrypt a text data and Decrypt the same*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
main()
{
long C,C1,T,P,Q,N,Z,Z1,E,D,De,i,k,rem,flag=0;
char text,c;
clrscr();
printf("enter the text:");
scanf("%c",&text);
T=text-64;
printf("enter the values of PandQ:");
scanf("%ld%ld",&P,&Q);
N=P*Q;
Z=(P-1)*(Q-1);
Z1=Z;
for(i=2;i<Z;i++) {
k=i;
Z1=Z;
while(1) {
rem=Z1%k;
if(rem==0&&k==1)
{
D=i;
flag=1;
60
break;
}
else
{
Z1=k;
k=rem;
if(k==0)
break;
}
}
if(flag==1)
{
break;
}
}
E=(abs(Z)+1)/D;
C1=pow(T,E);
C=C1%N;
printf("\nC:%ld\n",C);
c=C+64;
printf("%c",c);
printf("T:%ld\tP:%ld\TQ:%ld\tN:%ld\tZ:%ld\tD:%ld\tE:%ld\t",T,P,Q,N,Z,D,E);
printf("\n after decrypt....");
De=pow(C,D);
De=De%N;
De=De+64;
printf("\n%c",De);
getch();
}
OUTPUT:
61
Viva Questions:
1. Expand RSA
2. What is encryption and decryption in RSA?
3. To encrypt a message P, Compute c=-----------?
4. To compute c compute P=---------------?
5. Define cryptography.
PROGRAM:
#include<stdio.h>
int main()
{
char str[20], str1[10]="", str2[10]="";
int i, cnt1=0, cnt2=0;
3. Implement and study the performance of GSM on NS2/NS3 (Using MAC layer) or
equivalent environment.
4. Implement and study the performance of CDMA on NS2/NS3 (Using stack called
Call net) or equivalent environment.
WCDMA.
• It has simple architecture because of low operating expenditure
• Time required for connecting network and is in range of a few hundred ms and power
savings states can now be entered and exited very quickly
63
• Both FDD and TDD can be used on same platform.
• Optimized signaling for connection establishment and other air interface and mobility
management procedures have further improved the user experience.
Architecture of LTE:
LTE parameters:
• Transmission bandwidth.
• Mobility.
• Frequency range.
• Duplexing.
• Channel bandwidth.
• Channel coding.
• MIMO.
• Multi-antenna technology.
64
Sample code for LTE:
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/lte-module.h"
#include "ns3/config-store-module.h"
using namespace ns3;
int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
ConfigStore inputConfig;
inputConfig.ConfigureDefaults ();
cmd.Parse (argc, argv);
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
lteHelper->SetAttribute ("PathlossModel", StringValue
("ns3::FriisSpectrumPropagationLossModel"));
NodeContainer enbNodes;
NodeContainer ueNodes;
enbNodes.Create (1);
ueNodes.Create (3);
MobilityHelper mobility;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); mobility.Install
(enbNodes);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (ueNodes);
NetDeviceContainer enbDevs;
NetDeviceContainer ueDevs;
65
enbDevs = lteHelper->InstallEnbDevice (enbNodes); ueDevs = lteHelper-
>InstallUeDevice (ueNodes); lteHelper->Attach (ueDevs, enbDevs.Get (0));
enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE;
EpsBearer bearer (q);
lteHelper->ActivateDataRadioBearer (ueDevs, bearer);
Simulator::Stop (Seconds (0.5));
lteHelper->EnablePhyTraces ();
lteHelper->EnableMacTraces ();
lteHelper->EnableRlcTraces ();
double distance_temp [] = { 1000,1000,1000};
std::vector<double> userDistance;
userDistance.assign (distance_temp, distance_temp + 3);
for (int i = 0; i < 3; i++)
{
Ptr<ConstantPositionMobilityModel > mm = ueNodes.Get (i)-
>GetObject<ConstantPositionMobilityModel> (); mm->SetPosition (Vector
(userDistance[i], 0.0, 0.0)); }
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
66