You are on page 1of 74

CACHING STRATEGIES BASED ON INFORMATION DENSITY ESTIMATION IN WIRELESS AD HOC NETWORKS

A PROJECT REPORT Submitted by

C.Vinoth Kum ! C.P! "hu A.Hu## in


in $ !ti % &u%&i%%m'nt &o! th' ( !) o& th' )'*!'' o&

BACHELOR OF ENGINEERING IN
COMP+TER SCIENCE AND ENGINEERING

SETH+ INSTIT+TE OF TECHNOLOGY P+LLOOR, KARIAPATTI-./.01..

ANNA +NIVERSITY2 CHENNAI .11 1/3. APRIL /10/

SETH+ INSTIT+TE OF TECHNOLOGY P+LLOOR, KARIAPATTI-./. 01..

ANNA +NIVERSITY2 CHENNAI .11 1/3.


BONAFIDE CERTIFICATE

Certified that this project report

Mu%ti$%' P 56't# T! n#&'!!in* In C.VINOTH K+MAR n)

Wi!'%'## N't(o!6# is the bonafide work of C.PRABH+ n) A.H+SSIAN supervision.

who carried out the project work under my

. SIGNAT+RE HEAD OF THE DEPARTMENT SIGNAT+RE S+PERVISOR

CERTIFICATE FROM THE IND+STRIES A"out A$t'5h Aptech is a global learning company involved in multiple areas of education & with training centres spread across 5 continents. Aptech... ...is the First ! education & training company in Asia to receive the "# $%%&' (%%% -ade ,ird. and so on ...has a dedicated arm 1 Aptech 2earning "ervices 1 for developing useful & comprehensive content for each of its courses A"out A$t'5h Com$ut'! E)u5 tion ((1year1old Aptech Computer 3ducation provides world1class ! training across the world. !hrough its global network of centers. Aptech has so far turned 5 million students into successful professionals. Aptech alumni are employed as 4rogrammers. !echnical support. 5atabase administrators. !echnical writers. 5ata analysts & "ystem administrators with leading ! companies. n ndia. Aptech offers various career1building programs to students. f you have completed Class &( or are a graduate. these programs can enable you to get a great ! career. )uality certification China/ ...is ranked the *o. & ! education provider in China through +Aptech ,eida ...is the *o. & ! training company in countries like 0ietnam. *igeria. ran.

ACKNOWLEDGEMENT

First we would like to thank GOD the almighty for giving us the talent and opportunity to complete our project and our ,.3 deree. 6e wish to e7press our earned great fullness to our 8onourable Founder and Chairman. M!. S. Moh mm') J %''% B.S.57 B.L7 for his encouragement e7tended to us to undertake this project work. 6e would like to thank and e7press our gratitude to our 4rincipal. D!. A. S'nthi% Kum ! B.E7 M.E7 Ph.D7 for providing all necessary facilities for the completion of the project.

6e wish like to thank and e7press our gratitude to our Chief 37ecutive #fficer. M!. S. M. S''ni Mohi)''n B.Com7 M.B.A7 N 8i F thim 5irector1 Administration. M!#.S.M. Ni%o&'! F thim B.E.7 and 5irector1 9 &5. M#.S. M. B.T'5h7 and -oint Chief 37ecutive #fficer. :r.S.M. S''ni Moh mm') A%i ! M ! i66 9 ! B.E; for their support to this project work.

6e wish to e7press our profound gratitude to our 8ead of the 5epartment P!o&. D!. J. Su)h for ranting us the necessary permission to proceed with our project.

6e are immensely grateful to our guide. supervisor and overseer M!#. P.K!i#hn :'ni ME., a lot throughout the course of the project. 6e render our sincere thanks for his great support in completing this project successfully.

6e thank our P !'nt#, F 5u%t9, M'm"'!#, Su$$o!tin* #t && and F!i'n)# for their help e7tended during these times.
4

ABSTRACT
5ata caching strategy for ad hoc networks whose nodes e7change information items in a peer1to1peer fashion. 5ata caching is a fully distributed scheme where each node. upon receiving re)uested information. determines the cache drop time of the information or which content to replace to make room for the newly arrived information. !hese decisions are made depending on the perceived presence< of the content in the nodes pro7imity. whose estimation does not cause any additional overhead to the information sharing system. 6e devise a strategy where nodes. independent of each other. decide whether to cache some content and for how long. n the case of small1si=ed caches. we aim to design a content replacement strategy that allows nodes to successfully store newly received information while maintaining the good performance of the content distribution system. >nder both conditions. each node takes decisions according to its perception of what nearby users may store in their caches and with the aim of differentiating its own cache content from the other nodes?. !he result is the creation of content diversity within the nodes neighborhood so that a re)uesting user likely finds the desired information nearby. 6e simulate our caching algorithms in different ad hoc network scenarios and compare them with other caching schemes. showing that our solution succeeds in creating the desired content diversity. thus leading to a resource1 efficient information access.

TABLE OF CONTENTS

Ch $t'! No 0.
Int!o)u5tion

Tit%'
ntroduction About !he #rgani=ation ntroduction About !he 4roject@"ystem 9eview #f 2iterature Aoal #f 4resent 6ork

P *' No

0 / ; 3

/.

D'&inin* Th' P!o"%'m 37isting "ystem *eed For !he *ew "ystem 4roblem 5efinition

. < =

>.

R'?ui!'m'nt S$'5i&i5 tion 8ardware "pecification "oftware "pecification "oftware -ustification

@ 01 00

;.

S9#t'm D'#i*n Conceptual 5esign 5etailed 5esign >ml 5iagrams

>1 >0 >> >=

3. ..

S9#t'm Im$%'m'nt tion S9#t'm T'#tin* >nit !esting ntegration !esting Functional !esting

;0 ;/ ;> ;; ;3

<.

Con5%u#ion Future 3nhancements

=.

A$$'n)i5'# "napshot And Coding 4art

;. .<

@.

Bi"%io*! $h9

LIST OF FIG+RES Fi*u!' No Fi*u!' Tit%' P *' No

LIST OF ABBREVIATIONS NAMES ABBREVIATION

0. INTROD+CTION 0.0 INTROD+CTION ABO+T THE ORGANISATION


Founded in&$$B. 4acific ,lue !echnologies 4vt. 2td is a consulting and software development firm dedicated to business success through long1term relationship with our clients and staff. ,ased in Chennai. 4acific ,lue !echnologies has grown from a one1person startup to a significant corporation of 5%% talented professionals having more than &% branches all over the world. 4acific ,lue !echnologies is dynamic. service oriented enterprise. and is positioned to successfully respond to trends and changes in the information technology in the industry. 4acific ,lue !echnology?s client relationships are based on the highest )uality professional technology consulting and development services. 4acific ,lue !echnologies enjoys and e7cellent reputation as a proven resource for strategic planning. needs. assessment. client@server programming and interactive multimedia. internet@intranet development . networking and security services. 6ith customer in private business and the public sector. takes pride in a history of projects that significantly service. 4acific ,lue !echnologies focus on long term relationship with staff is reflected through clear communication of e7pectation. performance based recognition and advancement. and an environment that supports employee?s professional development. 4acific ,lue !echnology?s staff. comprised almost entirely of full time company employees. is held to standards of accountability. integrity. creativity and competence. !he dedication. skills. and integrity of 4acific ,lue !echnology?s staff are key to the firm?s success. enhance and @or improve client?s business practices and level of

10

0./ INTROD+CTION ABO+T THE PROJECTASYSTEM


Ad hoc networks are multi hop wireless networks of small computing devices with wireless interfaces. !he computing devices could be conventional computers Cfor e7ample. 45A. laptop. or 4CD or backbone routing platforms or even embedded processors such as sensor nodes. !he problem of optimal placement of caches to reduce overall cost of accessing data is motivated by the following two defining characteristics of ad hoc networks. First. the ad hoc networks are multi hop networks without a central base station. !hus. remote access of information typically occurs via multi hop routing. which can greatly benefit from caching to reduce access latency. "econd. the network is generally resource constrained in terms of channel bandwidth or battery power in the nodes. Caching helps in reducing communication. this results in savings in bandwidth. as well as battery energy. !he problem of cache placement is particularly challenging when each network node has a limited memory to cache data items. n this paper. our focus is on developing efficient caching techni)ues in ad hoc networks with memory limitations. 9esearch into data storage. access. and dissemination techni)ues in ad hoc networks is not new. n particular. these mechanisms have been investigated in connection with sensor networking peer1to1peer networks mesh networks world wide 6eb and even more general ad hoc networks. 8owever. the presented approaches have so far been somewhat ad hoc< and empirically based. without any strong analytical foundation. n contrast. the theory literature abounds in analytical studies into the optimality properties of caching and replica allocation problems. 8owever. distributed implementations of these techni)ues and their performances in comple7 network settings have not been investigated. t is even unclear whether these techni)ues are amenable to efficient distributed implementations. #ur goal in this paper is to develop an approach that is both analytically tractable with a provable performance bound in a centrali=ed setting and is also amenable to a natural distributed implementation. n our network model. there are multiple data items; each data item has a server. and a set of clients that wish to access the data item at a given fre)uency. 3ach node carefully chooses data items to cache in its limited memory to minimi=e the overall access cost. 3ssentially. in this article. we develop efficient strategies to select data items to cache at each node. n particular. we develop two algorithmsEa centrali=ed appro7imation algorithm. which delivers a F1appro7imation C(1appro7imation for uniform si=e data itemsD solution. and a locali=ed distributed algorithm. which is based on the appro7imation algorithm and can handle

11

mobility of nodes and dynamic traffic conditions. >sing simulations. we show that the distributed algorithm performs very close to the appro7imation algorithm. Finally. we show through e7tensive e7periments on ns( that our proposed distributed algorithm performs much better than a prior approach over a broad range of parameter values. #urs is the first work to present a distributed implementation based on an appro7imation algorithm for the general problem of cache placement of multiple data items under memory constraint. 5ata caching strategy for ad hoc networks whose nodes e7change information items in a peer1to1peer fashion. 5ata caching is a fully distributed scheme where each node. upon receiving re)uested information. determines the cache drop time of the information or which content to replace to make room for the newly arrived information. !hese decisions are made depending on the perceived presence< of the content in the nodes pro7imity. whose estimation does not cause any additional overhead to the information sharing system. 6e devise a strategy where nodes. independent of each other. decide whether to cache some content and for how long. n the case of small1si=ed caches. we aim to design a content replacement strategy that allows nodes to successfully store newly received information while maintaining the good performance of the content distribution system. >nder both conditions. each node takes decisions according to its perception of what nearby users may store in their caches and with the aim of differentiating its own cache content from the other nodes?. !he result is the creation of content diversity within the nodes neighborhood so that a re)uesting user likely finds the desired information nearby. 6e simulate our caching algorithms in different ad hoc network scenarios and compare them with other caching schemes. showing that our solution succeeds in creating the desired content diversity. thus leading to a resource1efficient information access.

12

0.> REVIEW OF LITERAT+RE

2iterature survey is the most important step in software development process. ,efore developing the tool it is necessary to determine the time factor. economy n company strength. #nce these things r satisfied. ten ne7t steps are to determine which operating system and language can be used for developing the tool. #nce the programmers start building the tool the programmers need lot of e7ternal support. !his support can be obtained from senior programmers. from book or from websites. ,efore building the system the above consideration r taken into account for developing the proposed system. OVERVIEW2 6e propose. called 8amlet. aims at creating content diversity within the node neighborhood so that users likely find a copy of the different information items nearby C9egardless of the content popularity levelD and avoid flooding the network with )uery messages. Although a similar concept has been put forward in the novelty in our proposal resides in the probabilistic estimate. run by each node. of the information presence Ci.e.. of the cached contentD in the node pro7imity. !he estimate is performed in a cross1layer fashion by overhearing content )uery and information reply messages due to the broadcast nature of the wireless channel. ,y leveraging such a local estimate. nodes autonomously decide what information to keep and for how long. resulting in a distributed scheme that does not re)uire additional control messages.

13

Th' H m%'t $$!o 5h $$%i'# to th' &o%%o(in* 5 #'#. G 2arge1si=ed caches n this case. nodes can potentially store a large portion Ci.e.. up to 5%HD of the available information items. 9educed memory usage is a desirable Cif not re)uiredD condition. because the same memory may be shared by different services and applications that run at nodes. n such a scenario. a caching decision consists of computing for how long a given content should be stored by a node that has previously re)uested it. with the goal of minimi=ing the memory usage without affecting the overall information retrieval performance; G "mall1si=ed caches n this case. nodes have a dedicated but limited amount of memory where to store a small percentage Ci.e.. up to &%HD of the data that they retrieve. !he caching decision translates into a cache replacement strategy that selects the information items to be dropped among the information items just received and the information items that already fill up the dedicated memory. 6e evaluate the performance of 8amlet in different mobile network scenarios. where nodes communicate through ad hoc connectivity. !he results show that our solution ensures a high )uery resolution ratio while maintaining the traffic load very low. even for scarcely popular content. and consistently along different network connectivity and mobility scenarios.

14

0.; GOAL OF PRESENT WORK

#ur goal in this paper is to develop an approach that is both analytically tractable with a provable performance bound in a centrali=ed setting and is also amenable to a natural distributed implementation. n our network model. there are multiple data items; each data item has a server. and a set of clients that wish to access the data item at a given fre)uency. 3ach node carefully chooses data items to cache in its limited memory to minimi=e the overall access cost. 3ssentially. in this article. we develop efficient strategies to select data items to cache at each node. n particular. we develop two algorithmsEa centrali=ed appro7imation algorithm. which delivers a F1appro7imation C(1appro7imation for uniform si=e data itemsD solution. and a locali=ed distributed algorithm. which is based on the appro7imation algorithm and can handle mobility of nodes and dynamic traffic conditions. >sing simulations. we show that the distributed algorithm performs very close to the appro7imation algorithm. Finally. we show through e7tensive e7periments on ns( that our proposed distributed algorithm performs much better than a prior approach over a broad range of parameter values. #urs is the first work to present a distributed implementation based on an appro7imation algorithm for the general problem of cache placement of multiple data items under memory constraint. 5ata caching strategy for ad hoc networks whose nodes e7change information items in a peer1to1peer fashion. 5ata caching is a fully distributed scheme where each node. upon receiving re)uested information. determines the cache drop time of the information or which content to replace to make room for the newly arrived information. !hese decisions are made depending on the perceived presence< of the content in the nodes pro7imity. whose estimation does not cause any additional overhead to the information sharing system.

15

/. DEFINING THE PROBLEM /.0 EBISTING SYSTEM


37isting cooperative caching schemes for the 6eb environment can be classified as message1based. directory1based. hash based. or router1based. !he cache array routing protocol is the most notable hash based cooperative caching protocol. !he rationale behind CA94 constitutes load distribution by hash routing among 6eb pro7y cache arrays. A mobile node doesn?t know whether the data source or some other nodes serve its re)uest. f multiple data sources e7ist. or if the mobile node doesn?t know where the data source is. 8ybrid Cache might not be a good option. n addition. caching nodes outside the path between the re)uesting node and the data source might not be able to share cache information with the re)uesting node.

LIMITATIONS OF EBISTING SYSTEM2


37isting cooperative caching schemes for the 6eb environment can be classified as message1based. directory1based. hash based. or router1based. !he cache array routing protocol is the most notable hash based cooperative caching protocol. !he rationale behind CA94 constitutes load distribution by hash routing among 6eb pro7y cache arrays.

16

/./ NEED FOR THE NEW SYSTEM2


6e simulate our caching algorithms in different ad hoc network scenarios and compare them with other caching schemes. showing that our solution succeeds in creating the desired content diversity. thus leading to a resource1efficient information access. 5ata caching strategy for ad hoc networks whose nodes e7change information items in a peer1to1peer fashion. !hese decisions are made depending on the perceived presence< of the content in the nodes pro7imity. whose estimation does not cause any additional overhead to the information sharing system. 8owever. the solution that was proposed is based on the formation of an overlay network composed of mediator< nodes. and it is only fitted to static connected networks with stable links among nodes. 6e proposes a complete framework for information retrieval and caching in mobile ad hoc networks. and it is built on an underlying routing protocol and re)uires the manual setting of a network wide Caching =one< !hese assumptions. along with the significant communication overhead needed to elect mediator< nodes. make this scheme unsuitable for the mobile environments. ADVANTAGES OF PROPOSED SYSTEM 5ata caching can significantly improve the efficiency of information access in a

wireless ad hoc network by reducing the access latency and bandwidth usage. 5ata for information retrieval and caching in mobile ad hoc networks. and it is

built on an underlying routing protocol and re)uires the manual setting of a network wide Caching =one<.

17

/.> PROBLEM DEFINITION

:obile environment can be classified as message1based. directory1based. hash based. or router1based data source is. 8ybrid Cache might not be a good option. !he cache array routing protocol is the most notable hash based cooperative caching protocol. 5ata caching strategy for ad hoc networks whose nodes e7change information items in a peer1to1peer fashion. 5ata caching is a fully distributed scheme where each node. upon receiving re)uested information. determines the cache drop time of the information or which content to replace to make room for the newly arrived information.

!hese decisions are made depending on the perceived presence< of the content in the nodes pro7imity. whose estimation does not cause any additional overhead to the information sharing system.

18

>. REC+IREMENT SPECIFICATION >.0 HARDWARE SPECIFICATION


!he above 8ardware specifications were used in both "erver and Client machines when developing.

4rocessor 4rocessor "peed 9am 8ard 5isk 5rive Floppy 5isk 5rive C519#: 5rive :onitor Jeyboard :ouse

' ' ' ' ' ' ' ' '

4entium F (.5 Ah= 5&( :, B%A, "ony "ony &I< inches !0" Aold 2ogitech

19

>./ SOFTWARE SPECIFICATION

#perating "ystem

'

6indows K4 4rofessional

!echnology >sed

'

-5J L.%

!ools 6eb "erver ,rowser

' ' '

3clipse M.M nternet nformation "erver nternet 37plorer L.%

20

>.> SOFTWARE J+STIFICATION JAVA TECHNOLOGY2


-ava technology is both a programming language and a platform. Th' J : P!o*! mmin* L n*u *' !he -ava programming language is a high1level language that can be characteri=ed by all of the following bu==words' "imple Architecture neutral #bject oriented 4ortable 5istributed 8igh performance nterpreted :ultithreaded 9obust 5ynamic "ecure

6ith most programming languages. you either compile or interpret a program so that you can run it on your computer. !he -ava programming language is unusual in that a program is both compiled and interpreted. 6ith the compiler. first you translate a program into an intermediate language called Java byte codes Ethe platform1independent codes interpreted by the interpreter on the -ava platform. !he interpreter parses and runs each -ava byte code instruction on the computer. Compilation happens just once; interpretation occurs each time the program is e7ecuted. !he following figure illustrates how this works.

21

Nou can think of -ava byte codes as the machine code instructions for the Java Virtual Machine C-ava 0:D. 3very -ava interpreter. whether it?s a development tool or a 6eb browser that can run applets. is an implementation of the -ava 0:. -ava byte codes help make write once. run anywhere< possible. Nou can compile your program into byte codes on any platform that has a -ava compiler. !he byte codes can then be run on any implementation of the -ava 0:. !hat means that as long as a computer has a -ava 0:. the same program written in the -ava programming language can run on 6indows (%%%. a "olaris workstation. or on an i:ac.

Th' J : P% t&o!m A platform is the hardware or software environment in which a program runs. 6e?ve already mentioned some of the most popular platforms like 6indows (%%%. 2inu7. "olaris. and :ac#". :ost platforms can be described as a combination of the operating system and hardware. !he -ava platform differs from most other platforms in that it?s a software1only platform that runs on top of other hardware1based platforms. !he -ava platform has two components'

!he J : Vi!tu % M 5hin' C-ava 0:D !he J : A$$%i5 tion P!o*! mmin* Int'!& 5' C-ava A4 D

Nou?ve already been introduced to the -ava 0:. t?s the base for the -ava platform and is ported onto various hardware1based platforms.

22

!he -ava A4 is a large collection of ready1made software components that provide many useful capabilities. such as graphical user interface CA> D widgets. !he -ava A4 is grouped into libraries of related classes and interfaces; these libraries are known as packages. !he ne7t section. 6hat Can -ava !echnology 5oO 8ighlights what functionality some of the packages in the -ava A4 provide. !he following figure depicts a program that?s running on the -ava platform. As the figure shows. the -ava A4 and the virtual machine insulate the program from the hardware.

*ative code is code that after you compile it. the compiled code runs on a specific hardware platform. As a platform1independent environment. the -ava platform can be a bit slower than native code. 8owever. smart compilers. well1tuned interpreters. and just1in1time byte code compilers can bring performance close to that of native code without threatening portability. 6hat Can -ava !echnology 5oO !he most common types of programs written in the -ava programming language are applets and applications. f you?ve surfed the 6eb. you?re probably already familiar with applets. An applet is a program that adheres to certain conventions that allow it to run within a -ava1enabled browser. 8owever. the -ava programming language is not just for writing cute. entertaining applets for the 6eb. !he general1purpose. high1level -ava programming language is also a powerful software platform. >sing the generous A4 . you can write many types of programs. An application is a standalone program that runs directly on the -ava platform. A special kind of application known as a server serves and supports clients on a network. 37amples of servers are 6eb servers. pro7y servers. mail servers. and print servers. Another speciali=ed program is a servlet. A servlet can almost be thought of as an applet that runs on the server side. -ava "ervlets are a popular choice for building interactive web applications. replacing the use of CA scripts. "ervlets are similar to applets in that they are runtime e7tensions of applications. nstead of working in browsers. though. servlets run within -ava 6eb servers. configuring or tailoring the server. 8ow does the A4 support all these kinds of programsO t does so with packages of software components that provides a wide range of functionality. 3very full implementation of the -ava platform gives you the following features'

23

1. Th' '##'nti %#' #bjects. strings. threads. numbers. input and output. data structures. system properties. date and time. and so on. 2. A$$%'t#' !he set of conventions used by applets. 3. N't(o!6in*' >92s. !C4 C!ransmission Control 4rotocolD. >54 C>ser 5ata gram 4rotocolD sockets. and 4 C nternet 4rotocolD addresses. 4. Int'!n tion %i8 tion' 8elp for writing programs that can be locali=ed for users worldwide. 4rograms can automatically adapt to specific locales and be displayed in the appropriate language. 5. S'5u!it9' ,oth low level and high level. including electronic signatures. public and private key management. access control. and certificates. 6. So&t( !' 5om$on'nt#' Jnown as -ava,eans!:. can plug into e7isting component architectures. 7. O"D'5t #'!i %i8 tion' Allows lightweight persistence and communication via 9emote :ethod nvocation C9: D. 8. J : D t " #' Conn'5ti:it9 EJDBCTMF' 4rovides uniform access to a wide range of relational databases. !he -ava platform also has A4 s for (5 and M5 graphics. accessibility. servers. collaboration. telephony. speech. animation. and more. !he following figure depicts what is included in the -ava ( "5J.

8ow 6ill -ava !echnology Change :y 2ifeO 6e can?t promise you fame. fortune. or even a job if you learn the -ava programming language. "till. it is likely to make your programs better and re)uires less effort than other languages. 6e believe that -ava technology will help you do the following'

24

1. G't #t !t') ?ui56%9' Although the -ava programming language is a powerful object1 oriented language. it?s easy to learn. especially for programmers already familiar with C or CPP. 2. W!it' %'## 5o)'' Comparisons of program metrics Cclass counts. method counts. and so onD suggest that a program written in the -ava programming language can be four times smaller than the same program in CPP. 3. W!it' "'tt'! 5o)'' !he -ava programming language encourages good coding practices. and its garbage collection helps you avoid memory leaks. ts object orientation. its -ava,eans component architecture. and its wide1ranging. easily e7tendible A4 let you reuse other people?s tested code and introduce fewer bugs. 4. D':'%o$ $!o*! m# mo!' ?ui56%9' Nour development time may be as much as twice as fast versus writing the same program in CPP. 6hyO Nou write fewer lines of code and it is a simpler programming language than CPP. 5. A:oi) $% t&o!m )'$'n)'n5i'# (ith 011G Pu!' J : ' Nou can keep your program portable by avoiding the use of libraries written in other languages. !he &%%H 4ure -ava!: 4roduct Certification 4rogram has a repository of historical process manuals. white papers. brochures. and similar materials online. 6. W!it' on5', !un n9(h'!'' ,ecause &%%H 4ure -ava programs are compiled into

machine1independent byte codes. they run consistently on any -ava platform. 7. Di#t!i"ut' #o&t( !' mo!' ' #i%9' Nou can upgrade applets easily from a central server. Applets take advantage of the feature of allowing new classes to be loaded on the fly.< without recompiling the entire program.

25

ODBC :icrosoft #pen 5atabase Connectivity C#5,CD is a standard programming interface forapplication developers and database systems providers. ,efore #5,C became a de facto standard for 6indows programs to interface with database systems. programmers had to use proprietary languages for each database they wanted to connect to. *ow. #5,C has made the choice of the database system almost irrelevant from a coding perspective. which is as it should be. Application developers have much more important things to worry about than the synta7 that is needed to port their program from one database to another when business needs suddenly change. !hrough the #5,C Administrator in Control 4anel. you can specify the particular database that is associated with a data source that an #5,C application program is written to use. !hink of an #5,C data source as a door with a name on it. 3ach door will lead you to a particular database. For e7ample. the data source named "ales Figures might be a "Q2 "erver database. whereas the Accounts 4ayable data source could refer to an Access database. !he physical database referred to by a data source can reside anywhere on the 2A*. !he #5,C system files are not installed on your system by 6indows $5. 9ather. they are installed when you setup a separate database application. such as "Q2 "erver Client or 0isual ,asic F.%. 6hen the #5,C icon is installed in Control 4anel. it uses a file called #5,C *"!.522. t is also possible to administer your #5,C data sources through a stand1 alone program called #5,CA5:.3K3. !here is a &L1bit and a M(1bit version of this program and each maintains a separate list of #5,C data sources. From a programming perspective. the beauty of #5,C is that the application can be written to use the same set of function calls to interface with any data source. regardless of the database vendor. !he source code of the application doesn?t change whether it talks to #racle or "Q2 "erver. 6e only mention these two as an e7ample. !here are #5,C drivers available for several do=en popular database systems. 3ven 37cel spreadsheets and plain te7t files can be turned into data sources. !he operating system uses the 9egistry information written by #5,C Administrator to determine which low1level #5,C drivers are needed to talk to the data source Csuch as the interface to #racle or "Q2 "erverD. !he loading of the #5,C drivers is transparent to the #5,C application program. n a client@server environment. the #5,C A4 even handles many of the network issues for the application programmer.

26

!he advantages of this scheme are so numerous that you are probably thinking there must be some catch. !he only disadvantage of #5,C is that it isn?t as efficient as talking directly to the native database interface. #5,C has had many detractors make the charge that it is too slow. :icrosoft has always claimed that the critical factor in performance is the )uality of the driver software that is used. n our humble opinion. this is true. !he availability of good #5,C drivers has improved a great deal recently. And anyway. the criticism about performance is somewhat analogous to those who said that compilers would never match the speed of pure assembly language. :aybe not. but the compiler Cor #5,CD gives you the opportunity to write cleaner programs. which means you finish sooner. :eanwhile. computers get faster every year. JDBC n an effort to set an independent database standard A4 for -ava; "un :icrosystems developed -ava 5atabase Connectivity. or -5,C. -5,C offers a generic "Q2 database access mechanism that provides a consistent interface to a variety of 95,:"s. !his consistent interface is achieved through the use of plug1in< database connectivity modules. or drivers. f a database vendor wishes to have -5,C support. he or she must provide the driver for each platform that the database and -ava run on. !o gain a wider acceptance of -5,C. "un based -5,C?s framework on #5,C. As you discovered earlier in this chapter. #5,C has widespread support on a variety of platforms. ,asing -5,C on #5,C will allow vendors to bring -5,C drivers to market much faster than developing a completely new connectivity solution. -5,C was announced in :arch of &$$L. t was released for a $% day public review that ended -une B. &$$L. ,ecause of user input. the final -5,C v&.% specification was released soon after. !he remainder of this section will cover enough information about -5,C for you to know what it is about and how to use it effectively. !his is by no means a complete overview of -5,C. !hat would fill an entire book.

27

JDBC Go %# Few software packages are designed without goals in mind. -5,C is one that. because of its many goals. drove the development of the A4 . !hese goals. in conjunction with early reviewer feedback. have finali=ed the -5,C class library into a solid framework for building database applications in -ava. !he goals that were set for -5,C are important. !hey will give you some insight as to why certain classes and functionalities behave the way they do. !he eight design goals for -5,C are as follows' 0. SCL L':'% API !he designers felt that their main goal was to define a "Q2 interface for -ava. Although not the lowest database interface level possible. it is at a low enough level for higher1level tools and A4 s to be created. Conversely. it is at a high enough level for application programmers to use it confidently. Attaining this goal allows for future tool vendors to generate< -5,C code and to hide many of -5,C?s comple7ities from the end user. /. SCL Con&o!m n5' "Q2 synta7 varies as you move from database vendor to database vendor. n an effort to support a wide variety of vendors. -5,C will allow any )uery statement to be passed through it to the underlying database driver. !his allows the connectivity module to handle non1 standard functionality in a manner that is suitable for its users. M. JDBC mu#t "' im$%'m'nt % on to$ o& 5ommon ) t " #' int'!& 5'# !he -5,C "Q2 A4 must sit< on top of other common "Q2 level A4 s. !his goal allows -5,C to use e7isting #5,C level drivers by the use of a software interface. !his interface would translate -5,C calls to #5,C and vice versa. ;. P!o:i)' J : int'!& 5' th t i# 5on#i#t'nt (ith th' !'#t o& th' J : #9#t'm ,ecause of -ava?s acceptance in the user community thus far. the designers feel that they should not stray from the current design of the core -ava system. 3. K''$ it #im$%' !his goal probably appears in all software design goal listings. -5,C is no e7ception. "un felt that the design of -5,C should be very simple. allowing for only one method of completing a task per mechanism. Allowing duplicate functionality only serves to confuse the users of the A4 . .. +#' #t!on*, #t ti5 t9$in* (h'!':'! $o##i"%' "trong typing allows for more error checking to be done at compile time; also. less error appear at runtime. <. K''$ th' 5ommon 5 #'# #im$%' 28

,ecause more often than not. the usual "Q2 calls used by the programmer are simple SELECT?s. INSERT?s. DELETE?s and UPDATE?s. these )ueries should be simple to perform with -5,C. 8owever. more comple7 "Q2 statements should also be possible. Finally we decided to proceed the implementation using -ava *etworking. And for dynamically updating the cache table we go for :" Access database. Java Program Interpreter

Compilers

My Program

Java ha two things: a programming language and a platform. -ava is a high1level programming language that is all of the following

"imple Architecture1*eutral #bject1#riented 4ortable 5istributed 8igh14erformance nterpreted :ultithreaded 9obust 5ynamic "ecure

-ava is also unusual in that each -ava program is both compiled and interpreted. 6ith a compile you translate a -ava program into an intermediate language called -ava byte codes the platform1 independent code instruction is passed and run on the computer. Compilation happens just once; interpretation occurs each time the program is e7ecuted. !he figure illustrates how this works. Nou can think of -ava byte codes as the machine code instructions for the -ava 0irtual :achine C-ava 0:D. 3very -ava interpreter. whether it?s a -ava development tool or a 6eb browser that

29

can run -ava applets. is an implementation of the -ava 0:. !he -ava 0: can also be implemented in hardware. -ava byte codes help make write once. run anywhere< possible. Nou can compile your -ava program into byte codes on my platform that has a -ava compiler. !he byte codes can then be run any implementation of the -ava 0:. For e7ample. the same -ava program can run 6indows *!. "olaris. and :acintosh.

*etworking TCPAIP #t 56 !he !C4@ 4 stack is shorter than the #" one'

!C4 is a connection1oriented protocol; >54 C>ser 5atagram 4rotocolD is a connectionless protocol.

IP ) t *! mH# !he 4 layer provides a connectionless and unreliable delivery system. t considers each datagram independently of the others. Any association between datagram must be supplied by the higher layers. !he 4 layer supplies a checksum that includes its own header. !he header

30

includes the source and destination addresses. !he 4 layer handles routing through an nternet. t is also responsible for breaking up large datagram into smaller ones for transmission and reassembling them at the other end.

+DP
>54 is also connectionless and unreliable. 6hat it adds to 4 is a checksum for the contents of the datagram and port numbers. !hese are used to give a client@server model 1 see later. TCP !C4 supplies logic to give a reliable connection1oriented protocol above 4. t provides a virtual circuit that two processes can use to communicate. Int'!n't ))!'##'# n order to use a service. you must be able to find it. !he nternet uses an address scheme for machines so that they can be located. !he address is a M( bit integer which gives the 4 address. !his encodes a network 5 and more addressing. !he network 5 falls into various classes according to the si=e of the network address. N't(o!6 ))!'## Class A uses B bits for the network address with (F bits left over for other addressing. Class , uses &L bit network addressing. Class C uses (F bit network addressing and class 5 uses all M(. Su"n't ))!'## nternally. the >* K network is divided into sub networks. ,uilding && is currently on one sub network and uses &%1bit addressing. allowing &%(F different hosts. Ho#t ))!'## B bits are finally used for host addresses within our subnet. !his places a limit of (5L machines that can be on the subnet.

31

Tot % ))!'##

!he M( bit address is usually written as F integers separated by dots. Po!t A))!'##'# A service e7ists on a host. and is identified by its port. !his is a &L bit number. !o send a message to a server. you send it to the port for that service of the host that it is running on. !his is not location transparencyR Certain of these ports are Swell knownS. So56't# A socket is a data structure maintained by the system to handle network connections. A socket is created using the call socket. t returns an integer that is like a file descriptor. n fact. under 6indows. this handle can be used with Read File and Write File functions. Tinclude Usys@types.hV Tinclude Usys@socket.hV int socketCint family. int type. int protocolD; 8ere SfamilyS will be AF_INET for 4 communications. protocol will be =ero. and type will depend on whether !C4 or >54 is used. !wo processes wishing to communicate over a network create a socket each. !hese are similar to two ends of a pipe 1 but the actual pipe does not yet e7ist. JF!'' Ch !t -FreeChart is a free &%%H -ava chart library that makes it easy for developers to display professional )uality charts in their applications. -FreeChart/s e7tensive feature set includes' A consistent and well1documented A4 . supporting a wide range of chart types; A fle7ible design that is easy to e7tend. and targets both server1side and client1side applications;

32

"upport for many output types. including "wing components. image files Cincluding 4*A and -43AD. and vector graphics file formats Cincluding 45F. 34" and "0AD; -FreeChart is Sopen sourceS or. more specifically. free software. t is distributed under the terms of the A*> 2esser Aeneral 4ublic 2icence C2A42D. which permits use in proprietary applications. 0. M $ Vi#u %i8 tion# Charts showing values that relate to geographical areas. "ome e7amples include' CaD population density in each state of the >nited "tates. CbD income per capita for each country in 3urope. CcD life e7pectancy in each country of the world. !he tasks in this project include' "ourcing freely redistributable vector outlines for the countries of the world. states@provinces in particular countries C>"A in particular. but also other areasD; Creating an appropriate dataset interface Cplus default implementationD. a rendered. and integrating this with the e7isting KN4lot class in -FreeChart; !esting. documenting. testing some more. documenting some more. /. Tim' S'!i'# Ch !t Int'! 5ti:it9 mplement a new Cto -FreeChartD feature for interactive time series charts 111 to display a separate control that shows a small version of A22 the time series data. with a sliding SviewS rectangle that allows you to select the subset of the time series data to display in the main chart. >. D #h"o !)# !here is currently a lot of interest in dashboard displays. Create a fle7ible dashboard mechanism that supports a subset of -FreeChart chart types Cdials. pies. thermometers. bars. and lines@time seriesD that can be delivered easily via both -ava 6eb "tart and an applet. ;. P!o$'!t9 E)ito!# !he property editor mechanism in -FreeChart only handles a small subset of the properties that can be set for charts. 37tend Cor reimplementD this mechanism to provide greater end1user control over the appearance of the charts.

33

F. SYSTEM DESIGN ;.0 CONCEPT+AL DESIGN

A !"

#$! J#I % I

&'!

!&"#()

34

!I*'+#(% (!%P# %! &# A$$(!%% A%%I*

35

;./ DETAILED DESIGN


0F :ost people talk about detailed design. they are referring to a process known as top1

down design. n short. when you think about the problem you are trying to solve. you start at the highest level and then work yourself into the details. !his approach works very well when you have an overall structure you want your application to live within. At the macro level you are considering how many machines will be needed to host your application. which e7isting services you will need to use. etc. As you dive deeper. you are looking at use cases Cor user stories if you prefer that terminologyD. and error handling Cuse cases have both normal and error condition paths to worry aboutD. As you go even further into the details. you are looking at your algorithm. state transitions. logical se)uence. and how internal parts of the code work together. /F !he classic top1down approach to detailed design is what is taught with the SwaterfallS

methodology. 333 process guides. >:2 vendors. universities. and C:: among others. n many of these heavy processes they have you writing two design documents. #ne is the overall architectural diagram Cthe top level designD. !he other is the detailed design where you go further down the rabbit hole. n many cases it is the only approach to design many people know. t is a very logical and methodical approach to breaking down a software problem. >F !he main advantage is that you have identified what the critical sections are likely going

to be. f you will need to start working on how your software will be using another e7isting service. you have compiled your list of integration points. Nou would be able to start talks with the owners of those services to plan your integration along with how to handle une7pected events. !he main disadvantage is that many times people go too far down the rabit hole. and the design document takes a life of its own. 6hile it is advantageous to have an overall vision and architecture for how an application will work. you will invariably find your initial thoughts on the core details were flat wrong. 6hen that happens. either the design document is neglected or you have whole teams maintaining the paper and slowing progress on work.

36

;F

/ve already mentioned top1down design. so it follows there must be a Sbottom1upS

approach. rightO As it turns out. there is. 3ssentially. the Sbottom1upS approach is the core thought process behind !est 5riven 5evelopment and Continuous 5esign methodologies. 3ssentially. the details of working code start driving the design of how larger chunks of working code cooperate and interface with each other. 6ith !55. you have unit tests to ensure that the details behave properly and keep validating your design. Continuous design teaches us that we will never truly know the details until the software is done. !herefore. why try to fight the factO nstead of a big up1front design stage. the design is built in increments over several iterations of design@code and testing. t is actually a very liberating concept that lets you concentrate on solving problems. ,ottom line. there is no perfect answer. For me. down and bottom1up design works well. 3ssentially. picture. find a healthy balance between top1

still take the time to think about the big

even map out a plan for the user interface idioms and my best ideas for it/s design.

8owever. don/t go into great detail because know the details will change. ,asically. you need to stop the top1down process when you are getting to areas you are not sure about. #nce you get to those areas. start with the bottom1up approach. !his lets you try different things. verify with the customer if it makes sense to them. and continue to improve over time.

37

;.> +ML DIAGRAMS ,%! CA%! $IA*(AM%-

38

C.A%% $IA*(AM%-

Networ !ender

"dd nodes Node #reation Nodes in $ell

%ata #a$hing !tart mo&ilit' (efresh nodes

#a$hing )ath

"d*a$ent Nodes +otal Nodes ,et !hortest ,et #ahing Nodes )ath differen$e

39

%!2,! C! $IA*(AM%-

e/ no0e -

et/or1 -

Parent -

-nter the networ .ind the parent (eturn parent node position

"tta$h as $hild node (eorgani/e the networ

#al$ulate new address 0pdate routing ta&les (eturn address and routing ta&le

40

AC&I3I&4 $IA*(AM%-

41

$A&A5.#" $IA*(AM-

D t F%o( Di *! m2 L':'%-1

42

D t F%o( Di *! m2 L':'%-0

43

%ata .low %iagram : 1evel 2

44

D t F%o( Di *! m 2L':'% >

45

3. SYSTEM IMPLEMENTATION

mplementation is the state in the system where the theoretical design is turned into a working system. !he most crucial stage in achieving a new successful system and in giving confidence on the new system for the users that will work efficiently and effectively. !he system can be implemented only after thorough testing in done and if found to work according to the specification. f involves careful planning. investigation of the current system and its constraints on implementation. design of methods to achieve the changeover. an evaluation of changeover methods apart from planning. !wo major tasks of preparing the implementation are education. training of the users and testing the systems. "ystem analysis and design efforts will be more for comple7 systems beings implemented. ,ased on policies of individuals organi=ation an implementation coordinating committee has been appointed. !he implementation process begins with preparing a plan for the implementation system. According to this plan. the other activities are to be carried out. n this plan. discussion has been made regarding the e)uipment. resources and how to test the activities. !hus a clear plan is preparing for the activities. E?ui$m'nt A5?ui#ition According to the above plan. the necessary e)uipment has to be ac)uired to implement the new system. 4rime !ech has all the hardware re)uirements for installing and maintaining the package.

P!o*! m 5o)' $!'$ ! tion #ne of the most important development activities is the code of programming. !he system 5F5?s and other channels are converted to modular programs. !hey have to be complied. tested and debugged.

46

+#'! M nu %#

#nce planning has been completed the major effort of the computer department is to ensure that the user department consists of education and trained staff. as the system becomes more comple7. !he success of a system depends upon how they are operated and used. !hus the )uality of training. the personnel is connected to the success of the system. For this purpose system and user manuals are prepared. n system manuals. details about the forms and blocks triggers. 6hich were used to develop them. were specified. manuals data flow diagrams. charts and screen formats are given. n user Also error messages

associated were e7plained in details. !he users were shown the success and they were taught how to operate the system. 2ive demonstration and visuals aids were used to teach them.

LIST OF MOD+LES Mo)u%'#


According to the analysis three modules has been traced out in the design of work. !he modules are as follows. 0. SELF-ORGANIIING /. SELF-ADDRESSING EMANETF >. INTEGRATED CACHE-RO+TING ;. LOCALIIED CACHING POLICY 3. DISTRIB+TED CACHING ALGORITHM

47

MOD+LE DESCRIPTION2 SELF-ORGANIIING2 :ultiple 5ata?s for cache placement of multiple data items in ad hoc networks. n the first approach. each node caches the items most fre)uently accessed by itself; the second approach eliminates replications among neighboring nodes introduced by the first approach; the third approach re)uire one or more central< nodes to gather neighborhood information and determine caching placements. !he first two approaches are largely locali=ed. and hence. would fare very badly when the percentage of client nodes in the network is low. or the access fre)uencies are uniform. n other related works. discuss placement of transparent< caches in tree networks. SELF-ADDRESSING2 A multi1hop ad hoc network can be represented as an undirected the nodes in the network and E are the set of weighted edges in the graph. !wo network nodes that can communicate directly with each other are connected by an edge in the graph. !he edge weight may represent a link metric such as loss rate. delay. or transmission power. For the cache placement problem addressed in this article. there are multiple data items and each data item is served by its server Ca network node may act as a server for more than one data itemsD. 3ach network node has limited memory and can cache multiple data items subject to its memory capacity limitation. !he objective of our cache placement problem is to minimi=e the overall access cost. ,elow. we give a formal definition of the cache placement problem addressed in this system. INTEGRATED CACHE-RO+TING2 *earest1caching tables can be used in conjunction with any underlying routing protocol to reach the nearest cache node. as long as the distances to other nodes are maintained by the routing protocol. 8owever. note that maintaining cache1routing tables instead of nearest1cache tables and routing tables doesn?t offer any clear advantage in terms of number of messages transmissions.

48

6e could maintain the integrated cache1routing tables in the similar vein as routing tables are maintained in mobile ad hoc networks. Alternatively. we could have the servers periodically broadcast the latest cache lists. n our simulations. we adopted the latter strategy. since it precludes the need to broadcast Add Cache and 5elete Cache messages to some e7tent.

LOCALIIED CACHING POLICY2 !he caching policy of 5CA is as follows. 3ach node computes benefit of data items based on its local traffic< observed for a sufficiently long time. !he local traffic of a node i includes its own local data re)uests. nonlocal data re)uests to data items cached at i. and the traffic that the node i is forwarding to other nodes in the network. A node decides to cache the most beneficial Cin terms of local benefit per unit si=e of data itemD data items that can fit in its local memory. 6hen the local cache memory of a node is full. the following cache replacement policy is used. n particular. a data item is newly cached only if its local benefit is higher than the benefit threshold. and a data item replaces a set of cached data items only if the difference in their local benefits is greater than the benefit threshold.

DISTRIB+TED GREEDY ALGORITHM EDCAF2 n this subsection. we describe a locali=ed distributed implementation of 5CA. 6e refer to the designed distributed implementation as 5CA C5istributed Caching AlgorithmD. !he advantage of 5CA is that it adapts to dynamic traffic conditions. and can be easily implemented in an operational Cpossibly. mobileD network with low communication overheads. 6hile we cannot prove any bound on the )uality of the solution produced by 5CA. we show through e7tensive simulations that the performance of the 5CA.

49

.. SYSTEM TESTING
!he important phase of software development is concerned with translating the design specification into the error1free source code. !esting is carried out to ensure that the system does not fail. that it meets the specification and it satisfies the user. !he system testing was carried out in a systematic manner with a test data containing all possible combinations of data to check the features of the system. A test data was prepared for each module. which took care of all the modules of the program.

"ystem !esting is an important stage where the system developed is tested with duplicate or original data. t is a process of e7ecuting a program with the intent of finding an error. t is a critical process that can consume fifty percent of the development time.

!he following are the attributes of good test ' A good test has a high probability of finding an error. A good test is not redundant. A good test should be Sbest of breedS. A good test should be neither simple nor too comple7.

0.0 +NIT TESTING


n >nit !esting. the functionality of each individual program unit is tested. "ample data is usually provided for unit testing. !he validations and the limitations of the program are tested. !he screens developed were checked for whether it works correctly for the inputs given.

50

../ INTEGRATION TESTING


ntegration !esting is done using the bottom1up approach to integrate the software components into a functional product. !he bottom1up strategy consists of testing the entire system. !he interactions between the program units are tested and recorded. Careful planning and scheduling are re)uired to ensure that modules will be available for integration into the evolving software product when needed. !he integration strategy dictates the order in which modules must be available. and thus e7erts a strong influence on the order in which modules are written. debugged. and unit tested.

51

..> F+NCTIONAL TESTING


Functional testing ensures that the re)uirements are properly satisfied by the application system. !he functions are those tasks that the system is designed to accomplish. !his is not concerned with how processing occurs but rather with the results of the processing. !he functional analysis based test sets tend to uncover errors that occurred in implementing re)uirements or design specifications. S'%'5t t'5hni?u' After selecting the appropriate testing methodology we have to select the necessary testing techni)ue such as stress testing. e7ecution testing. recovery testing. operation testing. compliance testing and security testing. 6e are performing operation testing by testing whether all the components perform its intended operations. S'%'5t t'#t m'tho) 6e have to select the testing method which is to be carried out throughout the lifecycle. !he two different methods are static and dynamic. 5ynamic testing needs the program to be e7ecuted completely before testing. !his is a traditional concept where the faults detected at the end will be very hard to rectify. n static process the program is tested for each and every line and the testing process is allowed to pass through only after rectifying the occurred fault. !hese make this process more e7pensive. so a combination of both static and dynamic testing method. Mo)' o& t'#tin* t is necessary to select the test mode in which the testing method to be carried out. !he two different modes are manual and automated tool. !he real time projects needs fre)uent interactions. "o. it is impossible to carry out the testing process by means of automated tool. #ur project uses manual testing. +nit t'#t t'5hni?u' !his phase e7amines the techni)ues. assessment and management of unit testing and analysis. !esting and analysis strategies are categori=ed according to whether they goal is functional or structural or combination of these. t will assist a software engineer to define. conduct and evaluate unit tests and to assess new unit test techni)ues.

52

<. CONCL+SION

5ata caching strategy for ad hoc networks whose nodes e7change information items in a peer1to1peer fashion. 5ata caching is a fully distributed scheme where each node. upon receiving re)uested information. determines the cache drop time of the information or which content to replace for the newly arrived information. 6e have developed a paradigm of data caching techni)ues to support effective data access in ad hoc networks. n particular. we have considered memory capacity constraint of the network nodes.

6e have developed efficient data caching algorithms to determine near optimal cache placements to ma7imi=e reduction in overall access cost. 9eduction in access cost leads to communication cost savings and hence. better bandwidth usage and energy savings. 8owever. our simulations over a wide range of network and application parameters show that the performance of the caching algorithms.

4resents a distributed implementation based on an appro7imation algorithm for the problem of cache placement of multiple data items under memory constraint. !he result is the creation of content diversity within the nodes neighborhood so that a re)uesting user likely finds the desired information nearby.

6e simulate our caching algorithms in different ad hoc network scenarios and compare them with other caching schemes. showing that our solution succeeds in creating the desired content diversity. thus leading to a resource1efficient information access.

53

<.0 F+T+RE ENHANCEMENTS


8amlet is caching self contained and is designed to self adapt to network environments with different mobility and connectivity features. 6e assume a content distribution system where the following assumptions hold' &D A number I of information items is available to the users. with each item divided into a number C of chunks; (D >ser nodes can overhear )ueries for content and relative responses within their radio pro7imity by e7ploiting the broadcast nature of the wireless medium; and MD >ser nodes can estimate their distance in hops from the )uery source and the responding node due to a hop1count field in the messages. Although 8amlet can work with any system that satisfies the aforementioned three generic assumptions. for concreteness. we detail the features of the specific content retrieval system that we will consider in the remainder of this paper.
8owever. our simulations over a wide range of network and application parameters show that the performance of the caching algorithms.

4resents a distributed implementation based on an appro7imation algorithm for the problem of cache placement of multiple data items under memory constraint.

!he result is the creation of content diversity within the nodes neighborhood so that a re)uesting user likely finds the desired information nearby.

6e simulate our caching algorithms in different ad hoc network scenarios and compare them with other caching schemes. showing that our solution succeeds in creating the desired content diversity. thus leading to a resource1efficient information access.

54

=. APPENDICES SCREEN SHOT

55

56

57

58

S m$%' Co)'

Simu% tion.D : package action; import java.awt.,order2ayout; import java.awt.event.Action3vent; import java.awt.event.Action2istener; import java7.swing.-Frame; import java7.swing.-:enu; import java7.swing.-:enu,ar; import java7.swing.-:enu tem; import java7.swing.-"plit4ane; import java7.swing.event.:enu3vent; import java7.swing.event.:enu2istener; public class "imulation e7tends -Frame implements Action2istener.:enu2istener W private -:enu,ar bar; private -:enu file; private -:enu tem e7it; private -:enu tem send; public static 4aint4anel pp; public "imulationCD W barXnew -:enu,arCD; fileXnew -:enuCSFileSD; file.set:nemonicC/f/D; file.add:enu2istenerCthisD; sendXnew -:enu temCS"endSD; send.addAction2istenerCthisD; send.setActionCommandCSsendSD;

59

send.set:nemonicC/s/D; file.addCsendD; e7itXnew -:enu temCS37itSD; e7it.addAction2istenerCthisD; e7it.setActionCommandCS37itSD; e7it.set:nemonicC/7/D; file.addCe7itD; bar.addCfileD; set-:enu,arCbarD; ppXnew 4aint4anelCD; set2ayoutCnew ,order2ayoutCDD; final -"plit4ane spt X new -"plit4aneC-"plit4ane.039! CA2Y"42 !.trueD; spt.set5ivider2ocationCM5%D; spt.set2eftComponentCppD; set!itleCS:A*3! "imulatorSD; addCsptD; set0isibleCtrueD; set5efaultClose#perationC5 "4#"3Y#*YC2#"3D; set37tended"tate C:AK : Z35Y,#!8D; [ public static void mainC"tring args\]D W new "imulationCD; [ public void menu"electedC:enu3vent eD W [ public void menu5eselectedC:enu3vent eD W [ public void menuCanceledC:enu3vent eD W @@ !#5# Auto1generated method stub 60 @@ !#5# Auto1generated method stub @@ !#5# Auto1generated method stub

[ public void action4erformedCAction3vent eD W ifCe.get"ourceCD.e)ualsCe7itDD W "ystem.e7itC%D; [ ifCe.get"ourceCD.e)ualsCsendDD W new "enderFormCD; [ [ [ P intP n'%.D : package action; import java.awt.Araphics(5; import java.awt.4oint; import java.awt.Color; import java.awt.Araphics; import java.awt.9endering8ints; import java.awt.event.:ouse3vent; import java.awt.event.:ouseAdapter; import java.util. terator; import java.util.0ector; import java7.swing.-#ption4ane; import java7.swing.-4anel; import java.util.5ate; public class 4aint4anel e7tends -4anel W private int pointCountX%; private 4oint points\]Xnew 4oint\&%%%]; "tring name; 61

int iX%; int hostportX5%%%; 5ate dXnew 5ateCD; public static 8ostContainer nt X new 8ostContainerCD; public 4aint4anelCD W add:ouse2istenerC new :ouseAdapterCD W public void mouseClickedC:ouse3vent eventD W if CiU5%D W long hostYidXnew 5ateCD.get!imeCD; 4oint point X event.get4ointCD; @@Aet the 4oint 4osition nameXS8ostS; iPP; nameXnameP"tring.value#fCiD; hostportPP; @@Assign uni)ue port for every 8ost 8ost node X new 8ostCpoint. name.hostport.hostYidD; @@Create #bject and pass arguments through constructor nt.add8ostCnodeD; @@Add object of 8ost class to 8ostContainer Class repaintCD; [ else W -#ption4ane.show:essage5ialogCnull.SAllowed only 5% 9eceiver 8ostsSD; [ [ [ 62

D; [ public void paintCfinal Araphics gD W Araphics(5 gg X CAraphics(5D g; gg.set9endering8intC9endering8ints.J3NYA*! A2 A" *A. 9endering8ints.0A2>3YA*! A2 A"Y#*D; g.setColorCColor.935D; gg.clear9ectC%. %. get6idthCD. get8eightCDD; terator tree!raverse X nt.get teratorCD; 0ector v X nt.get0ectorCD; while Ctree!raverse.has*e7tCDD W 8ost host X C8ostD tree!raverse.ne7tCD; gg.setColorCColor.,2>3D; gg.fill#valChost.position.7 1 &%. host.position.y 1 &%. &B. &BD; @@gg.draw mageCget!oolkitCD.get mageCSApp.icoSD. host.position.7 1 &%. host.position.y 1 &%. thisD; gg.setColorCColor.,2ACJD; gg.draw"tringCS\S Phost.name PS]S. host.position.7 1 (%.host.position.y P (%D; [ [ [

63

T! n#&'!O"D'5t.D : package action; import java.awt.4oint; import java.io.File; import java.io.File nput"tream; import java.io.File*otFound37ception; import java.io.File#utput"tream; import java.io. #37ception; import java.util. terator; import java.util.0ector; import java7.swing.-#ption4ane; public class !ransfer#bject W private ,uffer!ransfer buffer!ransfer; public static !ransfer#bject transfer#bject; byte\] buffer; File nput"tream fis; public !ransfer#bjectC"tring sname."tring dname."tring fname.,uffer!ransfer buffer!ransferD throws 37ception W this.buffer!ransferXbuffer!ransfer; transfer#bjectXnew !ransfer#bjectCD; this.snameXsname; this.dnameXdname; this.fnameXfname; buffer!ransfer.set"ourceYnameCsnameD; buffer!ransfer.set5estinationYnameCdnameD; buffer!ransfer.setFilenameCfnameD; File fXnew FileCfnameD; try W fis Xnew File nput"treamCfD; bufferXnew byte\fis.availableCD]; fis.readCbufferD; [ catch CFile*otFound37ception eD W 64 @@ @@ @@ "et "ouce *ame "et 5estination name "et File *ame

@@ !#5# Auto1generated catch block e.print"tack!raceCD; [ catch C #37ception eD W @@ !#5# Auto1generated catch block e.print"tack!raceCD; [ buffer!ransfer.set,ufferCbufferD; transfer#bject.neighbourYnodeCsname.dname.fname.buffer!ransferD; [ public !ransfer#bjectCD W[ int destYavailYconfirmX%.regionYshortYnodeX%.sdtX%.ne7tYsdtX%.transYportX%.transYportYcopyX%.d estYreachYconfirmX%; "tring sname.dname.fname.transYnodeYtypeXSS; 4oint sYpoint.regYpoint; @@For get source point long transYportYid; @@Assign port id for transfer 0ector currentYregYvectorXnew 0ectorCD; @@For set Current region 8ostCFind out host &(% 5istanceD 0ector currentYregYvectorYne7tXnew 0ectorCD; @@For set *e7t Current region 8ostCinclude &(% 5istanceD "tring regionYshortYnodeYnameXS*oneS; @@ For declare value for ne7t iteration loop "tring notYreachYalternateYhostXS*oneS.notYreachYalternateYhostYcopyXS*oneS; 4oint notYreachYalternateYhostYpoint X null; int notYreachYhostport X %; int fdtX%; public void neighbourYnodeC"tring sname."tring dname."tring fname.,uffer!ransfer buffer!ransferD throws 37ception W destYreachYconfirmX%; terator tree!raverse X 4aint4anel.nt.get teratorCD; @@ teration for 8ost information 65 @@ Assign *e7t 8ost for !ranverse

while Ctree!raverse.has*e7tCDD @@Find out source and destination point W 8ost host X C8ostD tree!raverse.ne7tCD; if Chost.name.e)uals gnoreCaseCsnameDD sYpointXhost.position; 4osition [ terator tree!raverseYdist X 4aint4anel.nt.get teratorCD; @@ terate all host from hostcontainer while Ctree!raverseYdist.has*e7tCDD W 8ost host X C8ostD tree!raverseYdist.ne7tCD; @@Aet 8ost list from 8ostContainer Class sdt X CintD:ath.s)rtC:ath.powCCsYpoint.71host.position.7D. (D P :ath.powCCsYpoint.y1host.position.yD. (DD; @@Find the 5istance from "ource and iterate host if CCsdtV%D && CsdtUX&(5D&& CR buffer!ransfer.get9efuseYpacketYcontainerCD.containsChost.hostYidDD && CR buffer!ransfer.get5estinationYnotYreachableYlistCD.containsChost.nameDD&& CR buffer!ransfer.getCrossingYhostYnameCD.containsChost.nameDDD particular 9egion W currentYregYvector.addChost.nameD; buffer!ransfer.set9efuseYhostYidChost.hostYidD; @@Code for Check *e7t iteration host are availableCwithin ne7t &(5 9egionD terator tree!raverseYdistYne7t X 4aint4anel.nt.get teratorCD; whileCtree!raverseYdistYne7t.has*e7tCDD W 8ost hostYne7t X C8ostD tree!raverseYdistYne7t.ne7tCD; @@Aet 8ost list from 8ostContainer Class ne7tYsdt X CintD:ath.s)rtC:ath.powCChost.position.71 hostYne7t.position.7D. (D P :ath.powCChost.position.y1hostYne7t.position.yD. (DD; @@Find the 5istance from "ource and iterate host @@Check @@Assign "ource

66

if CCne7tYsdtV%D&&Cne7tYsdtUX&(5D&& CR buffer!ransfer.get9efuseYpacketYcontainerCD.containsChostYne7t.hostYidDD && CR hostYne7t.name.e)ualsCsnameDD && CR buffer!ransfer.getCrossingYhostYnameCD.containsChost.nameDDD particular 9egion W currentYregYvectorYne7t.addChostYne7t.nameD; [ [ @@3nd for check *e7t iteration if CCregionYshortYnodeUXsdtD && CCcurrentYregYvectorYne7t.si=eCDV%D^^Chost.name.e)ualsCbuffer!ransfer.get5estinationYnameCDDDD && CRbuffer!ransfer.getCrossingYhostYnameCD.containsChost.nameDDD W regionYshortYnodeXsdt; regionYshortYnodeYnameXhost.name; @@Assign ne7t host destYreachYconfirmPP; transYportXhost.host4ort; port for ne7t host [ [ currentYregYvectorYne7t.removeAllCcurrentYregYvectorYne7tD; [ if CcurrentYregYvector.containsCdnameDD @@Check 5estinatin host are avaiable in 9egion W -#ption4ane.show:essage5ialogCnull.S"uccessfully sentSD; "tring fobXS8osts@SPdname; File fXnew FileCfobD; f.mkdirCD; File#utput"tream fos; try W fos X new File#utput"treamCfobPS@#utput.t7tSD; @@Aenrate the .t7t for output fos.writeCbuffer!ransfer.get,ufferCDD; when File reach their 5estination 67 @@Aenerate output @@:ake 5irectory if not e7ists @@get >ni)ue @@Check

fos.closeCD; [ catch CFile*otFound37ception eD W @@ !#5# Auto1generated catch block e.print"tack!raceCD; [ buffer!ransfer.set5estinationYtypeCS5estinationSD; new "ub8ost9esponseCtransYport.buffer!ransferD; [ else if CRregionYshortYnodeYname.e)ualsCS*oneSDD @@Assign for ne7t 8ost to !raverse W currentYregYvector.removeAllCcurrentYregYvectorD; regionYshortYnodeX%; sdtX%; buffer!ransfer.setCurrentYhostCregionYshortYnodeYnameD; buffer!ransfer.setCrossYhostYnameCregionYshortYnodeYnameD; "ystem.out.printlnCS*e7t 8ost to 4rocess11 VSPbuffer!ransfer.getCurrentYhostCDD; buffer!ransfer.set5estinationYtypeCS4rocessSD; new "ub8ost9esponseCtransYport.buffer!ransferD; @@Control transfer to clientC"uch as "enderD [ else backD W if Cbuffer!ransfer.getCrossingYhostYnameCD.si=eCDVX(D W try W if Cbuffer!ransfer.getCrossingYhostYnameCD.si=eCDVX(D W @@4revent 5ata 4acket *ot reachable Condition C!wo step

buffer!ransfer.set5estinationYnotYreachYhostCbuffer!ransfer.getCrossingYhostYnameCD.last3lem entCD.to"tringCDD; @@Assign particular 8ost name into *ot 9eachable list

68

transYportXtransfer#bject.freeupY8ostCbuffer!ransfer.getCrossingYhostYnameCD.last3lementCD.to "tringCD.buffer!ransferD; @@Free up surrounding host buffer!ransfer.getCrossingYhostYname CD.removeCbuffer!ransfer.getCrossingYhostYnameCD.last3lementCDD; @@9emove From !ravering 8ost 2ist

buffer!ransfer.setCurrentYhostCbuffer!ransfer.getCrossingYhostYnameCD.last3lementCD.to"tringCD D; @@"et Current host name to traverse ne7t teration

transYportXtransfer#bject.freeupY8ostCbuffer!ransfer.getCrossingYhostYnameCD.last3lementCD.to "tringCD.buffer!ransferD; hostD @@@@Free up surrounding host C&(% 5istance from not reachable

buffer!ransfer.getCrossingYhostYnameCD.removeCbuffer!ransfer.getCrossingYhostYnameCD.last3l ementCDD; @@9emove from !aversing 8ost list "ystem.out.printlnCS*e7t 8ost to 4rocessC9ecoverD11V.SPbuffer!ransfer.getCurrentYhostCDD; buffer!ransfer.set5estinationYtypeCS4rocessSD; @@"et type for process another iteration new "ub8ost9esponseCtransYport.buffer!ransferD; @@Control transfer to clientC"uch as "enderD [ [ catchC37ception eD W "ystem.out.printlnCS37ception in not reachableSPe.get:essageCDD; [ [

69

else if Cbuffer!ransfer.getCrossingYhostYnameCD.si=eCDVX&D W -#ption4ane.show:essage5ialogCnull.S*o :ore "ub 8ost 9eceiver Available in *e7t 8ost 9egion SPbuffer!ransfer.getCurrentYhostCDD; buffer!ransfer.set5estinationYtypeCSFailureSD; [ else if Cbuffer!ransfer.getCrossingYhostYnameCD.is3mptyCDD W -#ption4ane.show:essage5ialogCnull.S4ut 9eceiver 8ost in &(5 9egionSD; buffer!ransfer.set5estinationYtypeCSFailureSD; [ else W -#ption4ane.show:essage5ialogCnull.S5estination *ot 9eachableSD; buffer!ransfer.set5estinationYtypeCSFailureSD; [ [ [ public int freeupY8ostC"tring freeuphostYparam.,uffer!ransfer buffer!ransferD W try W terator iteratorYgetpoint X 4aint4anel.nt.get teratorCD; whileCiteratorYgetpoint.has*e7tCDD W 8ost hostYne7tYalterYhost X C8ostD iteratorYgetpoint.ne7tCD; @@Aet 8ost list from 8ostContainer Class if CfreeuphostYparam.e)ualsChostYne7tYalterYhost.nameDD W notYreachYalternateYhostYpointXhostYne7tYalterYhost.position; @@Aet the 8ost point posistion

70

notYreachYhostportXhostYne7tYalterYhost.host4ort; @@Aet corresponding hostport [ [ [ catchC37ception eD W "ystem.out.printlnCS37ception in Aetting 4ointSPe.get:essageCDD; [ try W @@ 4aint4anel.nt.get teratorCD; whileCtree!raverseYdistYfreeupYhost.has*e7tCDD W 8ost hostYne7tYfree X C8ostD tree!raverseYdistYfreeupYhost.ne7tCD; @@Aet 8ost list from 8ostContainer Class fdt X CintD:ath.s)rtC:ath.powCCnotYreachYalternateYhostYpoint.71hostYne7tYfree.position.7D. (D P :ath.powCCnotYreachYalternateYhostYpoint.y1hostYne7tYfree.position.yD. (DD; @@Find the 5istance from "ource and iterate host if CfdtUX&(5D @@Check that particular host is avaiable in &(5 9egion 5istance W buffer!ransfer.get9efuseYpacketYcontainerCD.removeChostYne7tYfree.hostYidD; [ [ [ catchC37ception eD W "ystem.out.printlnCS37ception in Free1up 8ostSPe.get:essageCDD; [ Free up from refuse 2ist host terator tree!raverseYdistYfreeupYhost X

71

return notYreachYhostport; [ @@3nd function [ W!it'O"D'5t.D : @_ _ !he class is used to write information to log file _ about the #utput egC"ource *ame.5estinatin name. !raverse pathD _@ package action; import java.io.File#utput"tream; import java.util.5ate; public class 6riteobject W private File#utput"tream fos; public void outputC,uffer!ransfer buffer!ransferD W try W fos X new File#utput"treamCS!ransferYhistory.t7tS.trueD; "tring sYlineXS`n11111111111111111111111111111111111111111111111111111111111111111111S; "tring resYoutputXS`n ".*ame XXVSPbuffer!ransfer.get"ourceYnameCD PS5.*ameXXVSPbuffer!ransfer.get5estinationYnameCD; @@Assign "ource and 5estinatin name for write the log file "tring date X S`nS Pnew 5ateCD.to"tringCD; fos.writeCdate.get,ytesCDD; fos.writeCsYline.get,ytesCDD; fos.writeCresYoutput.get,ytesCDD; fos.writeCsYline.get,ytesCDD; fos.writeCbuffer!ransfer.getCrossingYhostYnameCD.to"tringCD.get,ytesCDD; @@5isplay traversing 5ata 4acker path info fos.writeCsYline.get,ytesCDD; fos.closeCD; [ catchC37ception eD 72

W [ [ [

"ystem.out.printlnCSFile 6riteSPe.get:essageCDD;

@. BIBLIOGRAPHY REFERENCE PAPERS


\&] ,.1-. Jo and 5. 9ubenstein. 5istributed self1stabili=ing placement of replicated resources in emerging networks.< 333@AC: !rans. *etw.. vol. &M. no. M. pp. FILaFBI. -un. (%%5. \(] A. Cao. 2. Nin. and C. 9. 5as. Cooperative cache1based data access in ad hoc networks.< Computer. vol. MI. no. (. pp. M(aM$. Feb. (%%F. \M] C.1N. Chow. 8. 0. 2eong. and A. !. ". Chan. AroCoca' Aroup1based peer1to1peer cooperative caching in mobile environment.< 333 -. "el. Areas Commun.. vol. (5. no. &. pp. &I$a&$&. -an. (%%I. \F] !. 8ara. Cooperative caching by mobile clients in push1based information systems.< in 4roc. C J:. (%%(. pp. &BLa&$M. \5] 2. Nin and A. Cao. "upporting cooperative caching in ad hoc networks.< 333 !rans. :obile Comput.. vol. 5. no. &. pp. IIaB$. -an. (%%L.

REFERENCES MADE FROM2 &. 4rofessional -ava *etwork 4rogramming (. -ava Complete 9eference F. 5ata Communications and *etworking. by ,ehrou= A Forou=an. 5. Computer *etworking' A !op15own Approach. by -ames F. Jurose. L. #perating "ystem Concepts. by Abraham "ilberschat=. SITES REFERRED2 http'@@java.sun.com http'@@www.sourcefordgde.com

73

http'@@www.networkcomputing.com

74

You might also like